Skip to content

Commit dc89be0

Browse files
authored
fix: Hide ADB status patch (#4814)
1 parent 84bc40c commit dc89be0

File tree

8 files changed

+29
-11
lines changed

8 files changed

+29
-11
lines changed

extensions/all/misc/adb/hide-adb/src/main/java/app/revanced/extension/all/hide/adb/HideAdbPatch.java renamed to extensions/all/misc/adb/hide-adb/src/main/java/app/revanced/extension/all/misc/hide/adb/HideAdbPatch.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.extension.all.hide.adb;
1+
package app.revanced.extension.all.misc.hide.adb;
22

33
import android.content.ContentResolver;
44
import android.provider.Settings;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.extension.all.connectivity.wifi.spoof;
1+
package app.revanced.extension.all.misc.connectivity.wifi.spoof;
22

33
import android.app.PendingIntent;
44
import android.content.Context;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.extension.all.screencapture.removerestriction;
1+
package app.revanced.extension.all.misc.screencapture.removerestriction;
22

33
import android.media.AudioAttributes;
44
import android.os.Build;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.extension.all.screenshot.removerestriction;
1+
package app.revanced.extension.all.misc.screenshot.removerestriction;
22

33
import android.view.Window;
44
import android.view.WindowManager;

patches/src/main/kotlin/app/revanced/patches/all/misc/adb/HideAdbPatch.kt

+22-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,28 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
1010
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
1111
import com.android.tools.smali.dexlib2.util.MethodUtil
1212

13-
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/all/spoof/adb/SpoofAdbPatch;"
13+
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/all/misc/hide/adb/HideAdbPatch;"
1414

15-
private val SETTINGS_GLOBAL_GET_INT_METHOD_REFERENCE = ImmutableMethodReference(
15+
private val SETTINGS_GLOBAL_GET_INT_OR_THROW_METHOD_REFERENCE = ImmutableMethodReference(
1616
"Landroid/provider/Settings\$Global;",
1717
"getInt",
18-
emptyList(),
18+
listOf("Landroid/content/ContentResolver;", "Ljava/lang/String;"),
1919
"I"
2020
)
2121

22+
private val SETTINGS_GLOBAL_GET_INT_OR_DEFAULT_METHOD_REFERENCE = ImmutableMethodReference(
23+
"Landroid/provider/Settings\$Global;",
24+
"getInt",
25+
listOf("Landroid/content/ContentResolver;", "Ljava/lang/String;", "I"),
26+
"I"
27+
)
28+
29+
private fun MethodReference.anyMethodSignatureMatches(vararg anyOf: MethodReference): Boolean {
30+
return anyOf.any {
31+
MethodUtil.methodSignaturesMatch(it, this)
32+
}
33+
}
34+
2235
@Suppress("unused")
2336
val hideAdbStatusPatch = bytecodePatch(
2437
name = "Hide ADB status",
@@ -33,7 +46,12 @@ val hideAdbStatusPatch = bytecodePatch(
3346
val reference = instruction
3447
.takeIf { it.opcode == Opcode.INVOKE_STATIC }
3548
?.getReference<MethodReference>()
36-
?.takeIf { MethodUtil.methodSignaturesMatch(SETTINGS_GLOBAL_GET_INT_METHOD_REFERENCE, it) }
49+
?.takeIf {
50+
it.anyMethodSignatureMatches(it,
51+
SETTINGS_GLOBAL_GET_INT_OR_THROW_METHOD_REFERENCE,
52+
SETTINGS_GLOBAL_GET_INT_OR_DEFAULT_METHOD_REFERENCE
53+
)
54+
}
3755
?: return@filterMap null
3856

3957
Triple(instruction as Instruction35c, instructionIndex, reference.parameterTypes)

patches/src/main/kotlin/app/revanced/patches/all/misc/connectivity/wifi/spoof/SpoofWifiPatch.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
66
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
77

88
private const val EXTENSION_CLASS_DESCRIPTOR_PREFIX =
9-
"Lapp/revanced/extension/all/connectivity/wifi/spoof/SpoofWifiPatch"
9+
"Lapp/revanced/extension/all/misc/connectivity/wifi/spoof/SpoofWifiPatch"
1010

1111
private const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;"
1212

patches/src/main/kotlin/app/revanced/patches/all/misc/screencapture/RemoveScreenCaptureRestrictionPatch.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private val removeCaptureRestrictionResourcePatch = resourcePatch(
2525
}
2626

2727
private const val EXTENSION_CLASS_DESCRIPTOR_PREFIX =
28-
"Lapp/revanced/extension/all/screencapture/removerestriction/RemoveScreenCaptureRestrictionPatch"
28+
"Lapp/revanced/extension/all/misc/screencapture/removerestriction/RemoveScreenCaptureRestrictionPatch"
2929
private const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;"
3030

3131
@Suppress("unused")

patches/src/main/kotlin/app/revanced/patches/all/misc/screenshot/RemoveScreenshotRestrictionPatch.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c
1010
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
1111

1212
private const val EXTENSION_CLASS_DESCRIPTOR_PREFIX =
13-
"Lapp/revanced/extension/all/screenshot/removerestriction/RemoveScreenshotRestrictionPatch"
13+
"Lapp/revanced/extension/all/misc/screenshot/removerestriction/RemoveScreenshotRestrictionPatch"
1414
private const val EXTENSION_CLASS_DESCRIPTOR = "$EXTENSION_CLASS_DESCRIPTOR_PREFIX;"
1515

1616
@Suppress("unused")

0 commit comments

Comments
 (0)