@@ -7,8 +7,49 @@ package app.morphe.patches.googlephotos.misc.login
77import app.morphe.patcher.Fingerprint
88import app.morphe.util.getReference
99import com.android.tools.smali.dexlib2.AccessFlags
10+ import com.android.tools.smali.dexlib2.iface.ClassDef
11+ import com.android.tools.smali.dexlib2.iface.Method
12+ import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
1013import com.android.tools.smali.dexlib2.iface.reference.FieldReference
1114import com.android.tools.smali.dexlib2.iface.reference.MethodReference
15+ import com.android.tools.smali.dexlib2.iface.reference.StringReference
16+
17+ private fun Method.referencesString (value : String ) =
18+ implementation?.instructions?.any {
19+ it.getReference<StringReference >()?.string == value
20+ } == true
21+
22+ private fun Method.referencesStringContaining (value : String ) =
23+ implementation?.instructions?.any {
24+ it.getReference<StringReference >()?.string?.contains(value) == true
25+ } == true
26+
27+ private fun Method.referencesMethod (returnType : String , parameters : List <String >? = null) =
28+ implementation?.instructions?.any {
29+ it.getReference<MethodReference >()?.let { ref ->
30+ ref.returnType == returnType && (parameters == null || ref.parameterTypes.toList() == parameters)
31+ } == true
32+ } == true
33+
34+ private fun Method.referencesVoidMethodWithSingleObjectParameter () =
35+ implementation?.instructions?.any {
36+ it.getReference<MethodReference >()?.let { ref ->
37+ ref.returnType == " V" &&
38+ ref.parameterTypes.size == 1 &&
39+ ref.parameterTypes.first().startsWith(" L" )
40+ } == true
41+ } == true
42+
43+ private fun Method.referencesIntLiteral (value : Int ) =
44+ implementation?.instructions?.any {
45+ it is NarrowLiteralInstruction && it.narrowLiteral == value
46+ } == true
47+
48+ private fun ClassDef.hasMethodReferencingString (value : String ) =
49+ methods.any { it.referencesString(value) }
50+
51+ private fun ClassDef.hasMethodReferencingStringContaining (value : String ) =
52+ methods.any { it.referencesStringContaining(value) }
1253
1354/* *
1455 * Matches `aext.d()` — the AccountValidityMonitor method that enqueues `CheckAccountTask`
@@ -18,18 +59,16 @@ internal object AccountValidityMonitorCheckFingerprint : Fingerprint(
1859 accessFlags = listOf(AccessFlags .PUBLIC , AccessFlags .FINAL ),
1960 returnType = " V" ,
2061 parameters = listOf(),
21- custom = { method, _ ->
22- method.implementation?.instructions?.let { insns ->
23- insns.any {
62+ custom = { method, classDef ->
63+ classDef.hasMethodReferencingString("AccountValidityMonitor ") &&
64+ classDef.hasMethodReferencingString("com.google.android.apps.photos.login.AccountValidityMonitor .CheckAccountTask ") &&
65+ method.implementation?.instructions?.let { instructions ->
66+ instructions.any {
2467 it.getReference<FieldReference >()?.let { ref ->
25- ref.definingClass == " Laexv; " && ref. name == " a" && ref.type == " I"
68+ ref.name == " a" && ref.type == " I"
2669 } == true
27- } && insns.any {
28- it.getReference<MethodReference >()?.toString()?.contains(
29- "AccountValidityMonitor \$CheckAccountTask "
30- ) == true
31- }
32- } ? : false
70+ } && method.referencesVoidMethodWithSingleObjectParameter()
71+ } == true
3372 },
3473)
3574
@@ -42,14 +81,12 @@ internal object FrictionlessEligibilityFingerprint : Fingerprint(
4281 accessFlags = listOf(AccessFlags .PUBLIC , AccessFlags .FINAL ),
4382 returnType = " Z" ,
4483 parameters = listOf(),
45- custom = { method, _ ->
46- method.implementation?.instructions?.let { insns ->
47- insns.any {
48- it.getReference<MethodReference >()?.toString() == " Lasgb;->b()Z"
49- } && insns.any {
50- it.getReference<MethodReference >()?.toString() == " Laexs;->o(I)V"
51- }
52- } ? : false
84+ custom = { method, classDef ->
85+ classDef.hasMethodReferencingStringContaining("maybeStartFrictionless") &&
86+ classDef.hasMethodReferencingString("ProvideFrctAccountTask ") &&
87+ method.referencesMethod("Z ", emptyList()) &&
88+ method.referencesMethod("V ", listOf("I ")) &&
89+ method.referencesIntLiteral(-1)
5390 },
5491)
5592
0 commit comments