@@ -26,10 +26,10 @@ import crimera.patches.twitter.misc.settings.fingerprints.UrlInterpreterActivity
2626 compatiblePackages = [CompatiblePackage (" com.twitter.android" )],
2727)
2828object SettingsPatch : BytecodePatch(
29- setOf(SettingsFingerprint , AuthorizeAppActivity , IntegrationsUtilsFingerprint ,UrlInterpreterActivity )
29+ setOf(SettingsFingerprint , AuthorizeAppActivity , IntegrationsUtilsFingerprint , UrlInterpreterActivity ),
3030) {
3131 private const val INTEGRATIONS_PACKAGE = " Lapp/revanced/integrations/twitter"
32- private const val UTILS_DESCRIPTOR = " $INTEGRATIONS_PACKAGE /Utils"
32+ const val UTILS_DESCRIPTOR = " $INTEGRATIONS_PACKAGE /Utils"
3333 private const val ACTIVITY_HOOK_CLASS = " Lapp/revanced/integrations/twitter/settings/ActivityHook;"
3434 private const val DEEPLINK_HOOK_CLASS = " Lapp/revanced/integrations/twitter/settings/DeepLink;"
3535 private const val ADD_PREF_DESCRIPTOR =
@@ -45,26 +45,39 @@ object SettingsPatch : BytecodePatch(
4545 " invoke-static {}, $ACTIVITY_HOOK_CLASS ->startSettingsActivity()V"
4646
4747 override fun execute (context : BytecodeContext ) {
48- val result = SettingsFingerprint .result
49- ? : throw PatchException (" Fingerprint not found" )
48+ val result =
49+ SettingsFingerprint .result
50+ ? : throw PatchException (" Fingerprint not found" )
5051
5152 val initMethod = result.mutableClass.methods.first()
5253
53- val arrayCreation = initMethod.getInstructions()
54- .first { it.opcode == Opcode .FILLED_NEW_ARRAY_RANGE }.location.index+ 1
54+ val arrayCreation =
55+ initMethod
56+ .getInstructions()
57+ .first { it.opcode == Opcode .FILLED_NEW_ARRAY_RANGE }
58+ .location.index + 1
5559
56- initMethod.getInstruction<BuilderInstruction11x >(arrayCreation).registerA.also { reg->
57- initMethod.addInstructions(arrayCreation+ 1 , """
60+ initMethod.getInstruction<BuilderInstruction11x >(arrayCreation).registerA.also { reg ->
61+ initMethod.addInstructions(
62+ arrayCreation + 1 ,
63+ """
5864 const-string v1, "pref_mod"
5965 invoke-static {v$reg , v1}, $ADD_PREF_DESCRIPTOR
6066 move-result-object v$reg
61- """ )
67+ """ ,
68+ )
6269 }
6370
6471 val prefCLickedMethod = result.mutableClass.methods.find { it.returnType == " Z" }!!
65- val constIndex = prefCLickedMethod.getInstructions().first{ it.opcode == Opcode .CONST_4 }.location.index
72+ val constIndex =
73+ prefCLickedMethod
74+ .getInstructions()
75+ .first { it.opcode == Opcode .CONST_4 }
76+ .location.index
6677
67- prefCLickedMethod.addInstructionsWithLabels(1 , """
78+ prefCLickedMethod.addInstructionsWithLabels(
79+ 1 ,
80+ """
6881 const-string v1, "pref_mod"
6982 invoke-virtual {p1, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
7083 move-result v2
@@ -77,40 +90,44 @@ object SettingsPatch : BytecodePatch(
7790 const/4 v3, 0x1
7891 return v3
7992 """ ,
80- ExternalLabel (" cont" , prefCLickedMethod.getInstruction(constIndex))
93+ ExternalLabel (" cont" , prefCLickedMethod.getInstruction(constIndex)),
8194 )
8295
8396 AuthorizeAppActivity .result?.apply {
8497 mutableMethod.addInstructionsWithLabels(
85- 1 , """
98+ 1 ,
99+ """
86100 invoke-static {p0}, $ACTIVITY_HOOK_CLASS ->create(Landroid/app/Activity;)Z
87101 move-result v0
88102 if-nez v0, :no_piko_settings_init
89103 """ .trimIndent(),
90104 ExternalLabel (
91105 " no_piko_settings_init" ,
92- mutableMethod.getInstructions().first { it.opcode == Opcode .RETURN_VOID })
106+ mutableMethod.getInstructions().first { it.opcode == Opcode .RETURN_VOID },
107+ ),
93108 )
94109 } ? : throw PatchException (" ProxySettingsActivityFingerprint not found" )
95110
96111 UrlInterpreterActivity .result?.apply {
97112 val instructions = mutableMethod.getInstructions()
98- val loc = instructions.first { it.opcode == Opcode .INVOKE_SUPER }.location.index+ 1
113+ val loc = instructions.first { it.opcode == Opcode .INVOKE_SUPER }.location.index + 1
99114 mutableMethod.addInstructionsWithLabels(
100- loc, """
115+ loc,
116+ """
101117 invoke-static {p0}, $DEEPLINK_HOOK_CLASS ->deeplink(Landroid/app/Activity;)Z
102118 move-result v0
103119 if-nez v0, :deep_link
104120 """ .trimIndent(),
105121 ExternalLabel (
106122 " deep_link" ,
107- instructions.first { it.opcode == Opcode .RETURN_VOID })
123+ instructions.first { it.opcode == Opcode .RETURN_VOID },
124+ ),
108125 )
109126 } ? : throw PatchException (" UrlInterpreterActivity not found" )
110127
111128 IntegrationsUtilsFingerprint .result!! .mutableMethod.addInstruction(
112129 0 ,
113- " ${SSTS_DESCRIPTOR } ->load()V"
130+ " ${SSTS_DESCRIPTOR } ->load()V" ,
114131 )
115132 }
116- }
133+ }
0 commit comments