Skip to content

Commit 5eb8ec3

Browse files
jhenrique09kdrag0n
authored andcommitted
Introduce PixelPropsUtils
* That will spoof build fingerprints on some g00gle apps * Thanks to @kdrag0n for the original idea at ProtonAOSP/android_frameworks_base@5a54bfd @neobuddy89: * Squash subsequent changes by jhenrique09 Signed-off-by: jhenrique09 <[email protected]> Co-authored-by: Danny Lin <[email protected]> Signed-off-by: Pranav Vashi <[email protected]> Signed-off-by: Pranav Vashi <[email protected]>
1 parent 1daa4bc commit 5eb8ec3

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

core/java/com/android/internal/os/Zygote.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import android.system.Os;
3636
import android.util.Log;
3737

38+
import com.android.internal.util.crdroid.PixelPropsUtils;
39+
3840
import dalvik.annotation.optimization.FastNative;
3941
import dalvik.system.ZygoteHooks;
4042

@@ -794,6 +796,9 @@ static void setAppProcessName(ZygoteArguments args, String loggingTag) {
794796
} else {
795797
Log.w(loggingTag, "Unable to set package name.");
796798
}
799+
800+
// Set pixel props
801+
PixelPropsUtils.setProps(args.mPackageName);
797802
}
798803

799804
private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: ";
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (C) 2020 The Pixel Experience Project
3+
* 2021 crDroid Android Project
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.android.internal.util.crdroid;
19+
20+
import android.os.Build;
21+
import android.util.Log;
22+
23+
import java.util.Arrays;
24+
import java.lang.reflect.Field;
25+
import java.util.HashMap;
26+
import java.util.Map;
27+
28+
public class PixelPropsUtils {
29+
30+
private static final String TAG = PixelPropsUtils.class.getSimpleName();
31+
private static final boolean DEBUG = false;
32+
33+
private static final Map<String, Object> propsToChange;
34+
35+
private static final String[] packagesToChange = {
36+
"com.google.android.apps.safetyhub",
37+
"com.google.android.apps.turbo",
38+
"com.google.android.apps.wallpaper",
39+
"com.google.android.apps.maps",
40+
"com.google.android.gms",
41+
"com.google.android.googlequicksearchbox"
42+
};
43+
44+
static {
45+
propsToChange = new HashMap<>();
46+
propsToChange.put("BRAND", "google");
47+
propsToChange.put("MANUFACTURER", "Google");
48+
propsToChange.put("DEVICE", "redfin");
49+
propsToChange.put("PRODUCT", "redfin");
50+
propsToChange.put("MODEL", "Pixel 5");
51+
propsToChange.put("FINGERPRINT", "google/redfin/redfin:11/RQ2A.210305.007/7124944:user/release-keys");
52+
}
53+
54+
public static void setProps(String packageName) {
55+
if (packageName == null) {
56+
return;
57+
}
58+
if (Arrays.asList(packagesToChange).contains(packageName)) {
59+
if (DEBUG) {
60+
Log.d(TAG, "Defining props for: " + packageName);
61+
}
62+
for (Map.Entry<String, Object> prop : propsToChange.entrySet()) {
63+
String key = prop.getKey();
64+
Object value = prop.getValue();
65+
setPropValue(key, value);
66+
}
67+
}
68+
// Set proper indexing fingerprint
69+
if (packageName.equals("com.google.android.settings.intelligence")) {
70+
setPropValue("FINGERPRINT", Build.DATE);
71+
}
72+
}
73+
74+
private static void setPropValue(String key, Object value) {
75+
try {
76+
if (DEBUG) {
77+
Log.d(TAG, "Defining prop " + key + " to " + value.toString());
78+
}
79+
Field field = Build.class.getDeclaredField(key);
80+
field.setAccessible(true);
81+
field.set(null, value);
82+
field.setAccessible(false);
83+
} catch (NoSuchFieldException | IllegalAccessException e) {
84+
Log.e(TAG, "Failed to set prop " + key, e);
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)