summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jared Duke <jdduke@google.com> 2024-10-04 22:51:27 +0000
committer Jared Duke <jdduke@google.com> 2024-10-18 23:36:29 +0000
commitf7eba82552d9d064cc794aa035098d1d59c17167 (patch)
tree6b067f49cd4a6867209f7c4dfc4ca9f66209bdbd
parentdbea722f1e388bae5976c6a5eca0508044cbf194 (diff)
Integrate system feature codegen into SystemServer + framework
Reroute feature queries in SystemServer init for the following APIS: * hasFeatureWatch * hasFeatureAutomotive * hasFeatureEmbedded Also handle related queries in ApplicationPackageManager for such features. The current codegen is a no-op with respect to this behavior as RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS is flagged as off, and these features are not yet defined at compile time. A follow-up change will refactor additional feature types and queries to use the new helper API, with some supportive lint checks where appropriate. This usage remains restricted to internal platform targets. Bug: 203143243 Test: atest FrameworksServicesTests FrameworksCoreTests Flag: build.RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS Change-Id: I3d82c9d775b23106238dd4bb067d69465332de85
-rw-r--r--core/java/android/app/ApplicationPackageManager.java11
-rw-r--r--services/java/com/android/server/SystemServer.java10
2 files changed, 15 insertions, 6 deletions
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 5956e2bde242..7a9553258006 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -129,6 +129,7 @@ import com.android.internal.annotations.GuardedBy;
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;
@@ -818,6 +819,16 @@ public class ApplicationPackageManager extends PackageManager {
@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 b676fa2455b1..cae941f98abf 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -104,6 +104,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.notification.SystemNotificationChannels;
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.util.ConcurrentUtils;
import com.android.internal.util.EmergencyAffordanceManager;
@@ -1465,8 +1466,7 @@ public final class SystemServer implements Dumpable {
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");
@@ -2708,7 +2708,7 @@ public final class SystemServer implements Dumpable {
t.traceEnd();
}
- if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_EMBEDDED)) {
+ if (RoSystemFeatures.hasFeatureEmbedded(context)) {
t.traceBegin("StartIoTSystemService");
mSystemServiceManager.startService(IOT_SERVICE_CLASS);
t.traceEnd();
@@ -3077,9 +3077,7 @@ public final class SystemServer implements Dumpable {
}, 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);