generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 317
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): Add
Spoof features
patch
- Loading branch information
Showing
5 changed files
with
134 additions
and
5 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
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/app/revanced/patches/googlephotos/features/SpoofBuildInfoPatch.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,14 @@ | ||
package app.revanced.patches.googlephotos.features | ||
|
||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.all.misc.build.BaseSpoofBuildInfoPatch | ||
|
||
@Patch(description = "Spoof build info to Google Pixel XL.") | ||
internal class SpoofBuildInfoPatch : BaseSpoofBuildInfoPatch() { | ||
override val brand = "google" | ||
override val manufacturer = "Google" | ||
override val device = "marlin" | ||
override val product = "marlin" | ||
override val model = "Pixel XL" | ||
override val fingerprint = "google/marlin/marlin:10/QP1A.191005.007.A3/5972272:user/release-keys" | ||
} |
87 changes: 87 additions & 0 deletions
87
src/main/kotlin/app/revanced/patches/googlephotos/features/SpoofFeaturesPatch.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,87 @@ | ||
package app.revanced.patches.googlephotos.features | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringArrayPatchOption | ||
import app.revanced.patches.googlephotos.features.fingerprints.InitializeFeaturesEnumFingerprint | ||
import app.revanced.util.getReference | ||
import app.revanced.util.resultOrThrow | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
import com.android.tools.smali.dexlib2.iface.reference.StringReference | ||
|
||
@Patch( | ||
name = "Spoof features", | ||
description = "Spoofs the device to enable Google Pixel exclusive features, including unlimited storage.", | ||
dependencies = [SpoofBuildInfoPatch::class], | ||
compatiblePackages = [CompatiblePackage("com.google.android.apps.photos")], | ||
) | ||
@Suppress("unused") | ||
object SpoofFeaturesPatch : BytecodePatch(setOf(InitializeFeaturesEnumFingerprint)) { | ||
private val featuresToEnable by stringArrayPatchOption( | ||
"featuresToEnable", | ||
arrayOf( | ||
"com.google.android.apps.photos.NEXUS_PRELOAD", | ||
"com.google.android.apps.photos.nexus_preload", | ||
), | ||
title = "Features to enable", | ||
description = "Google Pixel exclusive features to enable. Features up to Pixel XL enable the unlimited storage feature.", | ||
required = true, | ||
) | ||
|
||
private val featuresToDisable by stringArrayPatchOption( | ||
"featuresToDisable", | ||
arrayOf( | ||
"com.google.android.apps.photos.PIXEL_2017_PRELOAD", | ||
"com.google.android.apps.photos.PIXEL_2018_PRELOAD", | ||
"com.google.android.apps.photos.PIXEL_2019_MIDYEAR_PRELOAD", | ||
"com.google.android.apps.photos.PIXEL_2019_PRELOAD", | ||
"com.google.android.feature.PIXEL_2020_MIDYEAR_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2020_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2021_MIDYEAR_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2021_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2022_MIDYEAR_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2022_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2023_MIDYEAR_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2023_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2024_MIDYEAR_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2024_EXPERIENCE", | ||
"com.google.android.feature.PIXEL_2025_MIDYEAR_EXPERIENCE", | ||
), | ||
title = "Features to disable", | ||
description = "Google Pixel exclusive features to disable." + | ||
"Features after Pixel XL may have to be disabled for unlimited storage depending on the device.", | ||
required = true, | ||
) | ||
|
||
override fun execute(context: BytecodeContext) { | ||
val featuresToEnable = featuresToEnable!!.toSet() | ||
val featuresToDisable = featuresToDisable!!.toSet() | ||
|
||
InitializeFeaturesEnumFingerprint.resultOrThrow().let { result -> | ||
result.mutableMethod.apply { | ||
getInstructions().filter { it.opcode == Opcode.CONST_STRING }.forEach { | ||
val feature = it.getReference<StringReference>()!!.string | ||
|
||
val spoofedFeature = when (feature) { | ||
in featuresToEnable -> "android.hardware.wifi" | ||
in featuresToDisable -> "dummy" | ||
else -> return@forEach | ||
} | ||
|
||
val constStringIndex = it.location.index | ||
val constStringRegister = (it as OneRegisterInstruction).registerA | ||
|
||
replaceInstruction( | ||
constStringIndex, | ||
"const-string v$constStringRegister, \"$spoofedFeature\"", | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
.../revanced/patches/googlephotos/features/fingerprints/InitializeFeaturesEnumFingerprint.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,7 @@ | ||
package app.revanced.patches.googlephotos.features.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object InitializeFeaturesEnumFingerprint : MethodFingerprint( | ||
strings = listOf("com.google.android.apps.photos.NEXUS_PRELOAD"), | ||
) |
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