forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Google Photos): Restore hidden 'Back up while charging' toggle (R…
…eVanced#3678) Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
.../revanced/patches/googlephotos/preferences/RestoreHiddenBackUpWhileChargingTogglePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package app.revanced.patches.googlephotos.preferences | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.googlephotos.preferences.fingerprints.BackupPreferencesFingerprint | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch( | ||
name = "Restore hidden 'Back up while charging' toggle", | ||
description = "Restores a hidden toggle to only run backups when the device is charging.", | ||
compatiblePackages = [CompatiblePackage("com.google.android.apps.photos")], | ||
) | ||
@Suppress("unused") | ||
object RestoreHiddenBackUpWhileChargingTogglePatch : BytecodePatch( | ||
setOf(BackupPreferencesFingerprint), | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
// Patches 'backup_prefs_had_backup_only_when_charging_enabled' to always be true. | ||
BackupPreferencesFingerprint.result?.let { | ||
val chargingPrefStringIndex = it.scanResult.stringsScanResult!!.matches.first().index | ||
it.mutableMethod.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") | ||
} | ||
} ?: throw Exception("BackupPreferencesFingerprint result not found") | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...pp/revanced/patches/googlephotos/preferences/fingerprints/BackupPreferencesFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package app.revanced.patches.googlephotos.preferences.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
internal object BackupPreferencesFingerprint : MethodFingerprint( | ||
returnType = "Lcom/google/android/apps/photos/backup/data/BackupPreferences;", | ||
strings = listOf( | ||
"backup_prefs_had_backup_only_when_charging_enabled", | ||
), | ||
) |