Merge "Integrate system feature codegen into SystemServer + framework" into main am: f098e278ed am: a03e5b5ecf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3293664
Change-Id: I599e033776a18c80e8abdbaa7b7bcdbc575ea30b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index ed6b851..fb5a12b 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -132,6 +132,7 @@
import com.android.internal.annotations.Immutable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.SomeArgs;
+import com.android.internal.pm.RoSystemFeatures;
import com.android.internal.util.UserIcons;
import dalvik.system.VMRuntime;
@@ -822,6 +823,16 @@
@Override
public Boolean recompute(HasSystemFeatureQuery query) {
try {
+ // As an optimization, check first to see if the feature was defined at
+ // compile-time as either available or unavailable.
+ // TODO(b/203143243): Consider hoisting this optimization out of the cache
+ // after the trunk stable (build) flag has soaked and more features are
+ // defined at compile-time.
+ Boolean maybeHasSystemFeature =
+ RoSystemFeatures.maybeHasFeature(query.name, query.version);
+ if (maybeHasSystemFeature != null) {
+ return maybeHasSystemFeature.booleanValue();
+ }
return ActivityThread.currentActivityThread().getPackageManager().
hasSystemFeature(query.name, query.version);
} catch (RemoteException e) {
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 0b7ce75..e052f94 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -106,6 +106,7 @@
import com.android.internal.os.ApplicationSharedMemory;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.RuntimeInit;
+import com.android.internal.pm.RoSystemFeatures;
import com.android.internal.policy.AttributeCache;
import com.android.internal.protolog.ProtoLog;
import com.android.internal.protolog.ProtoLogConfigurationServiceImpl;
@@ -1495,8 +1496,7 @@
boolean disableCameraService = SystemProperties.getBoolean("config.disable_cameraservice",
false);
- boolean isWatch = context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WATCH);
+ boolean isWatch = RoSystemFeatures.hasFeatureWatch(context);
boolean isArc = context.getPackageManager().hasSystemFeature(
"org.chromium.arc");
@@ -2758,7 +2758,7 @@
t.traceEnd();
}
- if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_EMBEDDED)) {
+ if (RoSystemFeatures.hasFeatureEmbedded(context)) {
t.traceBegin("StartIoTSystemService");
mSystemServiceManager.startService(IOT_SERVICE_CLASS);
t.traceEnd();
@@ -3137,9 +3137,7 @@
}, WEBVIEW_PREPARATION);
}
- boolean isAutomotive = mPackageManager
- .hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
- if (isAutomotive) {
+ if (RoSystemFeatures.hasFeatureAutomotive(context)) {
t.traceBegin("StartCarServiceHelperService");
final SystemService cshs = mSystemServiceManager
.startService(CAR_SERVICE_HELPER_SERVICE_CLASS);