Skip to content

Commit 7f1c248

Browse files
author
John Spurlock
committed
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
1 parent 20de160 commit 7f1c248

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/SettingsProvider/res/values/defaults.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,7 @@
174174
<bool name="def_screensaver_activate_on_sleep">false</bool>
175175
<!-- ComponentName of the default screen saver (Settings.Secure.SCREENSAVER_COMPONENT) -->
176176
<string name="def_screensaver_component">com.google.android.deskclock/com.android.deskclock.Screensaver</string>
177+
178+
<!-- Default for Settings.Secure.USER_SETUP_COMPLETE -->
179+
<bool name="def_user_setup_complete">false</bool>
177180
</resources>

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
6868
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
6969
// is properly propagated through your change. Not doing so will result in a loss of user
7070
// settings.
71-
private static final int DATABASE_VERSION = 92;
71+
private static final int DATABASE_VERSION = 93;
7272

7373
private Context mContext;
7474
private int mUserHandle;
@@ -1449,6 +1449,30 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
14491449
upgradeVersion = 92;
14501450
}
14511451

1452+
if (upgradeVersion == 92) {
1453+
SQLiteStatement stmt = null;
1454+
try {
1455+
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
1456+
+ " VALUES(?,?);");
1457+
if (mUserHandle == UserHandle.USER_OWNER) {
1458+
// consider existing primary users to have made it through user setup
1459+
// if the globally-scoped device-provisioned bit is set
1460+
// (indicating they already made it through setup as primary)
1461+
int deviceProvisioned = getIntValueFromTable(db, TABLE_GLOBAL,
1462+
Settings.Global.DEVICE_PROVISIONED, 0);
1463+
loadSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
1464+
deviceProvisioned);
1465+
} else {
1466+
// otherwise use the default
1467+
loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
1468+
R.bool.def_user_setup_complete);
1469+
}
1470+
} finally {
1471+
if (stmt != null) stmt.close();
1472+
}
1473+
upgradeVersion = 93;
1474+
}
1475+
14521476
// *** Remember to update DATABASE_VERSION above!
14531477

14541478
if (upgradeVersion != currentVersion) {
@@ -2016,6 +2040,9 @@ private void loadSecureSettings(SQLiteDatabase db) {
20162040
loadBooleanSetting(stmt,
20172041
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_AUTO_UPDATE,
20182042
R.bool.def_accessibility_display_magnification_auto_update);
2043+
2044+
loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE,
2045+
R.bool.def_user_setup_complete);
20192046
} finally {
20202047
if (stmt != null) stmt.close();
20212048
}

0 commit comments

Comments
 (0)