Merge "Some logging for settings reset"

This commit is contained in:
TreeHugger Robot
2017-03-24 02:17:15 +00:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 0 deletions

View File

@@ -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.

View File

@@ -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,

View File

@@ -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();
}