The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.providers.settings; |
| 18 | |
| 19 | import android.content.ComponentName; |
| 20 | import android.content.ContentValues; |
| 21 | import android.content.Context; |
| 22 | import android.content.Intent; |
| 23 | import android.content.pm.ActivityInfo; |
Dianne Hackborn | 13579ed | 2012-11-28 18:05:36 -0800 | [diff] [blame] | 24 | import android.content.pm.IPackageManager; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 25 | import android.content.pm.PackageManager; |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 26 | import android.content.res.XmlResourceParser; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 27 | import android.database.Cursor; |
| 28 | import android.database.sqlite.SQLiteDatabase; |
| 29 | import android.database.sqlite.SQLiteOpenHelper; |
| 30 | import android.database.sqlite.SQLiteStatement; |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 31 | import android.media.AudioSystem; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 32 | import android.media.AudioManager; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 33 | import android.net.ConnectivityManager; |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 34 | import android.os.Build; |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 35 | import android.os.Environment; |
Dianne Hackborn | 13579ed | 2012-11-28 18:05:36 -0800 | [diff] [blame] | 36 | import android.os.RemoteException; |
| 37 | import android.os.ServiceManager; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 38 | import android.os.SystemProperties; |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 39 | import android.os.UserHandle; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 40 | import android.provider.Settings; |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 41 | import android.provider.Settings.Global; |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 42 | import android.provider.Settings.Secure; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 43 | import android.text.TextUtils; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 44 | import android.util.Log; |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 45 | |
Libin.Tang@motorola.com | 0499bb5 | 2014-10-10 14:55:57 -0500 | [diff] [blame] | 46 | import com.android.ims.ImsConfig; |
Gilles Debunne | fa53d30 | 2011-07-08 10:40:51 -0700 | [diff] [blame] | 47 | import com.android.internal.content.PackageHelper; |
Grace Chen | 6ad1c5e | 2017-06-13 16:07:45 -0700 | [diff] [blame] | 48 | import com.android.internal.telephony.Phone; |
Gilles Debunne | fa53d30 | 2011-07-08 10:40:51 -0700 | [diff] [blame] | 49 | import com.android.internal.telephony.RILConstants; |
| 50 | import com.android.internal.util.XmlUtils; |
| 51 | import com.android.internal.widget.LockPatternUtils; |
| 52 | import com.android.internal.widget.LockPatternView; |
| 53 | |
| 54 | import org.xmlpull.v1.XmlPullParser; |
| 55 | import org.xmlpull.v1.XmlPullParserException; |
| 56 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 57 | import java.io.File; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 58 | import java.io.IOException; |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 59 | import java.util.HashSet; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 60 | import java.util.List; |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 61 | import java.util.Set; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 64 | * Legacy settings database helper class for {@link SettingsProvider}. |
| 65 | * |
| 66 | * IMPORTANT: Do not add any more upgrade steps here as the global, |
| 67 | * secure, and system settings are no longer stored in a database |
| 68 | * but are kept in memory and persisted to XML. |
| 69 | * |
| 70 | * See: SettingsProvider.UpgradeController#onUpgradeLocked |
| 71 | * |
| 72 | * @deprecated The implementation is frozen. Do not add any new code to this class! |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 73 | */ |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 74 | @Deprecated |
| 75 | class DatabaseHelper extends SQLiteOpenHelper { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 76 | private static final String TAG = "SettingsProvider"; |
| 77 | private static final String DATABASE_NAME = "settings.db"; |
Jim Miller | f186055 | 2009-09-09 17:46:35 -0700 | [diff] [blame] | 78 | |
| 79 | // Please, please please. If you update the database version, check to make sure the |
| 80 | // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion' |
| 81 | // is properly propagated through your change. Not doing so will result in a loss of user |
| 82 | // settings. |
John Spurlock | 8c51d0b | 2014-11-07 15:14:21 -0500 | [diff] [blame] | 83 | private static final int DATABASE_VERSION = 118; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 84 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 85 | private Context mContext; |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 86 | private int mUserHandle; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 87 | |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 88 | private static final HashSet<String> mValidTables = new HashSet<String>(); |
| 89 | |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 90 | private static final String DATABASE_JOURNAL_SUFFIX = "-journal"; |
| 91 | private static final String DATABASE_BACKUP_SUFFIX = "-backup"; |
| 92 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 93 | private static final String TABLE_SYSTEM = "system"; |
| 94 | private static final String TABLE_SECURE = "secure"; |
| 95 | private static final String TABLE_GLOBAL = "global"; |
| 96 | |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 97 | static { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 98 | mValidTables.add(TABLE_SYSTEM); |
| 99 | mValidTables.add(TABLE_SECURE); |
| 100 | mValidTables.add(TABLE_GLOBAL); |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 101 | |
| 102 | // These are old. |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 103 | mValidTables.add("bluetooth_devices"); |
| 104 | mValidTables.add("bookmarks"); |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 105 | mValidTables.add("favorites"); |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 106 | mValidTables.add("old_favorites"); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 107 | mValidTables.add("android_metadata"); |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 110 | static String dbNameForUser(final int userHandle) { |
| 111 | // The owner gets the unadorned db name; |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 112 | if (userHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 113 | return DATABASE_NAME; |
| 114 | } else { |
| 115 | // Place the database in the user-specific data tree so that it's |
| 116 | // cleaned up automatically when the user is deleted. |
| 117 | File databaseFile = new File( |
| 118 | Environment.getUserSystemDirectory(userHandle), DATABASE_NAME); |
Fyodor Kupolov | 497b5fa | 2015-12-17 10:47:33 -0800 | [diff] [blame] | 119 | // If databaseFile doesn't exist, database can be kept in memory. It's safe because the |
| 120 | // database will be migrated and disposed of immediately after onCreate finishes |
| 121 | if (!databaseFile.exists()) { |
| 122 | Log.i(TAG, "No previous database file exists - running in in-memory mode"); |
| 123 | return null; |
| 124 | } |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 125 | return databaseFile.getPath(); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | public DatabaseHelper(Context context, int userHandle) { |
| 130 | super(context, dbNameForUser(userHandle), null, DATABASE_VERSION); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 131 | mContext = context; |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 132 | mUserHandle = userHandle; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 135 | public static boolean isValidTable(String name) { |
| 136 | return mValidTables.contains(name); |
| 137 | } |
| 138 | |
Fyodor Kupolov | 497b5fa | 2015-12-17 10:47:33 -0800 | [diff] [blame] | 139 | private boolean isInMemory() { |
| 140 | return getDatabaseName() == null; |
| 141 | } |
| 142 | |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 143 | public void dropDatabase() { |
| 144 | close(); |
Fyodor Kupolov | 497b5fa | 2015-12-17 10:47:33 -0800 | [diff] [blame] | 145 | // No need to remove files if db is in memory |
| 146 | if (isInMemory()) { |
| 147 | return; |
| 148 | } |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 149 | File databaseFile = mContext.getDatabasePath(getDatabaseName()); |
| 150 | if (databaseFile.exists()) { |
| 151 | databaseFile.delete(); |
| 152 | } |
| 153 | File databaseJournalFile = mContext.getDatabasePath(getDatabaseName() |
| 154 | + DATABASE_JOURNAL_SUFFIX); |
| 155 | if (databaseJournalFile.exists()) { |
| 156 | databaseJournalFile.delete(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | public void backupDatabase() { |
| 161 | close(); |
Fyodor Kupolov | 497b5fa | 2015-12-17 10:47:33 -0800 | [diff] [blame] | 162 | // No need to backup files if db is in memory |
| 163 | if (isInMemory()) { |
| 164 | return; |
| 165 | } |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 166 | File databaseFile = mContext.getDatabasePath(getDatabaseName()); |
| 167 | if (!databaseFile.exists()) { |
| 168 | return; |
| 169 | } |
| 170 | File backupFile = mContext.getDatabasePath(getDatabaseName() |
| 171 | + DATABASE_BACKUP_SUFFIX); |
| 172 | if (backupFile.exists()) { |
| 173 | return; |
| 174 | } |
| 175 | databaseFile.renameTo(backupFile); |
| 176 | } |
| 177 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 178 | private void createSecureTable(SQLiteDatabase db) { |
| 179 | db.execSQL("CREATE TABLE secure (" + |
| 180 | "_id INTEGER PRIMARY KEY AUTOINCREMENT," + |
| 181 | "name TEXT UNIQUE ON CONFLICT REPLACE," + |
| 182 | "value TEXT" + |
| 183 | ");"); |
| 184 | db.execSQL("CREATE INDEX secureIndex1 ON secure (name);"); |
| 185 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 186 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 187 | private void createGlobalTable(SQLiteDatabase db) { |
| 188 | db.execSQL("CREATE TABLE global (" + |
| 189 | "_id INTEGER PRIMARY KEY AUTOINCREMENT," + |
| 190 | "name TEXT UNIQUE ON CONFLICT REPLACE," + |
| 191 | "value TEXT" + |
| 192 | ");"); |
| 193 | db.execSQL("CREATE INDEX globalIndex1 ON global (name);"); |
| 194 | } |
| 195 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 196 | @Override |
| 197 | public void onCreate(SQLiteDatabase db) { |
| 198 | db.execSQL("CREATE TABLE system (" + |
| 199 | "_id INTEGER PRIMARY KEY AUTOINCREMENT," + |
| 200 | "name TEXT UNIQUE ON CONFLICT REPLACE," + |
| 201 | "value TEXT" + |
| 202 | ");"); |
| 203 | db.execSQL("CREATE INDEX systemIndex1 ON system (name);"); |
| 204 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 205 | createSecureTable(db); |
| 206 | |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 207 | // Only create the global table for the singleton 'owner/system' user |
| 208 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 209 | createGlobalTable(db); |
| 210 | } |
| 211 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 212 | db.execSQL("CREATE TABLE bluetooth_devices (" + |
| 213 | "_id INTEGER PRIMARY KEY," + |
| 214 | "name TEXT," + |
| 215 | "addr TEXT," + |
| 216 | "channel INTEGER," + |
| 217 | "type INTEGER" + |
| 218 | ");"); |
| 219 | |
| 220 | db.execSQL("CREATE TABLE bookmarks (" + |
| 221 | "_id INTEGER PRIMARY KEY," + |
| 222 | "title TEXT," + |
| 223 | "folder TEXT," + |
| 224 | "intent TEXT," + |
| 225 | "shortcut INTEGER," + |
| 226 | "ordering INTEGER" + |
| 227 | ");"); |
| 228 | |
| 229 | db.execSQL("CREATE INDEX bookmarksIndex1 ON bookmarks (folder);"); |
| 230 | db.execSQL("CREATE INDEX bookmarksIndex2 ON bookmarks (shortcut);"); |
| 231 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 232 | // Populate bookmarks table with initial bookmarks |
Dianne Hackborn | 13579ed | 2012-11-28 18:05:36 -0800 | [diff] [blame] | 233 | boolean onlyCore = false; |
| 234 | try { |
| 235 | onlyCore = IPackageManager.Stub.asInterface(ServiceManager.getService( |
| 236 | "package")).isOnlyCoreApps(); |
| 237 | } catch (RemoteException e) { |
| 238 | } |
| 239 | if (!onlyCore) { |
| 240 | loadBookmarks(db); |
| 241 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 242 | |
| 243 | // Load initial volume levels into DB |
| 244 | loadVolumeLevels(db); |
| 245 | |
| 246 | // Load inital settings values |
| 247 | loadSettings(db); |
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 252 | Log.w(TAG, "Upgrading settings database from version " + oldVersion + " to " |
| 253 | + currentVersion); |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 254 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 255 | int upgradeVersion = oldVersion; |
| 256 | |
| 257 | // Pattern for upgrade blocks: |
| 258 | // |
| 259 | // if (upgradeVersion == [the DATABASE_VERSION you set] - 1) { |
| 260 | // .. your upgrade logic.. |
| 261 | // upgradeVersion = [the DATABASE_VERSION you set] |
| 262 | // } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 263 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 264 | if (upgradeVersion == 20) { |
| 265 | /* |
| 266 | * Version 21 is part of the volume control refresh. There is no |
| 267 | * longer a UI-visible for setting notification vibrate on/off (in |
| 268 | * our design), but the functionality still exists. Force the |
| 269 | * notification vibrate to on. |
| 270 | */ |
| 271 | loadVibrateSetting(db, true); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 272 | |
| 273 | upgradeVersion = 21; |
| 274 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 275 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 276 | if (upgradeVersion < 22) { |
| 277 | upgradeVersion = 22; |
| 278 | // Upgrade the lock gesture storage location and format |
| 279 | upgradeLockPatternLocation(db); |
| 280 | } |
| 281 | |
| 282 | if (upgradeVersion < 23) { |
| 283 | db.execSQL("UPDATE favorites SET iconResource=0 WHERE iconType=0"); |
| 284 | upgradeVersion = 23; |
| 285 | } |
| 286 | |
| 287 | if (upgradeVersion == 23) { |
| 288 | db.beginTransaction(); |
| 289 | try { |
| 290 | db.execSQL("ALTER TABLE favorites ADD spanX INTEGER"); |
| 291 | db.execSQL("ALTER TABLE favorites ADD spanY INTEGER"); |
| 292 | // Shortcuts, applications, folders |
| 293 | db.execSQL("UPDATE favorites SET spanX=1, spanY=1 WHERE itemType<=0"); |
| 294 | // Photo frames, clocks |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 295 | db.execSQL( |
| 296 | "UPDATE favorites SET spanX=2, spanY=2 WHERE itemType=1000 or itemType=1002"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 297 | // Search boxes |
| 298 | db.execSQL("UPDATE favorites SET spanX=4, spanY=1 WHERE itemType=1001"); |
| 299 | db.setTransactionSuccessful(); |
| 300 | } finally { |
| 301 | db.endTransaction(); |
| 302 | } |
| 303 | upgradeVersion = 24; |
| 304 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 305 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 306 | if (upgradeVersion == 24) { |
| 307 | db.beginTransaction(); |
| 308 | try { |
| 309 | // The value of the constants for preferring wifi or preferring mobile have been |
| 310 | // swapped, so reload the default. |
| 311 | db.execSQL("DELETE FROM system WHERE name='network_preference'"); |
| 312 | db.execSQL("INSERT INTO system ('name', 'value') values ('network_preference', '" + |
| 313 | ConnectivityManager.DEFAULT_NETWORK_PREFERENCE + "')"); |
| 314 | db.setTransactionSuccessful(); |
| 315 | } finally { |
| 316 | db.endTransaction(); |
| 317 | } |
| 318 | upgradeVersion = 25; |
| 319 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 320 | |
| 321 | if (upgradeVersion == 25) { |
| 322 | db.beginTransaction(); |
| 323 | try { |
| 324 | db.execSQL("ALTER TABLE favorites ADD uri TEXT"); |
| 325 | db.execSQL("ALTER TABLE favorites ADD displayMode INTEGER"); |
| 326 | db.setTransactionSuccessful(); |
| 327 | } finally { |
| 328 | db.endTransaction(); |
| 329 | } |
| 330 | upgradeVersion = 26; |
| 331 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 332 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 333 | if (upgradeVersion == 26) { |
| 334 | // This introduces the new secure settings table. |
| 335 | db.beginTransaction(); |
| 336 | try { |
| 337 | createSecureTable(db); |
| 338 | db.setTransactionSuccessful(); |
| 339 | } finally { |
| 340 | db.endTransaction(); |
| 341 | } |
| 342 | upgradeVersion = 27; |
| 343 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 344 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 345 | if (upgradeVersion == 27) { |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 346 | String[] settingsToMove = { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 347 | Settings.Secure.ADB_ENABLED, |
| 348 | Settings.Secure.ANDROID_ID, |
| 349 | Settings.Secure.BLUETOOTH_ON, |
| 350 | Settings.Secure.DATA_ROAMING, |
| 351 | Settings.Secure.DEVICE_PROVISIONED, |
| 352 | Settings.Secure.HTTP_PROXY, |
| 353 | Settings.Secure.INSTALL_NON_MARKET_APPS, |
| 354 | Settings.Secure.LOCATION_PROVIDERS_ALLOWED, |
| 355 | Settings.Secure.LOGGING_ID, |
| 356 | Settings.Secure.NETWORK_PREFERENCE, |
| 357 | Settings.Secure.PARENTAL_CONTROL_ENABLED, |
| 358 | Settings.Secure.PARENTAL_CONTROL_LAST_UPDATE, |
| 359 | Settings.Secure.PARENTAL_CONTROL_REDIRECT_URL, |
| 360 | Settings.Secure.SETTINGS_CLASSNAME, |
| 361 | Settings.Secure.USB_MASS_STORAGE_ENABLED, |
| 362 | Settings.Secure.USE_GOOGLE_MAIL, |
| 363 | Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, |
| 364 | Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, |
| 365 | Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, |
| 366 | Settings.Secure.WIFI_ON, |
| 367 | Settings.Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE, |
| 368 | Settings.Secure.WIFI_WATCHDOG_AP_COUNT, |
| 369 | Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS, |
| 370 | Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED, |
| 371 | Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS, |
| 372 | Settings.Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT, |
| 373 | Settings.Secure.WIFI_WATCHDOG_MAX_AP_CHECKS, |
| 374 | Settings.Secure.WIFI_WATCHDOG_ON, |
| 375 | Settings.Secure.WIFI_WATCHDOG_PING_COUNT, |
| 376 | Settings.Secure.WIFI_WATCHDOG_PING_DELAY_MS, |
| 377 | Settings.Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS, |
| 378 | }; |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 379 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, settingsToMove, false); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 380 | upgradeVersion = 28; |
| 381 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 382 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 383 | if (upgradeVersion == 28 || upgradeVersion == 29) { |
| 384 | // Note: The upgrade to 28 was flawed since it didn't delete the old |
| 385 | // setting first before inserting. Combining 28 and 29 with the |
| 386 | // fixed version. |
| 387 | |
| 388 | // This upgrade adds the STREAM_NOTIFICATION type to the list of |
| 389 | // types affected by ringer modes (silent, vibrate, etc.) |
| 390 | db.beginTransaction(); |
| 391 | try { |
| 392 | db.execSQL("DELETE FROM system WHERE name='" |
| 393 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 394 | int newValue = (1 << AudioManager.STREAM_RING) |
| 395 | | (1 << AudioManager.STREAM_NOTIFICATION) |
| 396 | | (1 << AudioManager.STREAM_SYSTEM); |
| 397 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 398 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 399 | + String.valueOf(newValue) + "')"); |
| 400 | db.setTransactionSuccessful(); |
| 401 | } finally { |
| 402 | db.endTransaction(); |
| 403 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 404 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 405 | upgradeVersion = 30; |
| 406 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 407 | |
The Android Open Source Project | 9266c55 | 2009-01-15 16:12:10 -0800 | [diff] [blame] | 408 | if (upgradeVersion == 30) { |
| 409 | /* |
| 410 | * Upgrade 31 clears the title for all quick launch shortcuts so the |
| 411 | * activities' titles will be resolved at display time. Also, the |
| 412 | * folder is changed to '@quicklaunch'. |
| 413 | */ |
| 414 | db.beginTransaction(); |
| 415 | try { |
| 416 | db.execSQL("UPDATE bookmarks SET folder = '@quicklaunch'"); |
| 417 | db.execSQL("UPDATE bookmarks SET title = ''"); |
| 418 | db.setTransactionSuccessful(); |
| 419 | } finally { |
| 420 | db.endTransaction(); |
| 421 | } |
| 422 | upgradeVersion = 31; |
| 423 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 424 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 425 | if (upgradeVersion == 31) { |
| 426 | /* |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 427 | * Animations are now managed in preferences, and may be |
| 428 | * enabled or disabled based on product resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 429 | */ |
| 430 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 431 | SQLiteStatement stmt = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 432 | try { |
| 433 | db.execSQL("DELETE FROM system WHERE name='" |
| 434 | + Settings.System.WINDOW_ANIMATION_SCALE + "'"); |
| 435 | db.execSQL("DELETE FROM system WHERE name='" |
| 436 | + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 437 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 438 | + " VALUES(?,?);"); |
| 439 | loadDefaultAnimationSettings(stmt); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 440 | db.setTransactionSuccessful(); |
| 441 | } finally { |
| 442 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 443 | if (stmt != null) stmt.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 444 | } |
| 445 | upgradeVersion = 32; |
| 446 | } |
| 447 | |
| 448 | if (upgradeVersion == 32) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | upgradeVersion = 33; |
| 450 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 451 | |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 452 | if (upgradeVersion == 33) { |
| 453 | // Set the default zoom controls to: tap-twice to bring up +/- |
| 454 | db.beginTransaction(); |
| 455 | try { |
| 456 | db.execSQL("INSERT INTO system(name,value) values('zoom','2');"); |
| 457 | db.setTransactionSuccessful(); |
| 458 | } finally { |
| 459 | db.endTransaction(); |
| 460 | } |
| 461 | upgradeVersion = 34; |
| 462 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | |
Mike Lockwood | bcab8df | 2009-06-25 16:39:09 -0400 | [diff] [blame] | 464 | if (upgradeVersion == 34) { |
| 465 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 466 | SQLiteStatement stmt = null; |
Mike Lockwood | bcab8df | 2009-06-25 16:39:09 -0400 | [diff] [blame] | 467 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 468 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 469 | + " VALUES(?,?);"); |
| 470 | loadSecure35Settings(stmt); |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 471 | db.setTransactionSuccessful(); |
| 472 | } finally { |
| 473 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 474 | if (stmt != null) stmt.close(); |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 475 | } |
Jim Miller | f186055 | 2009-09-09 17:46:35 -0700 | [diff] [blame] | 476 | upgradeVersion = 35; |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 477 | } |
| 478 | // due to a botched merge from donut to eclair, the initialization of ASSISTED_GPS_ENABLED |
| 479 | // was accidentally done out of order here. |
| 480 | // to fix this, ASSISTED_GPS_ENABLED is now initialized while upgrading from 38 to 39, |
| 481 | // and we intentionally do nothing from 35 to 36 now. |
| 482 | if (upgradeVersion == 35) { |
The Android Open Source Project | 575d1af | 2009-07-03 08:55:59 -0700 | [diff] [blame] | 483 | upgradeVersion = 36; |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 484 | } |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 485 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 486 | if (upgradeVersion == 36) { |
| 487 | // This upgrade adds the STREAM_SYSTEM_ENFORCED type to the list of |
| 488 | // types affected by ringer modes (silent, vibrate, etc.) |
| 489 | db.beginTransaction(); |
| 490 | try { |
| 491 | db.execSQL("DELETE FROM system WHERE name='" |
| 492 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 493 | int newValue = (1 << AudioManager.STREAM_RING) |
| 494 | | (1 << AudioManager.STREAM_NOTIFICATION) |
| 495 | | (1 << AudioManager.STREAM_SYSTEM) |
| 496 | | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); |
| 497 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 498 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 499 | + String.valueOf(newValue) + "')"); |
| 500 | db.setTransactionSuccessful(); |
| 501 | } finally { |
| 502 | db.endTransaction(); |
| 503 | } |
Jim Miller | 4880575 | 2009-08-04 18:59:20 -0700 | [diff] [blame] | 504 | upgradeVersion = 37; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 505 | } |
| 506 | |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 507 | if (upgradeVersion == 37) { |
| 508 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 509 | SQLiteStatement stmt = null; |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 510 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 511 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 512 | + " VALUES(?,?);"); |
| 513 | loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS, |
| 514 | R.string.airplane_mode_toggleable_radios); |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 515 | db.setTransactionSuccessful(); |
| 516 | } finally { |
| 517 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 518 | if (stmt != null) stmt.close(); |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 519 | } |
| 520 | upgradeVersion = 38; |
| 521 | } |
| 522 | |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 523 | if (upgradeVersion == 38) { |
| 524 | db.beginTransaction(); |
| 525 | try { |
| 526 | String value = |
| 527 | mContext.getResources().getBoolean(R.bool.assisted_gps_enabled) ? "1" : "0"; |
| 528 | db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" + |
Jeff Sharkey | bdfce2e | 2012-09-26 15:54:06 -0700 | [diff] [blame] | 529 | Settings.Global.ASSISTED_GPS_ENABLED + "','" + value + "');"); |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 530 | db.setTransactionSuccessful(); |
| 531 | } finally { |
| 532 | db.endTransaction(); |
| 533 | } |
| 534 | |
| 535 | upgradeVersion = 39; |
| 536 | } |
| 537 | |
Dan Murphy | 951764b | 2009-08-27 14:59:03 -0500 | [diff] [blame] | 538 | if (upgradeVersion == 39) { |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 539 | upgradeAutoBrightness(db); |
Dan Murphy | 951764b | 2009-08-27 14:59:03 -0500 | [diff] [blame] | 540 | upgradeVersion = 40; |
| 541 | } |
| 542 | |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 543 | if (upgradeVersion == 40) { |
| 544 | /* |
| 545 | * All animations are now turned on by default! |
| 546 | */ |
| 547 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 548 | SQLiteStatement stmt = null; |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 549 | try { |
| 550 | db.execSQL("DELETE FROM system WHERE name='" |
| 551 | + Settings.System.WINDOW_ANIMATION_SCALE + "'"); |
| 552 | db.execSQL("DELETE FROM system WHERE name='" |
| 553 | + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 554 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 555 | + " VALUES(?,?);"); |
| 556 | loadDefaultAnimationSettings(stmt); |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 557 | db.setTransactionSuccessful(); |
| 558 | } finally { |
| 559 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 560 | if (stmt != null) stmt.close(); |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 561 | } |
| 562 | upgradeVersion = 41; |
| 563 | } |
| 564 | |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 565 | if (upgradeVersion == 41) { |
| 566 | /* |
| 567 | * Initialize newly public haptic feedback setting |
| 568 | */ |
| 569 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 570 | SQLiteStatement stmt = null; |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 571 | try { |
| 572 | db.execSQL("DELETE FROM system WHERE name='" |
| 573 | + Settings.System.HAPTIC_FEEDBACK_ENABLED + "'"); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 574 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 575 | + " VALUES(?,?);"); |
| 576 | loadDefaultHapticSettings(stmt); |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 577 | db.setTransactionSuccessful(); |
| 578 | } finally { |
| 579 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 580 | if (stmt != null) stmt.close(); |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 581 | } |
| 582 | upgradeVersion = 42; |
| 583 | } |
| 584 | |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 585 | if (upgradeVersion == 42) { |
| 586 | /* |
| 587 | * Initialize new notification pulse setting |
| 588 | */ |
| 589 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 590 | SQLiteStatement stmt = null; |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 591 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 592 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 593 | + " VALUES(?,?);"); |
| 594 | loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE, |
| 595 | R.bool.def_notification_pulse); |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 596 | db.setTransactionSuccessful(); |
| 597 | } finally { |
| 598 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 599 | if (stmt != null) stmt.close(); |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 600 | } |
| 601 | upgradeVersion = 43; |
| 602 | } |
| 603 | |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 604 | if (upgradeVersion == 43) { |
| 605 | /* |
| 606 | * This upgrade stores bluetooth volume separately from voice volume |
| 607 | */ |
| 608 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 609 | SQLiteStatement stmt = null; |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 610 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 611 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 612 | + " VALUES(?,?);"); |
| 613 | loadSetting(stmt, Settings.System.VOLUME_BLUETOOTH_SCO, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 614 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO)); |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 615 | db.setTransactionSuccessful(); |
| 616 | } finally { |
| 617 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 618 | if (stmt != null) stmt.close(); |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 619 | } |
| 620 | upgradeVersion = 44; |
| 621 | } |
| 622 | |
Doug Zongker | aed8f8e | 2010-01-07 18:07:50 -0800 | [diff] [blame] | 623 | if (upgradeVersion == 44) { |
| 624 | /* |
| 625 | * Gservices was moved into vendor/google. |
| 626 | */ |
| 627 | db.execSQL("DROP TABLE IF EXISTS gservices"); |
| 628 | db.execSQL("DROP INDEX IF EXISTS gservicesIndex1"); |
| 629 | upgradeVersion = 45; |
| 630 | } |
San Mehat | 87734d3 | 2010-01-08 12:53:06 -0800 | [diff] [blame] | 631 | |
| 632 | if (upgradeVersion == 45) { |
| 633 | /* |
Sudheer Shanka | 2250d56 | 2016-11-07 15:41:02 -0800 | [diff] [blame] | 634 | * New settings for StorageManagerService |
San Mehat | 87734d3 | 2010-01-08 12:53:06 -0800 | [diff] [blame] | 635 | */ |
| 636 | db.beginTransaction(); |
| 637 | try { |
| 638 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 639 | Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND + "','1');"); |
| 640 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 641 | Settings.Secure.MOUNT_UMS_AUTOSTART + "','0');"); |
| 642 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 643 | Settings.Secure.MOUNT_UMS_PROMPT + "','1');"); |
| 644 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 645 | Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED + "','1');"); |
| 646 | db.setTransactionSuccessful(); |
| 647 | } finally { |
| 648 | db.endTransaction(); |
| 649 | } |
| 650 | upgradeVersion = 46; |
| 651 | } |
| 652 | |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 653 | if (upgradeVersion == 46) { |
| 654 | /* |
| 655 | * The password mode constants have changed; reset back to no |
| 656 | * password. |
| 657 | */ |
| 658 | db.beginTransaction(); |
| 659 | try { |
| 660 | db.execSQL("DELETE FROM system WHERE name='lockscreen.password_type';"); |
| 661 | db.setTransactionSuccessful(); |
| 662 | } finally { |
| 663 | db.endTransaction(); |
| 664 | } |
| 665 | upgradeVersion = 47; |
| 666 | } |
| 667 | |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 668 | |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 669 | if (upgradeVersion == 47) { |
| 670 | /* |
| 671 | * The password mode constants have changed again; reset back to no |
| 672 | * password. |
| 673 | */ |
| 674 | db.beginTransaction(); |
| 675 | try { |
| 676 | db.execSQL("DELETE FROM system WHERE name='lockscreen.password_type';"); |
| 677 | db.setTransactionSuccessful(); |
| 678 | } finally { |
| 679 | db.endTransaction(); |
| 680 | } |
| 681 | upgradeVersion = 48; |
| 682 | } |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 683 | |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 684 | if (upgradeVersion == 48) { |
| 685 | /* |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 686 | * Default recognition service no longer initialized here, |
| 687 | * moved to RecognitionManagerService. |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 688 | */ |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 689 | upgradeVersion = 49; |
| 690 | } |
Jim Miller | 31f90b6 | 2010-01-20 13:35:20 -0800 | [diff] [blame] | 691 | |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 692 | if (upgradeVersion == 49) { |
| 693 | /* |
| 694 | * New settings for new user interface noises. |
| 695 | */ |
| 696 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 697 | SQLiteStatement stmt = null; |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 698 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 699 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 700 | + " VALUES(?,?);"); |
| 701 | loadUISoundEffectsSettings(stmt); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 702 | db.setTransactionSuccessful(); |
| 703 | } finally { |
| 704 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 705 | if (stmt != null) stmt.close(); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | upgradeVersion = 50; |
| 709 | } |
| 710 | |
Oscar Montemayor | f1cbfff | 2010-02-22 16:12:07 -0800 | [diff] [blame] | 711 | if (upgradeVersion == 50) { |
| 712 | /* |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 713 | * Install location no longer initiated here. |
Oscar Montemayor | f1cbfff | 2010-02-22 16:12:07 -0800 | [diff] [blame] | 714 | */ |
Oscar Montemayor | f1cbfff | 2010-02-22 16:12:07 -0800 | [diff] [blame] | 715 | upgradeVersion = 51; |
| 716 | } |
| 717 | |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 718 | if (upgradeVersion == 51) { |
| 719 | /* Move the lockscreen related settings to Secure, including some private ones. */ |
| 720 | String[] settingsToMove = { |
| 721 | Secure.LOCK_PATTERN_ENABLED, |
| 722 | Secure.LOCK_PATTERN_VISIBLE, |
| 723 | Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, |
| 724 | "lockscreen.password_type", |
| 725 | "lockscreen.lockoutattemptdeadline", |
| 726 | "lockscreen.patterneverchosen", |
| 727 | "lock_pattern_autolock", |
| 728 | "lockscreen.lockedoutpermanently", |
| 729 | "lockscreen.password_salt" |
| 730 | }; |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 731 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, settingsToMove, false); |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 732 | upgradeVersion = 52; |
| 733 | } |
| 734 | |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 735 | if (upgradeVersion == 52) { |
| 736 | // new vibration/silent mode settings |
| 737 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 738 | SQLiteStatement stmt = null; |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 739 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 740 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 741 | + " VALUES(?,?);"); |
| 742 | loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT, |
| 743 | R.bool.def_vibrate_in_silent); |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 744 | db.setTransactionSuccessful(); |
| 745 | } finally { |
| 746 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 747 | if (stmt != null) stmt.close(); |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | upgradeVersion = 53; |
| 751 | } |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 752 | |
Suchi Amalapurapu | 089262d | 2010-03-10 14:19:21 -0800 | [diff] [blame] | 753 | if (upgradeVersion == 53) { |
| 754 | /* |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 755 | * New settings for set install location UI no longer initiated here. |
Suchi Amalapurapu | 089262d | 2010-03-10 14:19:21 -0800 | [diff] [blame] | 756 | */ |
Suchi Amalapurapu | 089262d | 2010-03-10 14:19:21 -0800 | [diff] [blame] | 757 | upgradeVersion = 54; |
| 758 | } |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 759 | |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 760 | if (upgradeVersion == 54) { |
| 761 | /* |
| 762 | * Update the screen timeout value if set to never |
| 763 | */ |
| 764 | db.beginTransaction(); |
| 765 | try { |
| 766 | upgradeScreenTimeoutFromNever(db); |
| 767 | db.setTransactionSuccessful(); |
| 768 | } finally { |
| 769 | db.endTransaction(); |
| 770 | } |
| 771 | |
| 772 | upgradeVersion = 55; |
| 773 | } |
| 774 | |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 775 | if (upgradeVersion == 55) { |
| 776 | /* Move the install location settings. */ |
| 777 | String[] settingsToMove = { |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 778 | Global.SET_INSTALL_LOCATION, |
| 779 | Global.DEFAULT_INSTALL_LOCATION |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 780 | }; |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 781 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, settingsToMove, false); |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 782 | db.beginTransaction(); |
| 783 | SQLiteStatement stmt = null; |
| 784 | try { |
| 785 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 786 | + " VALUES(?,?);"); |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 787 | loadSetting(stmt, Global.SET_INSTALL_LOCATION, 0); |
| 788 | loadSetting(stmt, Global.DEFAULT_INSTALL_LOCATION, |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 789 | PackageHelper.APP_INSTALL_AUTO); |
| 790 | db.setTransactionSuccessful(); |
| 791 | } finally { |
| 792 | db.endTransaction(); |
| 793 | if (stmt != null) stmt.close(); |
| 794 | } |
| 795 | upgradeVersion = 56; |
| 796 | } |
Jake Hamby | 6659284 | 2010-08-24 19:55:20 -0700 | [diff] [blame] | 797 | |
| 798 | if (upgradeVersion == 56) { |
| 799 | /* |
| 800 | * Add Bluetooth to list of toggleable radios in airplane mode |
| 801 | */ |
| 802 | db.beginTransaction(); |
| 803 | SQLiteStatement stmt = null; |
| 804 | try { |
| 805 | db.execSQL("DELETE FROM system WHERE name='" |
| 806 | + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'"); |
| 807 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 808 | + " VALUES(?,?);"); |
| 809 | loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS, |
| 810 | R.string.airplane_mode_toggleable_radios); |
| 811 | db.setTransactionSuccessful(); |
| 812 | } finally { |
| 813 | db.endTransaction(); |
| 814 | if (stmt != null) stmt.close(); |
| 815 | } |
| 816 | upgradeVersion = 57; |
| 817 | } |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 818 | |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 819 | /************* The following are Honeycomb changes ************/ |
| 820 | |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 821 | if (upgradeVersion == 57) { |
| 822 | /* |
Phil Weaver | 09d4ff8 | 2017-03-31 11:22:17 -0700 | [diff] [blame] | 823 | * No longer initializing deleted setting ACCESSIBILITY_SCRIPT_INJECTION. |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 824 | */ |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 825 | upgradeVersion = 58; |
| 826 | } |
| 827 | |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 828 | if (upgradeVersion == 58) { |
| 829 | /* Add default for new Auto Time Zone */ |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 830 | int autoTimeValue = getIntValueFromSystem(db, Settings.System.AUTO_TIME, 0); |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 831 | db.beginTransaction(); |
| 832 | SQLiteStatement stmt = null; |
| 833 | try { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 834 | stmt = db.compileStatement("INSERT INTO system(name,value)" + " VALUES(?,?);"); |
| 835 | loadSetting(stmt, Settings.System.AUTO_TIME_ZONE, |
| 836 | autoTimeValue); // Sync timezone to NITZ if auto_time was enabled |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 837 | db.setTransactionSuccessful(); |
| 838 | } finally { |
| 839 | db.endTransaction(); |
| 840 | if (stmt != null) stmt.close(); |
| 841 | } |
| 842 | upgradeVersion = 59; |
| 843 | } |
| 844 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 845 | if (upgradeVersion == 59) { |
| 846 | // Persistence for the rotation lock feature. |
| 847 | db.beginTransaction(); |
| 848 | SQLiteStatement stmt = null; |
| 849 | try { |
| 850 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 851 | + " VALUES(?,?);"); |
| 852 | loadBooleanSetting(stmt, Settings.System.USER_ROTATION, |
| 853 | R.integer.def_user_rotation); // should be zero degrees |
| 854 | db.setTransactionSuccessful(); |
| 855 | } finally { |
| 856 | db.endTransaction(); |
| 857 | if (stmt != null) stmt.close(); |
| 858 | } |
| 859 | upgradeVersion = 60; |
| 860 | } |
| 861 | |
Amith Yamasani | 0038931 | 2010-11-05 11:22:21 -0700 | [diff] [blame] | 862 | if (upgradeVersion == 60) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 863 | // Don't do this for upgrades from Gingerbread |
| 864 | // Were only required for intra-Honeycomb upgrades for testing |
| 865 | // upgradeScreenTimeout(db); |
Amith Yamasani | 0038931 | 2010-11-05 11:22:21 -0700 | [diff] [blame] | 866 | upgradeVersion = 61; |
| 867 | } |
| 868 | |
Amith Yamasani | 79373f6 | 2010-11-18 16:32:48 -0800 | [diff] [blame] | 869 | if (upgradeVersion == 61) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 870 | // Don't do this for upgrades from Gingerbread |
| 871 | // Were only required for intra-Honeycomb upgrades for testing |
| 872 | // upgradeScreenTimeout(db); |
Amith Yamasani | 79373f6 | 2010-11-18 16:32:48 -0800 | [diff] [blame] | 873 | upgradeVersion = 62; |
| 874 | } |
| 875 | |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 876 | // Change the default for screen auto-brightness mode |
| 877 | if (upgradeVersion == 62) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 878 | // Don't do this for upgrades from Gingerbread |
| 879 | // Were only required for intra-Honeycomb upgrades for testing |
| 880 | // upgradeAutoBrightness(db); |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 881 | upgradeVersion = 63; |
| 882 | } |
| 883 | |
Eric Laurent | 25101b0 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 884 | if (upgradeVersion == 63) { |
| 885 | // This upgrade adds the STREAM_MUSIC type to the list of |
| 886 | // types affected by ringer modes (silent, vibrate, etc.) |
| 887 | db.beginTransaction(); |
| 888 | try { |
| 889 | db.execSQL("DELETE FROM system WHERE name='" |
| 890 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 891 | int newValue = (1 << AudioManager.STREAM_RING) |
| 892 | | (1 << AudioManager.STREAM_NOTIFICATION) |
| 893 | | (1 << AudioManager.STREAM_SYSTEM) |
| 894 | | (1 << AudioManager.STREAM_SYSTEM_ENFORCED) |
| 895 | | (1 << AudioManager.STREAM_MUSIC); |
| 896 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 897 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 898 | + String.valueOf(newValue) + "')"); |
| 899 | db.setTransactionSuccessful(); |
| 900 | } finally { |
| 901 | db.endTransaction(); |
| 902 | } |
| 903 | upgradeVersion = 64; |
| 904 | } |
| 905 | |
Svetoslav Ganov | 54d068ec | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 906 | if (upgradeVersion == 64) { |
| 907 | // New setting to configure the long press timeout. |
| 908 | db.beginTransaction(); |
| 909 | SQLiteStatement stmt = null; |
| 910 | try { |
| 911 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 912 | + " VALUES(?,?);"); |
| 913 | loadIntegerSetting(stmt, Settings.Secure.LONG_PRESS_TIMEOUT, |
| 914 | R.integer.def_long_press_timeout_millis); |
| 915 | stmt.close(); |
| 916 | db.setTransactionSuccessful(); |
| 917 | } finally { |
| 918 | db.endTransaction(); |
| 919 | if (stmt != null) stmt.close(); |
| 920 | } |
| 921 | upgradeVersion = 65; |
| 922 | } |
| 923 | |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 924 | /************* The following are Ice Cream Sandwich changes ************/ |
| 925 | |
Gilles Debunne | fa53d30 | 2011-07-08 10:40:51 -0700 | [diff] [blame] | 926 | if (upgradeVersion == 65) { |
| 927 | /* |
| 928 | * Animations are removed from Settings. Turned on by default |
| 929 | */ |
| 930 | db.beginTransaction(); |
| 931 | SQLiteStatement stmt = null; |
| 932 | try { |
| 933 | db.execSQL("DELETE FROM system WHERE name='" |
| 934 | + Settings.System.WINDOW_ANIMATION_SCALE + "'"); |
| 935 | db.execSQL("DELETE FROM system WHERE name='" |
| 936 | + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); |
| 937 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 938 | + " VALUES(?,?);"); |
| 939 | loadDefaultAnimationSettings(stmt); |
| 940 | db.setTransactionSuccessful(); |
| 941 | } finally { |
| 942 | db.endTransaction(); |
| 943 | if (stmt != null) stmt.close(); |
| 944 | } |
| 945 | upgradeVersion = 66; |
| 946 | } |
| 947 | |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 948 | if (upgradeVersion == 66) { |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 949 | // This upgrade makes sure that MODE_RINGER_STREAMS_AFFECTED is set |
| 950 | // according to device voice capability |
| 951 | db.beginTransaction(); |
| 952 | try { |
| 953 | int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | |
| 954 | (1 << AudioManager.STREAM_NOTIFICATION) | |
| 955 | (1 << AudioManager.STREAM_SYSTEM) | |
| 956 | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); |
| 957 | if (!mContext.getResources().getBoolean( |
| 958 | com.android.internal.R.bool.config_voice_capable)) { |
| 959 | ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); |
| 960 | } |
| 961 | db.execSQL("DELETE FROM system WHERE name='" |
| 962 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 963 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 964 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 965 | + String.valueOf(ringerModeAffectedStreams) + "')"); |
| 966 | db.setTransactionSuccessful(); |
| 967 | } finally { |
| 968 | db.endTransaction(); |
| 969 | } |
| 970 | upgradeVersion = 67; |
| 971 | } |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 972 | |
Svetoslav Ganov | a28a16d | 2011-07-28 11:24:21 -0700 | [diff] [blame] | 973 | if (upgradeVersion == 67) { |
| 974 | // New setting to enable touch exploration. |
| 975 | db.beginTransaction(); |
| 976 | SQLiteStatement stmt = null; |
| 977 | try { |
| 978 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 979 | + " VALUES(?,?);"); |
| 980 | loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED, |
| 981 | R.bool.def_touch_exploration_enabled); |
| 982 | stmt.close(); |
| 983 | db.setTransactionSuccessful(); |
| 984 | } finally { |
| 985 | db.endTransaction(); |
| 986 | if (stmt != null) stmt.close(); |
| 987 | } |
| 988 | upgradeVersion = 68; |
| 989 | } |
| 990 | |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 991 | if (upgradeVersion == 68) { |
| 992 | // Enable all system sounds by default |
| 993 | db.beginTransaction(); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 994 | try { |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 995 | db.execSQL("DELETE FROM system WHERE name='" |
| 996 | + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "'"); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 997 | db.setTransactionSuccessful(); |
| 998 | } finally { |
| 999 | db.endTransaction(); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 1000 | } |
| 1001 | upgradeVersion = 69; |
| 1002 | } |
Svetoslav Ganov | a28a16d | 2011-07-28 11:24:21 -0700 | [diff] [blame] | 1003 | |
Nick Pelly | 8d32a01 | 2011-08-09 07:03:49 -0700 | [diff] [blame] | 1004 | if (upgradeVersion == 69) { |
| 1005 | // Add RADIO_NFC to AIRPLANE_MODE_RADIO and AIRPLANE_MODE_TOGGLEABLE_RADIOS |
| 1006 | String airplaneRadios = mContext.getResources().getString( |
| 1007 | R.string.def_airplane_mode_radios); |
| 1008 | String toggleableRadios = mContext.getResources().getString( |
| 1009 | R.string.airplane_mode_toggleable_radios); |
| 1010 | db.beginTransaction(); |
| 1011 | try { |
| 1012 | db.execSQL("UPDATE system SET value='" + airplaneRadios + "' " + |
| 1013 | "WHERE name='" + Settings.System.AIRPLANE_MODE_RADIOS + "'"); |
| 1014 | db.execSQL("UPDATE system SET value='" + toggleableRadios + "' " + |
| 1015 | "WHERE name='" + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'"); |
| 1016 | db.setTransactionSuccessful(); |
| 1017 | } finally { |
| 1018 | db.endTransaction(); |
| 1019 | } |
| 1020 | upgradeVersion = 70; |
| 1021 | } |
| 1022 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1023 | if (upgradeVersion == 70) { |
| 1024 | // Update all built-in bookmarks. Some of the package names have changed. |
| 1025 | loadBookmarks(db); |
| 1026 | upgradeVersion = 71; |
| 1027 | } |
| 1028 | |
Svetoslav Ganov | 55f937a | 2011-12-05 11:42:07 -0800 | [diff] [blame] | 1029 | if (upgradeVersion == 71) { |
| 1030 | // New setting to specify whether to speak passwords in accessibility mode. |
| 1031 | db.beginTransaction(); |
| 1032 | SQLiteStatement stmt = null; |
| 1033 | try { |
| 1034 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 1035 | + " VALUES(?,?);"); |
| 1036 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, |
| 1037 | R.bool.def_accessibility_speak_password); |
Amith Yamasani | 6243edd | 2011-12-05 19:58:48 -0800 | [diff] [blame] | 1038 | db.setTransactionSuccessful(); |
Svetoslav Ganov | 55f937a | 2011-12-05 11:42:07 -0800 | [diff] [blame] | 1039 | } finally { |
| 1040 | db.endTransaction(); |
| 1041 | if (stmt != null) stmt.close(); |
| 1042 | } |
| 1043 | upgradeVersion = 72; |
| 1044 | } |
| 1045 | |
Amith Yamasani | 6243edd | 2011-12-05 19:58:48 -0800 | [diff] [blame] | 1046 | if (upgradeVersion == 72) { |
| 1047 | // update vibration settings |
| 1048 | db.beginTransaction(); |
| 1049 | SQLiteStatement stmt = null; |
| 1050 | try { |
| 1051 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 1052 | + " VALUES(?,?);"); |
| 1053 | loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT, |
| 1054 | R.bool.def_vibrate_in_silent); |
| 1055 | db.setTransactionSuccessful(); |
| 1056 | } finally { |
| 1057 | db.endTransaction(); |
| 1058 | if (stmt != null) stmt.close(); |
| 1059 | } |
| 1060 | upgradeVersion = 73; |
| 1061 | } |
| 1062 | |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 1063 | if (upgradeVersion == 73) { |
Amith Yamasani | 398c83c | 2011-12-13 10:38:47 -0800 | [diff] [blame] | 1064 | upgradeVibrateSettingFromNone(db); |
| 1065 | upgradeVersion = 74; |
| 1066 | } |
| 1067 | |
| 1068 | if (upgradeVersion == 74) { |
Phil Weaver | 09d4ff8 | 2017-03-31 11:22:17 -0700 | [diff] [blame] | 1069 | // No longer using URL from which WebView loads a JavaScript based screen-reader. |
Amith Yamasani | 398c83c | 2011-12-13 10:38:47 -0800 | [diff] [blame] | 1070 | upgradeVersion = 75; |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 1071 | } |
Mike Lockwood | 7bef739 | 2011-10-20 16:51:53 -0400 | [diff] [blame] | 1072 | if (upgradeVersion == 75) { |
| 1073 | db.beginTransaction(); |
| 1074 | SQLiteStatement stmt = null; |
| 1075 | Cursor c = null; |
| 1076 | try { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1077 | c = db.query(TABLE_SECURE, new String[] {"_id", "value"}, |
Mike Lockwood | 7bef739 | 2011-10-20 16:51:53 -0400 | [diff] [blame] | 1078 | "name='lockscreen.disabled'", |
| 1079 | null, null, null, null); |
| 1080 | // only set default if it has not yet been set |
| 1081 | if (c == null || c.getCount() == 0) { |
| 1082 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 1083 | + " VALUES(?,?);"); |
| 1084 | loadBooleanSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, |
| 1085 | R.bool.def_lockscreen_disabled); |
| 1086 | } |
| 1087 | db.setTransactionSuccessful(); |
| 1088 | } finally { |
| 1089 | db.endTransaction(); |
| 1090 | if (c != null) c.close(); |
| 1091 | if (stmt != null) stmt.close(); |
| 1092 | } |
| 1093 | upgradeVersion = 76; |
| 1094 | } |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 1095 | |
Eric Laurent | bffc3d1 | 2012-05-07 17:43:49 -0700 | [diff] [blame] | 1096 | /************* The following are Jelly Bean changes ************/ |
| 1097 | |
| 1098 | if (upgradeVersion == 76) { |
| 1099 | // Removed VIBRATE_IN_SILENT setting |
| 1100 | db.beginTransaction(); |
| 1101 | try { |
| 1102 | db.execSQL("DELETE FROM system WHERE name='" |
| 1103 | + Settings.System.VIBRATE_IN_SILENT + "'"); |
| 1104 | db.setTransactionSuccessful(); |
| 1105 | } finally { |
| 1106 | db.endTransaction(); |
| 1107 | } |
| 1108 | |
| 1109 | upgradeVersion = 77; |
| 1110 | } |
| 1111 | |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 1112 | if (upgradeVersion == 77) { |
| 1113 | // Introduce "vibrate when ringing" setting |
| 1114 | loadVibrateWhenRingingSetting(db); |
| 1115 | |
| 1116 | upgradeVersion = 78; |
| 1117 | } |
Eric Laurent | bffc3d1 | 2012-05-07 17:43:49 -0700 | [diff] [blame] | 1118 | |
alanv | 3a67eb3 | 2012-06-22 10:47:28 -0700 | [diff] [blame] | 1119 | if (upgradeVersion == 78) { |
Phil Weaver | 09d4ff8 | 2017-03-31 11:22:17 -0700 | [diff] [blame] | 1120 | // ACCESSIBILITY_SCREEN_READER_URL has been removed |
alanv | 3a67eb3 | 2012-06-22 10:47:28 -0700 | [diff] [blame] | 1121 | upgradeVersion = 79; |
| 1122 | } |
| 1123 | |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 1124 | if (upgradeVersion == 79) { |
| 1125 | // Before touch exploration was a global setting controlled by the user |
| 1126 | // via the UI. However, if the enabled accessibility services do not |
| 1127 | // handle touch exploration mode, enabling it makes no sense. Therefore, |
| 1128 | // now the services request touch exploration mode and the user is |
| 1129 | // presented with a dialog to allow that and if she does we store that |
| 1130 | // in the database. As a result of this change a user that has enabled |
| 1131 | // accessibility, touch exploration, and some accessibility services |
| 1132 | // may lose touch exploration state, thus rendering the device useless |
| 1133 | // unless sighted help is provided, since the enabled service(s) are |
| 1134 | // not in the list of services to which the user granted a permission |
| 1135 | // to put the device in touch explore mode. Here we are allowing all |
| 1136 | // enabled accessibility services to toggle touch exploration provided |
| 1137 | // accessibility and touch exploration are enabled and no services can |
| 1138 | // toggle touch exploration. Note that the user has already manually |
| 1139 | // enabled the services and touch exploration which means the she has |
| 1140 | // given consent to have these services work in touch exploration mode. |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1141 | final boolean accessibilityEnabled = getIntValueFromTable(db, TABLE_SECURE, |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 1142 | Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1; |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1143 | final boolean touchExplorationEnabled = getIntValueFromTable(db, TABLE_SECURE, |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 1144 | Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1; |
| 1145 | if (accessibilityEnabled && touchExplorationEnabled) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1146 | String enabledServices = getStringValueFromTable(db, TABLE_SECURE, |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 1147 | Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, ""); |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1148 | String touchExplorationGrantedServices = getStringValueFromTable(db, TABLE_SECURE, |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 1149 | Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, ""); |
| 1150 | if (TextUtils.isEmpty(touchExplorationGrantedServices) |
| 1151 | && !TextUtils.isEmpty(enabledServices)) { |
| 1152 | SQLiteStatement stmt = null; |
| 1153 | try { |
| 1154 | db.beginTransaction(); |
| 1155 | stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)" |
| 1156 | + " VALUES(?,?);"); |
| 1157 | loadSetting(stmt, |
| 1158 | Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, |
| 1159 | enabledServices); |
| 1160 | db.setTransactionSuccessful(); |
| 1161 | } finally { |
| 1162 | db.endTransaction(); |
| 1163 | if (stmt != null) stmt.close(); |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | upgradeVersion = 80; |
| 1168 | } |
| 1169 | |
Daniel Sandler | fdb7c36 | 2012-08-06 17:02:55 -0400 | [diff] [blame] | 1170 | // vvv Jelly Bean MR1 changes begin here vvv |
| 1171 | |
Svetoslav Ganov | ca34bcf | 2012-08-16 12:22:23 -0700 | [diff] [blame] | 1172 | if (upgradeVersion == 80) { |
Daniel Sandler | fdb7c36 | 2012-08-06 17:02:55 -0400 | [diff] [blame] | 1173 | // update screensaver settings |
| 1174 | db.beginTransaction(); |
| 1175 | SQLiteStatement stmt = null; |
| 1176 | try { |
| 1177 | stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)" |
| 1178 | + " VALUES(?,?);"); |
| 1179 | loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ENABLED, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 1180 | com.android.internal.R.bool.config_dreamsEnabledByDefault); |
Daniel Sandler | fdb7c36 | 2012-08-06 17:02:55 -0400 | [diff] [blame] | 1181 | loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 1182 | com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault); |
John Spurlock | 1a868b7 | 2012-08-22 09:56:51 -0400 | [diff] [blame] | 1183 | loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 1184 | com.android.internal.R.bool.config_dreamsActivatedOnSleepByDefault); |
John Spurlock | 1a868b7 | 2012-08-22 09:56:51 -0400 | [diff] [blame] | 1185 | loadStringSetting(stmt, Settings.Secure.SCREENSAVER_COMPONENTS, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 1186 | com.android.internal.R.string.config_dreamsDefaultComponent); |
| 1187 | loadStringSetting(stmt, Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT, |
| 1188 | com.android.internal.R.string.config_dreamsDefaultComponent); |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1189 | |
Daniel Sandler | fdb7c36 | 2012-08-06 17:02:55 -0400 | [diff] [blame] | 1190 | db.setTransactionSuccessful(); |
| 1191 | } finally { |
| 1192 | db.endTransaction(); |
| 1193 | if (stmt != null) stmt.close(); |
| 1194 | } |
Svetoslav Ganov | ca34bcf | 2012-08-16 12:22:23 -0700 | [diff] [blame] | 1195 | upgradeVersion = 81; |
Daniel Sandler | fdb7c36 | 2012-08-06 17:02:55 -0400 | [diff] [blame] | 1196 | } |
| 1197 | |
rich cannings | 16e119e | 2012-09-06 12:04:37 -0700 | [diff] [blame] | 1198 | if (upgradeVersion == 81) { |
| 1199 | // Add package verification setting |
| 1200 | db.beginTransaction(); |
| 1201 | SQLiteStatement stmt = null; |
| 1202 | try { |
| 1203 | stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)" |
| 1204 | + " VALUES(?,?);"); |
Jeff Sharkey | bdfce2e | 2012-09-26 15:54:06 -0700 | [diff] [blame] | 1205 | loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE, |
rich cannings | 16e119e | 2012-09-06 12:04:37 -0700 | [diff] [blame] | 1206 | R.bool.def_package_verifier_enable); |
| 1207 | db.setTransactionSuccessful(); |
| 1208 | } finally { |
| 1209 | db.endTransaction(); |
| 1210 | if (stmt != null) stmt.close(); |
| 1211 | } |
| 1212 | upgradeVersion = 82; |
| 1213 | } |
| 1214 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1215 | if (upgradeVersion == 82) { |
| 1216 | // Move to per-user settings dbs |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1217 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1218 | |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1219 | db.beginTransaction(); |
| 1220 | SQLiteStatement stmt = null; |
| 1221 | try { |
| 1222 | // Migrate now-global settings. Note that this happens before |
| 1223 | // new users can be created. |
| 1224 | createGlobalTable(db); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1225 | String[] settingsToMove = setToStringArray( |
| 1226 | SettingsProvider.sSystemMovedToGlobalSettings); |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1227 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, false); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1228 | settingsToMove = setToStringArray( |
| 1229 | SettingsProvider.sSecureMovedToGlobalSettings); |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1230 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, false); |
| 1231 | |
| 1232 | db.setTransactionSuccessful(); |
| 1233 | } finally { |
| 1234 | db.endTransaction(); |
| 1235 | if (stmt != null) stmt.close(); |
| 1236 | } |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1237 | } |
| 1238 | upgradeVersion = 83; |
| 1239 | } |
| 1240 | |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1241 | if (upgradeVersion == 83) { |
| 1242 | // 1. Setting whether screen magnification is enabled. |
| 1243 | // 2. Setting for screen magnification scale. |
| 1244 | // 3. Setting for screen magnification auto update. |
| 1245 | db.beginTransaction(); |
| 1246 | SQLiteStatement stmt = null; |
| 1247 | try { |
| 1248 | stmt = db.compileStatement("INSERT INTO secure(name,value) VALUES(?,?);"); |
| 1249 | loadBooleanSetting(stmt, |
| 1250 | Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, |
| 1251 | R.bool.def_accessibility_display_magnification_enabled); |
| 1252 | stmt.close(); |
| 1253 | stmt = db.compileStatement("INSERT INTO secure(name,value) VALUES(?,?);"); |
| 1254 | loadFractionSetting(stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, |
| 1255 | R.fraction.def_accessibility_display_magnification_scale, 1); |
| 1256 | stmt.close(); |
Christopher Tate | 1a9c0dfd | 2012-09-06 22:17:43 -0700 | [diff] [blame] | 1257 | |
| 1258 | db.setTransactionSuccessful(); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1259 | } finally { |
| 1260 | db.endTransaction(); |
| 1261 | if (stmt != null) stmt.close(); |
| 1262 | } |
| 1263 | upgradeVersion = 84; |
| 1264 | } |
| 1265 | |
Christopher Tate | 1a9c0dfd | 2012-09-06 22:17:43 -0700 | [diff] [blame] | 1266 | if (upgradeVersion == 84) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1267 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1268 | db.beginTransaction(); |
| 1269 | SQLiteStatement stmt = null; |
| 1270 | try { |
| 1271 | // Patch up the slightly-wrong key migration from 82 -> 83 for those |
| 1272 | // devices that missed it, ignoring if the move is redundant |
| 1273 | String[] settingsToMove = { |
| 1274 | Settings.Secure.ADB_ENABLED, |
| 1275 | Settings.Secure.BLUETOOTH_ON, |
| 1276 | Settings.Secure.DATA_ROAMING, |
| 1277 | Settings.Secure.DEVICE_PROVISIONED, |
| 1278 | Settings.Secure.INSTALL_NON_MARKET_APPS, |
| 1279 | Settings.Secure.USB_MASS_STORAGE_ENABLED |
| 1280 | }; |
| 1281 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); |
| 1282 | db.setTransactionSuccessful(); |
| 1283 | } finally { |
| 1284 | db.endTransaction(); |
| 1285 | if (stmt != null) stmt.close(); |
| 1286 | } |
Christopher Tate | 1a9c0dfd | 2012-09-06 22:17:43 -0700 | [diff] [blame] | 1287 | } |
| 1288 | upgradeVersion = 85; |
| 1289 | } |
| 1290 | |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 1291 | if (upgradeVersion == 85) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1292 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1293 | db.beginTransaction(); |
| 1294 | try { |
| 1295 | // Fix up the migration, ignoring already-migrated elements, to snap up to |
| 1296 | // date with new changes to the set of global versus system/secure settings |
| 1297 | String[] settingsToMove = { Settings.System.STAY_ON_WHILE_PLUGGED_IN }; |
| 1298 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, true); |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 1299 | |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1300 | db.setTransactionSuccessful(); |
| 1301 | } finally { |
| 1302 | db.endTransaction(); |
| 1303 | } |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 1304 | } |
| 1305 | upgradeVersion = 86; |
| 1306 | } |
| 1307 | |
rich cannings | 4d8fc79 | 2012-09-07 14:43:43 -0700 | [diff] [blame] | 1308 | if (upgradeVersion == 86) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1309 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1310 | db.beginTransaction(); |
| 1311 | try { |
| 1312 | String[] settingsToMove = { |
Jeff Sharkey | bdfce2e | 2012-09-26 15:54:06 -0700 | [diff] [blame] | 1313 | Settings.Global.PACKAGE_VERIFIER_ENABLE, |
| 1314 | Settings.Global.PACKAGE_VERIFIER_TIMEOUT, |
| 1315 | Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1316 | }; |
| 1317 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); |
rich cannings | 4d8fc79 | 2012-09-07 14:43:43 -0700 | [diff] [blame] | 1318 | |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1319 | db.setTransactionSuccessful(); |
| 1320 | } finally { |
| 1321 | db.endTransaction(); |
| 1322 | } |
rich cannings | 4d8fc79 | 2012-09-07 14:43:43 -0700 | [diff] [blame] | 1323 | } |
| 1324 | upgradeVersion = 87; |
| 1325 | } |
| 1326 | |
Christopher Tate | c868b64 | 2012-09-12 17:41:04 -0700 | [diff] [blame] | 1327 | if (upgradeVersion == 87) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1328 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1329 | db.beginTransaction(); |
| 1330 | try { |
| 1331 | String[] settingsToMove = { |
Jeff Sharkey | bdfce2e | 2012-09-26 15:54:06 -0700 | [diff] [blame] | 1332 | Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS, |
| 1333 | Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS, |
| 1334 | Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1335 | }; |
| 1336 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); |
Christopher Tate | c868b64 | 2012-09-12 17:41:04 -0700 | [diff] [blame] | 1337 | |
Christopher Tate | 59c5bee | 2012-09-13 14:38:33 -0700 | [diff] [blame] | 1338 | db.setTransactionSuccessful(); |
| 1339 | } finally { |
| 1340 | db.endTransaction(); |
| 1341 | } |
Christopher Tate | c868b64 | 2012-09-12 17:41:04 -0700 | [diff] [blame] | 1342 | } |
| 1343 | upgradeVersion = 88; |
| 1344 | } |
| 1345 | |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 1346 | if (upgradeVersion == 88) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1347 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 1348 | db.beginTransaction(); |
| 1349 | try { |
| 1350 | String[] settingsToMove = { |
| 1351 | Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD, |
| 1352 | Settings.Global.BATTERY_DISCHARGE_THRESHOLD, |
| 1353 | Settings.Global.SEND_ACTION_APP_ERROR, |
| 1354 | Settings.Global.DROPBOX_AGE_SECONDS, |
| 1355 | Settings.Global.DROPBOX_MAX_FILES, |
| 1356 | Settings.Global.DROPBOX_QUOTA_KB, |
| 1357 | Settings.Global.DROPBOX_QUOTA_PERCENT, |
| 1358 | Settings.Global.DROPBOX_RESERVE_PERCENT, |
| 1359 | Settings.Global.DROPBOX_TAG_PREFIX, |
| 1360 | Settings.Global.ERROR_LOGCAT_PREFIX, |
| 1361 | Settings.Global.SYS_FREE_STORAGE_LOG_INTERVAL, |
| 1362 | Settings.Global.DISK_FREE_CHANGE_REPORTING_THRESHOLD, |
| 1363 | Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE, |
| 1364 | Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES, |
| 1365 | Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES, |
| 1366 | Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS, |
| 1367 | Settings.Global.CONNECTIVITY_CHANGE_DELAY, |
| 1368 | Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED, |
| 1369 | Settings.Global.CAPTIVE_PORTAL_SERVER, |
| 1370 | Settings.Global.NSD_ON, |
| 1371 | Settings.Global.SET_INSTALL_LOCATION, |
| 1372 | Settings.Global.DEFAULT_INSTALL_LOCATION, |
| 1373 | Settings.Global.INET_CONDITION_DEBOUNCE_UP_DELAY, |
| 1374 | Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY, |
| 1375 | Settings.Global.READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT, |
| 1376 | Settings.Global.HTTP_PROXY, |
| 1377 | Settings.Global.GLOBAL_HTTP_PROXY_HOST, |
| 1378 | Settings.Global.GLOBAL_HTTP_PROXY_PORT, |
| 1379 | Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST, |
| 1380 | Settings.Global.SET_GLOBAL_HTTP_PROXY, |
| 1381 | Settings.Global.DEFAULT_DNS_SERVER, |
| 1382 | }; |
| 1383 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); |
| 1384 | db.setTransactionSuccessful(); |
| 1385 | } finally { |
| 1386 | db.endTransaction(); |
| 1387 | } |
| 1388 | } |
| 1389 | upgradeVersion = 89; |
| 1390 | } |
| 1391 | |
Jeff Sharkey | 0ac1028 | 2012-10-01 12:50:22 -0700 | [diff] [blame] | 1392 | if (upgradeVersion == 89) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1393 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Jeff Sharkey | 0ac1028 | 2012-10-01 12:50:22 -0700 | [diff] [blame] | 1394 | db.beginTransaction(); |
| 1395 | try { |
| 1396 | String[] prefixesToMove = { |
| 1397 | Settings.Global.BLUETOOTH_HEADSET_PRIORITY_PREFIX, |
| 1398 | Settings.Global.BLUETOOTH_A2DP_SINK_PRIORITY_PREFIX, |
| 1399 | Settings.Global.BLUETOOTH_INPUT_DEVICE_PRIORITY_PREFIX, |
| 1400 | }; |
| 1401 | |
| 1402 | movePrefixedSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, prefixesToMove); |
| 1403 | |
| 1404 | db.setTransactionSuccessful(); |
| 1405 | } finally { |
| 1406 | db.endTransaction(); |
| 1407 | } |
| 1408 | } |
| 1409 | upgradeVersion = 90; |
| 1410 | } |
| 1411 | |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 1412 | if (upgradeVersion == 90) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1413 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 1414 | db.beginTransaction(); |
| 1415 | try { |
| 1416 | String[] systemToGlobal = { |
| 1417 | Settings.Global.WINDOW_ANIMATION_SCALE, |
| 1418 | Settings.Global.TRANSITION_ANIMATION_SCALE, |
| 1419 | Settings.Global.ANIMATOR_DURATION_SCALE, |
| 1420 | Settings.Global.FANCY_IME_ANIMATIONS, |
| 1421 | Settings.Global.COMPATIBILITY_MODE, |
| 1422 | Settings.Global.EMERGENCY_TONE, |
| 1423 | Settings.Global.CALL_AUTO_RETRY, |
| 1424 | Settings.Global.DEBUG_APP, |
| 1425 | Settings.Global.WAIT_FOR_DEBUGGER, |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 1426 | Settings.Global.ALWAYS_FINISH_ACTIVITIES, |
| 1427 | }; |
| 1428 | String[] secureToGlobal = { |
| 1429 | Settings.Global.PREFERRED_NETWORK_MODE, |
Naveen Kalla | b4d485c | 2013-07-03 16:39:27 -0700 | [diff] [blame] | 1430 | Settings.Global.CDMA_SUBSCRIPTION_MODE, |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 1431 | }; |
| 1432 | |
| 1433 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, systemToGlobal, true); |
| 1434 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, secureToGlobal, true); |
| 1435 | |
| 1436 | db.setTransactionSuccessful(); |
| 1437 | } finally { |
| 1438 | db.endTransaction(); |
| 1439 | } |
| 1440 | } |
| 1441 | upgradeVersion = 91; |
| 1442 | } |
| 1443 | |
Eric Laurent | 55b0222 | 2012-10-03 11:56:23 -0700 | [diff] [blame] | 1444 | if (upgradeVersion == 91) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1445 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Eric Laurent | 55b0222 | 2012-10-03 11:56:23 -0700 | [diff] [blame] | 1446 | db.beginTransaction(); |
| 1447 | try { |
| 1448 | // Move ringer mode from system to global settings |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1449 | String[] settingsToMove = { Settings.Global.MODE_RINGER }; |
Eric Laurent | 55b0222 | 2012-10-03 11:56:23 -0700 | [diff] [blame] | 1450 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, true); |
| 1451 | |
| 1452 | db.setTransactionSuccessful(); |
| 1453 | } finally { |
| 1454 | db.endTransaction(); |
| 1455 | } |
| 1456 | } |
| 1457 | upgradeVersion = 92; |
| 1458 | } |
| 1459 | |
John Spurlock | 7f1c248 | 2012-10-05 11:15:28 -0400 | [diff] [blame] | 1460 | if (upgradeVersion == 92) { |
| 1461 | SQLiteStatement stmt = null; |
| 1462 | try { |
| 1463 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 1464 | + " VALUES(?,?);"); |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1465 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
John Spurlock | 7f1c248 | 2012-10-05 11:15:28 -0400 | [diff] [blame] | 1466 | // consider existing primary users to have made it through user setup |
| 1467 | // if the globally-scoped device-provisioned bit is set |
| 1468 | // (indicating they already made it through setup as primary) |
| 1469 | int deviceProvisioned = getIntValueFromTable(db, TABLE_GLOBAL, |
| 1470 | Settings.Global.DEVICE_PROVISIONED, 0); |
| 1471 | loadSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE, |
| 1472 | deviceProvisioned); |
| 1473 | } else { |
| 1474 | // otherwise use the default |
| 1475 | loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE, |
| 1476 | R.bool.def_user_setup_complete); |
| 1477 | } |
| 1478 | } finally { |
| 1479 | if (stmt != null) stmt.close(); |
| 1480 | } |
| 1481 | upgradeVersion = 93; |
| 1482 | } |
| 1483 | |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1484 | if (upgradeVersion == 93) { |
| 1485 | // Redo this step, since somehow it didn't work the first time for some users |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1486 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1487 | db.beginTransaction(); |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1488 | try { |
| 1489 | // Migrate now-global settings |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1490 | String[] settingsToMove = setToStringArray( |
| 1491 | SettingsProvider.sSystemMovedToGlobalSettings); |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1492 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_GLOBAL, settingsToMove, true); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1493 | settingsToMove = setToStringArray( |
| 1494 | SettingsProvider.sSecureMovedToGlobalSettings); |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1495 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); |
| 1496 | |
| 1497 | db.setTransactionSuccessful(); |
| 1498 | } finally { |
| 1499 | db.endTransaction(); |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 1500 | } |
| 1501 | } |
| 1502 | upgradeVersion = 94; |
| 1503 | } |
| 1504 | |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 1505 | if (upgradeVersion == 94) { |
| 1506 | // Add wireless charging started sound setting |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1507 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Amith Yamasani | 2d43fab | 2012-12-12 09:52:26 -0800 | [diff] [blame] | 1508 | db.beginTransaction(); |
| 1509 | SQLiteStatement stmt = null; |
| 1510 | try { |
| 1511 | stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" |
| 1512 | + " VALUES(?,?);"); |
| 1513 | loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND, |
| 1514 | R.string.def_wireless_charging_started_sound); |
| 1515 | db.setTransactionSuccessful(); |
| 1516 | } finally { |
| 1517 | db.endTransaction(); |
| 1518 | if (stmt != null) stmt.close(); |
| 1519 | } |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 1520 | } |
| 1521 | upgradeVersion = 95; |
| 1522 | } |
| 1523 | |
Christopher Tate | 58f41ec | 2013-01-11 15:40:36 -0800 | [diff] [blame] | 1524 | if (upgradeVersion == 95) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1525 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 58f41ec | 2013-01-11 15:40:36 -0800 | [diff] [blame] | 1526 | db.beginTransaction(); |
| 1527 | try { |
| 1528 | String[] settingsToMove = { Settings.Global.BUGREPORT_IN_POWER_MENU }; |
| 1529 | moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); |
| 1530 | db.setTransactionSuccessful(); |
| 1531 | } finally { |
| 1532 | db.endTransaction(); |
| 1533 | } |
| 1534 | } |
| 1535 | upgradeVersion = 96; |
| 1536 | } |
| 1537 | |
Mike Cleron | d1ed3ce | 2013-02-01 18:36:41 +0000 | [diff] [blame] | 1538 | if (upgradeVersion == 96) { |
Svetoslav Ganov | 447d946 | 2013-02-01 19:46:20 +0000 | [diff] [blame] | 1539 | // NOP bump due to a reverted change that some people got on upgrade. |
Mike Cleron | d1ed3ce | 2013-02-01 18:36:41 +0000 | [diff] [blame] | 1540 | upgradeVersion = 97; |
| 1541 | } |
| 1542 | |
Daniel Sandler | dea6462 | 2013-09-23 16:05:57 -0400 | [diff] [blame] | 1543 | if (upgradeVersion == 97) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1544 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Daniel Sandler | dea6462 | 2013-09-23 16:05:57 -0400 | [diff] [blame] | 1545 | db.beginTransaction(); |
| 1546 | SQLiteStatement stmt = null; |
| 1547 | try { |
| 1548 | stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" |
| 1549 | + " VALUES(?,?);"); |
| 1550 | loadIntegerSetting(stmt, Settings.Global.LOW_BATTERY_SOUND_TIMEOUT, |
| 1551 | R.integer.def_low_battery_sound_timeout); |
| 1552 | db.setTransactionSuccessful(); |
| 1553 | } finally { |
| 1554 | db.endTransaction(); |
| 1555 | if (stmt != null) stmt.close(); |
| 1556 | } |
| 1557 | } |
| 1558 | upgradeVersion = 98; |
| 1559 | } |
| 1560 | |
Dan Sandler | 82a6c5c | 2014-02-20 14:43:20 -0500 | [diff] [blame] | 1561 | if (upgradeVersion == 98) { |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 1562 | // no-op; LOCK_SCREEN_SHOW_NOTIFICATIONS now handled in version 106 |
Dan Sandler | 82a6c5c | 2014-02-20 14:43:20 -0500 | [diff] [blame] | 1563 | upgradeVersion = 99; |
| 1564 | } |
| 1565 | |
Chris Wren | 1cdd7dd | 2014-02-28 17:49:20 -0500 | [diff] [blame] | 1566 | if (upgradeVersion == 99) { |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 1567 | // no-op; HEADS_UP_NOTIFICATIONS_ENABLED now handled in version 100 |
| 1568 | upgradeVersion = 100; |
| 1569 | } |
| 1570 | |
| 1571 | if (upgradeVersion == 100) { |
| 1572 | // note: LOCK_SCREEN_SHOW_NOTIFICATIONS now handled in version 106 |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1573 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Chris Wren | 1cdd7dd | 2014-02-28 17:49:20 -0500 | [diff] [blame] | 1574 | db.beginTransaction(); |
| 1575 | SQLiteStatement stmt = null; |
| 1576 | try { |
| 1577 | stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" |
| 1578 | + " VALUES(?,?);"); |
| 1579 | loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED, |
| 1580 | R.integer.def_heads_up_enabled); |
| 1581 | db.setTransactionSuccessful(); |
| 1582 | } finally { |
| 1583 | db.endTransaction(); |
| 1584 | if (stmt != null) stmt.close(); |
| 1585 | } |
| 1586 | } |
Chris Wren | 5242cf3 | 2014-03-19 16:16:48 -0400 | [diff] [blame] | 1587 | upgradeVersion = 101; |
| 1588 | } |
Chris Wren | 1cdd7dd | 2014-02-28 17:49:20 -0500 | [diff] [blame] | 1589 | |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 1590 | if (upgradeVersion == 101) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1591 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 1592 | db.beginTransaction(); |
| 1593 | SQLiteStatement stmt = null; |
| 1594 | try { |
| 1595 | stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" |
| 1596 | + " VALUES(?,?);"); |
| 1597 | loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName()); |
| 1598 | db.setTransactionSuccessful(); |
| 1599 | } finally { |
| 1600 | db.endTransaction(); |
| 1601 | if (stmt != null) stmt.close(); |
| 1602 | } |
| 1603 | } |
| 1604 | upgradeVersion = 102; |
| 1605 | } |
| 1606 | |
Christopher Tate | aa036a2 | 2014-05-19 16:33:27 -0700 | [diff] [blame] | 1607 | if (upgradeVersion == 102) { |
| 1608 | db.beginTransaction(); |
| 1609 | SQLiteStatement stmt = null; |
| 1610 | try { |
| 1611 | // The INSTALL_NON_MARKET_APPS setting is becoming per-user rather |
| 1612 | // than device-global. |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1613 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | aa036a2 | 2014-05-19 16:33:27 -0700 | [diff] [blame] | 1614 | // In the owner user, the global table exists so we can migrate the |
| 1615 | // entry from there to the secure table, preserving its value. |
| 1616 | String[] globalToSecure = { |
| 1617 | Settings.Secure.INSTALL_NON_MARKET_APPS |
| 1618 | }; |
| 1619 | moveSettingsToNewTable(db, TABLE_GLOBAL, TABLE_SECURE, globalToSecure, true); |
| 1620 | } else { |
| 1621 | // Secondary users' dbs don't have the global table, so institute the |
| 1622 | // default. |
| 1623 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 1624 | + " VALUES(?,?);"); |
| 1625 | loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, |
| 1626 | R.bool.def_install_non_market_apps); |
| 1627 | } |
| 1628 | db.setTransactionSuccessful(); |
| 1629 | } finally { |
| 1630 | db.endTransaction(); |
| 1631 | if (stmt != null) stmt.close(); |
| 1632 | } |
| 1633 | upgradeVersion = 103; |
| 1634 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1635 | |
| 1636 | if (upgradeVersion == 103) { |
| 1637 | db.beginTransaction(); |
| 1638 | SQLiteStatement stmt = null; |
| 1639 | try { |
| 1640 | stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)" |
| 1641 | + " VALUES(?,?);"); |
| 1642 | loadBooleanSetting(stmt, Settings.Secure.WAKE_GESTURE_ENABLED, |
| 1643 | R.bool.def_wake_gesture_enabled); |
| 1644 | db.setTransactionSuccessful(); |
| 1645 | } finally { |
| 1646 | db.endTransaction(); |
| 1647 | if (stmt != null) stmt.close(); |
| 1648 | } |
| 1649 | upgradeVersion = 104; |
| 1650 | } |
| 1651 | |
Amith Yamasani | 1e9c218 | 2014-06-11 17:25:51 -0700 | [diff] [blame] | 1652 | if (upgradeVersion < 105) { |
Fyodor Kupolov | cd86ebf | 2015-09-29 17:06:50 -0700 | [diff] [blame] | 1653 | // No-op: GUEST_USER_ENABLED setting was removed |
Amith Yamasani | 1e9c218 | 2014-06-11 17:25:51 -0700 | [diff] [blame] | 1654 | upgradeVersion = 105; |
| 1655 | } |
| 1656 | |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 1657 | if (upgradeVersion < 106) { |
| 1658 | // LOCK_SCREEN_SHOW_NOTIFICATIONS is now per-user. |
| 1659 | db.beginTransaction(); |
| 1660 | SQLiteStatement stmt = null; |
| 1661 | try { |
| 1662 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 1663 | + " VALUES(?,?);"); |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 1664 | loadIntegerSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, |
| 1665 | R.integer.def_lock_screen_show_notifications); |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1666 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 1667 | final int oldShow = getIntValueFromTable(db, |
| 1668 | TABLE_GLOBAL, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, -1); |
| 1669 | if (oldShow >= 0) { |
| 1670 | // overwrite the default with whatever you had |
| 1671 | loadSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, oldShow); |
| 1672 | final SQLiteStatement deleteStmt |
| 1673 | = db.compileStatement("DELETE FROM global WHERE name=?"); |
| 1674 | deleteStmt.bindString(1, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS); |
| 1675 | deleteStmt.execute(); |
| 1676 | } |
| 1677 | } |
| 1678 | db.setTransactionSuccessful(); |
| 1679 | } finally { |
| 1680 | db.endTransaction(); |
| 1681 | if (stmt != null) stmt.close(); |
| 1682 | } |
| 1683 | upgradeVersion = 106; |
| 1684 | } |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 1685 | |
| 1686 | if (upgradeVersion < 107) { |
| 1687 | // Add trusted sound setting |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1688 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 1689 | db.beginTransaction(); |
| 1690 | SQLiteStatement stmt = null; |
| 1691 | try { |
| 1692 | stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" |
| 1693 | + " VALUES(?,?);"); |
| 1694 | loadStringSetting(stmt, Settings.Global.TRUSTED_SOUND, |
| 1695 | R.string.def_trusted_sound); |
| 1696 | db.setTransactionSuccessful(); |
| 1697 | } finally { |
| 1698 | db.endTransaction(); |
| 1699 | if (stmt != null) stmt.close(); |
| 1700 | } |
| 1701 | } |
| 1702 | upgradeVersion = 107; |
| 1703 | } |
| 1704 | |
Jeff Brown | 49cb613 | 2014-08-20 14:32:38 -0700 | [diff] [blame] | 1705 | if (upgradeVersion < 108) { |
| 1706 | // Reset the auto-brightness setting to default since the behavior |
| 1707 | // of the feature is now quite different and is being presented to |
| 1708 | // the user in a new way as "adaptive brightness". |
| 1709 | db.beginTransaction(); |
| 1710 | SQLiteStatement stmt = null; |
| 1711 | try { |
| 1712 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 1713 | + " VALUES(?,?);"); |
| 1714 | loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 1715 | R.bool.def_screen_brightness_automatic_mode); |
| 1716 | db.setTransactionSuccessful(); |
| 1717 | } finally { |
| 1718 | db.endTransaction(); |
| 1719 | if (stmt != null) stmt.close(); |
| 1720 | } |
| 1721 | upgradeVersion = 108; |
| 1722 | } |
| 1723 | |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 1724 | if (upgradeVersion < 109) { |
| 1725 | db.beginTransaction(); |
| 1726 | SQLiteStatement stmt = null; |
| 1727 | try { |
| 1728 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 1729 | + " VALUES(?,?);"); |
| 1730 | loadBooleanSetting(stmt, Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, |
| 1731 | R.bool.def_lock_screen_allow_private_notifications); |
| 1732 | db.setTransactionSuccessful(); |
| 1733 | } finally { |
| 1734 | db.endTransaction(); |
| 1735 | if (stmt != null) stmt.close(); |
| 1736 | } |
| 1737 | upgradeVersion = 109; |
| 1738 | } |
| 1739 | |
Tyler Gunn | 2c830a2 | 2014-09-02 08:39:35 -0700 | [diff] [blame] | 1740 | if (upgradeVersion < 110) { |
| 1741 | // The SIP_CALL_OPTIONS value SIP_ASK_EACH_TIME is being deprecated. |
| 1742 | // If the SIP_CALL_OPTIONS setting is set to SIP_ASK_EACH_TIME, default to |
| 1743 | // SIP_ADDRESS_ONLY. |
| 1744 | db.beginTransaction(); |
| 1745 | SQLiteStatement stmt = null; |
| 1746 | try { |
| 1747 | stmt = db.compileStatement("UPDATE system SET value = ? " + |
| 1748 | "WHERE name = ? AND value = ?;"); |
| 1749 | stmt.bindString(1, Settings.System.SIP_ADDRESS_ONLY); |
| 1750 | stmt.bindString(2, Settings.System.SIP_CALL_OPTIONS); |
| 1751 | stmt.bindString(3, Settings.System.SIP_ASK_ME_EACH_TIME); |
| 1752 | stmt.execute(); |
| 1753 | db.setTransactionSuccessful(); |
| 1754 | } finally { |
| 1755 | db.endTransaction(); |
| 1756 | if (stmt != null) stmt.close(); |
| 1757 | } |
| 1758 | upgradeVersion = 110; |
| 1759 | } |
| 1760 | |
John Spurlock | 7d424b6 | 2014-09-09 17:05:54 -0400 | [diff] [blame] | 1761 | if (upgradeVersion < 111) { |
| 1762 | // reset ringer mode, so it doesn't force zen mode to follow |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1763 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
John Spurlock | 7d424b6 | 2014-09-09 17:05:54 -0400 | [diff] [blame] | 1764 | db.beginTransaction(); |
| 1765 | SQLiteStatement stmt = null; |
| 1766 | try { |
| 1767 | stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)" |
| 1768 | + " VALUES(?,?);"); |
| 1769 | loadSetting(stmt, Settings.Global.MODE_RINGER, AudioManager.RINGER_MODE_NORMAL); |
| 1770 | db.setTransactionSuccessful(); |
| 1771 | } finally { |
| 1772 | db.endTransaction(); |
| 1773 | if (stmt != null) stmt.close(); |
| 1774 | } |
| 1775 | } |
| 1776 | upgradeVersion = 111; |
| 1777 | } |
| 1778 | |
Jerome Poichet | 550021e | 2014-09-11 10:38:12 -0700 | [diff] [blame] | 1779 | if (upgradeVersion < 112) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1780 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Jerome Poichet | 550021e | 2014-09-11 10:38:12 -0700 | [diff] [blame] | 1781 | // When device name was added, we went with Manufacturer + Model, device name should |
| 1782 | // actually be Model only. |
| 1783 | // Update device name to Model if it wasn't modified by user. |
| 1784 | db.beginTransaction(); |
| 1785 | SQLiteStatement stmt = null; |
| 1786 | try { |
| 1787 | stmt = db.compileStatement("UPDATE global SET value = ? " |
| 1788 | + " WHERE name = ? AND value = ?"); |
| 1789 | stmt.bindString(1, getDefaultDeviceName()); // new default device name |
| 1790 | stmt.bindString(2, Settings.Global.DEVICE_NAME); |
| 1791 | stmt.bindString(3, getOldDefaultDeviceName()); // old default device name |
| 1792 | stmt.execute(); |
| 1793 | db.setTransactionSuccessful(); |
| 1794 | } finally { |
| 1795 | db.endTransaction(); |
| 1796 | if (stmt != null) stmt.close(); |
| 1797 | } |
| 1798 | } |
| 1799 | upgradeVersion = 112; |
| 1800 | } |
| 1801 | |
Jeff Brown | 05af6ad | 2014-09-30 20:54:30 -0700 | [diff] [blame] | 1802 | if (upgradeVersion < 113) { |
| 1803 | db.beginTransaction(); |
| 1804 | SQLiteStatement stmt = null; |
| 1805 | try { |
| 1806 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 1807 | + " VALUES(?,?);"); |
| 1808 | loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT, |
| 1809 | R.integer.def_sleep_timeout); |
| 1810 | db.setTransactionSuccessful(); |
| 1811 | } finally { |
| 1812 | db.endTransaction(); |
| 1813 | if (stmt != null) stmt.close(); |
| 1814 | } |
| 1815 | upgradeVersion = 113; |
| 1816 | } |
| 1817 | |
Bryce Lee | fb1cf36 | 2014-10-22 16:56:08 -0700 | [diff] [blame] | 1818 | // We skipped 114 to handle a merge conflict with the introduction of theater mode. |
| 1819 | |
| 1820 | if (upgradeVersion < 115) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1821 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Bryce Lee | fb1cf36 | 2014-10-22 16:56:08 -0700 | [diff] [blame] | 1822 | db.beginTransaction(); |
| 1823 | SQLiteStatement stmt = null; |
| 1824 | try { |
| 1825 | stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" |
| 1826 | + " VALUES(?,?);"); |
| 1827 | loadBooleanSetting(stmt, Global.THEATER_MODE_ON, |
| 1828 | R.bool.def_theater_mode_on); |
| 1829 | db.setTransactionSuccessful(); |
| 1830 | } finally { |
| 1831 | db.endTransaction(); |
| 1832 | if (stmt != null) stmt.close(); |
| 1833 | } |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 1834 | } |
Bryce Lee | fb1cf36 | 2014-10-22 16:56:08 -0700 | [diff] [blame] | 1835 | upgradeVersion = 115; |
| 1836 | } |
| 1837 | |
| 1838 | if (upgradeVersion < 116) { |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 1839 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 04e6827 | 2014-10-22 10:36:42 -0700 | [diff] [blame] | 1840 | db.beginTransaction(); |
| 1841 | SQLiteStatement stmt = null; |
| 1842 | try { |
| 1843 | stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" |
| 1844 | + " VALUES(?,?);"); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1845 | loadSetting(stmt, Settings.Global.ENHANCED_4G_MODE_ENABLED, |
| 1846 | ImsConfig.FeatureValueConstants.ON); |
Christopher Tate | 04e6827 | 2014-10-22 10:36:42 -0700 | [diff] [blame] | 1847 | db.setTransactionSuccessful(); |
| 1848 | } finally { |
| 1849 | db.endTransaction(); |
| 1850 | if (stmt != null) stmt.close(); |
| 1851 | } |
Libin.Tang@motorola.com | 0499bb5 | 2014-10-10 14:55:57 -0500 | [diff] [blame] | 1852 | } |
Bryce Lee | fb1cf36 | 2014-10-22 16:56:08 -0700 | [diff] [blame] | 1853 | upgradeVersion = 116; |
Libin.Tang@motorola.com | 0499bb5 | 2014-10-10 14:55:57 -0500 | [diff] [blame] | 1854 | } |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 1855 | |
Jason Monk | 94cfd9d | 2014-10-31 13:18:21 -0400 | [diff] [blame] | 1856 | if (upgradeVersion < 117) { |
| 1857 | db.beginTransaction(); |
| 1858 | try { |
| 1859 | String[] systemToSecure = { |
| 1860 | Settings.Secure.LOCK_TO_APP_EXIT_LOCKED |
| 1861 | }; |
| 1862 | moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, systemToSecure, true); |
| 1863 | db.setTransactionSuccessful(); |
| 1864 | } finally { |
| 1865 | db.endTransaction(); |
| 1866 | } |
| 1867 | upgradeVersion = 117; |
| 1868 | } |
| 1869 | |
John Spurlock | 8c51d0b | 2014-11-07 15:14:21 -0500 | [diff] [blame] | 1870 | if (upgradeVersion < 118) { |
| 1871 | // Reset rotation-lock-for-accessibility on upgrade, since it now hides the display |
| 1872 | // setting. |
| 1873 | db.beginTransaction(); |
| 1874 | SQLiteStatement stmt = null; |
| 1875 | try { |
| 1876 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 1877 | + " VALUES(?,?);"); |
| 1878 | loadSetting(stmt, Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0); |
| 1879 | db.setTransactionSuccessful(); |
| 1880 | } finally { |
| 1881 | db.endTransaction(); |
| 1882 | if (stmt != null) stmt.close(); |
| 1883 | } |
| 1884 | upgradeVersion = 118; |
| 1885 | } |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1886 | |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 1887 | /* |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1888 | * IMPORTANT: Do not add any more upgrade steps here as the global, |
| 1889 | * secure, and system settings are no longer stored in a database |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 1890 | * but are kept in memory and persisted to XML. |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1891 | * |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 1892 | * See: SettingsProvider.UpgradeController#onUpgradeLocked |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1893 | */ |
| 1894 | |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 1895 | if (upgradeVersion != currentVersion) { |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1896 | recreateDatabase(db, oldVersion, upgradeVersion, currentVersion); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1897 | } |
| 1898 | } |
| 1899 | |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1900 | public void recreateDatabase(SQLiteDatabase db, int oldVersion, |
| 1901 | int upgradeVersion, int currentVersion) { |
| 1902 | db.execSQL("DROP TABLE IF EXISTS global"); |
| 1903 | db.execSQL("DROP TABLE IF EXISTS globalIndex1"); |
| 1904 | db.execSQL("DROP TABLE IF EXISTS system"); |
| 1905 | db.execSQL("DROP INDEX IF EXISTS systemIndex1"); |
| 1906 | db.execSQL("DROP TABLE IF EXISTS secure"); |
| 1907 | db.execSQL("DROP INDEX IF EXISTS secureIndex1"); |
| 1908 | db.execSQL("DROP TABLE IF EXISTS gservices"); |
| 1909 | db.execSQL("DROP INDEX IF EXISTS gservicesIndex1"); |
| 1910 | db.execSQL("DROP TABLE IF EXISTS bluetooth_devices"); |
| 1911 | db.execSQL("DROP TABLE IF EXISTS bookmarks"); |
| 1912 | db.execSQL("DROP INDEX IF EXISTS bookmarksIndex1"); |
| 1913 | db.execSQL("DROP INDEX IF EXISTS bookmarksIndex2"); |
| 1914 | db.execSQL("DROP TABLE IF EXISTS favorites"); |
| 1915 | |
| 1916 | onCreate(db); |
| 1917 | |
| 1918 | // Added for diagnosing settings.db wipes after the fact |
| 1919 | String wipeReason = oldVersion + "/" + upgradeVersion + "/" + currentVersion; |
| 1920 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 1921 | "wiped_db_reason" + "','" + wipeReason + "');"); |
| 1922 | } |
| 1923 | |
| 1924 | private String[] setToStringArray(Set<String> set) { |
Christopher Tate | a96798e4 | 2012-09-06 19:07:19 -0700 | [diff] [blame] | 1925 | String[] array = new String[set.size()]; |
| 1926 | return set.toArray(array); |
| 1927 | } |
| 1928 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1929 | private void moveSettingsToNewTable(SQLiteDatabase db, |
| 1930 | String sourceTable, String destTable, |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 1931 | String[] settingsToMove, boolean doIgnore) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1932 | // Copy settings values from the source table to the dest, and remove from the source |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1933 | SQLiteStatement insertStmt = null; |
| 1934 | SQLiteStatement deleteStmt = null; |
| 1935 | |
| 1936 | db.beginTransaction(); |
| 1937 | try { |
Christopher Tate | 9219874 | 2012-09-07 12:00:13 -0700 | [diff] [blame] | 1938 | insertStmt = db.compileStatement("INSERT " |
| 1939 | + (doIgnore ? " OR IGNORE " : "") |
| 1940 | + " INTO " + destTable + " (name,value) SELECT name,value FROM " |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 1941 | + sourceTable + " WHERE name=?"); |
| 1942 | deleteStmt = db.compileStatement("DELETE FROM " + sourceTable + " WHERE name=?"); |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1943 | |
| 1944 | for (String setting : settingsToMove) { |
| 1945 | insertStmt.bindString(1, setting); |
| 1946 | insertStmt.execute(); |
| 1947 | |
| 1948 | deleteStmt.bindString(1, setting); |
| 1949 | deleteStmt.execute(); |
| 1950 | } |
| 1951 | db.setTransactionSuccessful(); |
| 1952 | } finally { |
| 1953 | db.endTransaction(); |
| 1954 | if (insertStmt != null) { |
| 1955 | insertStmt.close(); |
| 1956 | } |
| 1957 | if (deleteStmt != null) { |
| 1958 | deleteStmt.close(); |
| 1959 | } |
| 1960 | } |
| 1961 | } |
| 1962 | |
Jeff Sharkey | 0ac1028 | 2012-10-01 12:50:22 -0700 | [diff] [blame] | 1963 | /** |
| 1964 | * Move any settings with the given prefixes from the source table to the |
| 1965 | * destination table. |
| 1966 | */ |
| 1967 | private void movePrefixedSettingsToNewTable( |
| 1968 | SQLiteDatabase db, String sourceTable, String destTable, String[] prefixesToMove) { |
| 1969 | SQLiteStatement insertStmt = null; |
| 1970 | SQLiteStatement deleteStmt = null; |
| 1971 | |
| 1972 | db.beginTransaction(); |
| 1973 | try { |
| 1974 | insertStmt = db.compileStatement("INSERT INTO " + destTable |
| 1975 | + " (name,value) SELECT name,value FROM " + sourceTable |
| 1976 | + " WHERE substr(name,0,?)=?"); |
| 1977 | deleteStmt = db.compileStatement( |
| 1978 | "DELETE FROM " + sourceTable + " WHERE substr(name,0,?)=?"); |
| 1979 | |
| 1980 | for (String prefix : prefixesToMove) { |
| 1981 | insertStmt.bindLong(1, prefix.length() + 1); |
| 1982 | insertStmt.bindString(2, prefix); |
| 1983 | insertStmt.execute(); |
| 1984 | |
| 1985 | deleteStmt.bindLong(1, prefix.length() + 1); |
| 1986 | deleteStmt.bindString(2, prefix); |
| 1987 | deleteStmt.execute(); |
| 1988 | } |
| 1989 | db.setTransactionSuccessful(); |
| 1990 | } finally { |
| 1991 | db.endTransaction(); |
| 1992 | if (insertStmt != null) { |
| 1993 | insertStmt.close(); |
| 1994 | } |
| 1995 | if (deleteStmt != null) { |
| 1996 | deleteStmt.close(); |
| 1997 | } |
| 1998 | } |
| 1999 | } |
| 2000 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2001 | private void upgradeLockPatternLocation(SQLiteDatabase db) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2002 | Cursor c = db.query(TABLE_SYSTEM, new String[] {"_id", "value"}, "name='lock_pattern'", |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2003 | null, null, null, null); |
| 2004 | if (c.getCount() > 0) { |
| 2005 | c.moveToFirst(); |
| 2006 | String lockPattern = c.getString(1); |
| 2007 | if (!TextUtils.isEmpty(lockPattern)) { |
| 2008 | // Convert lock pattern |
| 2009 | try { |
Jim Miller | 31f90b6 | 2010-01-20 13:35:20 -0800 | [diff] [blame] | 2010 | LockPatternUtils lpu = new LockPatternUtils(mContext); |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2011 | List<LockPatternView.Cell> cellPattern = |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2012 | LockPatternUtils.stringToPattern(lockPattern); |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 2013 | lpu.saveLockPattern(cellPattern, null, UserHandle.USER_SYSTEM); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2014 | } catch (IllegalArgumentException e) { |
| 2015 | // Don't want corrupted lock pattern to hang the reboot process |
| 2016 | } |
| 2017 | } |
| 2018 | c.close(); |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2019 | db.delete(TABLE_SYSTEM, "name='lock_pattern'", null); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2020 | } else { |
| 2021 | c.close(); |
| 2022 | } |
| 2023 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2024 | |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 2025 | private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) { |
| 2026 | // See if the timeout is -1 (for "Never"). |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2027 | Cursor c = db.query(TABLE_SYSTEM, new String[] { "_id", "value" }, "name=? AND value=?", |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 2028 | new String[] { Settings.System.SCREEN_OFF_TIMEOUT, "-1" }, |
| 2029 | null, null, null); |
| 2030 | |
| 2031 | SQLiteStatement stmt = null; |
| 2032 | if (c.getCount() > 0) { |
| 2033 | c.close(); |
| 2034 | try { |
| 2035 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 2036 | + " VALUES(?,?);"); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2037 | |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 2038 | // Set the timeout to 30 minutes in milliseconds |
Amith Yamasani | cd66caf | 2010-04-12 15:49:12 -0700 | [diff] [blame] | 2039 | loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, |
| 2040 | Integer.toString(30 * 60 * 1000)); |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 2041 | } finally { |
| 2042 | if (stmt != null) stmt.close(); |
| 2043 | } |
| 2044 | } else { |
| 2045 | c.close(); |
| 2046 | } |
| 2047 | } |
| 2048 | |
Amith Yamasani | 398c83c | 2011-12-13 10:38:47 -0800 | [diff] [blame] | 2049 | private void upgradeVibrateSettingFromNone(SQLiteDatabase db) { |
| 2050 | int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON, 0); |
| 2051 | // If the ringer vibrate value is invalid, set it to the default |
| 2052 | if ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_OFF) { |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2053 | vibrateSetting = AudioSystem.getValueForVibrateSetting(0, |
Amith Yamasani | 398c83c | 2011-12-13 10:38:47 -0800 | [diff] [blame] | 2054 | AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT); |
| 2055 | } |
| 2056 | // Apply the same setting to the notification vibrate value |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2057 | vibrateSetting = AudioSystem.getValueForVibrateSetting(vibrateSetting, |
Amith Yamasani | 398c83c | 2011-12-13 10:38:47 -0800 | [diff] [blame] | 2058 | AudioManager.VIBRATE_TYPE_NOTIFICATION, vibrateSetting); |
| 2059 | |
| 2060 | SQLiteStatement stmt = null; |
| 2061 | try { |
| 2062 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 2063 | + " VALUES(?,?);"); |
| 2064 | loadSetting(stmt, Settings.System.VIBRATE_ON, vibrateSetting); |
| 2065 | } finally { |
| 2066 | if (stmt != null) |
| 2067 | stmt.close(); |
| 2068 | } |
| 2069 | } |
| 2070 | |
Amith Yamasani | 79373f6 | 2010-11-18 16:32:48 -0800 | [diff] [blame] | 2071 | private void upgradeScreenTimeout(SQLiteDatabase db) { |
| 2072 | // Change screen timeout to current default |
| 2073 | db.beginTransaction(); |
| 2074 | SQLiteStatement stmt = null; |
| 2075 | try { |
| 2076 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 2077 | + " VALUES(?,?);"); |
| 2078 | loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, |
| 2079 | R.integer.def_screen_off_timeout); |
| 2080 | db.setTransactionSuccessful(); |
| 2081 | } finally { |
| 2082 | db.endTransaction(); |
| 2083 | if (stmt != null) |
| 2084 | stmt.close(); |
| 2085 | } |
| 2086 | } |
| 2087 | |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 2088 | private void upgradeAutoBrightness(SQLiteDatabase db) { |
| 2089 | db.beginTransaction(); |
| 2090 | try { |
| 2091 | String value = |
| 2092 | mContext.getResources().getBoolean( |
| 2093 | R.bool.def_screen_brightness_automatic_mode) ? "1" : "0"; |
| 2094 | db.execSQL("INSERT OR REPLACE INTO system(name,value) values('" + |
| 2095 | Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');"); |
| 2096 | db.setTransactionSuccessful(); |
| 2097 | } finally { |
| 2098 | db.endTransaction(); |
| 2099 | } |
| 2100 | } |
| 2101 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2102 | /** |
| 2103 | * Loads the default set of bookmarked shortcuts from an xml file. |
| 2104 | * |
| 2105 | * @param db The database to write the values into |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2106 | */ |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2107 | private void loadBookmarks(SQLiteDatabase db) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2108 | ContentValues values = new ContentValues(); |
| 2109 | |
| 2110 | PackageManager packageManager = mContext.getPackageManager(); |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 2111 | try { |
| 2112 | XmlResourceParser parser = mContext.getResources().getXml(R.xml.bookmarks); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2113 | XmlUtils.beginDocument(parser, "bookmarks"); |
| 2114 | |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 2115 | final int depth = parser.getDepth(); |
| 2116 | int type; |
| 2117 | |
| 2118 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 2119 | parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
| 2120 | |
| 2121 | if (type != XmlPullParser.START_TAG) { |
| 2122 | continue; |
| 2123 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2124 | |
| 2125 | String name = parser.getName(); |
| 2126 | if (!"bookmark".equals(name)) { |
| 2127 | break; |
| 2128 | } |
| 2129 | |
| 2130 | String pkg = parser.getAttributeValue(null, "package"); |
| 2131 | String cls = parser.getAttributeValue(null, "class"); |
| 2132 | String shortcutStr = parser.getAttributeValue(null, "shortcut"); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2133 | String category = parser.getAttributeValue(null, "category"); |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 2134 | |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 2135 | int shortcutValue = shortcutStr.charAt(0); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2136 | if (TextUtils.isEmpty(shortcutStr)) { |
| 2137 | Log.w(TAG, "Unable to get shortcut for: " + pkg + "/" + cls); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2138 | continue; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2139 | } |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 2140 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2141 | final Intent intent; |
| 2142 | final String title; |
| 2143 | if (pkg != null && cls != null) { |
| 2144 | ActivityInfo info = null; |
| 2145 | ComponentName cn = new ComponentName(pkg, cls); |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 2146 | try { |
| 2147 | info = packageManager.getActivityInfo(cn, 0); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2148 | } catch (PackageManager.NameNotFoundException e) { |
| 2149 | String[] packages = packageManager.canonicalToCurrentPackageNames( |
| 2150 | new String[] { pkg }); |
| 2151 | cn = new ComponentName(packages[0], cls); |
| 2152 | try { |
| 2153 | info = packageManager.getActivityInfo(cn, 0); |
| 2154 | } catch (PackageManager.NameNotFoundException e1) { |
| 2155 | Log.w(TAG, "Unable to add bookmark: " + pkg + "/" + cls, e); |
| 2156 | continue; |
| 2157 | } |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 2158 | } |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2159 | |
| 2160 | intent = new Intent(Intent.ACTION_MAIN, null); |
| 2161 | intent.addCategory(Intent.CATEGORY_LAUNCHER); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2162 | intent.setComponent(cn); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2163 | title = info.loadLabel(packageManager).toString(); |
| 2164 | } else if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2165 | intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2166 | title = ""; |
| 2167 | } else { |
| 2168 | Log.w(TAG, "Unable to add bookmark for shortcut " + shortcutStr |
| 2169 | + ": missing package/class or category attributes"); |
| 2170 | continue; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2171 | } |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2172 | |
| 2173 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2174 | values.put(Settings.Bookmarks.INTENT, intent.toUri(0)); |
| 2175 | values.put(Settings.Bookmarks.TITLE, title); |
| 2176 | values.put(Settings.Bookmarks.SHORTCUT, shortcutValue); |
| 2177 | db.delete("bookmarks", "shortcut = ?", |
| 2178 | new String[] { Integer.toString(shortcutValue) }); |
| 2179 | db.insert("bookmarks", null, values); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2180 | } |
| 2181 | } catch (XmlPullParserException e) { |
| 2182 | Log.w(TAG, "Got execption parsing bookmarks.", e); |
| 2183 | } catch (IOException e) { |
| 2184 | Log.w(TAG, "Got execption parsing bookmarks.", e); |
| 2185 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2186 | } |
| 2187 | |
| 2188 | /** |
| 2189 | * Loads the default volume levels. It is actually inserting the index of |
| 2190 | * the volume array for each of the volume controls. |
| 2191 | * |
| 2192 | * @param db the database to insert the volume levels into |
| 2193 | */ |
| 2194 | private void loadVolumeLevels(SQLiteDatabase db) { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2195 | SQLiteStatement stmt = null; |
| 2196 | try { |
| 2197 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 2198 | + " VALUES(?,?);"); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2199 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2200 | loadSetting(stmt, Settings.System.VOLUME_MUSIC, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2201 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_MUSIC)); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2202 | loadSetting(stmt, Settings.System.VOLUME_RING, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2203 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_RING)); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2204 | loadSetting(stmt, Settings.System.VOLUME_SYSTEM, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2205 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_SYSTEM)); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2206 | loadSetting( |
| 2207 | stmt, |
| 2208 | Settings.System.VOLUME_VOICE, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2209 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_VOICE_CALL)); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2210 | loadSetting(stmt, Settings.System.VOLUME_ALARM, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2211 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_ALARM)); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2212 | loadSetting( |
| 2213 | stmt, |
| 2214 | Settings.System.VOLUME_NOTIFICATION, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2215 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_NOTIFICATION)); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2216 | loadSetting( |
| 2217 | stmt, |
| 2218 | Settings.System.VOLUME_BLUETOOTH_SCO, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2219 | AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO)); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2220 | |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 2221 | // By default: |
| 2222 | // - ringtones, notification, system and music streams are affected by ringer mode |
| 2223 | // on non voice capable devices (tablets) |
| 2224 | // - ringtones, notification and system streams are affected by ringer mode |
| 2225 | // on voice capable devices (phones) |
| 2226 | int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | |
| 2227 | (1 << AudioManager.STREAM_NOTIFICATION) | |
| 2228 | (1 << AudioManager.STREAM_SYSTEM) | |
| 2229 | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); |
| 2230 | if (!mContext.getResources().getBoolean( |
| 2231 | com.android.internal.R.bool.config_voice_capable)) { |
| 2232 | ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); |
| 2233 | } |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2234 | loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED, |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 2235 | ringerModeAffectedStreams); |
| 2236 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2237 | loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED, |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2238 | AudioSystem.DEFAULT_MUTE_STREAMS_AFFECTED); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2239 | } finally { |
| 2240 | if (stmt != null) stmt.close(); |
| 2241 | } |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2242 | |
| 2243 | loadVibrateWhenRingingSetting(db); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2244 | } |
| 2245 | |
| 2246 | private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) { |
| 2247 | if (deleteOld) { |
| 2248 | db.execSQL("DELETE FROM system WHERE name='" + Settings.System.VIBRATE_ON + "'"); |
| 2249 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2250 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2251 | SQLiteStatement stmt = null; |
| 2252 | try { |
| 2253 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 2254 | + " VALUES(?,?);"); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2255 | |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2256 | // Vibrate on by default for ringer, on for notification |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2257 | int vibrate = 0; |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2258 | vibrate = AudioSystem.getValueForVibrateSetting(vibrate, |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2259 | AudioManager.VIBRATE_TYPE_NOTIFICATION, |
| 2260 | AudioManager.VIBRATE_SETTING_ONLY_SILENT); |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 2261 | vibrate |= AudioSystem.getValueForVibrateSetting(vibrate, |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2262 | AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2263 | loadSetting(stmt, Settings.System.VIBRATE_ON, vibrate); |
| 2264 | } finally { |
| 2265 | if (stmt != null) stmt.close(); |
| 2266 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2267 | } |
| 2268 | |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2269 | private void loadVibrateWhenRingingSetting(SQLiteDatabase db) { |
| 2270 | // The default should be off. VIBRATE_SETTING_ONLY_SILENT should also be ignored here. |
| 2271 | // Phone app should separately check whether AudioManager#getRingerMode() returns |
| 2272 | // RINGER_MODE_VIBRATE, with which the device should vibrate anyway. |
| 2273 | int vibrateSetting = getIntValueFromSystem(db, Settings.System.VIBRATE_ON, |
| 2274 | AudioManager.VIBRATE_SETTING_OFF); |
| 2275 | boolean vibrateWhenRinging = ((vibrateSetting & 3) == AudioManager.VIBRATE_SETTING_ON); |
| 2276 | |
| 2277 | SQLiteStatement stmt = null; |
| 2278 | try { |
| 2279 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 2280 | + " VALUES(?,?);"); |
| 2281 | loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, vibrateWhenRinging ? 1 : 0); |
| 2282 | } finally { |
| 2283 | if (stmt != null) stmt.close(); |
| 2284 | } |
| 2285 | } |
| 2286 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2287 | private void loadSettings(SQLiteDatabase db) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2288 | loadSystemSettings(db); |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2289 | loadSecureSettings(db); |
Xiaohui Chen | 43765b7 | 2015-08-31 10:57:33 -0700 | [diff] [blame] | 2290 | // The global table only exists for the 'owner/system' user |
| 2291 | if (mUserHandle == UserHandle.USER_SYSTEM) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2292 | loadGlobalSettings(db); |
| 2293 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2294 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2295 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2296 | private void loadSystemSettings(SQLiteDatabase db) { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2297 | SQLiteStatement stmt = null; |
| 2298 | try { |
| 2299 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 2300 | + " VALUES(?,?);"); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2301 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2302 | loadBooleanSetting(stmt, Settings.System.DIM_SCREEN, |
| 2303 | R.bool.def_dim_screen); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2304 | loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, |
| 2305 | R.integer.def_screen_off_timeout); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2306 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2307 | // Set default cdma DTMF type |
| 2308 | loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2309 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2310 | // Set default hearing aid |
| 2311 | loadSetting(stmt, Settings.System.HEARING_AID, 0); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2312 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2313 | // Set default tty mode |
| 2314 | loadSetting(stmt, Settings.System.TTY_MODE, 0); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2315 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2316 | loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, |
| 2317 | R.integer.def_screen_brightness); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2318 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2319 | loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2320 | R.bool.def_screen_brightness_automatic_mode); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2321 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2322 | loadDefaultAnimationSettings(stmt); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2323 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2324 | loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION, |
| 2325 | R.bool.def_accelerometer_rotation); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2326 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2327 | loadDefaultHapticSettings(stmt); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2328 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2329 | loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE, |
| 2330 | R.bool.def_notification_pulse); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 2331 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2332 | loadUISoundEffectsSettings(stmt); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 2333 | |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 2334 | loadIntegerSetting(stmt, Settings.System.POINTER_SPEED, |
| 2335 | R.integer.def_pointer_speed); |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 2336 | |
| 2337 | /* |
| 2338 | * IMPORTANT: Do not add any more upgrade steps here as the global, |
| 2339 | * secure, and system settings are no longer stored in a database |
| 2340 | * but are kept in memory and persisted to XML. |
| 2341 | * |
| 2342 | * See: SettingsProvider.UpgradeController#onUpgradeLocked |
| 2343 | */ |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2344 | } finally { |
| 2345 | if (stmt != null) stmt.close(); |
| 2346 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2347 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2348 | |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 2349 | private void loadUISoundEffectsSettings(SQLiteStatement stmt) { |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 2350 | loadBooleanSetting(stmt, Settings.System.DTMF_TONE_WHEN_DIALING, |
| 2351 | R.bool.def_dtmf_tones_enabled); |
| 2352 | loadBooleanSetting(stmt, Settings.System.SOUND_EFFECTS_ENABLED, |
| 2353 | R.bool.def_sound_effects_enabled); |
| 2354 | loadBooleanSetting(stmt, Settings.System.HAPTIC_FEEDBACK_ENABLED, |
| 2355 | R.bool.def_haptic_feedback); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 2356 | |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 2357 | loadIntegerSetting(stmt, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, |
| 2358 | R.integer.def_lockscreen_sounds_enabled); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 2359 | } |
| 2360 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2361 | private void loadDefaultAnimationSettings(SQLiteStatement stmt) { |
| 2362 | loadFractionSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE, |
| 2363 | R.fraction.def_window_animation_scale, 1); |
| 2364 | loadFractionSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE, |
| 2365 | R.fraction.def_window_transition_scale, 1); |
| 2366 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2367 | |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 2368 | private void loadDefaultHapticSettings(SQLiteStatement stmt) { |
| 2369 | loadBooleanSetting(stmt, Settings.System.HAPTIC_FEEDBACK_ENABLED, |
| 2370 | R.bool.def_haptic_feedback); |
| 2371 | } |
| 2372 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 2373 | private void loadSecureSettings(SQLiteDatabase db) { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2374 | SQLiteStatement stmt = null; |
| 2375 | try { |
| 2376 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 2377 | + " VALUES(?,?);"); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2378 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2379 | loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, |
| 2380 | R.string.def_location_providers_allowed); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2381 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2382 | // Don't do this. The SystemServer will initialize ADB_ENABLED from a |
| 2383 | // persistent system property instead. |
| 2384 | //loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2385 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2386 | // Allow mock locations default, based on build |
| 2387 | loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, |
| 2388 | "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2389 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2390 | loadSecure35Settings(stmt); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2391 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2392 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND, |
| 2393 | R.bool.def_mount_play_notification_snd); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2394 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2395 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_AUTOSTART, |
| 2396 | R.bool.def_mount_ums_autostart); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2397 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2398 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_PROMPT, |
| 2399 | R.bool.def_mount_ums_prompt); |
Daisuke Miyakawa | 3c60eeb | 2012-05-08 12:08:25 -0700 | [diff] [blame] | 2400 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2401 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED, |
| 2402 | R.bool.def_mount_ums_notify_enabled); |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 2403 | |
Svetoslav Ganov | 54d068ec | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 2404 | loadIntegerSetting(stmt, Settings.Secure.LONG_PRESS_TIMEOUT, |
| 2405 | R.integer.def_long_press_timeout_millis); |
Svetoslav Ganov | a28a16d | 2011-07-28 11:24:21 -0700 | [diff] [blame] | 2406 | |
| 2407 | loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED, |
| 2408 | R.bool.def_touch_exploration_enabled); |
Svetoslav Ganov | 55f937a | 2011-12-05 11:42:07 -0800 | [diff] [blame] | 2409 | |
| 2410 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, |
| 2411 | R.bool.def_accessibility_speak_password); |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 2412 | |
Amith Yamasani | d1645f8 | 2012-06-12 11:53:26 -0700 | [diff] [blame] | 2413 | if (SystemProperties.getBoolean("ro.lockscreen.disable.default", false) == true) { |
| 2414 | loadSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, "1"); |
| 2415 | } else { |
| 2416 | loadBooleanSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, |
| 2417 | R.bool.def_lockscreen_disabled); |
| 2418 | } |
Mike Lockwood | 2395527 | 2011-10-21 11:22:48 -0400 | [diff] [blame] | 2419 | |
John Spurlock | 634471e | 2012-08-09 10:41:37 -0400 | [diff] [blame] | 2420 | loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ENABLED, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 2421 | com.android.internal.R.bool.config_dreamsEnabledByDefault); |
John Spurlock | 634471e | 2012-08-09 10:41:37 -0400 | [diff] [blame] | 2422 | loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 2423 | com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault); |
John Spurlock | 1a868b7 | 2012-08-22 09:56:51 -0400 | [diff] [blame] | 2424 | loadBooleanSetting(stmt, Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 2425 | com.android.internal.R.bool.config_dreamsActivatedOnSleepByDefault); |
John Spurlock | 1a868b7 | 2012-08-22 09:56:51 -0400 | [diff] [blame] | 2426 | loadStringSetting(stmt, Settings.Secure.SCREENSAVER_COMPONENTS, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 2427 | com.android.internal.R.string.config_dreamsDefaultComponent); |
John Spurlock | 1a868b7 | 2012-08-22 09:56:51 -0400 | [diff] [blame] | 2428 | loadStringSetting(stmt, Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT, |
John Spurlock | ed108f3 | 2012-10-18 16:49:24 -0400 | [diff] [blame] | 2429 | com.android.internal.R.string.config_dreamsDefaultComponent); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 2430 | |
| 2431 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, |
| 2432 | R.bool.def_accessibility_display_magnification_enabled); |
| 2433 | |
| 2434 | loadFractionSetting(stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, |
| 2435 | R.fraction.def_accessibility_display_magnification_scale, 1); |
| 2436 | |
John Spurlock | 7f1c248 | 2012-10-05 11:15:28 -0400 | [diff] [blame] | 2437 | loadBooleanSetting(stmt, Settings.Secure.USER_SETUP_COMPLETE, |
| 2438 | R.bool.def_user_setup_complete); |
Mike Lockwood | c02c4a7 | 2014-01-07 14:46:22 -0800 | [diff] [blame] | 2439 | |
| 2440 | loadStringSetting(stmt, Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS, |
| 2441 | R.string.def_immersive_mode_confirmations); |
| 2442 | |
Christopher Tate | aa036a2 | 2014-05-19 16:33:27 -0700 | [diff] [blame] | 2443 | loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, |
| 2444 | R.bool.def_install_non_market_apps); |
| 2445 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 2446 | loadBooleanSetting(stmt, Settings.Secure.WAKE_GESTURE_ENABLED, |
| 2447 | R.bool.def_wake_gesture_enabled); |
| 2448 | |
Dan Sandler | 52e5701e | 2014-07-22 23:14:54 -0400 | [diff] [blame] | 2449 | loadIntegerSetting(stmt, Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, |
| 2450 | R.integer.def_lock_screen_show_notifications); |
| 2451 | |
Chris Wren | cd8f4f7 | 2014-08-27 18:48:13 -0400 | [diff] [blame] | 2452 | loadBooleanSetting(stmt, Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, |
| 2453 | R.bool.def_lock_screen_allow_private_notifications); |
| 2454 | |
Jeff Brown | 05af6ad | 2014-09-30 20:54:30 -0700 | [diff] [blame] | 2455 | loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT, |
| 2456 | R.integer.def_sleep_timeout); |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 2457 | |
| 2458 | /* |
| 2459 | * IMPORTANT: Do not add any more upgrade steps here as the global, |
| 2460 | * secure, and system settings are no longer stored in a database |
| 2461 | * but are kept in memory and persisted to XML. |
| 2462 | * |
| 2463 | * See: SettingsProvider.UpgradeController#onUpgradeLocked |
| 2464 | */ |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 2465 | } finally { |
| 2466 | if (stmt != null) stmt.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2467 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2468 | } |
| 2469 | |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 2470 | private void loadSecure35Settings(SQLiteStatement stmt) { |
| 2471 | loadBooleanSetting(stmt, Settings.Secure.BACKUP_ENABLED, |
| 2472 | R.bool.def_backup_enabled); |
Jim Miller | 31f90b6 | 2010-01-20 13:35:20 -0800 | [diff] [blame] | 2473 | |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 2474 | loadStringSetting(stmt, Settings.Secure.BACKUP_TRANSPORT, |
| 2475 | R.string.def_backup_transport); |
| 2476 | } |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 2477 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2478 | private void loadGlobalSettings(SQLiteDatabase db) { |
| 2479 | SQLiteStatement stmt = null; |
| 2480 | try { |
| 2481 | stmt = db.compileStatement("INSERT OR IGNORE INTO global(name,value)" |
| 2482 | + " VALUES(?,?);"); |
| 2483 | |
| 2484 | // --- Previously in 'system' |
| 2485 | loadBooleanSetting(stmt, Settings.Global.AIRPLANE_MODE_ON, |
| 2486 | R.bool.def_airplane_mode_on); |
| 2487 | |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 2488 | loadBooleanSetting(stmt, Settings.Global.THEATER_MODE_ON, |
| 2489 | R.bool.def_theater_mode_on); |
| 2490 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2491 | loadStringSetting(stmt, Settings.Global.AIRPLANE_MODE_RADIOS, |
| 2492 | R.string.def_airplane_mode_radios); |
| 2493 | |
| 2494 | loadStringSetting(stmt, Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS, |
| 2495 | R.string.airplane_mode_toggleable_radios); |
| 2496 | |
| 2497 | loadBooleanSetting(stmt, Settings.Global.ASSISTED_GPS_ENABLED, |
| 2498 | R.bool.assisted_gps_enabled); |
| 2499 | |
| 2500 | loadBooleanSetting(stmt, Settings.Global.AUTO_TIME, |
| 2501 | R.bool.def_auto_time); // Sync time to NITZ |
| 2502 | |
| 2503 | loadBooleanSetting(stmt, Settings.Global.AUTO_TIME_ZONE, |
| 2504 | R.bool.def_auto_time_zone); // Sync timezone to NITZ |
| 2505 | |
| 2506 | loadSetting(stmt, Settings.Global.STAY_ON_WHILE_PLUGGED_IN, |
| 2507 | ("1".equals(SystemProperties.get("ro.kernel.qemu")) || |
| 2508 | mContext.getResources().getBoolean(R.bool.def_stay_on_while_plugged_in)) |
| 2509 | ? 1 : 0); |
| 2510 | |
| 2511 | loadIntegerSetting(stmt, Settings.Global.WIFI_SLEEP_POLICY, |
| 2512 | R.integer.def_wifi_sleep_policy); |
| 2513 | |
Eric Laurent | 55b0222 | 2012-10-03 11:56:23 -0700 | [diff] [blame] | 2514 | loadSetting(stmt, Settings.Global.MODE_RINGER, |
| 2515 | AudioManager.RINGER_MODE_NORMAL); |
| 2516 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2517 | // --- Previously in 'secure' |
Christopher Tate | 6f5a9a9 | 2012-09-14 17:24:28 -0700 | [diff] [blame] | 2518 | loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE, |
| 2519 | R.bool.def_package_verifier_enable); |
| 2520 | |
| 2521 | loadBooleanSetting(stmt, Settings.Global.WIFI_ON, |
| 2522 | R.bool.def_wifi_on); |
| 2523 | |
| 2524 | loadBooleanSetting(stmt, Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, |
| 2525 | R.bool.def_networks_available_notification_on); |
| 2526 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2527 | loadBooleanSetting(stmt, Settings.Global.BLUETOOTH_ON, |
| 2528 | R.bool.def_bluetooth_on); |
| 2529 | |
| 2530 | // Enable or disable Cell Broadcast SMS |
| 2531 | loadSetting(stmt, Settings.Global.CDMA_CELL_BROADCAST_SMS, |
| 2532 | RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED); |
| 2533 | |
| 2534 | // Data roaming default, based on build |
| 2535 | loadSetting(stmt, Settings.Global.DATA_ROAMING, |
| 2536 | "true".equalsIgnoreCase( |
| 2537 | SystemProperties.get("ro.com.android.dataroaming", |
| 2538 | "false")) ? 1 : 0); |
| 2539 | |
| 2540 | loadBooleanSetting(stmt, Settings.Global.DEVICE_PROVISIONED, |
| 2541 | R.bool.def_device_provisioned); |
| 2542 | |
| 2543 | final int maxBytes = mContext.getResources().getInteger( |
| 2544 | R.integer.def_download_manager_max_bytes_over_mobile); |
| 2545 | if (maxBytes > 0) { |
| 2546 | loadSetting(stmt, Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE, |
| 2547 | Integer.toString(maxBytes)); |
| 2548 | } |
| 2549 | |
| 2550 | final int recommendedMaxBytes = mContext.getResources().getInteger( |
| 2551 | R.integer.def_download_manager_recommended_max_bytes_over_mobile); |
| 2552 | if (recommendedMaxBytes > 0) { |
| 2553 | loadSetting(stmt, Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE, |
| 2554 | Integer.toString(recommendedMaxBytes)); |
| 2555 | } |
| 2556 | |
| 2557 | // Mobile Data default, based on build |
| 2558 | loadSetting(stmt, Settings.Global.MOBILE_DATA, |
| 2559 | "true".equalsIgnoreCase( |
| 2560 | SystemProperties.get("ro.com.android.mobiledata", |
| 2561 | "true")) ? 1 : 0); |
| 2562 | |
| 2563 | loadBooleanSetting(stmt, Settings.Global.NETSTATS_ENABLED, |
| 2564 | R.bool.def_netstats_enabled); |
| 2565 | |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2566 | loadBooleanSetting(stmt, Settings.Global.USB_MASS_STORAGE_ENABLED, |
| 2567 | R.bool.def_usb_mass_storage_enabled); |
| 2568 | |
| 2569 | loadIntegerSetting(stmt, Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT, |
| 2570 | R.integer.def_max_dhcp_retries); |
| 2571 | |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 2572 | loadBooleanSetting(stmt, Settings.Global.WIFI_DISPLAY_ON, |
| 2573 | R.bool.def_wifi_display_on); |
| 2574 | |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 2575 | loadStringSetting(stmt, Settings.Global.LOCK_SOUND, |
| 2576 | R.string.def_lock_sound); |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 2577 | loadStringSetting(stmt, Settings.Global.UNLOCK_SOUND, |
| 2578 | R.string.def_unlock_sound); |
Adrian Roos | 49e057d | 2014-08-13 17:14:51 +0200 | [diff] [blame] | 2579 | loadStringSetting(stmt, Settings.Global.TRUSTED_SOUND, |
| 2580 | R.string.def_trusted_sound); |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 2581 | loadIntegerSetting(stmt, Settings.Global.POWER_SOUNDS_ENABLED, |
| 2582 | R.integer.def_power_sounds_enabled); |
| 2583 | loadStringSetting(stmt, Settings.Global.LOW_BATTERY_SOUND, |
| 2584 | R.string.def_low_battery_sound); |
| 2585 | loadIntegerSetting(stmt, Settings.Global.DOCK_SOUNDS_ENABLED, |
| 2586 | R.integer.def_dock_sounds_enabled); |
Vinod Krishnan | cf11cea | 2016-10-20 22:57:02 -0700 | [diff] [blame] | 2587 | loadIntegerSetting(stmt, Settings.Global.DOCK_SOUNDS_ENABLED_WHEN_ACCESSIBILITY, |
| 2588 | R.integer.def_dock_sounds_enabled_when_accessibility); |
Amith Yamasani | 531c237 | 2012-10-08 14:43:20 -0700 | [diff] [blame] | 2589 | loadStringSetting(stmt, Settings.Global.DESK_DOCK_SOUND, |
| 2590 | R.string.def_desk_dock_sound); |
| 2591 | loadStringSetting(stmt, Settings.Global.DESK_UNDOCK_SOUND, |
| 2592 | R.string.def_desk_undock_sound); |
| 2593 | loadStringSetting(stmt, Settings.Global.CAR_DOCK_SOUND, |
| 2594 | R.string.def_car_dock_sound); |
| 2595 | loadStringSetting(stmt, Settings.Global.CAR_UNDOCK_SOUND, |
| 2596 | R.string.def_car_undock_sound); |
Jeff Brown | 84e2756 | 2012-12-07 13:56:34 -0800 | [diff] [blame] | 2597 | loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND, |
| 2598 | R.string.def_wireless_charging_started_sound); |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 2599 | |
Dmytro Dubovyk | 729f668 | 2012-12-18 18:07:50 +0200 | [diff] [blame] | 2600 | loadIntegerSetting(stmt, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, |
| 2601 | R.integer.def_dock_audio_media_enabled); |
| 2602 | |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 2603 | loadSetting(stmt, Settings.Global.SET_INSTALL_LOCATION, 0); |
| 2604 | loadSetting(stmt, Settings.Global.DEFAULT_INSTALL_LOCATION, |
| 2605 | PackageHelper.APP_INSTALL_AUTO); |
| 2606 | |
| 2607 | // Set default cdma emergency tone |
| 2608 | loadSetting(stmt, Settings.Global.EMERGENCY_TONE, 0); |
| 2609 | |
| 2610 | // Set default cdma call auto retry |
| 2611 | loadSetting(stmt, Settings.Global.CALL_AUTO_RETRY, 0); |
| 2612 | |
Naveen Kalla | 97ecc9e | 2012-07-13 20:10:22 -0700 | [diff] [blame] | 2613 | // Set the preferred network mode to target desired value or Default |
| 2614 | // value defined in RILConstants |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 2615 | int type; |
Amit Mahajan | 4fea092 | 2014-11-18 12:56:28 -0800 | [diff] [blame] | 2616 | type = RILConstants.PREFERRED_NETWORK_MODE; |
Jeff Sharkey | 6e2bee7 | 2012-10-01 13:39:08 -0700 | [diff] [blame] | 2617 | loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, type); |
| 2618 | |
Naveen Kalla | b4d485c | 2013-07-03 16:39:27 -0700 | [diff] [blame] | 2619 | // Set the preferred cdma subscription source to target desired value or default |
Grace Chen | 6ad1c5e | 2017-06-13 16:07:45 -0700 | [diff] [blame] | 2620 | // value defined in Phone |
Naveen Kalla | b4d485c | 2013-07-03 16:39:27 -0700 | [diff] [blame] | 2621 | type = SystemProperties.getInt("ro.telephony.default_cdma_sub", |
Grace Chen | 6ad1c5e | 2017-06-13 16:07:45 -0700 | [diff] [blame] | 2622 | Phone.PREFERRED_CDMA_SUBSCRIPTION); |
Naveen Kalla | b4d485c | 2013-07-03 16:39:27 -0700 | [diff] [blame] | 2623 | loadSetting(stmt, Settings.Global.CDMA_SUBSCRIPTION_MODE, type); |
| 2624 | |
Daniel Sandler | dea6462 | 2013-09-23 16:05:57 -0400 | [diff] [blame] | 2625 | loadIntegerSetting(stmt, Settings.Global.LOW_BATTERY_SOUND_TIMEOUT, |
| 2626 | R.integer.def_low_battery_sound_timeout); |
| 2627 | |
Oskar Grönqvist | 2c4254e | 2013-12-11 14:14:33 +0100 | [diff] [blame] | 2628 | loadIntegerSetting(stmt, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, |
| 2629 | R.integer.def_wifi_scan_always_available); |
| 2630 | |
Chris Wren | 5242cf3 | 2014-03-19 16:16:48 -0400 | [diff] [blame] | 2631 | loadIntegerSetting(stmt, Global.HEADS_UP_NOTIFICATIONS_ENABLED, |
| 2632 | R.integer.def_heads_up_enabled); |
| 2633 | |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 2634 | loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName()); |
| 2635 | |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 2636 | loadSetting(stmt, Settings.Global.ENHANCED_4G_MODE_ENABLED, |
| 2637 | ImsConfig.FeatureValueConstants.ON); |
Jeff Brown | 503cffc | 2015-03-26 18:08:51 -0700 | [diff] [blame] | 2638 | |
| 2639 | /* |
| 2640 | * IMPORTANT: Do not add any more upgrade steps here as the global, |
| 2641 | * secure, and system settings are no longer stored in a database |
| 2642 | * but are kept in memory and persisted to XML. |
| 2643 | * |
| 2644 | * See: SettingsProvider.UpgradeController#onUpgradeLocked |
| 2645 | */ |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2646 | } finally { |
| 2647 | if (stmt != null) stmt.close(); |
| 2648 | } |
| 2649 | } |
| 2650 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2651 | private void loadSetting(SQLiteStatement stmt, String key, Object value) { |
| 2652 | stmt.bindString(1, key); |
| 2653 | stmt.bindString(2, value.toString()); |
| 2654 | stmt.execute(); |
| 2655 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2656 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2657 | private void loadStringSetting(SQLiteStatement stmt, String key, int resid) { |
| 2658 | loadSetting(stmt, key, mContext.getResources().getString(resid)); |
| 2659 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2660 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2661 | private void loadBooleanSetting(SQLiteStatement stmt, String key, int resid) { |
| 2662 | loadSetting(stmt, key, |
| 2663 | mContext.getResources().getBoolean(resid) ? "1" : "0"); |
| 2664 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2665 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2666 | private void loadIntegerSetting(SQLiteStatement stmt, String key, int resid) { |
| 2667 | loadSetting(stmt, key, |
| 2668 | Integer.toString(mContext.getResources().getInteger(resid))); |
| 2669 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2670 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2671 | private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, int base) { |
| 2672 | loadSetting(stmt, key, |
| 2673 | Float.toString(mContext.getResources().getFraction(resid, base, base))); |
| 2674 | } |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2675 | |
| 2676 | private int getIntValueFromSystem(SQLiteDatabase db, String name, int defaultValue) { |
Christopher Tate | 06efb53 | 2012-08-24 15:29:27 -0700 | [diff] [blame] | 2677 | return getIntValueFromTable(db, TABLE_SYSTEM, name, defaultValue); |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | private int getIntValueFromTable(SQLiteDatabase db, String table, String name, |
| 2681 | int defaultValue) { |
| 2682 | String value = getStringValueFromTable(db, table, name, null); |
| 2683 | return (value != null) ? Integer.parseInt(value) : defaultValue; |
| 2684 | } |
| 2685 | |
| 2686 | private String getStringValueFromTable(SQLiteDatabase db, String table, String name, |
| 2687 | String defaultValue) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2688 | Cursor c = null; |
| 2689 | try { |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 2690 | c = db.query(table, new String[] { Settings.System.VALUE }, "name='" + name + "'", |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2691 | null, null, null, null); |
| 2692 | if (c != null && c.moveToFirst()) { |
| 2693 | String val = c.getString(0); |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 2694 | return val == null ? defaultValue : val; |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2695 | } |
| 2696 | } finally { |
| 2697 | if (c != null) c.close(); |
| 2698 | } |
Svetoslav Ganov | 8631701 | 2012-08-15 22:13:00 -0700 | [diff] [blame] | 2699 | return defaultValue; |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 2700 | } |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 2701 | |
Jerome Poichet | 550021e | 2014-09-11 10:38:12 -0700 | [diff] [blame] | 2702 | private String getOldDefaultDeviceName() { |
Jeff Sharkey | ad59c43 | 2014-09-12 15:56:30 -0700 | [diff] [blame] | 2703 | return mContext.getResources().getString(R.string.def_device_name, |
Jerome Poichet | 550021e | 2014-09-11 10:38:12 -0700 | [diff] [blame] | 2704 | Build.MANUFACTURER, Build.MODEL); |
| 2705 | } |
| 2706 | |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 2707 | private String getDefaultDeviceName() { |
Jeff Sharkey | ad59c43 | 2014-09-12 15:56:30 -0700 | [diff] [blame] | 2708 | return mContext.getResources().getString(R.string.def_device_name_simple, Build.MODEL); |
Jerome Poichet | 147b4d7 | 2014-05-12 18:13:27 -0700 | [diff] [blame] | 2709 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2710 | } |