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

Commit 999439bc authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

SettingsProvider: move SYSTEM_PROFILES_ENABLED to CMSettings



When upgrading from 12.1 -> 13.0, we end up losing this setting because
we forward all calls for that setting directly to the CMSettings table,
which would not have a default set.

Most of the code assumes profiles are on by default. So if the user had
profiles disabled (and potentially in a state they were unaware of), the
upgrade could cause some pains as it would ignore their old setting.

Ticket: OPO-620

Change-Id: I2b645dc9422fe15daf62d89e77b3e1429c668c04
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 83527974
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -2023,6 +2023,7 @@ public class SettingsProvider extends ContentProvider {
                if ((oldVersion == newVersion || oldVersion == CM_SETTINGS_DB_VERSION)) {
                    if (oldVersion == CM_SETTINGS_DB_VERSION && !hasReplayedDefaultsFromL()) {
                        forceReplayAOSPDefaults(mUserId);
                        forceMigrateProfilesEnabled(mUserId);
                        setDefaultsReplayedFromLFlag();
                    }
                    return;
@@ -2221,6 +2222,23 @@ public class SettingsProvider extends ContentProvider {
                }
            }

            private void forceMigrateProfilesEnabled(int userId) {
                final SettingsState systemSettings = getSystemSettingsLocked(userId);
                final Setting settingLocked = systemSettings.getSettingLocked(
                        CMSettings.System.SYSTEM_PROFILES_ENABLED);
                if (settingLocked != null) {
                    final String value = settingLocked.getValue();
                    if (value != null) {
                        CMSettings.System.putStringForUser(getContext().getContentResolver(),
                                CMSettings.System.SYSTEM_PROFILES_ENABLED,
                                value,
                                userId);
                        systemSettings.deleteSettingLocked(
                                CMSettings.System.SYSTEM_PROFILES_ENABLED);
                    }
                }
            }

        }
    }
}