@@ -6,8 +6,12 @@ package app.morphe.patches.googlephotos.misc.login
66
77import app.morphe.patches.shared.compat.AppCompatibilities
88import app.morphe.patcher.extensions.InstructionExtensions.addInstruction
9- import app.morphe.patcher.extensions.InstructionExtensions.addInstructions
9+ import app.morphe.patcher.extensions.InstructionExtensions.getInstruction
10+ import app.morphe.patcher.extensions.InstructionExtensions.replaceInstruction
1011import app.morphe.patcher.patch.bytecodePatch
12+ import app.morphe.util.getReference
13+ import app.morphe.util.indexOfFirstInstructionOrThrow
14+ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
1115
1216@Suppress(" unused" )
1317val selectedAccountPatch = bytecodePatch(
@@ -23,14 +27,22 @@ val selectedAccountPatch = bytecodePatch(
2327 " return-void" ,
2428 )
2529
26- // 2) Make the frictionless-login eligibility check always succeed.
27- FrictionlessEligibilityFingerprint .method.addInstructions(
28- 0 ,
29- """
30- const/4 p0, 0x1
31- return p0
32- """ ,
33- )
30+ // 2) Keep the frictionless eligibility result intact, but prevent the
31+ // MicroG failure path from clearing the selected account.
32+ FrictionlessEligibilityFingerprint .method.apply {
33+ val clearSelectedAccountIndex = indexOfFirstInstructionOrThrow {
34+ getReference<MethodReference >()?.let { ref ->
35+ ref.name == " o" &&
36+ ref.returnType == " V" &&
37+ ref.parameterTypes.toList() == listOf (" I" )
38+ } == true
39+ }
40+ val accountHandlerClass = getInstruction(clearSelectedAccountIndex)
41+ .getReference<MethodReference >()!!
42+ .definingClass
43+
44+ replaceInstruction(clearSelectedAccountIndex, " invoke-virtual {p0}, $accountHandlerClass ->p()V" )
45+ }
3446 }
3547}
3648
0 commit comments