Skip to content

Commit

Permalink
base: Switch to PixelPropsUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
jhenrique09 authored and basamaryan committed Aug 14, 2023
1 parent 7834dd7 commit dc5ae03
Show file tree
Hide file tree
Showing 8 changed files with 399 additions and 317 deletions.
55 changes: 52 additions & 3 deletions core/java/android/app/ApplicationPackageManager.java
Expand Up @@ -121,7 +121,6 @@
import com.android.internal.annotations.Immutable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.PropImitationHooks;
import com.android.internal.util.UserIcons;

import dalvik.system.VMRuntime;
Expand Down Expand Up @@ -808,10 +807,60 @@ public Boolean recompute(HasSystemFeatureQuery query) {
}
};

private static final String[] pTensorCodenames = {
"felix",
"tangorpro",
"lynx",
"cheetah",
"panther",
"bluejay",
"oriole",
"raven"
};

private static final String[] featuresPixel = {
"com.google.android.apps.photos.PIXEL_2019_PRELOAD",
"com.google.android.apps.photos.PIXEL_2019_MIDYEAR_PRELOAD",
"com.google.android.apps.photos.PIXEL_2018_PRELOAD",
"com.google.android.apps.photos.PIXEL_2017_PRELOAD",
"com.google.android.feature.PIXEL_2021_MIDYEAR_EXPERIENCE",
"com.google.android.feature.PIXEL_2020_EXPERIENCE",
"com.google.android.feature.PIXEL_2020_MIDYEAR_EXPERIENCE",
"com.google.android.feature.PIXEL_2019_EXPERIENCE",
"com.google.android.feature.PIXEL_2019_MIDYEAR_EXPERIENCE",
"com.google.android.feature.PIXEL_2018_EXPERIENCE",
"com.google.android.feature.PIXEL_2017_EXPERIENCE",
"com.google.android.feature.PIXEL_EXPERIENCE",
"com.google.android.feature.GOOGLE_BUILD",
"com.google.android.feature.GOOGLE_EXPERIENCE"
};

private static final String[] featuresTensor = {
"com.google.android.feature.PIXEL_2022_EXPERIENCE",
"com.google.android.feature.PIXEL_2022_MIDYEAR_EXPERIENCE",
"com.google.android.feature.PIXEL_2021_EXPERIENCE",
};

private static final String[] featuresNexus = {
"com.google.android.apps.photos.NEXUS_PRELOAD",
"com.google.android.apps.photos.nexus_preload"
};

@Override
public boolean hasSystemFeature(String name, int version) {
return PropImitationHooks.hasSystemFeature(name,
mHasSystemFeatureCache.query(new HasSystemFeatureQuery(name, version)));
if (name != null && Arrays.asList(featuresTensor).contains(name) &&
!Arrays.asList(pTensorCodenames).contains(SystemProperties.get("ro.product.device"))) {
return false;
}
String packageName = ActivityThread.currentPackageName();
if (packageName != null &&
packageName.equals("com.google.android.apps.photos")) {
if (Arrays.asList(featuresPixel).contains(name)) return false;
if (Arrays.asList(featuresNexus).contains(name)) return true;
}
if (Arrays.asList(featuresPixel).contains(name)) return true;

return mHasSystemFeatureCache.query(new HasSystemFeatureQuery(name, version));
}

/** @hide */
Expand Down
9 changes: 6 additions & 3 deletions core/java/android/app/Instrumentation.java
Expand Up @@ -56,7 +56,6 @@
import android.view.WindowManagerGlobal;

import com.android.internal.content.ReferrerIntent;
import com.android.internal.util.PropImitationHooks;

import java.io.File;
import java.lang.annotation.Retention;
Expand All @@ -65,6 +64,8 @@
import java.util.List;
import java.util.concurrent.TimeoutException;

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

/**
* Base class for implementing application instrumentation code. When running
* with instrumentation turned on, this class will be instantiated for you
Expand Down Expand Up @@ -1243,7 +1244,8 @@ public Application newApplication(ClassLoader cl, String className, Context cont
Application app = getFactory(context.getPackageName())
.instantiateApplication(cl, className);
app.attach(context);
PropImitationHooks.setProps(context);
String packageName = context.getPackageName();
PixelPropsUtils.setProps(packageName);
return app;
}

Expand All @@ -1261,7 +1263,8 @@ static public Application newApplication(Class<?> clazz, Context context)
ClassNotFoundException {
Application app = (Application)clazz.newInstance();
app.attach(context);
PropImitationHooks.setProps(context);
String packageName = context.getPackageName();
PixelPropsUtils.setProps(packageName);
return app;
}

Expand Down
280 changes: 0 additions & 280 deletions core/java/com/android/internal/util/PropImitationHooks.java

This file was deleted.

0 comments on commit dc5ae03

Please sign in to comment.