Skip to content

Commit a79deb9

Browse files
adithya2306nullbyteplkondors1995ReallySnow
authored andcommitted
base: AttestationHooks: Spoof device as Pixel XL for Google Photos
Enables unlimited photos and videos backup (restored functionality from PixelPropsUtils). Make this optional via overlay, as it needs to be disabled on some devices such as Pixel 6 series in order to utilize its tensor features. Squashed: Author: ReallySnow <[email protected]> Date: Fri Dec 31 16:40:23 2021 +0800 core: Blacklist Pixel 2017 and 2018 exclusive for Google Photos * In this way can use PixelPropsUtils to simulate the Pixel XL prop method to use the unlimited storage space of Google Photos * Thanks nullbytepl for the idea Change-Id: I92d472d319373d648365c8c63e301f1a915f8de9 Author: kondors1995 <[email protected]> Date: Mon Dec 20 16:53:46 2021 +0000 core: Extend Pixel feature blacklist for Google Photos Turns out having these breaks Original quality backups. Since these indicate that the device is pixel 4 which in turn breaks device spoofing as OG pixel Change-Id: Ibc57af35ca7e7146b3a839a544476ef716f85925 Author: Kuba Wojciechowski <[email protected]> Date: Fri Nov 5 01:52:51 2021 +0300 core: Blacklist P21 experience system feature from Google Photos We want to include the P21 experience flag to enable new features, however it seems like Google Photos uses it to decide whether to use the TPU tflite delegate. There doesn't seem to be any fallback so we need to make sure the feature is not exposed to the app so that a normal NNAPI/GPU delegate can be used instead. Test: Google Photos editor with PIXEL_2021_EXPERIENCE feature in product Signed-off-by: Kuba Wojciechowski <[email protected]> Change-Id: I51a02f8347324c7a85f3136b802dce4cc4556ac5 Co-authored-by: Kuba Wojciechowski <[email protected]> Co-authored-by: kondors1995 <[email protected]> Co-authored-by: ReallySnow <[email protected]> Change-Id: Ia785b7a004192c96d1c0abe58733fb8700d43e25 Signed-off-by: palaych <[email protected]> Signed-off-by: Adithya R <[email protected]>
1 parent bc142d8 commit a79deb9

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

core/java/android/app/ApplicationPackageManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
import com.android.internal.annotations.GuardedBy;
102102
import com.android.internal.annotations.Immutable;
103103
import com.android.internal.annotations.VisibleForTesting;
104+
import com.android.internal.gmscompat.AttestationHooks;
104105
import com.android.internal.os.SomeArgs;
105106
import com.android.internal.util.UserIcons;
106107

@@ -668,7 +669,8 @@ protected Boolean recompute(HasSystemFeatureQuery query) {
668669

669670
@Override
670671
public boolean hasSystemFeature(String name, int version) {
671-
return mHasSystemFeatureCache.query(new HasSystemFeatureQuery(name, version));
672+
return AttestationHooks.hasSystemFeature(name,
673+
mHasSystemFeatureCache.query(new HasSystemFeatureQuery(name, version)));
672674
}
673675

674676
/** @hide */

core/java/com/android/internal/gmscompat/AttestationHooks.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,59 @@
1717
package com.android.internal.gmscompat;
1818

1919
import android.app.Application;
20+
import android.content.res.Resources;
2021
import android.os.Build;
2122
import android.os.SystemProperties;
2223
import android.util.Log;
2324

25+
import com.android.internal.R;
26+
2427
import java.lang.reflect.Field;
28+
import java.util.Arrays;
29+
import java.util.HashMap;
30+
import java.util.Map;
2531

2632
/** @hide */
2733
public final class AttestationHooks {
2834
private static final String TAG = "GmsCompat/Attestation";
2935

3036
private static final String PACKAGE_GMS = "com.google.android.gms";
37+
private static final String PACKAGE_GPHOTOS = "com.google.android.apps.photos";
3138

3239
private static final String PROCESS_UNSTABLE = "com.google.android.gms.unstable";
3340

3441
private static final String PRODUCT_GMS_SPOOFING_FINGERPRINT =
3542
SystemProperties.get("ro.build.gms_fingerprint");
3643

44+
private static final Map<String, String> sP1Props = new HashMap<>();
45+
static {
46+
sP1Props.put("BRAND", "google");
47+
sP1Props.put("MANUFACTURER", "Google");
48+
sP1Props.put("DEVICE", "marlin");
49+
sP1Props.put("PRODUCT", "marlin");
50+
sP1Props.put("MODEL", "Pixel XL");
51+
sP1Props.put("FINGERPRINT", "google/marlin/marlin:10/QP1A.191005.007.A3/5972272:user/release-keys");
52+
}
53+
54+
private static final String[] sFeaturesBlacklist = {
55+
"PIXEL_2017_EXPERIENCE",
56+
"PIXEL_2017_PRELOAD",
57+
"PIXEL_2018_PRELOAD",
58+
"PIXEL_2019_EXPERIENCE",
59+
"PIXEL_2019_MIDYEAR_EXPERIENCE",
60+
"PIXEL_2019_MIDYEAR_PRELOAD",
61+
"PIXEL_2019_PRELOAD",
62+
"PIXEL_2020_EXPERIENCE",
63+
"PIXEL_2020_MIDYEAR_EXPERIENCE",
64+
"PIXEL_2021_EXPERIENCE",
65+
"PIXEL_2021_MIDYEAR_EXPERIENCE"
66+
};
67+
68+
private static volatile boolean sIsPhotos = false;
69+
70+
private static final boolean sSpoofPhotos =
71+
Resources.getSystem().getBoolean(R.bool.config_spoofGooglePhotos);
72+
3773
private AttestationHooks() { }
3874

3975
private static void setBuildField(String key, String value) {
@@ -66,6 +102,17 @@ public static void initApplicationBeforeOnCreate(Application app) {
66102
if (PACKAGE_GMS.equals(app.getPackageName()) &&
67103
PROCESS_UNSTABLE.equals(Application.getProcessName())) {
68104
spoofBuildGms();
105+
} else if (sSpoofPhotos && PACKAGE_GPHOTOS.equals(app.getPackageName())) {
106+
sIsPhotos = true;
107+
sP1Props.forEach((k, v) -> setBuildField(k, v));
108+
}
109+
}
110+
111+
public static boolean hasSystemFeature(String name, boolean def) {
112+
if (sIsPhotos && def &&
113+
Arrays.stream(sFeaturesBlacklist).anyMatch(name::contains)) {
114+
return false;
69115
}
116+
return def;
70117
}
71118
}

core/res/res/values/custom_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,7 @@
226226
<bool name="config_pocketModeSupported">true</bool>
227227
<bool name="config_pocketUseLightSensor">true</bool>
228228

229+
<!-- Whether to spoof device as Pixel XL for Google Photos -->
230+
<bool name="config_spoofGooglePhotos">true</bool>
231+
229232
</resources>

core/res/res/values/custom_symbols.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,7 @@
162162
<java-symbol type="bool" name="config_pocketModeSupported" />
163163
<java-symbol type="bool" name="config_pocketUseLightSensor" />
164164

165+
<!-- Whether to spoof device as Pixel XL for Google Photos -->
166+
<java-symbol type="bool" name="config_spoofGooglePhotos" />
167+
165168
</resources>

0 commit comments

Comments
 (0)