diff options
| author | 2024-02-01 00:00:03 +0000 | |
|---|---|---|
| committer | 2024-02-02 14:51:05 +0000 | |
| commit | 210a439639285c696bf706bc7a84af812969b04f (patch) | |
| tree | 00b0366823b6a6ea3057d197d4c798df97f1fef1 | |
| parent | 04d99941db7784fe918cee104535ccb33c6a3e77 (diff) | |
Not remove trunk flags when set legacy flags
This change prevents removing trunk flags when set legacy flags. Before
this change when setSettingsLocked is called, it will iterate all flags
under the namespace, and if the flag is not in the updated set, then the
flag will be removed. This will cause a issue for local testing of the
trunk flags. If the trunk flag is set through adb while this method is
called for updating legacy flags, the trunk flag in the same namespace
will be reverted.
Bug: 318744532
Test: adb change a flag, and reboot the device, and check the flag value
Change-Id: If5192c4736605f8cb0a87e49e95167415c1be289
| -rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java index 6f3c88fc8706..ae71cece803f 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java @@ -612,12 +612,19 @@ final class SettingsState { String packageName) { List<String> changedKeys = new ArrayList<>(); final Iterator<Map.Entry<String, Setting>> iterator = mSettings.entrySet().iterator(); + int index = prefix.lastIndexOf('/'); + String namespace = index < 0 ? "" : prefix.substring(0, index); + Map<String, String> trunkFlagMap = + mNamespaceDefaults.get(namespace); // Delete old keys with the prefix that are not part of the new set. + // trunk flags will not be configured with restricted propagation + // trunk flags will be explicitly set, so not removing them here while (iterator.hasNext()) { Map.Entry<String, Setting> entry = iterator.next(); final String key = entry.getKey(); final Setting oldState = entry.getValue(); - if (key != null && key.startsWith(prefix) && !keyValues.containsKey(key)) { + if (key != null && (trunkFlagMap == null || !trunkFlagMap.containsKey(key)) + && key.startsWith(prefix) && !keyValues.containsKey(key)) { iterator.remove(); FrameworkStatsLog.write(FrameworkStatsLog.SETTING_CHANGED, key, |