ComponentAlias: Change device config namespace
Now use the namespace "activity_manager_ca". Reason: When the device boots up, phenotype will reset all the values in "activity_manager". To avoid it, we use a different namespace. Test: atest ComponentAliasTests ComponentAliasTests1 ComponentAliasTests2 Bug: 196254758 Change-Id: I540417a1e1b612424e8426981c1e02e1c68132f8
This commit is contained in:
parent
836db75e0f
commit
9b8d1d4b34
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user