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