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

Commit 9efbc135 authored by Winson Chiu's avatar Winson Chiu
Browse files

Move SystemConfig to services.jar

Migrates getDefaultVrComponents used by SettingsProvider and
adds a flag for hidden API enforcement to ApplicationInfo.

This removes any dependency on SystemConfig from core/ and
so it can be moved into services/core and exposed as a
mainline API.

This was done instead of exposing all of the methods through
SystemConfigManager, as that is designed for use across
processes, and it's more efficient to expose SystemConfig
directly for modules running in the server process.

Although VrManager is a nullable service, so getDefaultVrComponents
had to live there to simplify the logic and maintain the existing
behavior.

Bug: 236389629

Change-Id: I4c2b14e1d34aaf439ceb1a3f9c8207e5d39fa6c2
parent 2ae0de31
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;

import com.android.server.SystemConfig;

import java.util.List;

/**
@@ -50,7 +48,7 @@ import java.util.List;
 * <overlayable name="OverlayableResourcesName" actor="overlay://namespace/actorName">
 * }</pre></p>
 *
 * <p>Actors are defined through {@link SystemConfig}. Only system packages can be used.
 * <p>Actors are defined through SystemConfig. Only system packages can be used.
 * The namespace "android" is reserved for use by AOSP and any "android" definitions must
 * have an implementation on device that fulfill their intended functionality.</p>
 *
+13 −3
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.window.OnBackInvokedCallback;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.Parcelling;
import com.android.internal.util.Parcelling.BuiltIn.ForBoolean;
import com.android.server.SystemConfig;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -803,7 +802,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE = 1 << 2;


    /**
     * If false, {@link android.view.KeyEvent#KEYCODE_BACK} related events will be forwarded to
     * the Activities, Dialogs and Views and {@link android.app.Activity#onBackPressed()},
@@ -815,12 +813,24 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK = 1 << 3;

    /**
     * Whether or not this package is allowed to access hidden APIs. Replacement for legacy
     * implementation of {@link #isPackageWhitelistedForHiddenApis()}.
     *
     * This is an internal flag and should never be used outside of this class. The real API for
     * the hidden API enforcement policy is {@link #getHiddenApiEnforcementPolicy()}.
     *
     * @hide
     */
    public static final int PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS = 1 << 4;

    /** @hide */
    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
            PRIVATE_FLAG_EXT_PROFILEABLE,
            PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION,
            PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE,
            PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK,
            PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ApplicationInfoPrivateFlagsExt {}
@@ -2222,7 +2232,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    }

    private boolean isPackageWhitelistedForHiddenApis() {
        return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
        return (privateFlagsExt & PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS) != 0;
    }

    /**
+5 −0
Original line number Diff line number Diff line
@@ -47,4 +47,9 @@ interface ISystemConfig {
     * @see SystemConfigManager#getEnabledComponentOverrides
     */
    List<ComponentName> getEnabledComponentOverrides(String packageName);

    /**
     * @see SystemConfigManager#getDefaultVrComponents
     */
    List<ComponentName> getDefaultVrComponents();
}
+14 −0
Original line number Diff line number Diff line
@@ -147,4 +147,18 @@ public class SystemConfigManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Return the components that are enabled by default as VR mode listener services.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.QUERY_ALL_PACKAGES)
    public List<ComponentName> getDefaultVrComponents() {
        try {
            return mInterface.getDefaultVrComponents();
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
        return Collections.emptyList();
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
        android:sharedUserId="android.uid.system">

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

    <application android:allowClearUserData="false"
                 android:label="@string/app_label"
Loading