From f21fa5894b767474b7cedcc2eba7b2a65554169a Mon Sep 17 00:00:00 2001 From: fe <58902674+1fexd@users.noreply.github.com> Date: Sat, 4 Nov 2023 19:13:08 +0100 Subject: [PATCH] feat(Digitales Amt): Bump compatibility to `3.0.2` (#3217) Co-authored-by: oSumAtrIX --- .../detection/root/RootDetectionPatch.kt | 17 ++++++---- .../AttestationSupportedCheckFingerprint.kt | 13 ++++++++ .../BootloaderCheckFingerprint.kt | 13 ++++++++ ...Fingerprint.kt => RootCheckFingerprint.kt} | 3 +- .../signature/SpoofSignaturePatch.kt | 2 +- .../badge/RemoveNotificationBadgePatch.kt | 2 +- src/main/kotlin/app/revanced/util/Utils.kt | 32 +++++++++++++++++++ .../util/microg/MicroGBytecodeHelper.kt | 30 +---------------- 8 files changed, 74 insertions(+), 38 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/AttestationSupportedCheckFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/BootloaderCheckFingerprint.kt rename src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/{RootDetectionFingerprint.kt => RootCheckFingerprint.kt} (79%) create mode 100644 src/main/kotlin/app/revanced/util/Utils.kt diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt index 5c9d15589..5173e11dc 100644 --- a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/RootDetectionPatch.kt @@ -1,21 +1,26 @@ package app.revanced.patches.idaustria.detection.root import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.idaustria.detection.root.fingerprints.RootDetectionFingerprint +import app.revanced.patches.idaustria.detection.root.fingerprints.AttestationSupportedCheckFingerprint +import app.revanced.patches.idaustria.detection.root.fingerprints.BootloaderCheckFingerprint +import app.revanced.patches.idaustria.detection.root.fingerprints.RootCheckFingerprint +import app.revanced.util.Utils.returnEarly @Patch( name = "Remove root detection", description = "Removes the check for root permissions and unlocked bootloader.", - compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["2.7.1"])] + compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["3.0.2"])] ) @Suppress("unused") object RootDetectionPatch : BytecodePatch( - setOf(RootDetectionFingerprint) + setOf(AttestationSupportedCheckFingerprint, BootloaderCheckFingerprint, RootCheckFingerprint) ) { - override fun execute(context: BytecodeContext) = - RootDetectionFingerprint.result!!.mutableMethod.addInstruction(0, "return-void") + override fun execute(context: BytecodeContext) = listOf( + AttestationSupportedCheckFingerprint, + BootloaderCheckFingerprint, + RootCheckFingerprint + ).returnEarly(true) } diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/AttestationSupportedCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/AttestationSupportedCheckFingerprint.kt new file mode 100644 index 000000000..56bcfe515 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/AttestationSupportedCheckFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.idaustria.detection.root.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +object AttestationSupportedCheckFingerprint : MethodFingerprint( + "V", + accessFlags = AccessFlags.PUBLIC.value, + customFingerprint = { methodDef, _ -> + methodDef.name == "attestationSupportCheck" && + methodDef.definingClass.endsWith("/DeviceIntegrityCheck;") + } +) diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/BootloaderCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/BootloaderCheckFingerprint.kt new file mode 100644 index 000000000..9fee20dfd --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/BootloaderCheckFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.idaustria.detection.root.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +object BootloaderCheckFingerprint : MethodFingerprint( + "Z", + accessFlags = AccessFlags.PUBLIC.value, + customFingerprint = { methodDef, _ -> + methodDef.name == "bootloaderCheck" && + methodDef.definingClass.endsWith("/DeviceIntegrityCheck;") + } +) diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/RootDetectionFingerprint.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/RootCheckFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/RootDetectionFingerprint.kt rename to src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/RootCheckFingerprint.kt index 6636f2a3b..174a28b76 100644 --- a/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/RootDetectionFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/root/fingerprints/RootCheckFingerprint.kt @@ -3,10 +3,11 @@ package app.revanced.patches.idaustria.detection.root.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.AccessFlags -object RootDetectionFingerprint : MethodFingerprint( +object RootCheckFingerprint : MethodFingerprint( "V", accessFlags = AccessFlags.PUBLIC.value, customFingerprint = { methodDef, _ -> + methodDef.name == "rootCheck" && methodDef.definingClass.endsWith("/DeviceIntegrityCheck;") } ) diff --git a/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt index ff5bc8c7f..a98c90bc5 100644 --- a/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/idaustria/detection/signature/SpoofSignaturePatch.kt @@ -10,7 +10,7 @@ import app.revanced.patches.idaustria.detection.signature.fingerprints.SpoofSign @Patch( name = "Spoof signature", description = "Spoofs the signature of the app.", - compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["2.7.1"])] + compatiblePackages = [CompatiblePackage("at.gv.oe.app", ["3.0.2"])] ) @Suppress("unused") object SpoofSignaturePatch : BytecodePatch( diff --git a/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt b/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt index d039784a1..66c3bb5f2 100644 --- a/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/RemoveNotificationBadgePatch.kt @@ -11,7 +11,7 @@ import app.revanced.patches.songpal.badge.fingerprints.ShowNotificationFingerpri @Patch( name = "Remove notification badge", description = "Removes the red notification badge from the activity tab.", - compatiblePackages = [CompatiblePackage("com.sony.songpal.mdr")] + compatiblePackages = [CompatiblePackage("com.sony.songpal.mdr", ["10.1.0"])] ) @Suppress("unused") object RemoveNotificationBadgePatch : BytecodePatch(setOf(ShowNotificationFingerprint)) { diff --git a/src/main/kotlin/app/revanced/util/Utils.kt b/src/main/kotlin/app/revanced/util/Utils.kt new file mode 100644 index 000000000..fde3b77e9 --- /dev/null +++ b/src/main/kotlin/app/revanced/util/Utils.kt @@ -0,0 +1,32 @@ +package app.revanced.util + +import app.revanced.extensions.exception +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.fingerprint.MethodFingerprint + +object Utils { + /** + * Return the resolved methods of [MethodFingerprint]s early. + */ + fun List.returnEarly(bool: Boolean = false) { + val const = if (bool) "0x1" else "0x0" + this.forEach { fingerprint -> + fingerprint.result?.let { result -> + val stringInstructions = when (result.method.returnType.first()) { + 'L' -> """ + const/4 v0, $const + return-object v0 + """ + 'V' -> "return-void" + 'I', 'Z' -> """ + const/4 v0, $const + return v0 + """ + else -> throw Exception("This case should never happen.") + } + + result.mutableMethod.addInstructions(0, stringInstructions) + } ?: throw fingerprint.exception + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index fb6757e3d..458cb0cbd 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -1,13 +1,12 @@ package app.revanced.util.microg -import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod +import app.revanced.util.Utils.returnEarly import app.revanced.util.microg.Constants.ACTIONS import app.revanced.util.microg.Constants.AUTHORITIES import app.revanced.util.microg.Constants.MICROG_VENDOR @@ -213,31 +212,4 @@ internal object MicroGBytecodeHelper { } } } - - /** - * Return the resolved methods of a list of [MethodFingerprint] early. - */ - private fun List.returnEarly() { - this.forEach { fingerprint -> - fingerprint.result?.let { result -> - val stringInstructions = when (result.method.returnType.first()) { - 'L' -> """ - const/4 v0, 0x0 - return-object v0 - """ - - 'V' -> "return-void" - 'I' -> """ - const/4 v0, 0x0 - return v0 - """ - - else -> throw Exception("This case should never happen.") - } - result.mutableMethod.addInstructions( - 0, stringInstructions - ) - } ?: throw fingerprint.exception - } - } }