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; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 33 | import android.os.SystemProperties; |
| 34 | import android.provider.Settings; |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 35 | import android.provider.Settings.Secure; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 36 | import android.text.TextUtils; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 37 | import android.util.Log; |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 38 | |
Gilles Debunne | fa53d30 | 2011-07-08 10:40:51 -0700 | [diff] [blame] | 39 | import com.android.internal.content.PackageHelper; |
| 40 | import com.android.internal.telephony.BaseCommands; |
| 41 | import com.android.internal.telephony.Phone; |
| 42 | import com.android.internal.telephony.RILConstants; |
| 43 | import com.android.internal.util.XmlUtils; |
| 44 | import com.android.internal.widget.LockPatternUtils; |
| 45 | import com.android.internal.widget.LockPatternView; |
| 46 | |
| 47 | import org.xmlpull.v1.XmlPullParser; |
| 48 | import org.xmlpull.v1.XmlPullParserException; |
| 49 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 50 | import java.io.IOException; |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 51 | import java.util.HashSet; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 52 | import java.util.List; |
| 53 | |
| 54 | /** |
| 55 | * Database helper class for {@link SettingsProvider}. |
| 56 | * Mostly just has a bit {@link #onCreate} to initialize the database. |
| 57 | */ |
James Wylder | 074da8f | 2009-02-25 08:38:31 -0600 | [diff] [blame] | 58 | public class DatabaseHelper extends SQLiteOpenHelper { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 59 | private static final String TAG = "SettingsProvider"; |
| 60 | private static final String DATABASE_NAME = "settings.db"; |
Jim Miller | f186055 | 2009-09-09 17:46:35 -0700 | [diff] [blame] | 61 | |
| 62 | // Please, please please. If you update the database version, check to make sure the |
| 63 | // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion' |
| 64 | // is properly propagated through your change. Not doing so will result in a loss of user |
| 65 | // settings. |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 66 | private static final int DATABASE_VERSION = 74; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 67 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 68 | private Context mContext; |
| 69 | |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 70 | private static final HashSet<String> mValidTables = new HashSet<String>(); |
| 71 | |
| 72 | static { |
| 73 | mValidTables.add("system"); |
| 74 | mValidTables.add("secure"); |
| 75 | mValidTables.add("bluetooth_devices"); |
| 76 | mValidTables.add("bookmarks"); |
| 77 | |
| 78 | // These are old. |
| 79 | mValidTables.add("favorites"); |
| 80 | mValidTables.add("gservices"); |
| 81 | mValidTables.add("old_favorites"); |
| 82 | } |
| 83 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 84 | public DatabaseHelper(Context context) { |
| 85 | super(context, DATABASE_NAME, null, DATABASE_VERSION); |
| 86 | mContext = context; |
| 87 | } |
| 88 | |
Dianne Hackborn | 24117ce | 2010-07-12 15:54:38 -0700 | [diff] [blame] | 89 | public static boolean isValidTable(String name) { |
| 90 | return mValidTables.contains(name); |
| 91 | } |
| 92 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 93 | private void createSecureTable(SQLiteDatabase db) { |
| 94 | db.execSQL("CREATE TABLE secure (" + |
| 95 | "_id INTEGER PRIMARY KEY AUTOINCREMENT," + |
| 96 | "name TEXT UNIQUE ON CONFLICT REPLACE," + |
| 97 | "value TEXT" + |
| 98 | ");"); |
| 99 | db.execSQL("CREATE INDEX secureIndex1 ON secure (name);"); |
| 100 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 101 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 102 | @Override |
| 103 | public void onCreate(SQLiteDatabase db) { |
| 104 | db.execSQL("CREATE TABLE system (" + |
| 105 | "_id INTEGER PRIMARY KEY AUTOINCREMENT," + |
| 106 | "name TEXT UNIQUE ON CONFLICT REPLACE," + |
| 107 | "value TEXT" + |
| 108 | ");"); |
| 109 | db.execSQL("CREATE INDEX systemIndex1 ON system (name);"); |
| 110 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 111 | createSecureTable(db); |
| 112 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 113 | db.execSQL("CREATE TABLE bluetooth_devices (" + |
| 114 | "_id INTEGER PRIMARY KEY," + |
| 115 | "name TEXT," + |
| 116 | "addr TEXT," + |
| 117 | "channel INTEGER," + |
| 118 | "type INTEGER" + |
| 119 | ");"); |
| 120 | |
| 121 | db.execSQL("CREATE TABLE bookmarks (" + |
| 122 | "_id INTEGER PRIMARY KEY," + |
| 123 | "title TEXT," + |
| 124 | "folder TEXT," + |
| 125 | "intent TEXT," + |
| 126 | "shortcut INTEGER," + |
| 127 | "ordering INTEGER" + |
| 128 | ");"); |
| 129 | |
| 130 | db.execSQL("CREATE INDEX bookmarksIndex1 ON bookmarks (folder);"); |
| 131 | db.execSQL("CREATE INDEX bookmarksIndex2 ON bookmarks (shortcut);"); |
| 132 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 133 | // Populate bookmarks table with initial bookmarks |
| 134 | loadBookmarks(db); |
| 135 | |
| 136 | // Load initial volume levels into DB |
| 137 | loadVolumeLevels(db); |
| 138 | |
| 139 | // Load inital settings values |
| 140 | loadSettings(db); |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 145 | Log.w(TAG, "Upgrading settings database from version " + oldVersion + " to " |
| 146 | + currentVersion); |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 147 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 148 | int upgradeVersion = oldVersion; |
| 149 | |
| 150 | // Pattern for upgrade blocks: |
| 151 | // |
| 152 | // if (upgradeVersion == [the DATABASE_VERSION you set] - 1) { |
| 153 | // .. your upgrade logic.. |
| 154 | // upgradeVersion = [the DATABASE_VERSION you set] |
| 155 | // } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 156 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 157 | if (upgradeVersion == 20) { |
| 158 | /* |
| 159 | * Version 21 is part of the volume control refresh. There is no |
| 160 | * longer a UI-visible for setting notification vibrate on/off (in |
| 161 | * our design), but the functionality still exists. Force the |
| 162 | * notification vibrate to on. |
| 163 | */ |
| 164 | loadVibrateSetting(db, true); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 165 | |
| 166 | upgradeVersion = 21; |
| 167 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 168 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 169 | if (upgradeVersion < 22) { |
| 170 | upgradeVersion = 22; |
| 171 | // Upgrade the lock gesture storage location and format |
| 172 | upgradeLockPatternLocation(db); |
| 173 | } |
| 174 | |
| 175 | if (upgradeVersion < 23) { |
| 176 | db.execSQL("UPDATE favorites SET iconResource=0 WHERE iconType=0"); |
| 177 | upgradeVersion = 23; |
| 178 | } |
| 179 | |
| 180 | if (upgradeVersion == 23) { |
| 181 | db.beginTransaction(); |
| 182 | try { |
| 183 | db.execSQL("ALTER TABLE favorites ADD spanX INTEGER"); |
| 184 | db.execSQL("ALTER TABLE favorites ADD spanY INTEGER"); |
| 185 | // Shortcuts, applications, folders |
| 186 | db.execSQL("UPDATE favorites SET spanX=1, spanY=1 WHERE itemType<=0"); |
| 187 | // Photo frames, clocks |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 188 | db.execSQL( |
| 189 | "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] | 190 | // Search boxes |
| 191 | db.execSQL("UPDATE favorites SET spanX=4, spanY=1 WHERE itemType=1001"); |
| 192 | db.setTransactionSuccessful(); |
| 193 | } finally { |
| 194 | db.endTransaction(); |
| 195 | } |
| 196 | upgradeVersion = 24; |
| 197 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 198 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 199 | if (upgradeVersion == 24) { |
| 200 | db.beginTransaction(); |
| 201 | try { |
| 202 | // The value of the constants for preferring wifi or preferring mobile have been |
| 203 | // swapped, so reload the default. |
| 204 | db.execSQL("DELETE FROM system WHERE name='network_preference'"); |
| 205 | db.execSQL("INSERT INTO system ('name', 'value') values ('network_preference', '" + |
| 206 | ConnectivityManager.DEFAULT_NETWORK_PREFERENCE + "')"); |
| 207 | db.setTransactionSuccessful(); |
| 208 | } finally { |
| 209 | db.endTransaction(); |
| 210 | } |
| 211 | upgradeVersion = 25; |
| 212 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 213 | |
| 214 | if (upgradeVersion == 25) { |
| 215 | db.beginTransaction(); |
| 216 | try { |
| 217 | db.execSQL("ALTER TABLE favorites ADD uri TEXT"); |
| 218 | db.execSQL("ALTER TABLE favorites ADD displayMode INTEGER"); |
| 219 | db.setTransactionSuccessful(); |
| 220 | } finally { |
| 221 | db.endTransaction(); |
| 222 | } |
| 223 | upgradeVersion = 26; |
| 224 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 225 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 226 | if (upgradeVersion == 26) { |
| 227 | // This introduces the new secure settings table. |
| 228 | db.beginTransaction(); |
| 229 | try { |
| 230 | createSecureTable(db); |
| 231 | db.setTransactionSuccessful(); |
| 232 | } finally { |
| 233 | db.endTransaction(); |
| 234 | } |
| 235 | upgradeVersion = 27; |
| 236 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 237 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 238 | if (upgradeVersion == 27) { |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 239 | String[] settingsToMove = { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 240 | Settings.Secure.ADB_ENABLED, |
| 241 | Settings.Secure.ANDROID_ID, |
| 242 | Settings.Secure.BLUETOOTH_ON, |
| 243 | Settings.Secure.DATA_ROAMING, |
| 244 | Settings.Secure.DEVICE_PROVISIONED, |
| 245 | Settings.Secure.HTTP_PROXY, |
| 246 | Settings.Secure.INSTALL_NON_MARKET_APPS, |
| 247 | Settings.Secure.LOCATION_PROVIDERS_ALLOWED, |
| 248 | Settings.Secure.LOGGING_ID, |
| 249 | Settings.Secure.NETWORK_PREFERENCE, |
| 250 | Settings.Secure.PARENTAL_CONTROL_ENABLED, |
| 251 | Settings.Secure.PARENTAL_CONTROL_LAST_UPDATE, |
| 252 | Settings.Secure.PARENTAL_CONTROL_REDIRECT_URL, |
| 253 | Settings.Secure.SETTINGS_CLASSNAME, |
| 254 | Settings.Secure.USB_MASS_STORAGE_ENABLED, |
| 255 | Settings.Secure.USE_GOOGLE_MAIL, |
| 256 | Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, |
| 257 | Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, |
| 258 | Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, |
| 259 | Settings.Secure.WIFI_ON, |
| 260 | Settings.Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE, |
| 261 | Settings.Secure.WIFI_WATCHDOG_AP_COUNT, |
| 262 | Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS, |
| 263 | Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED, |
| 264 | Settings.Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS, |
| 265 | Settings.Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT, |
| 266 | Settings.Secure.WIFI_WATCHDOG_MAX_AP_CHECKS, |
| 267 | Settings.Secure.WIFI_WATCHDOG_ON, |
| 268 | Settings.Secure.WIFI_WATCHDOG_PING_COUNT, |
| 269 | Settings.Secure.WIFI_WATCHDOG_PING_DELAY_MS, |
| 270 | Settings.Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS, |
| 271 | }; |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 272 | moveFromSystemToSecure(db, settingsToMove); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 273 | upgradeVersion = 28; |
| 274 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 275 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 276 | if (upgradeVersion == 28 || upgradeVersion == 29) { |
| 277 | // Note: The upgrade to 28 was flawed since it didn't delete the old |
| 278 | // setting first before inserting. Combining 28 and 29 with the |
| 279 | // fixed version. |
| 280 | |
| 281 | // This upgrade adds the STREAM_NOTIFICATION type to the list of |
| 282 | // types affected by ringer modes (silent, vibrate, etc.) |
| 283 | db.beginTransaction(); |
| 284 | try { |
| 285 | db.execSQL("DELETE FROM system WHERE name='" |
| 286 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 287 | int newValue = (1 << AudioManager.STREAM_RING) |
| 288 | | (1 << AudioManager.STREAM_NOTIFICATION) |
| 289 | | (1 << AudioManager.STREAM_SYSTEM); |
| 290 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 291 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 292 | + String.valueOf(newValue) + "')"); |
| 293 | db.setTransactionSuccessful(); |
| 294 | } finally { |
| 295 | db.endTransaction(); |
| 296 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 297 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 298 | upgradeVersion = 30; |
| 299 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 300 | |
The Android Open Source Project | 9266c55 | 2009-01-15 16:12:10 -0800 | [diff] [blame] | 301 | if (upgradeVersion == 30) { |
| 302 | /* |
| 303 | * Upgrade 31 clears the title for all quick launch shortcuts so the |
| 304 | * activities' titles will be resolved at display time. Also, the |
| 305 | * folder is changed to '@quicklaunch'. |
| 306 | */ |
| 307 | db.beginTransaction(); |
| 308 | try { |
| 309 | db.execSQL("UPDATE bookmarks SET folder = '@quicklaunch'"); |
| 310 | db.execSQL("UPDATE bookmarks SET title = ''"); |
| 311 | db.setTransactionSuccessful(); |
| 312 | } finally { |
| 313 | db.endTransaction(); |
| 314 | } |
| 315 | upgradeVersion = 31; |
| 316 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 317 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | if (upgradeVersion == 31) { |
| 319 | /* |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 320 | * Animations are now managed in preferences, and may be |
| 321 | * enabled or disabled based on product resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 322 | */ |
| 323 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 324 | SQLiteStatement stmt = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | try { |
| 326 | db.execSQL("DELETE FROM system WHERE name='" |
| 327 | + Settings.System.WINDOW_ANIMATION_SCALE + "'"); |
| 328 | db.execSQL("DELETE FROM system WHERE name='" |
| 329 | + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 330 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 331 | + " VALUES(?,?);"); |
| 332 | loadDefaultAnimationSettings(stmt); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 333 | db.setTransactionSuccessful(); |
| 334 | } finally { |
| 335 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 336 | if (stmt != null) stmt.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | } |
| 338 | upgradeVersion = 32; |
| 339 | } |
| 340 | |
| 341 | if (upgradeVersion == 32) { |
| 342 | // The Wi-Fi watchdog SSID list is now seeded with the value of |
| 343 | // the property ro.com.android.wifi-watchlist |
| 344 | String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist"); |
| 345 | if (!TextUtils.isEmpty(wifiWatchList)) { |
| 346 | db.beginTransaction(); |
| 347 | try { |
| 348 | db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" + |
| 349 | Settings.Secure.WIFI_WATCHDOG_WATCH_LIST + "','" + |
| 350 | wifiWatchList + "');"); |
| 351 | db.setTransactionSuccessful(); |
| 352 | } finally { |
| 353 | db.endTransaction(); |
| 354 | } |
| 355 | } |
| 356 | upgradeVersion = 33; |
| 357 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 358 | |
The Android Open Source Project | 4df2423 | 2009-03-05 14:34:35 -0800 | [diff] [blame] | 359 | if (upgradeVersion == 33) { |
| 360 | // Set the default zoom controls to: tap-twice to bring up +/- |
| 361 | db.beginTransaction(); |
| 362 | try { |
| 363 | db.execSQL("INSERT INTO system(name,value) values('zoom','2');"); |
| 364 | db.setTransactionSuccessful(); |
| 365 | } finally { |
| 366 | db.endTransaction(); |
| 367 | } |
| 368 | upgradeVersion = 34; |
| 369 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | |
Mike Lockwood | bcab8df | 2009-06-25 16:39:09 -0400 | [diff] [blame] | 371 | if (upgradeVersion == 34) { |
| 372 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 373 | SQLiteStatement stmt = null; |
Mike Lockwood | bcab8df | 2009-06-25 16:39:09 -0400 | [diff] [blame] | 374 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 375 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 376 | + " VALUES(?,?);"); |
| 377 | loadSecure35Settings(stmt); |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 378 | db.setTransactionSuccessful(); |
| 379 | } finally { |
| 380 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 381 | if (stmt != null) stmt.close(); |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 382 | } |
Jim Miller | f186055 | 2009-09-09 17:46:35 -0700 | [diff] [blame] | 383 | upgradeVersion = 35; |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 384 | } |
| 385 | // due to a botched merge from donut to eclair, the initialization of ASSISTED_GPS_ENABLED |
| 386 | // was accidentally done out of order here. |
| 387 | // to fix this, ASSISTED_GPS_ENABLED is now initialized while upgrading from 38 to 39, |
| 388 | // and we intentionally do nothing from 35 to 36 now. |
| 389 | if (upgradeVersion == 35) { |
The Android Open Source Project | 575d1af | 2009-07-03 08:55:59 -0700 | [diff] [blame] | 390 | upgradeVersion = 36; |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 391 | } |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 392 | |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 393 | if (upgradeVersion == 36) { |
| 394 | // This upgrade adds the STREAM_SYSTEM_ENFORCED type to the list of |
| 395 | // types affected by ringer modes (silent, vibrate, etc.) |
| 396 | db.beginTransaction(); |
| 397 | try { |
| 398 | db.execSQL("DELETE FROM system WHERE name='" |
| 399 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 400 | int newValue = (1 << AudioManager.STREAM_RING) |
| 401 | | (1 << AudioManager.STREAM_NOTIFICATION) |
| 402 | | (1 << AudioManager.STREAM_SYSTEM) |
| 403 | | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); |
| 404 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 405 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 406 | + String.valueOf(newValue) + "')"); |
| 407 | db.setTransactionSuccessful(); |
| 408 | } finally { |
| 409 | db.endTransaction(); |
| 410 | } |
Jim Miller | 4880575 | 2009-08-04 18:59:20 -0700 | [diff] [blame] | 411 | upgradeVersion = 37; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 412 | } |
| 413 | |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 414 | if (upgradeVersion == 37) { |
| 415 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 416 | SQLiteStatement stmt = null; |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 417 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 418 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 419 | + " VALUES(?,?);"); |
| 420 | loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS, |
| 421 | R.string.airplane_mode_toggleable_radios); |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 422 | db.setTransactionSuccessful(); |
| 423 | } finally { |
| 424 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 425 | if (stmt != null) stmt.close(); |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 426 | } |
| 427 | upgradeVersion = 38; |
| 428 | } |
| 429 | |
Mike Lockwood | 02901eb | 2009-08-25 15:11:17 -0700 | [diff] [blame] | 430 | if (upgradeVersion == 38) { |
| 431 | db.beginTransaction(); |
| 432 | try { |
| 433 | String value = |
| 434 | mContext.getResources().getBoolean(R.bool.assisted_gps_enabled) ? "1" : "0"; |
| 435 | db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" + |
| 436 | Settings.Secure.ASSISTED_GPS_ENABLED + "','" + value + "');"); |
| 437 | db.setTransactionSuccessful(); |
| 438 | } finally { |
| 439 | db.endTransaction(); |
| 440 | } |
| 441 | |
| 442 | upgradeVersion = 39; |
| 443 | } |
| 444 | |
Dan Murphy | 951764b | 2009-08-27 14:59:03 -0500 | [diff] [blame] | 445 | if (upgradeVersion == 39) { |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 446 | upgradeAutoBrightness(db); |
Dan Murphy | 951764b | 2009-08-27 14:59:03 -0500 | [diff] [blame] | 447 | upgradeVersion = 40; |
| 448 | } |
| 449 | |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 450 | if (upgradeVersion == 40) { |
| 451 | /* |
| 452 | * All animations are now turned on by default! |
| 453 | */ |
| 454 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 455 | SQLiteStatement stmt = null; |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 456 | try { |
| 457 | db.execSQL("DELETE FROM system WHERE name='" |
| 458 | + Settings.System.WINDOW_ANIMATION_SCALE + "'"); |
| 459 | db.execSQL("DELETE FROM system WHERE name='" |
| 460 | + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 461 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 462 | + " VALUES(?,?);"); |
| 463 | loadDefaultAnimationSettings(stmt); |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 464 | db.setTransactionSuccessful(); |
| 465 | } finally { |
| 466 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 467 | if (stmt != null) stmt.close(); |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 468 | } |
| 469 | upgradeVersion = 41; |
| 470 | } |
| 471 | |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 472 | if (upgradeVersion == 41) { |
| 473 | /* |
| 474 | * Initialize newly public haptic feedback setting |
| 475 | */ |
| 476 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 477 | SQLiteStatement stmt = null; |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 478 | try { |
| 479 | db.execSQL("DELETE FROM system WHERE name='" |
| 480 | + Settings.System.HAPTIC_FEEDBACK_ENABLED + "'"); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 481 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 482 | + " VALUES(?,?);"); |
| 483 | loadDefaultHapticSettings(stmt); |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 484 | db.setTransactionSuccessful(); |
| 485 | } finally { |
| 486 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 487 | if (stmt != null) stmt.close(); |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 488 | } |
| 489 | upgradeVersion = 42; |
| 490 | } |
| 491 | |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 492 | if (upgradeVersion == 42) { |
| 493 | /* |
| 494 | * Initialize new notification pulse setting |
| 495 | */ |
| 496 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 497 | SQLiteStatement stmt = null; |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 498 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 499 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 500 | + " VALUES(?,?);"); |
| 501 | loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE, |
| 502 | R.bool.def_notification_pulse); |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 503 | db.setTransactionSuccessful(); |
| 504 | } finally { |
| 505 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 506 | if (stmt != null) stmt.close(); |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 507 | } |
| 508 | upgradeVersion = 43; |
| 509 | } |
| 510 | |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 511 | if (upgradeVersion == 43) { |
| 512 | /* |
| 513 | * This upgrade stores bluetooth volume separately from voice volume |
| 514 | */ |
| 515 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 516 | SQLiteStatement stmt = null; |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 517 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 518 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 519 | + " VALUES(?,?);"); |
| 520 | loadSetting(stmt, Settings.System.VOLUME_BLUETOOTH_SCO, |
| 521 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]); |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 522 | db.setTransactionSuccessful(); |
| 523 | } finally { |
| 524 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 525 | if (stmt != null) stmt.close(); |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 526 | } |
| 527 | upgradeVersion = 44; |
| 528 | } |
| 529 | |
Doug Zongker | aed8f8e | 2010-01-07 18:07:50 -0800 | [diff] [blame] | 530 | if (upgradeVersion == 44) { |
| 531 | /* |
| 532 | * Gservices was moved into vendor/google. |
| 533 | */ |
| 534 | db.execSQL("DROP TABLE IF EXISTS gservices"); |
| 535 | db.execSQL("DROP INDEX IF EXISTS gservicesIndex1"); |
| 536 | upgradeVersion = 45; |
| 537 | } |
San Mehat | 87734d3 | 2010-01-08 12:53:06 -0800 | [diff] [blame] | 538 | |
| 539 | if (upgradeVersion == 45) { |
| 540 | /* |
| 541 | * New settings for MountService |
| 542 | */ |
| 543 | db.beginTransaction(); |
| 544 | try { |
| 545 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 546 | Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND + "','1');"); |
| 547 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 548 | Settings.Secure.MOUNT_UMS_AUTOSTART + "','0');"); |
| 549 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 550 | Settings.Secure.MOUNT_UMS_PROMPT + "','1');"); |
| 551 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 552 | Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED + "','1');"); |
| 553 | db.setTransactionSuccessful(); |
| 554 | } finally { |
| 555 | db.endTransaction(); |
| 556 | } |
| 557 | upgradeVersion = 46; |
| 558 | } |
| 559 | |
Dianne Hackborn | df83afa | 2010-01-20 13:37:26 -0800 | [diff] [blame] | 560 | if (upgradeVersion == 46) { |
| 561 | /* |
| 562 | * The password mode constants have changed; reset back to no |
| 563 | * password. |
| 564 | */ |
| 565 | db.beginTransaction(); |
| 566 | try { |
| 567 | db.execSQL("DELETE FROM system WHERE name='lockscreen.password_type';"); |
| 568 | db.setTransactionSuccessful(); |
| 569 | } finally { |
| 570 | db.endTransaction(); |
| 571 | } |
| 572 | upgradeVersion = 47; |
| 573 | } |
| 574 | |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 575 | |
Dianne Hackborn | 9327f4f | 2010-01-29 10:38:29 -0800 | [diff] [blame] | 576 | if (upgradeVersion == 47) { |
| 577 | /* |
| 578 | * The password mode constants have changed again; reset back to no |
| 579 | * password. |
| 580 | */ |
| 581 | db.beginTransaction(); |
| 582 | try { |
| 583 | db.execSQL("DELETE FROM system WHERE name='lockscreen.password_type';"); |
| 584 | db.setTransactionSuccessful(); |
| 585 | } finally { |
| 586 | db.endTransaction(); |
| 587 | } |
| 588 | upgradeVersion = 48; |
| 589 | } |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 590 | |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 591 | if (upgradeVersion == 48) { |
| 592 | /* |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 593 | * Default recognition service no longer initialized here, |
| 594 | * moved to RecognitionManagerService. |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 595 | */ |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 596 | upgradeVersion = 49; |
| 597 | } |
Jim Miller | 31f90b6 | 2010-01-20 13:35:20 -0800 | [diff] [blame] | 598 | |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 599 | if (upgradeVersion == 49) { |
| 600 | /* |
| 601 | * New settings for new user interface noises. |
| 602 | */ |
| 603 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 604 | SQLiteStatement stmt = null; |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 605 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 606 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 607 | + " VALUES(?,?);"); |
| 608 | loadUISoundEffectsSettings(stmt); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 609 | db.setTransactionSuccessful(); |
| 610 | } finally { |
| 611 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 612 | if (stmt != null) stmt.close(); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | upgradeVersion = 50; |
| 616 | } |
| 617 | |
Oscar Montemayor | f1cbfff | 2010-02-22 16:12:07 -0800 | [diff] [blame] | 618 | if (upgradeVersion == 50) { |
| 619 | /* |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 620 | * Install location no longer initiated here. |
Oscar Montemayor | f1cbfff | 2010-02-22 16:12:07 -0800 | [diff] [blame] | 621 | */ |
Oscar Montemayor | f1cbfff | 2010-02-22 16:12:07 -0800 | [diff] [blame] | 622 | upgradeVersion = 51; |
| 623 | } |
| 624 | |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 625 | if (upgradeVersion == 51) { |
| 626 | /* Move the lockscreen related settings to Secure, including some private ones. */ |
| 627 | String[] settingsToMove = { |
| 628 | Secure.LOCK_PATTERN_ENABLED, |
| 629 | Secure.LOCK_PATTERN_VISIBLE, |
| 630 | Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, |
| 631 | "lockscreen.password_type", |
| 632 | "lockscreen.lockoutattemptdeadline", |
| 633 | "lockscreen.patterneverchosen", |
| 634 | "lock_pattern_autolock", |
| 635 | "lockscreen.lockedoutpermanently", |
| 636 | "lockscreen.password_salt" |
| 637 | }; |
| 638 | moveFromSystemToSecure(db, settingsToMove); |
| 639 | upgradeVersion = 52; |
| 640 | } |
| 641 | |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 642 | if (upgradeVersion == 52) { |
| 643 | // new vibration/silent mode settings |
| 644 | db.beginTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 645 | SQLiteStatement stmt = null; |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 646 | try { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 647 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 648 | + " VALUES(?,?);"); |
| 649 | loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT, |
| 650 | R.bool.def_vibrate_in_silent); |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 651 | db.setTransactionSuccessful(); |
| 652 | } finally { |
| 653 | db.endTransaction(); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 654 | if (stmt != null) stmt.close(); |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | upgradeVersion = 53; |
| 658 | } |
Suchi Amalapurapu | 089262d | 2010-03-10 14:19:21 -0800 | [diff] [blame] | 659 | |
| 660 | if (upgradeVersion == 53) { |
| 661 | /* |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 662 | * New settings for set install location UI no longer initiated here. |
Suchi Amalapurapu | 089262d | 2010-03-10 14:19:21 -0800 | [diff] [blame] | 663 | */ |
Suchi Amalapurapu | 089262d | 2010-03-10 14:19:21 -0800 | [diff] [blame] | 664 | upgradeVersion = 54; |
| 665 | } |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 666 | |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 667 | if (upgradeVersion == 54) { |
| 668 | /* |
| 669 | * Update the screen timeout value if set to never |
| 670 | */ |
| 671 | db.beginTransaction(); |
| 672 | try { |
| 673 | upgradeScreenTimeoutFromNever(db); |
| 674 | db.setTransactionSuccessful(); |
| 675 | } finally { |
| 676 | db.endTransaction(); |
| 677 | } |
| 678 | |
| 679 | upgradeVersion = 55; |
| 680 | } |
| 681 | |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 682 | if (upgradeVersion == 55) { |
| 683 | /* Move the install location settings. */ |
| 684 | String[] settingsToMove = { |
| 685 | Secure.SET_INSTALL_LOCATION, |
| 686 | Secure.DEFAULT_INSTALL_LOCATION |
| 687 | }; |
| 688 | moveFromSystemToSecure(db, settingsToMove); |
| 689 | db.beginTransaction(); |
| 690 | SQLiteStatement stmt = null; |
| 691 | try { |
| 692 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 693 | + " VALUES(?,?);"); |
| 694 | loadSetting(stmt, Secure.SET_INSTALL_LOCATION, 0); |
| 695 | loadSetting(stmt, Secure.DEFAULT_INSTALL_LOCATION, |
| 696 | PackageHelper.APP_INSTALL_AUTO); |
| 697 | db.setTransactionSuccessful(); |
| 698 | } finally { |
| 699 | db.endTransaction(); |
| 700 | if (stmt != null) stmt.close(); |
| 701 | } |
| 702 | upgradeVersion = 56; |
| 703 | } |
Jake Hamby | 6659284 | 2010-08-24 19:55:20 -0700 | [diff] [blame] | 704 | |
| 705 | if (upgradeVersion == 56) { |
| 706 | /* |
| 707 | * Add Bluetooth to list of toggleable radios in airplane mode |
| 708 | */ |
| 709 | db.beginTransaction(); |
| 710 | SQLiteStatement stmt = null; |
| 711 | try { |
| 712 | db.execSQL("DELETE FROM system WHERE name='" |
| 713 | + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'"); |
| 714 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 715 | + " VALUES(?,?);"); |
| 716 | loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS, |
| 717 | R.string.airplane_mode_toggleable_radios); |
| 718 | db.setTransactionSuccessful(); |
| 719 | } finally { |
| 720 | db.endTransaction(); |
| 721 | if (stmt != null) stmt.close(); |
| 722 | } |
| 723 | upgradeVersion = 57; |
| 724 | } |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 725 | |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 726 | /************* The following are Honeycomb changes ************/ |
| 727 | |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 728 | if (upgradeVersion == 57) { |
| 729 | /* |
| 730 | * New settings to: |
| 731 | * 1. Enable injection of accessibility scripts in WebViews. |
| 732 | * 2. Define the key bindings for traversing web content in WebViews. |
| 733 | */ |
| 734 | db.beginTransaction(); |
| 735 | SQLiteStatement stmt = null; |
| 736 | try { |
| 737 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 738 | + " VALUES(?,?);"); |
| 739 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, |
| 740 | R.bool.def_accessibility_script_injection); |
| 741 | stmt.close(); |
| 742 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 743 | + " VALUES(?,?);"); |
| 744 | loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS, |
| 745 | R.string.def_accessibility_web_content_key_bindings); |
| 746 | db.setTransactionSuccessful(); |
| 747 | } finally { |
| 748 | db.endTransaction(); |
| 749 | if (stmt != null) stmt.close(); |
| 750 | } |
| 751 | upgradeVersion = 58; |
| 752 | } |
| 753 | |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 754 | if (upgradeVersion == 58) { |
| 755 | /* Add default for new Auto Time Zone */ |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 756 | int autoTimeValue = getIntValueFromSystem(db, Settings.System.AUTO_TIME, 0); |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 757 | db.beginTransaction(); |
| 758 | SQLiteStatement stmt = null; |
| 759 | try { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 760 | stmt = db.compileStatement("INSERT INTO system(name,value)" + " VALUES(?,?);"); |
| 761 | loadSetting(stmt, Settings.System.AUTO_TIME_ZONE, |
| 762 | autoTimeValue); // Sync timezone to NITZ if auto_time was enabled |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 763 | db.setTransactionSuccessful(); |
| 764 | } finally { |
| 765 | db.endTransaction(); |
| 766 | if (stmt != null) stmt.close(); |
| 767 | } |
| 768 | upgradeVersion = 59; |
| 769 | } |
| 770 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 771 | if (upgradeVersion == 59) { |
| 772 | // Persistence for the rotation lock feature. |
| 773 | db.beginTransaction(); |
| 774 | SQLiteStatement stmt = null; |
| 775 | try { |
| 776 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 777 | + " VALUES(?,?);"); |
| 778 | loadBooleanSetting(stmt, Settings.System.USER_ROTATION, |
| 779 | R.integer.def_user_rotation); // should be zero degrees |
| 780 | db.setTransactionSuccessful(); |
| 781 | } finally { |
| 782 | db.endTransaction(); |
| 783 | if (stmt != null) stmt.close(); |
| 784 | } |
| 785 | upgradeVersion = 60; |
| 786 | } |
| 787 | |
Amith Yamasani | 0038931 | 2010-11-05 11:22:21 -0700 | [diff] [blame] | 788 | if (upgradeVersion == 60) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 789 | // Don't do this for upgrades from Gingerbread |
| 790 | // Were only required for intra-Honeycomb upgrades for testing |
| 791 | // upgradeScreenTimeout(db); |
Amith Yamasani | 0038931 | 2010-11-05 11:22:21 -0700 | [diff] [blame] | 792 | upgradeVersion = 61; |
| 793 | } |
| 794 | |
Amith Yamasani | 79373f6 | 2010-11-18 16:32:48 -0800 | [diff] [blame] | 795 | if (upgradeVersion == 61) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 796 | // Don't do this for upgrades from Gingerbread |
| 797 | // Were only required for intra-Honeycomb upgrades for testing |
| 798 | // upgradeScreenTimeout(db); |
Amith Yamasani | 79373f6 | 2010-11-18 16:32:48 -0800 | [diff] [blame] | 799 | upgradeVersion = 62; |
| 800 | } |
| 801 | |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 802 | // Change the default for screen auto-brightness mode |
| 803 | if (upgradeVersion == 62) { |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 804 | // Don't do this for upgrades from Gingerbread |
| 805 | // Were only required for intra-Honeycomb upgrades for testing |
| 806 | // upgradeAutoBrightness(db); |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 807 | upgradeVersion = 63; |
| 808 | } |
| 809 | |
Eric Laurent | 25101b0 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 810 | if (upgradeVersion == 63) { |
| 811 | // This upgrade adds the STREAM_MUSIC type to the list of |
| 812 | // types affected by ringer modes (silent, vibrate, etc.) |
| 813 | db.beginTransaction(); |
| 814 | try { |
| 815 | db.execSQL("DELETE FROM system WHERE name='" |
| 816 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 817 | int newValue = (1 << AudioManager.STREAM_RING) |
| 818 | | (1 << AudioManager.STREAM_NOTIFICATION) |
| 819 | | (1 << AudioManager.STREAM_SYSTEM) |
| 820 | | (1 << AudioManager.STREAM_SYSTEM_ENFORCED) |
| 821 | | (1 << AudioManager.STREAM_MUSIC); |
| 822 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 823 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 824 | + String.valueOf(newValue) + "')"); |
| 825 | db.setTransactionSuccessful(); |
| 826 | } finally { |
| 827 | db.endTransaction(); |
| 828 | } |
| 829 | upgradeVersion = 64; |
| 830 | } |
| 831 | |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 832 | if (upgradeVersion == 64) { |
| 833 | // New setting to configure the long press timeout. |
| 834 | db.beginTransaction(); |
| 835 | SQLiteStatement stmt = null; |
| 836 | try { |
| 837 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 838 | + " VALUES(?,?);"); |
| 839 | loadIntegerSetting(stmt, Settings.Secure.LONG_PRESS_TIMEOUT, |
| 840 | R.integer.def_long_press_timeout_millis); |
| 841 | stmt.close(); |
| 842 | db.setTransactionSuccessful(); |
| 843 | } finally { |
| 844 | db.endTransaction(); |
| 845 | if (stmt != null) stmt.close(); |
| 846 | } |
| 847 | upgradeVersion = 65; |
| 848 | } |
| 849 | |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 850 | /************* The following are Ice Cream Sandwich changes ************/ |
| 851 | |
Gilles Debunne | fa53d30 | 2011-07-08 10:40:51 -0700 | [diff] [blame] | 852 | if (upgradeVersion == 65) { |
| 853 | /* |
| 854 | * Animations are removed from Settings. Turned on by default |
| 855 | */ |
| 856 | db.beginTransaction(); |
| 857 | SQLiteStatement stmt = null; |
| 858 | try { |
| 859 | db.execSQL("DELETE FROM system WHERE name='" |
| 860 | + Settings.System.WINDOW_ANIMATION_SCALE + "'"); |
| 861 | db.execSQL("DELETE FROM system WHERE name='" |
| 862 | + Settings.System.TRANSITION_ANIMATION_SCALE + "'"); |
| 863 | stmt = db.compileStatement("INSERT INTO system(name,value)" |
| 864 | + " VALUES(?,?);"); |
| 865 | loadDefaultAnimationSettings(stmt); |
| 866 | db.setTransactionSuccessful(); |
| 867 | } finally { |
| 868 | db.endTransaction(); |
| 869 | if (stmt != null) stmt.close(); |
| 870 | } |
| 871 | upgradeVersion = 66; |
| 872 | } |
| 873 | |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 874 | if (upgradeVersion == 66) { |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 875 | // This upgrade makes sure that MODE_RINGER_STREAMS_AFFECTED is set |
| 876 | // according to device voice capability |
| 877 | db.beginTransaction(); |
| 878 | try { |
| 879 | int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | |
| 880 | (1 << AudioManager.STREAM_NOTIFICATION) | |
| 881 | (1 << AudioManager.STREAM_SYSTEM) | |
| 882 | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); |
| 883 | if (!mContext.getResources().getBoolean( |
| 884 | com.android.internal.R.bool.config_voice_capable)) { |
| 885 | ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); |
| 886 | } |
| 887 | db.execSQL("DELETE FROM system WHERE name='" |
| 888 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "'"); |
| 889 | db.execSQL("INSERT INTO system ('name', 'value') values ('" |
| 890 | + Settings.System.MODE_RINGER_STREAMS_AFFECTED + "', '" |
| 891 | + String.valueOf(ringerModeAffectedStreams) + "')"); |
| 892 | db.setTransactionSuccessful(); |
| 893 | } finally { |
| 894 | db.endTransaction(); |
| 895 | } |
| 896 | upgradeVersion = 67; |
| 897 | } |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 898 | |
Svetoslav Ganov | a28a16d | 2011-07-28 11:24:21 -0700 | [diff] [blame] | 899 | if (upgradeVersion == 67) { |
| 900 | // New setting to enable touch exploration. |
| 901 | db.beginTransaction(); |
| 902 | SQLiteStatement stmt = null; |
| 903 | try { |
| 904 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 905 | + " VALUES(?,?);"); |
| 906 | loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED, |
| 907 | R.bool.def_touch_exploration_enabled); |
| 908 | stmt.close(); |
| 909 | db.setTransactionSuccessful(); |
| 910 | } finally { |
| 911 | db.endTransaction(); |
| 912 | if (stmt != null) stmt.close(); |
| 913 | } |
| 914 | upgradeVersion = 68; |
| 915 | } |
| 916 | |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 917 | if (upgradeVersion == 68) { |
| 918 | // Enable all system sounds by default |
| 919 | db.beginTransaction(); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 920 | try { |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 921 | db.execSQL("DELETE FROM system WHERE name='" |
| 922 | + Settings.System.NOTIFICATIONS_USE_RING_VOLUME + "'"); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 923 | db.setTransactionSuccessful(); |
| 924 | } finally { |
| 925 | db.endTransaction(); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 926 | } |
| 927 | upgradeVersion = 69; |
| 928 | } |
Svetoslav Ganov | a28a16d | 2011-07-28 11:24:21 -0700 | [diff] [blame] | 929 | |
Nick Pelly | 8d32a01 | 2011-08-09 07:03:49 -0700 | [diff] [blame] | 930 | if (upgradeVersion == 69) { |
| 931 | // Add RADIO_NFC to AIRPLANE_MODE_RADIO and AIRPLANE_MODE_TOGGLEABLE_RADIOS |
| 932 | String airplaneRadios = mContext.getResources().getString( |
| 933 | R.string.def_airplane_mode_radios); |
| 934 | String toggleableRadios = mContext.getResources().getString( |
| 935 | R.string.airplane_mode_toggleable_radios); |
| 936 | db.beginTransaction(); |
| 937 | try { |
| 938 | db.execSQL("UPDATE system SET value='" + airplaneRadios + "' " + |
| 939 | "WHERE name='" + Settings.System.AIRPLANE_MODE_RADIOS + "'"); |
| 940 | db.execSQL("UPDATE system SET value='" + toggleableRadios + "' " + |
| 941 | "WHERE name='" + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'"); |
| 942 | db.setTransactionSuccessful(); |
| 943 | } finally { |
| 944 | db.endTransaction(); |
| 945 | } |
| 946 | upgradeVersion = 70; |
| 947 | } |
| 948 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 949 | if (upgradeVersion == 70) { |
| 950 | // Update all built-in bookmarks. Some of the package names have changed. |
| 951 | loadBookmarks(db); |
| 952 | upgradeVersion = 71; |
| 953 | } |
| 954 | |
Svetoslav Ganov | 55f937a | 2011-12-05 11:42:07 -0800 | [diff] [blame] | 955 | if (upgradeVersion == 71) { |
| 956 | // New setting to specify whether to speak passwords in accessibility mode. |
| 957 | db.beginTransaction(); |
| 958 | SQLiteStatement stmt = null; |
| 959 | try { |
| 960 | stmt = db.compileStatement("INSERT INTO secure(name,value)" |
| 961 | + " VALUES(?,?);"); |
| 962 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, |
| 963 | R.bool.def_accessibility_speak_password); |
Amith Yamasani | 6243edd | 2011-12-05 19:58:48 -0800 | [diff] [blame] | 964 | db.setTransactionSuccessful(); |
Svetoslav Ganov | 55f937a | 2011-12-05 11:42:07 -0800 | [diff] [blame] | 965 | } finally { |
| 966 | db.endTransaction(); |
| 967 | if (stmt != null) stmt.close(); |
| 968 | } |
| 969 | upgradeVersion = 72; |
| 970 | } |
| 971 | |
Amith Yamasani | 6243edd | 2011-12-05 19:58:48 -0800 | [diff] [blame] | 972 | if (upgradeVersion == 72) { |
| 973 | // update vibration settings |
| 974 | db.beginTransaction(); |
| 975 | SQLiteStatement stmt = null; |
| 976 | try { |
| 977 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 978 | + " VALUES(?,?);"); |
| 979 | loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT, |
| 980 | R.bool.def_vibrate_in_silent); |
| 981 | db.setTransactionSuccessful(); |
| 982 | } finally { |
| 983 | db.endTransaction(); |
| 984 | if (stmt != null) stmt.close(); |
| 985 | } |
| 986 | upgradeVersion = 73; |
| 987 | } |
| 988 | |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 989 | if (upgradeVersion == 73) { |
| 990 | // URL from which WebView loads a JavaScript based screen-reader. |
| 991 | db.beginTransaction(); |
| 992 | SQLiteStatement stmt = null; |
| 993 | try { |
| 994 | stmt = db.compileStatement("INSERT INTO secure(name,value) VALUES(?,?);"); |
| 995 | loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_SCREEN_READER_URL, |
| 996 | R.string.def_accessibility_screen_reader_url); |
| 997 | db.setTransactionSuccessful(); |
| 998 | } finally { |
| 999 | db.endTransaction(); |
| 1000 | if (stmt != null) stmt.close(); |
| 1001 | } |
| 1002 | upgradeVersion = 74; |
| 1003 | } |
| 1004 | |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 1005 | // *** Remember to update DATABASE_VERSION above! |
| 1006 | |
| 1007 | if (upgradeVersion != currentVersion) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1008 | Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion |
| 1009 | + ", must wipe the settings provider"); |
| 1010 | db.execSQL("DROP TABLE IF EXISTS system"); |
| 1011 | db.execSQL("DROP INDEX IF EXISTS systemIndex1"); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1012 | db.execSQL("DROP TABLE IF EXISTS secure"); |
| 1013 | db.execSQL("DROP INDEX IF EXISTS secureIndex1"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1014 | db.execSQL("DROP TABLE IF EXISTS gservices"); |
| 1015 | db.execSQL("DROP INDEX IF EXISTS gservicesIndex1"); |
| 1016 | db.execSQL("DROP TABLE IF EXISTS bluetooth_devices"); |
| 1017 | db.execSQL("DROP TABLE IF EXISTS bookmarks"); |
| 1018 | db.execSQL("DROP INDEX IF EXISTS bookmarksIndex1"); |
| 1019 | db.execSQL("DROP INDEX IF EXISTS bookmarksIndex2"); |
| 1020 | db.execSQL("DROP TABLE IF EXISTS favorites"); |
| 1021 | onCreate(db); |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 1022 | |
| 1023 | // Added for diagnosing settings.db wipes after the fact |
| 1024 | String wipeReason = oldVersion + "/" + upgradeVersion + "/" + currentVersion; |
| 1025 | db.execSQL("INSERT INTO secure(name,value) values('" + |
| 1026 | "wiped_db_reason" + "','" + wipeReason + "');"); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1027 | } |
| 1028 | } |
| 1029 | |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1030 | private void moveFromSystemToSecure(SQLiteDatabase db, String [] settingsToMove) { |
| 1031 | // Copy settings values from 'system' to 'secure' and delete them from 'system' |
| 1032 | SQLiteStatement insertStmt = null; |
| 1033 | SQLiteStatement deleteStmt = null; |
| 1034 | |
| 1035 | db.beginTransaction(); |
| 1036 | try { |
| 1037 | insertStmt = |
| 1038 | db.compileStatement("INSERT INTO secure (name,value) SELECT name,value FROM " |
| 1039 | + "system WHERE name=?"); |
| 1040 | deleteStmt = db.compileStatement("DELETE FROM system WHERE name=?"); |
| 1041 | |
| 1042 | |
| 1043 | for (String setting : settingsToMove) { |
| 1044 | insertStmt.bindString(1, setting); |
| 1045 | insertStmt.execute(); |
| 1046 | |
| 1047 | deleteStmt.bindString(1, setting); |
| 1048 | deleteStmt.execute(); |
| 1049 | } |
| 1050 | db.setTransactionSuccessful(); |
| 1051 | } finally { |
| 1052 | db.endTransaction(); |
| 1053 | if (insertStmt != null) { |
| 1054 | insertStmt.close(); |
| 1055 | } |
| 1056 | if (deleteStmt != null) { |
| 1057 | deleteStmt.close(); |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1062 | private void upgradeLockPatternLocation(SQLiteDatabase db) { |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1063 | Cursor c = db.query("system", new String[] {"_id", "value"}, "name='lock_pattern'", |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1064 | null, null, null, null); |
| 1065 | if (c.getCount() > 0) { |
| 1066 | c.moveToFirst(); |
| 1067 | String lockPattern = c.getString(1); |
| 1068 | if (!TextUtils.isEmpty(lockPattern)) { |
| 1069 | // Convert lock pattern |
| 1070 | try { |
Jim Miller | 31f90b6 | 2010-01-20 13:35:20 -0800 | [diff] [blame] | 1071 | LockPatternUtils lpu = new LockPatternUtils(mContext); |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1072 | List<LockPatternView.Cell> cellPattern = |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1073 | LockPatternUtils.stringToPattern(lockPattern); |
| 1074 | lpu.saveLockPattern(cellPattern); |
| 1075 | } catch (IllegalArgumentException e) { |
| 1076 | // Don't want corrupted lock pattern to hang the reboot process |
| 1077 | } |
| 1078 | } |
| 1079 | c.close(); |
| 1080 | db.delete("system", "name='lock_pattern'", null); |
| 1081 | } else { |
| 1082 | c.close(); |
| 1083 | } |
| 1084 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1085 | |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 1086 | private void upgradeScreenTimeoutFromNever(SQLiteDatabase db) { |
| 1087 | // See if the timeout is -1 (for "Never"). |
| 1088 | Cursor c = db.query("system", new String[] { "_id", "value" }, "name=? AND value=?", |
| 1089 | new String[] { Settings.System.SCREEN_OFF_TIMEOUT, "-1" }, |
| 1090 | null, null, null); |
| 1091 | |
| 1092 | SQLiteStatement stmt = null; |
| 1093 | if (c.getCount() > 0) { |
| 1094 | c.close(); |
| 1095 | try { |
| 1096 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 1097 | + " VALUES(?,?);"); |
| 1098 | |
| 1099 | // Set the timeout to 30 minutes in milliseconds |
Amith Yamasani | cd66caf | 2010-04-12 15:49:12 -0700 | [diff] [blame] | 1100 | loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, |
| 1101 | Integer.toString(30 * 60 * 1000)); |
Amith Yamasani | b6e6ffa | 2010-03-29 17:58:53 -0700 | [diff] [blame] | 1102 | } finally { |
| 1103 | if (stmt != null) stmt.close(); |
| 1104 | } |
| 1105 | } else { |
| 1106 | c.close(); |
| 1107 | } |
| 1108 | } |
| 1109 | |
Amith Yamasani | 79373f6 | 2010-11-18 16:32:48 -0800 | [diff] [blame] | 1110 | private void upgradeScreenTimeout(SQLiteDatabase db) { |
| 1111 | // Change screen timeout to current default |
| 1112 | db.beginTransaction(); |
| 1113 | SQLiteStatement stmt = null; |
| 1114 | try { |
| 1115 | stmt = db.compileStatement("INSERT OR REPLACE INTO system(name,value)" |
| 1116 | + " VALUES(?,?);"); |
| 1117 | loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, |
| 1118 | R.integer.def_screen_off_timeout); |
| 1119 | db.setTransactionSuccessful(); |
| 1120 | } finally { |
| 1121 | db.endTransaction(); |
| 1122 | if (stmt != null) |
| 1123 | stmt.close(); |
| 1124 | } |
| 1125 | } |
| 1126 | |
Amith Yamasani | f50c511 | 2011-01-07 11:32:30 -0800 | [diff] [blame] | 1127 | private void upgradeAutoBrightness(SQLiteDatabase db) { |
| 1128 | db.beginTransaction(); |
| 1129 | try { |
| 1130 | String value = |
| 1131 | mContext.getResources().getBoolean( |
| 1132 | R.bool.def_screen_brightness_automatic_mode) ? "1" : "0"; |
| 1133 | db.execSQL("INSERT OR REPLACE INTO system(name,value) values('" + |
| 1134 | Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');"); |
| 1135 | db.setTransactionSuccessful(); |
| 1136 | } finally { |
| 1137 | db.endTransaction(); |
| 1138 | } |
| 1139 | } |
| 1140 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1141 | /** |
| 1142 | * Loads the default set of bookmarked shortcuts from an xml file. |
| 1143 | * |
| 1144 | * @param db The database to write the values into |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1145 | */ |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1146 | private void loadBookmarks(SQLiteDatabase db) { |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1147 | ContentValues values = new ContentValues(); |
| 1148 | |
| 1149 | PackageManager packageManager = mContext.getPackageManager(); |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 1150 | try { |
| 1151 | XmlResourceParser parser = mContext.getResources().getXml(R.xml.bookmarks); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1152 | XmlUtils.beginDocument(parser, "bookmarks"); |
| 1153 | |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 1154 | final int depth = parser.getDepth(); |
| 1155 | int type; |
| 1156 | |
| 1157 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 1158 | parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
| 1159 | |
| 1160 | if (type != XmlPullParser.START_TAG) { |
| 1161 | continue; |
| 1162 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1163 | |
| 1164 | String name = parser.getName(); |
| 1165 | if (!"bookmark".equals(name)) { |
| 1166 | break; |
| 1167 | } |
| 1168 | |
| 1169 | String pkg = parser.getAttributeValue(null, "package"); |
| 1170 | String cls = parser.getAttributeValue(null, "class"); |
| 1171 | String shortcutStr = parser.getAttributeValue(null, "shortcut"); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1172 | String category = parser.getAttributeValue(null, "category"); |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 1173 | |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 1174 | int shortcutValue = shortcutStr.charAt(0); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1175 | if (TextUtils.isEmpty(shortcutStr)) { |
| 1176 | Log.w(TAG, "Unable to get shortcut for: " + pkg + "/" + cls); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1177 | continue; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1178 | } |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 1179 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1180 | final Intent intent; |
| 1181 | final String title; |
| 1182 | if (pkg != null && cls != null) { |
| 1183 | ActivityInfo info = null; |
| 1184 | ComponentName cn = new ComponentName(pkg, cls); |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 1185 | try { |
| 1186 | info = packageManager.getActivityInfo(cn, 0); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1187 | } catch (PackageManager.NameNotFoundException e) { |
| 1188 | String[] packages = packageManager.canonicalToCurrentPackageNames( |
| 1189 | new String[] { pkg }); |
| 1190 | cn = new ComponentName(packages[0], cls); |
| 1191 | try { |
| 1192 | info = packageManager.getActivityInfo(cn, 0); |
| 1193 | } catch (PackageManager.NameNotFoundException e1) { |
| 1194 | Log.w(TAG, "Unable to add bookmark: " + pkg + "/" + cls, e); |
| 1195 | continue; |
| 1196 | } |
Romain Guy | f02811f | 2010-03-09 16:33:51 -0800 | [diff] [blame] | 1197 | } |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1198 | |
| 1199 | intent = new Intent(Intent.ACTION_MAIN, null); |
| 1200 | intent.addCategory(Intent.CATEGORY_LAUNCHER); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1201 | intent.setComponent(cn); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1202 | title = info.loadLabel(packageManager).toString(); |
| 1203 | } else if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 1204 | intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1205 | title = ""; |
| 1206 | } else { |
| 1207 | Log.w(TAG, "Unable to add bookmark for shortcut " + shortcutStr |
| 1208 | + ": missing package/class or category attributes"); |
| 1209 | continue; |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1210 | } |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1211 | |
| 1212 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1213 | values.put(Settings.Bookmarks.INTENT, intent.toUri(0)); |
| 1214 | values.put(Settings.Bookmarks.TITLE, title); |
| 1215 | values.put(Settings.Bookmarks.SHORTCUT, shortcutValue); |
| 1216 | db.delete("bookmarks", "shortcut = ?", |
| 1217 | new String[] { Integer.toString(shortcutValue) }); |
| 1218 | db.insert("bookmarks", null, values); |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1219 | } |
| 1220 | } catch (XmlPullParserException e) { |
| 1221 | Log.w(TAG, "Got execption parsing bookmarks.", e); |
| 1222 | } catch (IOException e) { |
| 1223 | Log.w(TAG, "Got execption parsing bookmarks.", e); |
| 1224 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1225 | } |
| 1226 | |
| 1227 | /** |
| 1228 | * Loads the default volume levels. It is actually inserting the index of |
| 1229 | * the volume array for each of the volume controls. |
| 1230 | * |
| 1231 | * @param db the database to insert the volume levels into |
| 1232 | */ |
| 1233 | private void loadVolumeLevels(SQLiteDatabase db) { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1234 | SQLiteStatement stmt = null; |
| 1235 | try { |
| 1236 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 1237 | + " VALUES(?,?);"); |
| 1238 | |
| 1239 | loadSetting(stmt, Settings.System.VOLUME_MUSIC, |
| 1240 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_MUSIC]); |
| 1241 | loadSetting(stmt, Settings.System.VOLUME_RING, |
| 1242 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_RING]); |
| 1243 | loadSetting(stmt, Settings.System.VOLUME_SYSTEM, |
| 1244 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_SYSTEM]); |
| 1245 | loadSetting( |
| 1246 | stmt, |
| 1247 | Settings.System.VOLUME_VOICE, |
| 1248 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_VOICE_CALL]); |
| 1249 | loadSetting(stmt, Settings.System.VOLUME_ALARM, |
| 1250 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_ALARM]); |
| 1251 | loadSetting( |
| 1252 | stmt, |
| 1253 | Settings.System.VOLUME_NOTIFICATION, |
| 1254 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_NOTIFICATION]); |
| 1255 | loadSetting( |
| 1256 | stmt, |
| 1257 | Settings.System.VOLUME_BLUETOOTH_SCO, |
| 1258 | AudioManager.DEFAULT_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]); |
| 1259 | |
| 1260 | loadSetting(stmt, Settings.System.MODE_RINGER, |
| 1261 | AudioManager.RINGER_MODE_NORMAL); |
| 1262 | |
| 1263 | loadVibrateSetting(db, false); |
| 1264 | |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 1265 | // By default: |
| 1266 | // - ringtones, notification, system and music streams are affected by ringer mode |
| 1267 | // on non voice capable devices (tablets) |
| 1268 | // - ringtones, notification and system streams are affected by ringer mode |
| 1269 | // on voice capable devices (phones) |
| 1270 | int ringerModeAffectedStreams = (1 << AudioManager.STREAM_RING) | |
| 1271 | (1 << AudioManager.STREAM_NOTIFICATION) | |
| 1272 | (1 << AudioManager.STREAM_SYSTEM) | |
| 1273 | (1 << AudioManager.STREAM_SYSTEM_ENFORCED); |
| 1274 | if (!mContext.getResources().getBoolean( |
| 1275 | com.android.internal.R.bool.config_voice_capable)) { |
| 1276 | ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC); |
| 1277 | } |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1278 | loadSetting(stmt, Settings.System.MODE_RINGER_STREAMS_AFFECTED, |
Eric Laurent | c1d4166 | 2011-07-19 11:21:13 -0700 | [diff] [blame] | 1279 | ringerModeAffectedStreams); |
| 1280 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1281 | loadSetting(stmt, Settings.System.MUTE_STREAMS_AFFECTED, |
| 1282 | ((1 << AudioManager.STREAM_MUSIC) | |
| 1283 | (1 << AudioManager.STREAM_RING) | |
| 1284 | (1 << AudioManager.STREAM_NOTIFICATION) | |
| 1285 | (1 << AudioManager.STREAM_SYSTEM))); |
| 1286 | } finally { |
| 1287 | if (stmt != null) stmt.close(); |
| 1288 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | private void loadVibrateSetting(SQLiteDatabase db, boolean deleteOld) { |
| 1292 | if (deleteOld) { |
| 1293 | db.execSQL("DELETE FROM system WHERE name='" + Settings.System.VIBRATE_ON + "'"); |
| 1294 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1295 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1296 | SQLiteStatement stmt = null; |
| 1297 | try { |
| 1298 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 1299 | + " VALUES(?,?);"); |
| 1300 | |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 1301 | // Vibrate on by default for ringer, on for notification |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1302 | int vibrate = 0; |
| 1303 | vibrate = AudioService.getValueForVibrateSetting(vibrate, |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 1304 | AudioManager.VIBRATE_TYPE_NOTIFICATION, |
| 1305 | AudioManager.VIBRATE_SETTING_ONLY_SILENT); |
Joe Onorato | 8932020 | 2010-06-24 17:49:44 -0700 | [diff] [blame] | 1306 | vibrate |= AudioService.getValueForVibrateSetting(vibrate, |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 1307 | AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ONLY_SILENT); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1308 | loadSetting(stmt, Settings.System.VIBRATE_ON, vibrate); |
| 1309 | } finally { |
| 1310 | if (stmt != null) stmt.close(); |
| 1311 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1312 | } |
| 1313 | |
| 1314 | private void loadSettings(SQLiteDatabase db) { |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1315 | loadSystemSettings(db); |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1316 | loadSecureSettings(db); |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1317 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1318 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1319 | private void loadSystemSettings(SQLiteDatabase db) { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1320 | SQLiteStatement stmt = null; |
| 1321 | try { |
| 1322 | stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)" |
| 1323 | + " VALUES(?,?);"); |
| 1324 | |
| 1325 | loadBooleanSetting(stmt, Settings.System.DIM_SCREEN, |
| 1326 | R.bool.def_dim_screen); |
| 1327 | loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN, |
| 1328 | "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0); |
| 1329 | loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, |
| 1330 | R.integer.def_screen_off_timeout); |
| 1331 | |
| 1332 | // Set default cdma emergency tone |
| 1333 | loadSetting(stmt, Settings.System.EMERGENCY_TONE, 0); |
| 1334 | |
| 1335 | // Set default cdma call auto retry |
| 1336 | loadSetting(stmt, Settings.System.CALL_AUTO_RETRY, 0); |
| 1337 | |
| 1338 | // Set default cdma DTMF type |
| 1339 | loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0); |
| 1340 | |
| 1341 | // Set default hearing aid |
| 1342 | loadSetting(stmt, Settings.System.HEARING_AID, 0); |
| 1343 | |
| 1344 | // Set default tty mode |
| 1345 | loadSetting(stmt, Settings.System.TTY_MODE, 0); |
| 1346 | |
| 1347 | loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON, |
| 1348 | R.bool.def_airplane_mode_on); |
| 1349 | |
| 1350 | loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS, |
| 1351 | R.string.def_airplane_mode_radios); |
| 1352 | |
| 1353 | loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS, |
| 1354 | R.string.airplane_mode_toggleable_radios); |
| 1355 | |
| 1356 | loadBooleanSetting(stmt, Settings.System.AUTO_TIME, |
| 1357 | R.bool.def_auto_time); // Sync time to NITZ |
Amith Yamasani | ad450be | 2010-09-16 16:47:00 -0700 | [diff] [blame] | 1358 | |
| 1359 | loadBooleanSetting(stmt, Settings.System.AUTO_TIME_ZONE, |
| 1360 | R.bool.def_auto_time_zone); // Sync timezone to NITZ |
| 1361 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1362 | loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, |
| 1363 | R.integer.def_screen_brightness); |
| 1364 | |
| 1365 | loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 1366 | R.bool.def_screen_brightness_automatic_mode); |
| 1367 | |
| 1368 | loadDefaultAnimationSettings(stmt); |
| 1369 | |
| 1370 | loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION, |
| 1371 | R.bool.def_accelerometer_rotation); |
| 1372 | |
| 1373 | loadDefaultHapticSettings(stmt); |
| 1374 | |
| 1375 | loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE, |
| 1376 | R.bool.def_notification_pulse); |
Suchi Amalapurapu | 40e4725 | 2010-04-07 16:15:50 -0700 | [diff] [blame] | 1377 | loadSetting(stmt, Settings.Secure.SET_INSTALL_LOCATION, 0); |
| 1378 | loadSetting(stmt, Settings.Secure.DEFAULT_INSTALL_LOCATION, |
| 1379 | PackageHelper.APP_INSTALL_AUTO); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 1380 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1381 | loadUISoundEffectsSettings(stmt); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 1382 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1383 | loadBooleanSetting(stmt, Settings.System.VIBRATE_IN_SILENT, |
| 1384 | R.bool.def_vibrate_in_silent); |
Mike Lockwood | eabe8bf | 2010-08-31 14:35:23 -0400 | [diff] [blame] | 1385 | |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 1386 | loadIntegerSetting(stmt, Settings.System.POINTER_SPEED, |
| 1387 | R.integer.def_pointer_speed); |
| 1388 | |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1389 | } finally { |
| 1390 | if (stmt != null) stmt.close(); |
| 1391 | } |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1392 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1393 | |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 1394 | private void loadUISoundEffectsSettings(SQLiteStatement stmt) { |
| 1395 | loadIntegerSetting(stmt, Settings.System.POWER_SOUNDS_ENABLED, |
| 1396 | R.integer.def_power_sounds_enabled); |
| 1397 | loadStringSetting(stmt, Settings.System.LOW_BATTERY_SOUND, |
| 1398 | R.string.def_low_battery_sound); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 1399 | loadBooleanSetting(stmt, Settings.System.DTMF_TONE_WHEN_DIALING, |
| 1400 | R.bool.def_dtmf_tones_enabled); |
| 1401 | loadBooleanSetting(stmt, Settings.System.SOUND_EFFECTS_ENABLED, |
| 1402 | R.bool.def_sound_effects_enabled); |
| 1403 | loadBooleanSetting(stmt, Settings.System.HAPTIC_FEEDBACK_ENABLED, |
| 1404 | R.bool.def_haptic_feedback); |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 1405 | |
| 1406 | loadIntegerSetting(stmt, Settings.System.DOCK_SOUNDS_ENABLED, |
| 1407 | R.integer.def_dock_sounds_enabled); |
| 1408 | loadStringSetting(stmt, Settings.System.DESK_DOCK_SOUND, |
| 1409 | R.string.def_desk_dock_sound); |
| 1410 | loadStringSetting(stmt, Settings.System.DESK_UNDOCK_SOUND, |
| 1411 | R.string.def_desk_undock_sound); |
| 1412 | loadStringSetting(stmt, Settings.System.CAR_DOCK_SOUND, |
| 1413 | R.string.def_car_dock_sound); |
| 1414 | loadStringSetting(stmt, Settings.System.CAR_UNDOCK_SOUND, |
| 1415 | R.string.def_car_undock_sound); |
| 1416 | |
| 1417 | loadIntegerSetting(stmt, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, |
| 1418 | R.integer.def_lockscreen_sounds_enabled); |
| 1419 | loadStringSetting(stmt, Settings.System.LOCK_SOUND, |
| 1420 | R.string.def_lock_sound); |
| 1421 | loadStringSetting(stmt, Settings.System.UNLOCK_SOUND, |
| 1422 | R.string.def_unlock_sound); |
| 1423 | } |
| 1424 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1425 | private void loadDefaultAnimationSettings(SQLiteStatement stmt) { |
| 1426 | loadFractionSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE, |
| 1427 | R.fraction.def_window_animation_scale, 1); |
| 1428 | loadFractionSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE, |
| 1429 | R.fraction.def_window_transition_scale, 1); |
| 1430 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1431 | |
Dianne Hackborn | 075a18d | 2009-09-26 12:43:19 -0700 | [diff] [blame] | 1432 | private void loadDefaultHapticSettings(SQLiteStatement stmt) { |
| 1433 | loadBooleanSetting(stmt, Settings.System.HAPTIC_FEEDBACK_ENABLED, |
| 1434 | R.bool.def_haptic_feedback); |
| 1435 | } |
| 1436 | |
The Android Open Source Project | f013e1a | 2008-12-17 18:05:43 -0800 | [diff] [blame] | 1437 | private void loadSecureSettings(SQLiteDatabase db) { |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1438 | SQLiteStatement stmt = null; |
| 1439 | try { |
| 1440 | stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" |
| 1441 | + " VALUES(?,?);"); |
| 1442 | |
| 1443 | loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON, |
| 1444 | R.bool.def_bluetooth_on); |
| 1445 | |
| 1446 | // Data roaming default, based on build |
| 1447 | loadSetting(stmt, Settings.Secure.DATA_ROAMING, |
| 1448 | "true".equalsIgnoreCase( |
| 1449 | SystemProperties.get("ro.com.android.dataroaming", |
| 1450 | "false")) ? 1 : 0); |
| 1451 | |
| 1452 | loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, |
| 1453 | R.bool.def_install_non_market_apps); |
| 1454 | |
| 1455 | loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, |
| 1456 | R.string.def_location_providers_allowed); |
| 1457 | |
| 1458 | loadBooleanSetting(stmt, Settings.Secure.ASSISTED_GPS_ENABLED, |
| 1459 | R.bool.assisted_gps_enabled); |
| 1460 | |
| 1461 | loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE, |
| 1462 | R.integer.def_network_preference); |
| 1463 | |
| 1464 | loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED, |
| 1465 | R.bool.def_usb_mass_storage_enabled); |
| 1466 | |
| 1467 | loadBooleanSetting(stmt, Settings.Secure.WIFI_ON, |
| 1468 | R.bool.def_wifi_on); |
| 1469 | loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, |
| 1470 | R.bool.def_networks_available_notification_on); |
| 1471 | |
| 1472 | String wifiWatchList = SystemProperties.get("ro.com.android.wifi-watchlist"); |
| 1473 | if (!TextUtils.isEmpty(wifiWatchList)) { |
| 1474 | loadSetting(stmt, Settings.Secure.WIFI_WATCHDOG_WATCH_LIST, wifiWatchList); |
| 1475 | } |
| 1476 | |
| 1477 | // Set the preferred network mode to 0 = Global, CDMA default |
Wink Saville | d6bcfd1 | 2011-06-08 12:18:07 -0700 | [diff] [blame] | 1478 | int type; |
| 1479 | if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) { |
| 1480 | type = Phone.NT_MODE_GLOBAL; |
| 1481 | } else { |
| 1482 | type = SystemProperties.getInt("ro.telephony.default_network", |
| 1483 | RILConstants.PREFERRED_NETWORK_MODE); |
| 1484 | } |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1485 | loadSetting(stmt, Settings.Secure.PREFERRED_NETWORK_MODE, type); |
| 1486 | |
| 1487 | // Enable or disable Cell Broadcast SMS |
| 1488 | loadSetting(stmt, Settings.Secure.CDMA_CELL_BROADCAST_SMS, |
| 1489 | RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED); |
| 1490 | |
| 1491 | // Set the preferred cdma subscription to 0 = Subscription from RUIM, when available |
| 1492 | loadSetting(stmt, Settings.Secure.PREFERRED_CDMA_SUBSCRIPTION, |
| 1493 | RILConstants.PREFERRED_CDMA_SUBSCRIPTION); |
| 1494 | |
| 1495 | // Don't do this. The SystemServer will initialize ADB_ENABLED from a |
| 1496 | // persistent system property instead. |
| 1497 | //loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0); |
| 1498 | |
| 1499 | // Allow mock locations default, based on build |
| 1500 | loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, |
| 1501 | "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0); |
| 1502 | |
| 1503 | loadSecure35Settings(stmt); |
| 1504 | |
| 1505 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_PLAY_NOTIFICATION_SND, |
| 1506 | R.bool.def_mount_play_notification_snd); |
| 1507 | |
| 1508 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_AUTOSTART, |
| 1509 | R.bool.def_mount_ums_autostart); |
| 1510 | |
| 1511 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_PROMPT, |
| 1512 | R.bool.def_mount_ums_prompt); |
| 1513 | |
| 1514 | loadBooleanSetting(stmt, Settings.Secure.MOUNT_UMS_NOTIFY_ENABLED, |
| 1515 | R.bool.def_mount_ums_notify_enabled); |
Svetoslav Ganov | 585f13f8d | 2010-08-10 07:59:15 -0700 | [diff] [blame] | 1516 | |
| 1517 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, |
| 1518 | R.bool.def_accessibility_script_injection); |
| 1519 | |
| 1520 | loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS, |
| 1521 | R.string.def_accessibility_web_content_key_bindings); |
Paul Westbrook | d99d0dc | 2011-02-01 14:26:16 -0800 | [diff] [blame] | 1522 | |
| 1523 | final int maxBytes = mContext.getResources().getInteger( |
| 1524 | R.integer.def_download_manager_max_bytes_over_mobile); |
| 1525 | if (maxBytes > 0) { |
| 1526 | loadSetting(stmt, Settings.Secure.DOWNLOAD_MAX_BYTES_OVER_MOBILE, |
| 1527 | Integer.toString(maxBytes)); |
| 1528 | } |
| 1529 | |
| 1530 | final int recommendedMaxBytes = mContext.getResources().getInteger( |
| 1531 | R.integer.def_download_manager_recommended_max_bytes_over_mobile); |
| 1532 | if (recommendedMaxBytes > 0) { |
| 1533 | loadSetting(stmt, Settings.Secure.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE, |
| 1534 | Integer.toString(recommendedMaxBytes)); |
| 1535 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 1536 | |
| 1537 | loadIntegerSetting(stmt, Settings.Secure.LONG_PRESS_TIMEOUT, |
| 1538 | R.integer.def_long_press_timeout_millis); |
Svetoslav Ganov | a28a16d | 2011-07-28 11:24:21 -0700 | [diff] [blame] | 1539 | |
| 1540 | loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED, |
| 1541 | R.bool.def_touch_exploration_enabled); |
Svetoslav Ganov | 55f937a | 2011-12-05 11:42:07 -0800 | [diff] [blame] | 1542 | |
| 1543 | loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, |
| 1544 | R.bool.def_accessibility_speak_password); |
Svetoslav Ganov | 3ca5a74 | 2011-12-06 15:24:37 -0800 | [diff] [blame] | 1545 | |
| 1546 | loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_SCREEN_READER_URL, |
| 1547 | R.string.def_accessibility_screen_reader_url); |
Vasu Nori | 89206fdb | 2010-03-22 10:37:03 -0700 | [diff] [blame] | 1548 | } finally { |
| 1549 | if (stmt != null) stmt.close(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1550 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1551 | } |
| 1552 | |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 1553 | private void loadSecure35Settings(SQLiteStatement stmt) { |
| 1554 | loadBooleanSetting(stmt, Settings.Secure.BACKUP_ENABLED, |
| 1555 | R.bool.def_backup_enabled); |
Jim Miller | 31f90b6 | 2010-01-20 13:35:20 -0800 | [diff] [blame] | 1556 | |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 1557 | loadStringSetting(stmt, Settings.Secure.BACKUP_TRANSPORT, |
| 1558 | R.string.def_backup_transport); |
| 1559 | } |
Jim Miller | 6176677 | 2010-02-12 14:56:49 -0800 | [diff] [blame] | 1560 | |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1561 | private void loadSetting(SQLiteStatement stmt, String key, Object value) { |
| 1562 | stmt.bindString(1, key); |
| 1563 | stmt.bindString(2, value.toString()); |
| 1564 | stmt.execute(); |
| 1565 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1566 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1567 | private void loadStringSetting(SQLiteStatement stmt, String key, int resid) { |
| 1568 | loadSetting(stmt, key, mContext.getResources().getString(resid)); |
| 1569 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1570 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1571 | private void loadBooleanSetting(SQLiteStatement stmt, String key, int resid) { |
| 1572 | loadSetting(stmt, key, |
| 1573 | mContext.getResources().getBoolean(resid) ? "1" : "0"); |
| 1574 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1575 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1576 | private void loadIntegerSetting(SQLiteStatement stmt, String key, int resid) { |
| 1577 | loadSetting(stmt, key, |
| 1578 | Integer.toString(mContext.getResources().getInteger(resid))); |
| 1579 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1580 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1581 | private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, int base) { |
| 1582 | loadSetting(stmt, key, |
| 1583 | Float.toString(mContext.getResources().getFraction(resid, base, base))); |
| 1584 | } |
Amith Yamasani | 5cd1500 | 2011-11-16 11:19:48 -0800 | [diff] [blame] | 1585 | |
| 1586 | private int getIntValueFromSystem(SQLiteDatabase db, String name, int defaultValue) { |
| 1587 | int value = defaultValue; |
| 1588 | Cursor c = null; |
| 1589 | try { |
| 1590 | c = db.query("system", new String[] { Settings.System.VALUE }, "name='" + name + "'", |
| 1591 | null, null, null, null); |
| 1592 | if (c != null && c.moveToFirst()) { |
| 1593 | String val = c.getString(0); |
| 1594 | value = val == null ? defaultValue : Integer.parseInt(val); |
| 1595 | } |
| 1596 | } finally { |
| 1597 | if (c != null) c.close(); |
| 1598 | } |
| 1599 | return value; |
| 1600 | } |
The Android Open Source Project | 54b6cfa | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1601 | } |