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