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

Commit 210a4396 authored by Zhi Dou's avatar Zhi Dou
Browse files

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
parent 04d99941
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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,