Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ public final class app/revanced/patches/primevideo/misc/extension/ExtensionPatch
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

public final class app/revanced/patches/primevideo/misc/permissions/RenamePermissionsPatchKt {
public static final fun getRenamePermissionsPatch ()Lapp/revanced/patcher/patch/ResourcePatch;
}

public final class app/revanced/patches/protonmail/signature/RemoveSentFromSignaturePatchKt {
public static final fun getRemoveSentFromSignaturePatch ()Lapp/revanced/patcher/patch/ResourcePatch;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package app.revanced.patches.primevideo.misc.permissions

import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.resourcePatch
import app.revanced.util.asSequence
import app.revanced.util.getNode
import org.w3c.dom.Element

@Suppress("unused")
val renamePermissionsPatch = resourcePatch(
name = "Rename shared permissions",
description = "Rename certain permissions shared across Amazon apps. " +
"Applying this patch can fix installation errors, but can also break features in certain apps.",
use = false
) {
compatibleWith("com.amazon.avod.thirdpartyclient")

val permissionNames = setOf(
"com.amazon.identity.permission.CAN_CALL_MAP_INFORMATION_PROVIDER",
"com.amazon.identity.auth.device.perm.AUTH_SDK",
"com.amazon.dcp.sso.permission.account.changed",
"com.amazon.dcp.sso.permission.AmazonAccountPropertyService.property.changed",
"com.amazon.identity.permission.CALL_AMAZON_DEVICE_INFORMATION_PROVIDER",
"com.amazon.appmanager.preload.permission.READ_PRELOAD_DEVICE_INFO_PROVIDER"
)

execute {
document("AndroidManifest.xml").use { document ->
val manifest = document.getNode("manifest") as Element

val permissions = manifest
.getElementsByTagName("permission")
.asSequence()
.map { it as Element }
.filter { it.getAttribute("android:name") in permissionNames }

if (permissions.none()) throw PatchException("Could not find any permissions to rename")

permissions.forEach {
val name = it.getAttribute("android:name")
it.setAttribute("android:name", "revanced.$name")
}
}
}
}