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