Fix upgrade case for Settings.Secure.USER_SETUP_COMPLETE.
Existing primary users were never being marked as complete,
causing things that relied on this (e.g. showing the quick settings panel)
to break.
Bug:7282088
Change-Id: I9c8622f3cd0fb99a44477946d3db22fa2cbbc6fc
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index ab8e961b..9e137ce 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -174,4 +174,7 @@
<bool name="def_screensaver_activate_on_sleep">false</bool>
<!-- ComponentName of the default screen saver (Settings.Secure.SCREENSAVER_COMPONENT) -->
<string name="def_screensaver_component">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
+
+ <!-- Default for Settings.Secure.USER_SETUP_COMPLETE -->
+ <bool name="def_user_setup_complete">false</bool>
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index a9869d9..0b61abe 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -68,7 +68,7 @@
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
// is properly propagated through your change. Not doing so will result in a loss of user
// settings.
- private static final int DATABASE_VERSION = 92;
+ private static final int DATABASE_VERSION = 93;
private Context mContext;
private int mUserHandle;
@@ -1449,6 +1449,30 @@
upgradeVersion = 92;
}
+ if (upgradeVersion == 92) {
+ SQLiteStatement stmt = null;
+ try {
+ stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ + " VALUES(?,?);");
+ if (mUserHandle == UserHandle.USER_OWNER) {
+ // consider existing primary users to have made it through user setup
+ // if the globally-scoped device-provisioned bit is set
+ // (indicating they already made it through setup as primary)
+ int deviceProvisioned = getIntValueFromTable(db, TABLE_GLOBAL,
+ Settings.Global.DEVICE_PROVISIONED, 0);
+ loadSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
+ deviceProvisioned);
+ } else {
+ // otherwise use the default
+ loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
+ R.bool.def_user_setup_complete);
+ }
+ } finally {
+ if (stmt != null) stmt.close();
+ }
+ upgradeVersion = 93;
+ }
+
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != currentVersion) {
@@ -2016,6 +2040,9 @@
loadBooleanSetting(stmt,
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
R.bool.def_accessibility_display_magnification_auto_update);
+
+ loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
+ R.bool.def_user_setup_complete);
} finally {
if (stmt != null) stmt.close();
}