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