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