forked from LeddaZ/frameworks_base
PropImitationHooks: Run google-java-format with AOSP style
Change-Id: Ic3bf8e75eee14dfa5bf8c806688bfbbfbabd17e4
This commit is contained in:
parent
81d019fafe
commit
86e2a36c0a
|
@ -25,8 +25,8 @@ import android.app.TaskStackListener;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -50,58 +50,62 @@ public class PropImitationHooks {
|
||||||
private static final String PACKAGE_GPHOTOS = "com.google.android.apps.photos";
|
private static final String PACKAGE_GPHOTOS = "com.google.android.apps.photos";
|
||||||
|
|
||||||
private static final String PACKAGE_SETUPWIZARD = "com.google.android.setupwizard";
|
private static final String PACKAGE_SETUPWIZARD = "com.google.android.setupwizard";
|
||||||
private static final String PACKAGE_SUBSCRIPTION_RED = "com.google.android.apps.subscriptions.red";
|
private static final String PACKAGE_SUBSCRIPTION_RED =
|
||||||
|
"com.google.android.apps.subscriptions.red";
|
||||||
private static final String PACKAGE_VELVET = "com.google.android.googlequicksearchbox";
|
private static final String PACKAGE_VELVET = "com.google.android.googlequicksearchbox";
|
||||||
|
|
||||||
private static final ComponentName GMS_ADD_ACCOUNT_ACTIVITY = ComponentName.unflattenFromString(
|
private static final ComponentName GMS_ADD_ACCOUNT_ACTIVITY =
|
||||||
"com.google.android.gms/.auth.uiflows.minutemaid.MinuteMaidActivity");
|
ComponentName.unflattenFromString(
|
||||||
|
"com.google.android.gms/.auth.uiflows.minutemaid.MinuteMaidActivity");
|
||||||
|
|
||||||
private static final Map<String, String> sPixelNineProps = Map.of(
|
private static final Map<String, String> sPixelNineProps =
|
||||||
"PRODUCT", "komodo",
|
Map.of(
|
||||||
"DEVICE", "komodo",
|
"PRODUCT", "komodo",
|
||||||
"HARDWARE", "komodo",
|
"DEVICE", "komodo",
|
||||||
"MANUFACTURER", "Google",
|
"HARDWARE", "komodo",
|
||||||
"BRAND", "google",
|
"MANUFACTURER", "Google",
|
||||||
"MODEL", "Pixel 9 Pro XL",
|
"BRAND", "google",
|
||||||
"ID", "AP4A.241205.013",
|
"MODEL", "Pixel 9 Pro XL",
|
||||||
"FINGERPRINT", "google/komodo/komodo:15/AP4A.241205.013/12621605:user/release-keys"
|
"ID", "AP4A.241205.013",
|
||||||
);
|
"FINGERPRINT",
|
||||||
|
"google/komodo/komodo:15/AP4A.241205.013/12621605:user/release-keys");
|
||||||
|
|
||||||
private static final Map<String, String> sPixelTabletProps = Map.of(
|
private static final Map<String, String> sPixelTabletProps =
|
||||||
"PRODUCT", "tangorpro",
|
Map.of(
|
||||||
"DEVICE", "tangorpro",
|
"PRODUCT", "tangorpro",
|
||||||
"HARDWARE", "tangorpro",
|
"DEVICE", "tangorpro",
|
||||||
"MANUFACTURER", "Google",
|
"HARDWARE", "tangorpro",
|
||||||
"BRAND", "google",
|
"MANUFACTURER", "Google",
|
||||||
"MODEL", "Pixel Tablet",
|
"BRAND", "google",
|
||||||
"ID", "AP4A.241205.013",
|
"MODEL", "Pixel Tablet",
|
||||||
"FINGERPRINT", "google/tangorpro/tangorpro:15/AP4A.241205.013/12621605:user/release-keys"
|
"ID", "AP4A.241205.013",
|
||||||
);
|
"FINGERPRINT",
|
||||||
|
"google/tangorpro/tangorpro:15/AP4A.241205.013/12621605:user/release-keys");
|
||||||
|
|
||||||
private static final Set<String> sPixelFeatures = Set.of(
|
private static final Set<String> sPixelFeatures =
|
||||||
"PIXEL_2017_EXPERIENCE",
|
Set.of(
|
||||||
"PIXEL_2017_PRELOAD",
|
"PIXEL_2017_EXPERIENCE",
|
||||||
"PIXEL_2018_EXPERIENCE",
|
"PIXEL_2017_PRELOAD",
|
||||||
"PIXEL_2018_PRELOAD",
|
"PIXEL_2018_EXPERIENCE",
|
||||||
"PIXEL_2019_EXPERIENCE",
|
"PIXEL_2018_PRELOAD",
|
||||||
"PIXEL_2019_MIDYEAR_EXPERIENCE",
|
"PIXEL_2019_EXPERIENCE",
|
||||||
"PIXEL_2019_MIDYEAR_PRELOAD",
|
"PIXEL_2019_MIDYEAR_EXPERIENCE",
|
||||||
"PIXEL_2019_PRELOAD",
|
"PIXEL_2019_MIDYEAR_PRELOAD",
|
||||||
"PIXEL_2020_EXPERIENCE",
|
"PIXEL_2019_PRELOAD",
|
||||||
"PIXEL_2020_MIDYEAR_EXPERIENCE",
|
"PIXEL_2020_EXPERIENCE",
|
||||||
"PIXEL_2021_MIDYEAR_EXPERIENCE",
|
"PIXEL_2020_MIDYEAR_EXPERIENCE",
|
||||||
"PIXEL_EXPERIENCE"
|
"PIXEL_2021_MIDYEAR_EXPERIENCE",
|
||||||
);
|
"PIXEL_EXPERIENCE");
|
||||||
|
|
||||||
private static final Set<String> sTensorFeatures = Set.of(
|
private static final Set<String> sTensorFeatures =
|
||||||
"PIXEL_2021_EXPERIENCE",
|
Set.of(
|
||||||
"PIXEL_2022_EXPERIENCE",
|
"PIXEL_2021_EXPERIENCE",
|
||||||
"PIXEL_2022_MIDYEAR_EXPERIENCE",
|
"PIXEL_2022_EXPERIENCE",
|
||||||
"PIXEL_2023_EXPERIENCE",
|
"PIXEL_2022_MIDYEAR_EXPERIENCE",
|
||||||
"PIXEL_2023_MIDYEAR_EXPERIENCE",
|
"PIXEL_2023_EXPERIENCE",
|
||||||
"PIXEL_2024_EXPERIENCE",
|
"PIXEL_2023_MIDYEAR_EXPERIENCE",
|
||||||
"PIXEL_2024_MIDYEAR_EXPERIENCE"
|
"PIXEL_2024_EXPERIENCE",
|
||||||
);
|
"PIXEL_2024_MIDYEAR_EXPERIENCE");
|
||||||
|
|
||||||
private static volatile String[] sCertifiedProps;
|
private static volatile String[] sCertifiedProps;
|
||||||
private static volatile String sStockFp;
|
private static volatile String sStockFp;
|
||||||
|
@ -154,14 +158,19 @@ public class PropImitationHooks {
|
||||||
dlog("Spoofing Pixel Tablet for: " + packageName + " process: " + processName);
|
dlog("Spoofing Pixel Tablet for: " + packageName + " process: " + processName);
|
||||||
setProps(sPixelTabletProps);
|
setProps(sPixelTabletProps);
|
||||||
} else {
|
} else {
|
||||||
dlog("Spoofing Pixel 9 Pro XL for: " + packageName + " process: " + processName);
|
dlog(
|
||||||
|
"Spoofing Pixel 9 Pro XL for: "
|
||||||
|
+ packageName
|
||||||
|
+ " process: "
|
||||||
|
+ processName);
|
||||||
setProps(sPixelNineProps);
|
setProps(sPixelNineProps);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case PACKAGE_ARCORE:
|
case PACKAGE_ARCORE:
|
||||||
if (!sStockFp.isEmpty()) {
|
if (!sStockFp.isEmpty()) {
|
||||||
dlog("Setting stock fingerprint for: " + packageName);
|
dlog("Setting stock fingerprint for: " + packageName);
|
||||||
setPropValue("FINGERPRINT", sStockFp);;
|
setPropValue("FINGERPRINT", sStockFp);
|
||||||
|
;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -195,17 +204,23 @@ public class PropImitationHooks {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean was = isGmsAddAccountActivityOnTop();
|
final boolean was = isGmsAddAccountActivityOnTop();
|
||||||
final TaskStackListener taskStackListener = new TaskStackListener() {
|
final TaskStackListener taskStackListener =
|
||||||
@Override
|
new TaskStackListener() {
|
||||||
public void onTaskStackChanged() {
|
@Override
|
||||||
final boolean is = isGmsAddAccountActivityOnTop();
|
public void onTaskStackChanged() {
|
||||||
if (is ^ was) {
|
final boolean is = isGmsAddAccountActivityOnTop();
|
||||||
dlog("GmsAddAccountActivityOnTop is:" + is + " was:" + was +
|
if (is ^ was) {
|
||||||
", killing myself!"); // process will restart automatically later
|
dlog(
|
||||||
Process.killProcess(Process.myPid());
|
"GmsAddAccountActivityOnTop is:"
|
||||||
}
|
+ is
|
||||||
}
|
+ " was:"
|
||||||
};
|
+ was
|
||||||
|
+ ", killing myself!"); // process will restart
|
||||||
|
// automatically later
|
||||||
|
Process.killProcess(Process.myPid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
if (!was) {
|
if (!was) {
|
||||||
dlog("Spoofing build for GMS");
|
dlog("Spoofing build for GMS");
|
||||||
setCertifiedProps();
|
setCertifiedProps();
|
||||||
|
@ -235,7 +250,8 @@ public class PropImitationHooks {
|
||||||
try {
|
try {
|
||||||
final ActivityTaskManager.RootTaskInfo focusedTask =
|
final ActivityTaskManager.RootTaskInfo focusedTask =
|
||||||
ActivityTaskManager.getService().getFocusedRootTaskInfo();
|
ActivityTaskManager.getService().getFocusedRootTaskInfo();
|
||||||
return focusedTask != null && focusedTask.topActivity != null
|
return focusedTask != null
|
||||||
|
&& focusedTask.topActivity != null
|
||||||
&& focusedTask.topActivity.equals(GMS_ADD_ACCOUNT_ACTIVITY);
|
&& focusedTask.topActivity.equals(GMS_ADD_ACCOUNT_ACTIVITY);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Unable to get top activity!", e);
|
Log.e(TAG, "Unable to get top activity!", e);
|
||||||
|
@ -258,8 +274,9 @@ public class PropImitationHooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isCallerSafetyNet() {
|
private static boolean isCallerSafetyNet() {
|
||||||
return sIsGms && Arrays.stream(Thread.currentThread().getStackTrace())
|
return sIsGms
|
||||||
.anyMatch(elem -> elem.getClassName().contains("DroidGuard"));
|
&& Arrays.stream(Thread.currentThread().getStackTrace())
|
||||||
|
.anyMatch(elem -> elem.getClassName().contains("DroidGuard"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onEngineGetCertificateChain() {
|
public static void onEngineGetCertificateChain() {
|
||||||
|
@ -271,9 +288,11 @@ public class PropImitationHooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasSystemFeature(String name, boolean has) {
|
public static boolean hasSystemFeature(String name, boolean has) {
|
||||||
if (sIsPhotos && !sIsPixelDevice && has
|
if (sIsPhotos
|
||||||
|
&& !sIsPixelDevice
|
||||||
|
&& has
|
||||||
&& (sPixelFeatures.stream().anyMatch(name::contains)
|
&& (sPixelFeatures.stream().anyMatch(name::contains)
|
||||||
|| sTensorFeatures.stream().anyMatch(name::contains))) {
|
|| sTensorFeatures.stream().anyMatch(name::contains))) {
|
||||||
dlog("Blocked system feature " + name + " for Google Photos");
|
dlog("Blocked system feature " + name + " for Google Photos");
|
||||||
has = false;
|
has = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue