|
17 | 17 | package com.android.internal.gmscompat;
|
18 | 18 |
|
19 | 19 | import android.app.Application;
|
| 20 | +import android.content.res.Resources; |
20 | 21 | import android.os.Build;
|
21 | 22 | import android.os.SystemProperties;
|
22 | 23 | import android.util.Log;
|
23 | 24 |
|
| 25 | +import com.android.internal.R; |
| 26 | + |
24 | 27 | import java.lang.reflect.Field;
|
| 28 | +import java.util.Arrays; |
| 29 | +import java.util.HashMap; |
| 30 | +import java.util.Map; |
25 | 31 |
|
26 | 32 | /** @hide */
|
27 | 33 | public final class AttestationHooks {
|
28 | 34 | private static final String TAG = "GmsCompat/Attestation";
|
29 | 35 |
|
30 | 36 | private static final String PACKAGE_GMS = "com.google.android.gms";
|
| 37 | + private static final String PACKAGE_GPHOTOS = "com.google.android.apps.photos"; |
31 | 38 |
|
32 | 39 | private static final String PROCESS_UNSTABLE = "com.google.android.gms.unstable";
|
33 | 40 |
|
34 | 41 | private static final String PRODUCT_GMS_SPOOFING_FINGERPRINT =
|
35 | 42 | SystemProperties.get("ro.build.gms_fingerprint");
|
36 | 43 |
|
| 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 | + |
37 | 73 | private AttestationHooks() { }
|
38 | 74 |
|
39 | 75 | private static void setBuildField(String key, String value) {
|
@@ -66,6 +102,17 @@ public static void initApplicationBeforeOnCreate(Application app) {
|
66 | 102 | if (PACKAGE_GMS.equals(app.getPackageName()) &&
|
67 | 103 | PROCESS_UNSTABLE.equals(Application.getProcessName())) {
|
68 | 104 | 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; |
69 | 115 | }
|
| 116 | + return def; |
70 | 117 | }
|
71 | 118 | }
|
0 commit comments