Skip to content

Commit 3d0d94b

Browse files
author
LisoUseInAIKyrios
authored
fix(YouTube - GmsCore Support): Fix patch exception by using correct patch offset (#3543)
1 parent b84e6af commit 3d0d94b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import app.revanced.patches.shared.misc.gms.fingerprints.GooglePlayUtilityFinger
1818
import app.revanced.patches.shared.misc.gms.fingerprints.ServiceCheckFingerprint
1919
import app.revanced.util.exception
2020
import app.revanced.util.getReference
21-
import app.revanced.util.indexOfFirstInstructionOrThrow
21+
import app.revanced.util.indexOfFirstInstruction
2222
import app.revanced.util.returnEarly
2323
import com.android.tools.smali.dexlib2.Opcode
2424
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
@@ -115,15 +115,16 @@ abstract class BaseGmsCoreSupportPatch(
115115

116116
// Verify GmsCore is installed and whitelisted for power optimizations and background usage.
117117
mainActivityOnCreateFingerprint.result?.mutableMethod?.apply {
118-
val setContextIndex = indexOfFirstInstructionOrThrow {
119-
val reference = getReference<MethodReference>() ?: return@indexOfFirstInstructionOrThrow false
118+
// Temporary fix for Google photos integration.
119+
var setContextIndex = indexOfFirstInstruction {
120+
val reference = getReference<MethodReference>() ?: return@indexOfFirstInstruction false
120121

121122
reference.toString() == "Lapp/revanced/integrations/shared/Utils;->setContext(Landroid/content/Context;)V"
122123
}
123124

124125
// Add after setContext call, because this patch needs the context.
125126
addInstructions(
126-
setContextIndex + 1,
127+
if (setContextIndex < 0) 0 else setContextIndex + 1,
127128
"invoke-static/range { p0 .. p0 }, Lapp/revanced/integrations/shared/GmsCoreSupport;->" +
128129
"checkGmsCore(Landroid/app/Activity;)V",
129130
)

0 commit comments

Comments
 (0)