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