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