Skip to content

Commit

Permalink
feat(Google Photos): Add Spoof features patch
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Aug 14, 2024
1 parent 345e514 commit 88a82c8
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@ public final class app/revanced/patches/googlenews/misc/integrations/Integration
public static final field INSTANCE Lapp/revanced/patches/googlenews/misc/integrations/IntegrationsPatch;
}

public final class app/revanced/patches/googlephotos/features/SpoofFeaturesPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/googlephotos/features/SpoofFeaturesPatch;
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/googlephotos/features/fingerprints/InitializeFeaturesEnumFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint {
public static final field INSTANCE Lapp/revanced/patches/googlephotos/features/fingerprints/InitializeFeaturesEnumFingerprint;
}

public final class app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch {
public static final field INSTANCE Lapp/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch;
}
Expand Down
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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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",
"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",

),
title = "Features to enable",
description = "Google Pixel exclusive features to enable. Features up to Pixel 2020 enable the unlimited storage feature.",
required = true,
)

private val featuresToDisable by stringArrayPatchOption(
"featuresToDisable",
arrayOf(
"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 2020 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\"",
)
}
}
}
}
}
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"),
)

0 comments on commit 88a82c8

Please sign in to comment.