feat(Google Photos): Restore hidden 'Back up while charging' toggle (#3678)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
xob0t 2024-09-29 03:22:32 +03:00 committed by GitHub
parent a684b1cddb
commit f9e19ce6e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 0 deletions

View File

@ -321,6 +321,12 @@ public final class app/revanced/patches/googlephotos/misc/integrations/Integrati
public static final field INSTANCE Lapp/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch;
}
public final class app/revanced/patches/googlephotos/preferences/RestoreHiddenBackUpWhileChargingTogglePatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/googlephotos/preferences/RestoreHiddenBackUpWhileChargingTogglePatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}
public final class app/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V

View File

@ -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")
}
}

View File

@ -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",
),
)