Merge "Migrate usage of single property lister to multi prop listener." into qt-dev

am: 8e24abad64

Change-Id: Iba8191210ba73eaa42269891bf67cb8bd0cb3c1b
This commit is contained in:
Matt Pape
2019-05-01 13:14:37 -07:00
committed by android-build-merger
14 changed files with 135 additions and 150 deletions

View File

@@ -25,6 +25,7 @@ import android.content.Context;
import android.database.ContentObserver;
import android.os.ServiceManager;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.Properties;
import android.provider.Settings;
import android.service.textclassifier.TextClassifierService;
import android.view.textclassifier.TextClassifier.TextClassifierType;
@@ -199,7 +200,7 @@ public final class TextClassificationManager {
getApplicationContext().getContentResolver()
.unregisterContentObserver(mSettingsObserver);
if (ConfigParser.ENABLE_DEVICE_CONFIG) {
DeviceConfig.removeOnPropertyChangedListener(mSettingsObserver);
DeviceConfig.removeOnPropertiesChangedListener(mSettingsObserver);
}
}
} finally {
@@ -286,7 +287,7 @@ public final class TextClassificationManager {
}
private static final class SettingsObserver extends ContentObserver
implements DeviceConfig.OnPropertyChangedListener {
implements DeviceConfig.OnPropertiesChangedListener {
private final WeakReference<TextClassificationManager> mTcm;
@@ -298,7 +299,7 @@ public final class TextClassificationManager {
false /* notifyForDescendants */,
this);
if (ConfigParser.ENABLE_DEVICE_CONFIG) {
DeviceConfig.addOnPropertyChangedListener(
DeviceConfig.addOnPropertiesChangedListener(
DeviceConfig.NAMESPACE_TEXTCLASSIFIER,
ActivityThread.currentApplication().getMainExecutor(),
this);
@@ -311,7 +312,7 @@ public final class TextClassificationManager {
}
@Override
public void onPropertyChanged(String namespace, String name, String value) {
public void onPropertiesChanged(Properties properties) {
invalidateSettings();
}

View File

@@ -102,10 +102,10 @@ final class AssistantSettings extends ContentObserver {
}
private void registerDeviceConfigs() {
DeviceConfig.addOnPropertyChangedListener(
DeviceConfig.addOnPropertiesChangedListener(
DeviceConfig.NAMESPACE_SYSTEMUI,
this::postToHandler,
this::onDeviceConfigPropertyChanged);
(properties) -> onDeviceConfigPropertiesChanged(properties.getNamespace()));
// Update the fields in this class from the current state of the device config.
updateFromDeviceConfigFlags();
@@ -116,10 +116,10 @@ final class AssistantSettings extends ContentObserver {
}
@VisibleForTesting
void onDeviceConfigPropertyChanged(String namespace, String name, String value) {
void onDeviceConfigPropertiesChanged(String namespace) {
if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(namespace)) {
Log.e(LOG_TAG, "Received update from DeviceConfig for unrelated namespace: "
+ namespace + " " + name + "=" + value);
+ namespace);
return;
}

View File

@@ -96,10 +96,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
"false",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
"false");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertFalse(mAssistantSettings.mGenerateReplies);
}
@@ -111,10 +108,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
"true",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
"true");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertTrue(mAssistantSettings.mGenerateReplies);
}
@@ -126,10 +120,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
"false",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
"false");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertFalse(mAssistantSettings.mGenerateReplies);
@@ -138,10 +129,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
null,
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_REPLIES,
null);
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
// Go back to the default value.
assertTrue(mAssistantSettings.mGenerateReplies);
@@ -154,10 +142,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
"false",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
"false");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertFalse(mAssistantSettings.mGenerateActions);
}
@@ -169,10 +154,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
"true",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
"true");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertTrue(mAssistantSettings.mGenerateActions);
}
@@ -184,10 +166,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
"false",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
"false");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertFalse(mAssistantSettings.mGenerateActions);
@@ -196,10 +175,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
null,
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_GENERATE_ACTIONS,
null);
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
// Go back to the default value.
assertTrue(mAssistantSettings.mGenerateActions);
@@ -212,10 +188,7 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_MAX_MESSAGES_TO_EXTRACT,
"10",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_MAX_MESSAGES_TO_EXTRACT,
"10");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertEquals(10, mAssistantSettings.mMaxMessagesToExtract);
}
@@ -227,20 +200,14 @@ public class AssistantSettingsTest {
SystemUiDeviceConfigFlags.NAS_MAX_SUGGESTIONS,
"5",
false /* makeDefault */));
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_MAX_SUGGESTIONS,
"5");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertEquals(5, mAssistantSettings.mMaxSuggestions);
}
@Test
public void testMaxSuggestionsEmpty() {
mAssistantSettings.onDeviceConfigPropertyChanged(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_MAX_SUGGESTIONS,
"");
mAssistantSettings.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
assertEquals(DEFAULT_MAX_SUGGESTIONS, mAssistantSettings.mMaxSuggestions);
}

View File

@@ -39,6 +39,7 @@ import android.os.Handler;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.Properties;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
@@ -118,15 +119,18 @@ public class NotificationMediaManager implements Dumpable {
private ImageView mBackdropBack;
private boolean mShowCompactMediaSeekbar;
private final DeviceConfig.OnPropertyChangedListener mPropertyChangedListener =
new DeviceConfig.OnPropertyChangedListener() {
private final DeviceConfig.OnPropertiesChangedListener mPropertiesChangedListener =
new DeviceConfig.OnPropertiesChangedListener() {
@Override
public void onPropertyChanged(String namespace, String name, String value) {
if (SystemUiDeviceConfigFlags.COMPACT_MEDIA_SEEKBAR_ENABLED.equals(name)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: compact media seekbar flag updated: " + value);
public void onPropertiesChanged(Properties properties) {
for (String name : properties.getKeyset()) {
if (SystemUiDeviceConfigFlags.COMPACT_MEDIA_SEEKBAR_ENABLED.equals(name)) {
String value = properties.getString(name, null);
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: compact media seekbar flag updated: " + value);
}
mShowCompactMediaSeekbar = "true".equals(value);
}
mShowCompactMediaSeekbar = "true".equals(value);
}
}
};
@@ -189,9 +193,9 @@ public class NotificationMediaManager implements Dumpable {
DeviceConfig.getProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.COMPACT_MEDIA_SEEKBAR_ENABLED));
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
mContext.getMainExecutor(),
mPropertyChangedListener);
mPropertiesChangedListener);
}
public void setUpWithPresenter(NotificationPresenter presenter) {

View File

@@ -93,10 +93,10 @@ public final class SmartReplyConstants {
}
private void registerDeviceConfigListener() {
DeviceConfig.addOnPropertyChangedListener(
DeviceConfig.addOnPropertiesChangedListener(
DeviceConfig.NAMESPACE_SYSTEMUI,
this::postToHandler,
this::onDeviceConfigPropertyChanged);
(properties) -> onDeviceConfigPropertiesChanged(properties.getNamespace()));
}
private void postToHandler(Runnable r) {
@@ -104,10 +104,10 @@ public final class SmartReplyConstants {
}
@VisibleForTesting
void onDeviceConfigPropertyChanged(String namespace, String name, String value) {
void onDeviceConfigPropertiesChanged(String namespace) {
if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(namespace)) {
Log.e(TAG, "Received update from DeviceConfig for unrelated namespace: "
+ namespace + " " + name + "=" + value);
+ namespace);
return;
}

View File

@@ -229,8 +229,7 @@ public class SmartReplyConstantsTest extends SysuiTestCase {
}
private void triggerConstantsOnChange() {
mConstants.onDeviceConfigPropertyChanged(DeviceConfig.NAMESPACE_SYSTEMUI,
"" /* name */, "" /* value */);
mConstants.onDeviceConfigPropertiesChanged(DeviceConfig.NAMESPACE_SYSTEMUI);
}
private void resetAllDeviceConfigFlags() {

View File

@@ -94,6 +94,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* Entry point service for autofill management.
@@ -192,9 +193,9 @@ public final class AutofillManagerService
mUi = new AutoFillUI(ActivityThread.currentActivityThread().getSystemUiContext());
mAm = LocalServices.getService(ActivityManagerInternal.class);
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_AUTOFILL,
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_AUTOFILL,
ActivityThread.currentApplication().getMainExecutor(),
(namespace, key, value) -> onDeviceConfigChange(key));
(properties) -> onDeviceConfigChange(properties.getKeyset()));
setLogLevelFromSettings();
setMaxPartitionsFromSettings();
@@ -270,15 +271,17 @@ public final class AutofillManagerService
}
}
private void onDeviceConfigChange(@NonNull String key) {
switch (key) {
case AutofillManager.DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES:
case AutofillManager.DEVICE_CONFIG_AUGMENTED_SERVICE_IDLE_UNBIND_TIMEOUT:
case AutofillManager.DEVICE_CONFIG_AUGMENTED_SERVICE_REQUEST_TIMEOUT:
setDeviceConfigProperties();
break;
default:
Slog.i(mTag, "Ignoring change on " + key);
private void onDeviceConfigChange(@NonNull Set<String> keys) {
for (String key : keys) {
switch (key) {
case AutofillManager.DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES:
case AutofillManager.DEVICE_CONFIG_AUGMENTED_SERVICE_IDLE_UNBIND_TIMEOUT:
case AutofillManager.DEVICE_CONFIG_AUGMENTED_SERVICE_REQUEST_TIMEOUT:
setDeviceConfigProperties();
break;
default:
Slog.i(mTag, "Ignoring change on " + key);
}
}
}

View File

@@ -50,6 +50,7 @@ import android.os.ShellCallback;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.Properties;
import android.provider.Settings;
import android.service.contentcapture.ActivityEvent.ActivityEventType;
import android.util.ArraySet;
@@ -131,9 +132,9 @@ public final class ContentCaptureManagerService extends
com.android.internal.R.string.config_defaultContentCaptureService),
UserManager.DISALLOW_CONTENT_CAPTURE,
/*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_NO_REFRESH);
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
ActivityThread.currentApplication().getMainExecutor(),
(namespace, key, value) -> onDeviceConfigChange(key, value));
(properties) -> onDeviceConfigChange(properties));
setDeviceConfigProperties();
if (mDevCfgLogHistorySize > 0) {
@@ -255,23 +256,25 @@ public final class ContentCaptureManagerService extends
return enabled;
}
private void onDeviceConfigChange(@NonNull String key, @Nullable String value) {
switch (key) {
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_SERVICE_EXPLICITLY_ENABLED:
setDisabledByDeviceConfig(value);
return;
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL:
setLoggingLevelFromDeviceConfig();
return;
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_MAX_BUFFER_SIZE:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_TEXT_CHANGE_FLUSH_FREQUENCY:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT:
setFineTuneParamsFromDeviceConfig();
return;
default:
Slog.i(mTag, "Ignoring change on " + key);
private void onDeviceConfigChange(@NonNull Properties properties) {
for (String key : properties.getKeyset()) {
switch (key) {
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_SERVICE_EXPLICITLY_ENABLED:
setDisabledByDeviceConfig(properties.getString(key, null));
return;
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL:
setLoggingLevelFromDeviceConfig();
return;
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_MAX_BUFFER_SIZE:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_TEXT_CHANGE_FLUSH_FREQUENCY:
case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT:
setFineTuneParamsFromDeviceConfig();
return;
default:
Slog.i(mTag, "Ignoring change on " + key);
}
}
}

View File

@@ -802,8 +802,8 @@ class StorageManagerService extends IStorageManager.Stub
}
});
// For now, simply clone property when it changes
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_STORAGE,
mContext.getMainExecutor(), (namespace, name, value) -> {
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_STORAGE,
mContext.getMainExecutor(), (properties) -> {
refreshIsolatedStorageSettings();
});
refreshIsolatedStorageSettings();

View File

@@ -26,7 +26,8 @@ import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.OnPropertyChangedListener;
import android.provider.DeviceConfig.OnPropertiesChangedListener;
import android.provider.DeviceConfig.Properties;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.TextUtils.SimpleStringSplitter;
@@ -315,23 +316,25 @@ final class ActivityManagerConstants extends ContentObserver {
private static final Uri ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI =
Settings.Global.getUriFor(Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS);
private final OnPropertyChangedListener mOnDeviceConfigChangedListener =
new OnPropertyChangedListener() {
private final OnPropertiesChangedListener mOnDeviceConfigChangedListener =
new OnPropertiesChangedListener() {
@Override
public void onPropertyChanged(String namespace, String name, String value) {
if (name == null) {
return;
}
switch (name) {
case KEY_MAX_CACHED_PROCESSES:
updateMaxCachedProcesses();
break;
case KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED:
case KEY_BACKGROUND_ACTIVITY_STARTS_PACKAGE_NAMES_WHITELIST:
updateBackgroundActivityStarts();
break;
default:
break;
public void onPropertiesChanged(Properties properties) {
for (String name : properties.getKeyset()) {
if (name == null) {
return;
}
switch (name) {
case KEY_MAX_CACHED_PROCESSES:
updateMaxCachedProcesses();
break;
case KEY_DEFAULT_BACKGROUND_ACTIVITY_STARTS_ENABLED:
case KEY_BACKGROUND_ACTIVITY_STARTS_PACKAGE_NAMES_WHITELIST:
updateBackgroundActivityStarts();
break;
default:
break;
}
}
}
};
@@ -362,7 +365,7 @@ final class ActivityManagerConstants extends ContentObserver {
if (mSystemServerAutomaticHeapDumpEnabled) {
updateEnableAutomaticSystemServerHeapDumps();
}
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
ActivityThread.currentApplication().getMainExecutor(),
mOnDeviceConfigChangedListener);
updateMaxCachedProcesses();

View File

@@ -30,7 +30,8 @@ import android.os.Process;
import android.os.SystemClock;
import android.os.Trace;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.OnPropertyChangedListener;
import android.provider.DeviceConfig.OnPropertiesChangedListener;
import android.provider.DeviceConfig.Properties;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Slog;
@@ -126,29 +127,31 @@ public final class AppCompactor {
private final ArrayList<ProcessRecord> mPendingCompactionProcesses =
new ArrayList<ProcessRecord>();
private final ActivityManagerService mAm;
private final OnPropertyChangedListener mOnFlagsChangedListener =
new OnPropertyChangedListener() {
private final OnPropertiesChangedListener mOnFlagsChangedListener =
new OnPropertiesChangedListener() {
@Override
public void onPropertyChanged(String namespace, String name, String value) {
public void onPropertiesChanged(Properties properties) {
synchronized (mPhenotypeFlagLock) {
if (KEY_USE_COMPACTION.equals(name)) {
updateUseCompaction();
} else if (KEY_COMPACT_ACTION_1.equals(name)
|| KEY_COMPACT_ACTION_2.equals(name)) {
updateCompactionActions();
} else if (KEY_COMPACT_THROTTLE_1.equals(name)
|| KEY_COMPACT_THROTTLE_2.equals(name)
|| KEY_COMPACT_THROTTLE_3.equals(name)
|| KEY_COMPACT_THROTTLE_4.equals(name)) {
updateCompactionThrottles();
} else if (KEY_COMPACT_STATSD_SAMPLE_RATE.equals(name)) {
updateStatsdSampleRate();
} else if (KEY_COMPACT_FULL_RSS_THROTTLE_KB.equals(name)) {
updateFullRssThrottle();
} else if (KEY_COMPACT_FULL_DELTA_RSS_THROTTLE_KB.equals(name)) {
updateFullDeltaRssThrottle();
} else if (KEY_COMPACT_PROC_STATE_THROTTLE.equals(name)) {
updateProcStateThrottle();
for (String name : properties.getKeyset()) {
if (KEY_USE_COMPACTION.equals(name)) {
updateUseCompaction();
} else if (KEY_COMPACT_ACTION_1.equals(name)
|| KEY_COMPACT_ACTION_2.equals(name)) {
updateCompactionActions();
} else if (KEY_COMPACT_THROTTLE_1.equals(name)
|| KEY_COMPACT_THROTTLE_2.equals(name)
|| KEY_COMPACT_THROTTLE_3.equals(name)
|| KEY_COMPACT_THROTTLE_4.equals(name)) {
updateCompactionThrottles();
} else if (KEY_COMPACT_STATSD_SAMPLE_RATE.equals(name)) {
updateStatsdSampleRate();
} else if (KEY_COMPACT_FULL_RSS_THROTTLE_KB.equals(name)) {
updateFullRssThrottle();
} else if (KEY_COMPACT_FULL_DELTA_RSS_THROTTLE_KB.equals(name)) {
updateFullDeltaRssThrottle();
} else if (KEY_COMPACT_PROC_STATE_THROTTLE.equals(name)) {
updateProcStateThrottle();
}
}
}
if (mTestCallback != null) {
@@ -229,7 +232,7 @@ public final class AppCompactor {
* starts the background thread if necessary.
*/
public void init() {
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
ActivityThread.currentApplication().getMainExecutor(), mOnFlagsChangedListener);
synchronized (mPhenotypeFlagLock) {
updateUseCompaction();

View File

@@ -37,6 +37,7 @@ import android.os.Handler;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.Properties;
import android.provider.Settings;
import android.util.Base64;
import android.util.Slog;
@@ -138,18 +139,19 @@ public class GpuService extends SystemService {
}
}
private final class DeviceConfigListener implements DeviceConfig.OnPropertyChangedListener {
private final class DeviceConfigListener implements DeviceConfig.OnPropertiesChangedListener {
DeviceConfigListener() {
super();
DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_GAME_DRIVER,
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_GAME_DRIVER,
mContext.getMainExecutor(), this);
}
@Override
public void onPropertyChanged(String namespace, String name, String value) {
public void onPropertiesChanged(Properties properties) {
synchronized (mDeviceConfigLock) {
if (Settings.Global.GAME_DRIVER_BLACKLISTS.equals(name)) {
parseBlacklists(value != null ? value : "");
if (properties.getKeyset().contains(Settings.Global.GAME_DRIVER_BLACKLISTS)) {
parseBlacklists(
properties.getString(Settings.Global.GAME_DRIVER_BLACKLISTS, ""));
setBlacklist();
}
}

View File

@@ -1811,14 +1811,15 @@ public class NotificationManagerService extends SystemService {
}
private void registerDeviceConfigChange() {
DeviceConfig.addOnPropertyChangedListener(
DeviceConfig.addOnPropertiesChangedListener(
DeviceConfig.NAMESPACE_SYSTEMUI,
getContext().getMainExecutor(),
(namespace, name, value) -> {
if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(namespace)) {
(properties) -> {
if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(properties.getNamespace())) {
return;
}
if (SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE.equals(name)) {
if (properties.getKeyset()
.contains(SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE)) {
mAssistants.resetDefaultAssistantsIfNecessary();
}
});

View File

@@ -137,7 +137,6 @@ public final class TestableDeviceConfig implements TestRule {
return mKeyValueMap.get(getKey(namespace, name));
}).when(() -> DeviceConfig.getProperty(anyString(), anyString()));
return new TestWatcher() {
@Override
protected void succeeded(Description description) {