fix(Google Photos - Restore hidden 'Back up while charging' toggle): Constrain to last working app target (#4761)

This commit is contained in:
LisoUseInAIKyrios 2025-04-11 21:40:17 +02:00 committed by GitHub
parent 9387aae7ba
commit 152bb7c3ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,23 +3,29 @@ package app.revanced.patches.googlephotos.misc.preferences
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Suppress("unused")
val restoreHiddenBackUpWhileChargingTogglePatch = bytecodePatch(
name = "Restore hidden 'Back up while charging' toggle",
description = "Restores a hidden toggle to only run backups when the device is charging.",
use = false
) {
compatibleWith("com.google.android.apps.photos")
compatibleWith("com.google.android.apps.photos"("7.11.0.705590205"))
execute {
// Patches 'backup_prefs_had_backup_only_when_charging_enabled' to always be true.
val chargingPrefStringIndex = backupPreferencesFingerprint.stringMatches!!.first().index
backupPreferencesFingerprint.method.apply {
// Get the register of move-result.
val resultRegister = getInstruction<OneRegisterInstruction>(chargingPrefStringIndex + 2).registerA
// Insert const after move-result to override register as true.
addInstruction(chargingPrefStringIndex + 3, "const/4 v$resultRegister, 0x1")
backupPreferencesFingerprint.let {
it.method.apply {
val index = indexOfFirstInstructionOrThrow(
it.stringMatches!!.first().index,
Opcode.MOVE_RESULT
)
val register = getInstruction<OneRegisterInstruction>(index).registerA
addInstruction(index + 1, "const/4 v$register, 0x1")
}
}
}
}