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

Commit 3945202d authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Some logging for settings reset

If settings db gets reset because it disappeared/got corrupted,
then write the Build.ID of the OTA, so we know when it was reset.

Bug: 36365648
Test: manual
Change-Id: I499a7f65f07a61c0e4651dbd046fc5b16408c09d
parent f9747661
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -9740,6 +9740,16 @@ public final class Settings {
         */
        public static final String DATABASE_DOWNGRADE_REASON = "database_downgrade_reason";

        /**
         * The build id of when the settings database was first created (or re-created due it
         * being missing).
         *
         * Type: string
         *
         * @hide
         */
        public static final String DATABASE_CREATION_BUILDID = "database_creation_buildid";

        /**
         * Flag to toggle journal mode WAL on or off for the contacts database. WAL is enabled by
         * default. Set to 0 to disable.
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ public class SettingsBackupTest {
                    Settings.Global.CONTACTS_DATABASE_WAL_ENABLED,
                    Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE,
                    Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI,
                    Settings.Global.DATABASE_CREATION_BUILDID,
                    Settings.Global.DATABASE_DOWNGRADE_REASON,
                    Settings.Global.DATA_ROAMING,
                    Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS,
+10 −0
Original line number Diff line number Diff line
@@ -2037,6 +2037,8 @@ public class SettingsProvider extends ContentProvider {

        private final BackupManager mBackupManager;

        private String mSettingsCreationBuildId;

        public SettingsRegistry() {
            mHandler = new MyHandler(getContext().getMainLooper());
            mGenerationRegistry = new GenerationRegistry(mLock);
@@ -2502,6 +2504,8 @@ public class SettingsProvider extends ContentProvider {
                    return;
                }

                mSettingsCreationBuildId = Build.ID;

                final long identity = Binder.clearCallingIdentity();
                try {
                    List<UserInfo> users = mUserManager.getUsers(true);
@@ -2570,6 +2574,12 @@ public class SettingsProvider extends ContentProvider {
                ensureSettingsStateLocked(globalKey);
                SettingsState globalSettings = mSettingsStates.get(globalKey);
                migrateLegacySettingsLocked(globalSettings, database, TABLE_GLOBAL);
                // If this was just created
                if (mSettingsCreationBuildId != null) {
                    globalSettings.insertSettingLocked(Settings.Global.DATABASE_CREATION_BUILDID,
                            mSettingsCreationBuildId, null, true,
                            SettingsState.SYSTEM_PACKAGE_NAME);
                }
                globalSettings.persistSyncLocked();
            }