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

Commit a2d78d2a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "ComponentAlias: Change device config namespace" into tm-dev am: 45b079a3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17111872

Change-Id: Ieeee088445e19b6eb6ec9347c78934e539f2b5e7
parents 1d4c3a08 45b079a3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -73,6 +73,13 @@ public final class DeviceConfig {
    @SystemApi
    public static final String NAMESPACE_ACTIVITY_MANAGER = "activity_manager";

    /**
     * Namespace for activity manager, specific to the "component alias" feature. We needed a
     * different namespace in order to avoid phonetype from resetting it.
     * @hide
     */
    public static final String NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS = "activity_manager_ca";

    /**
     * Namespace for all activity manager related features that are used at the native level.
     * These features are applied at reboot.
+37 −6
Original line number Diff line number Diff line
@@ -127,7 +127,15 @@ final class ActivityManagerConstants extends ContentObserver {
    static final String KEY_KILL_BG_RESTRICTED_CACHED_IDLE = "kill_bg_restricted_cached_idle";
    static final String KEY_KILL_BG_RESTRICTED_CACHED_IDLE_SETTLE_TIME =
            "kill_bg_restricted_cached_idle_settle_time";
    /**
     * Note this key is on {@link DeviceConfig#NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS}.
     * @see #mEnableComponentAlias
     */
    static final String KEY_ENABLE_COMPONENT_ALIAS = "enable_experimental_component_alias";
    /**
     * Note this key is on {@link DeviceConfig#NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS}.
     * @see #mComponentAliasOverrides
     */
    static final String KEY_COMPONENT_ALIAS_OVERRIDES = "component_alias_overrides";

    private static final int DEFAULT_MAX_CACHED_PROCESSES = 32;
@@ -899,10 +907,6 @@ final class ActivityManagerConstants extends ContentObserver {
                            case KEY_ENABLE_EXTRA_SERVICE_RESTART_DELAY_ON_MEM_PRESSURE:
                                updateEnableExtraServiceRestartDelayOnMemPressure();
                                break;
                            case KEY_ENABLE_COMPONENT_ALIAS:
                            case KEY_COMPONENT_ALIAS_OVERRIDES:
                                updateComponentAliases();
                                break;
                            case KEY_PROCESS_KILL_TIMEOUT:
                                updateProcessKillTimeout();
                                break;
@@ -925,6 +929,26 @@ final class ActivityManagerConstants extends ContentObserver {
                }
            };

    private final OnPropertiesChangedListener mOnDeviceConfigChangedForComponentAliasListener =
            new OnPropertiesChangedListener() {
                @Override
                public void onPropertiesChanged(Properties properties) {
                    for (String name : properties.getKeyset()) {
                        if (name == null) {
                            return;
                        }
                        switch (name) {
                            case KEY_ENABLE_COMPONENT_ALIAS:
                            case KEY_COMPONENT_ALIAS_OVERRIDES:
                                updateComponentAliases();
                                break;
                            default:
                                break;
                        }
                    }
                }
            };

    ActivityManagerConstants(Context context, ActivityManagerService service, Handler handler) {
        super(handler);
        mService = service;
@@ -991,6 +1015,10 @@ final class ActivityManagerConstants extends ContentObserver {
        DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
                ActivityThread.currentApplication().getMainExecutor(),
                mOnDeviceConfigChangedListener);
        DeviceConfig.addOnPropertiesChangedListener(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS,
                ActivityThread.currentApplication().getMainExecutor(),
                mOnDeviceConfigChangedForComponentAliasListener);
        loadDeviceConfigConstants();
        // The following read from Settings.
        updateActivityStartsLoggingEnabled();
@@ -1000,6 +1028,9 @@ final class ActivityManagerConstants extends ContentObserver {
    private void loadDeviceConfigConstants() {
        mOnDeviceConfigChangedListener.onPropertiesChanged(
                DeviceConfig.getProperties(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER));
        mOnDeviceConfigChangedForComponentAliasListener.onPropertiesChanged(
                DeviceConfig.getProperties(
                        DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS));
    }

    public void setOverrideMaxCachedProcesses(int value) {
@@ -1379,11 +1410,11 @@ final class ActivityManagerConstants extends ContentObserver {

    private void updateComponentAliases() {
        mEnableComponentAlias = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS,
                KEY_ENABLE_COMPONENT_ALIAS,
                DEFAULT_ENABLE_COMPONENT_ALIAS);
        mComponentAliasOverrides = DeviceConfig.getString(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS,
                KEY_COMPONENT_ALIAS_OVERRIDES,
                DEFAULT_COMPONENT_ALIAS_OVERRIDES);
        mService.mComponentAliasResolver.update(mEnableComponentAlias, mComponentAliasOverrides);
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public class BaseComponentAliasTest {
    protected static final Context sContext = InstrumentationRegistry.getTargetContext();

    protected static final DeviceConfigStateHelper sDeviceConfig = new DeviceConfigStateHelper(
            DeviceConfig.NAMESPACE_ACTIVITY_MANAGER);
            DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS);
    @Before
    public void enableComponentAliasWithCompatFlag() throws Exception {
        Assume.assumeTrue(Build.isDebuggable());
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import org.junit.Test;

public class ComponentAliasEnableWithDeviceConfigTest {
    protected static final DeviceConfigStateHelper sDeviceConfig = new DeviceConfigStateHelper(
            DeviceConfig.NAMESPACE_ACTIVITY_MANAGER);
            DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS);

    @AfterClass
    public static void restoreDeviceConfig() throws Exception {
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import org.junit.Test;
 */
public class ComponentAliasNotSupportedOnUserBuildTest {
    protected static final DeviceConfigStateHelper sDeviceConfig = new DeviceConfigStateHelper(
            DeviceConfig.NAMESPACE_ACTIVITY_MANAGER);
            DeviceConfig.NAMESPACE_ACTIVITY_MANAGER_COMPONENT_ALIAS);

    @AfterClass
    public static void restoreDeviceConfig() throws Exception {