Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7eba825 authored by Jared Duke's avatar Jared Duke
Browse files

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
parent dbea722f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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) {
+4 −6
Original line number Diff line number Diff line
@@ -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);