Skip to content

Commit

Permalink
Introduce PixelPropsUtils
Browse files Browse the repository at this point in the history
* 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 <jhenrique09.mcz@hotmail.com>
Co-authored-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
  • Loading branch information
2 people authored and neobuddy89 committed Mar 12, 2021
1 parent 1daa4bc commit 5eb8ec3
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/java/com/android/internal/os/Zygote.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import android.system.Os;
import android.util.Log;

import com.android.internal.util.crdroid.PixelPropsUtils;

import dalvik.annotation.optimization.FastNative;
import dalvik.system.ZygoteHooks;

Expand Down Expand Up @@ -794,6 +796,9 @@ static void setAppProcessName(ZygoteArguments args, String loggingTag) {
} else {
Log.w(loggingTag, "Unable to set package name.");
}

// Set pixel props
PixelPropsUtils.setProps(args.mPackageName);
}

private static final String USAP_ERROR_PREFIX = "Invalid command to USAP: ";
Expand Down
87 changes: 87 additions & 0 deletions core/java/com/android/internal/util/crdroid/PixelPropsUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright (C) 2020 The Pixel Experience Project
* 2021 crDroid Android Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.internal.util.crdroid;

import android.os.Build;
import android.util.Log;

import java.util.Arrays;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class PixelPropsUtils {

private static final String TAG = PixelPropsUtils.class.getSimpleName();
private static final boolean DEBUG = false;

private static final Map<String, Object> propsToChange;

private static final String[] packagesToChange = {
"com.google.android.apps.safetyhub",
"com.google.android.apps.turbo",
"com.google.android.apps.wallpaper",
"com.google.android.apps.maps",
"com.google.android.gms",
"com.google.android.googlequicksearchbox"
};

static {
propsToChange = new HashMap<>();
propsToChange.put("BRAND", "google");
propsToChange.put("MANUFACTURER", "Google");
propsToChange.put("DEVICE", "redfin");
propsToChange.put("PRODUCT", "redfin");
propsToChange.put("MODEL", "Pixel 5");
propsToChange.put("FINGERPRINT", "google/redfin/redfin:11/RQ2A.210305.007/7124944:user/release-keys");
}

public static void setProps(String packageName) {
if (packageName == null) {
return;
}
if (Arrays.asList(packagesToChange).contains(packageName)) {
if (DEBUG) {
Log.d(TAG, "Defining props for: " + packageName);
}
for (Map.Entry<String, Object> prop : propsToChange.entrySet()) {
String key = prop.getKey();
Object value = prop.getValue();
setPropValue(key, value);
}
}
// Set proper indexing fingerprint
if (packageName.equals("com.google.android.settings.intelligence")) {
setPropValue("FINGERPRINT", Build.DATE);
}
}

private static void setPropValue(String key, Object value) {
try {
if (DEBUG) {
Log.d(TAG, "Defining prop " + key + " to " + value.toString());
}
Field field = Build.class.getDeclaredField(key);
field.setAccessible(true);
field.set(null, value);
field.setAccessible(false);
} catch (NoSuchFieldException | IllegalAccessException e) {
Log.e(TAG, "Failed to set prop " + key, e);
}
}
}

0 comments on commit 5eb8ec3

Please sign in to comment.