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