The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 android.provider; |
| 18 | |
| 19 | import com.google.android.collect.Maps; |
| 20 | |
| 21 | import org.apache.commons.codec.binary.Base64; |
| 22 | |
| 23 | import android.annotation.SdkConstant; |
| 24 | import android.annotation.SdkConstant.SdkConstantType; |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 25 | import android.content.ComponentName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.ContentQueryMap; |
| 27 | import android.content.ContentResolver; |
| 28 | import android.content.ContentValues; |
| 29 | import android.content.Context; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 30 | import android.content.IContentProvider; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.content.Intent; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 32 | import android.content.pm.ActivityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | import android.content.pm.PackageManager; |
| 34 | import android.content.pm.ResolveInfo; |
| 35 | import android.content.res.Configuration; |
| 36 | import android.content.res.Resources; |
| 37 | import android.database.Cursor; |
| 38 | import android.database.SQLException; |
| 39 | import android.net.Uri; |
| 40 | import android.os.*; |
| 41 | import android.telephony.TelephonyManager; |
| 42 | import android.text.TextUtils; |
| 43 | import android.util.AndroidException; |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 44 | import android.util.Config; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | import android.util.Log; |
| 46 | |
| 47 | import java.net.URISyntaxException; |
| 48 | import java.security.MessageDigest; |
| 49 | import java.security.NoSuchAlgorithmException; |
Vasu Nori | 272af00 | 2009-11-04 16:26:55 -0800 | [diff] [blame] | 50 | import java.util.Collections; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | import java.util.HashMap; |
| 52 | import java.util.HashSet; |
Vasu Nori | 272af00 | 2009-11-04 16:26:55 -0800 | [diff] [blame] | 53 | import java.util.Map; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | |
| 55 | |
| 56 | /** |
| 57 | * The Settings provider contains global system-level device preferences. |
| 58 | */ |
| 59 | public final class Settings { |
| 60 | |
| 61 | // Intent actions for Settings |
| 62 | |
| 63 | /** |
| 64 | * Activity Action: Show system settings. |
| 65 | * <p> |
| 66 | * Input: Nothing. |
| 67 | * <p> |
| 68 | * Output: nothing. |
| 69 | */ |
| 70 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 71 | public static final String ACTION_SETTINGS = "android.settings.SETTINGS"; |
| 72 | |
| 73 | /** |
| 74 | * Activity Action: Show settings to allow configuration of APNs. |
| 75 | * <p> |
| 76 | * Input: Nothing. |
| 77 | * <p> |
| 78 | * Output: nothing. |
| 79 | */ |
| 80 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 81 | public static final String ACTION_APN_SETTINGS = "android.settings.APN_SETTINGS"; |
| 82 | |
| 83 | /** |
| 84 | * Activity Action: Show settings to allow configuration of current location |
| 85 | * sources. |
| 86 | * <p> |
| 87 | * In some cases, a matching Activity may not exist, so ensure you |
| 88 | * safeguard against this. |
| 89 | * <p> |
| 90 | * Input: Nothing. |
| 91 | * <p> |
| 92 | * Output: Nothing. |
| 93 | */ |
| 94 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 95 | public static final String ACTION_LOCATION_SOURCE_SETTINGS = |
| 96 | "android.settings.LOCATION_SOURCE_SETTINGS"; |
| 97 | |
| 98 | /** |
| 99 | * Activity Action: Show settings to allow configuration of wireless controls |
| 100 | * such as Wi-Fi, Bluetooth and Mobile networks. |
| 101 | * <p> |
| 102 | * In some cases, a matching Activity may not exist, so ensure you |
| 103 | * safeguard against this. |
| 104 | * <p> |
| 105 | * Input: Nothing. |
| 106 | * <p> |
| 107 | * Output: Nothing. |
| 108 | */ |
| 109 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 110 | public static final String ACTION_WIRELESS_SETTINGS = |
| 111 | "android.settings.WIRELESS_SETTINGS"; |
| 112 | |
| 113 | /** |
| 114 | * Activity Action: Show settings to allow entering/exiting airplane mode. |
| 115 | * <p> |
| 116 | * In some cases, a matching Activity may not exist, so ensure you |
| 117 | * safeguard against this. |
| 118 | * <p> |
| 119 | * Input: Nothing. |
| 120 | * <p> |
| 121 | * Output: Nothing. |
| 122 | */ |
| 123 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 124 | public static final String ACTION_AIRPLANE_MODE_SETTINGS = |
| 125 | "android.settings.AIRPLANE_MODE_SETTINGS"; |
| 126 | |
| 127 | /** |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 128 | * Activity Action: Show settings for accessibility modules. |
| 129 | * <p> |
| 130 | * In some cases, a matching Activity may not exist, so ensure you |
| 131 | * safeguard against this. |
| 132 | * <p> |
| 133 | * Input: Nothing. |
| 134 | * <p> |
| 135 | * Output: Nothing. |
| 136 | */ |
| 137 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 138 | public static final String ACTION_ACCESSIBILITY_SETTINGS = |
| 139 | "android.settings.ACCESSIBILITY_SETTINGS"; |
| 140 | |
| 141 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | * Activity Action: Show settings to allow configuration of security and |
| 143 | * location privacy. |
| 144 | * <p> |
| 145 | * In some cases, a matching Activity may not exist, so ensure you |
| 146 | * safeguard against this. |
| 147 | * <p> |
| 148 | * Input: Nothing. |
| 149 | * <p> |
| 150 | * Output: Nothing. |
| 151 | */ |
| 152 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 153 | public static final String ACTION_SECURITY_SETTINGS = |
| 154 | "android.settings.SECURITY_SETTINGS"; |
| 155 | |
| 156 | /** |
Amith Yamasani | c15255a | 2009-09-23 15:33:19 -0700 | [diff] [blame] | 157 | * Activity Action: Show settings to allow configuration of privacy options. |
| 158 | * <p> |
| 159 | * In some cases, a matching Activity may not exist, so ensure you |
| 160 | * safeguard against this. |
| 161 | * <p> |
| 162 | * Input: Nothing. |
| 163 | * <p> |
| 164 | * Output: Nothing. |
| 165 | */ |
| 166 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 167 | public static final String ACTION_PRIVACY_SETTINGS = |
| 168 | "android.settings.PRIVACY_SETTINGS"; |
| 169 | |
| 170 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | * Activity Action: Show settings to allow configuration of Wi-Fi. |
| 172 | |
| 173 | * <p> |
| 174 | * In some cases, a matching Activity may not exist, so ensure you |
| 175 | * safeguard against this. |
| 176 | * <p> |
| 177 | * Input: Nothing. |
| 178 | * <p> |
| 179 | * Output: Nothing. |
| 180 | |
| 181 | */ |
| 182 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 183 | public static final String ACTION_WIFI_SETTINGS = |
| 184 | "android.settings.WIFI_SETTINGS"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 185 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 186 | /** |
| 187 | * Activity Action: Show settings to allow configuration of a static IP |
| 188 | * address for Wi-Fi. |
| 189 | * <p> |
| 190 | * In some cases, a matching Activity may not exist, so ensure you safeguard |
| 191 | * against this. |
| 192 | * <p> |
| 193 | * Input: Nothing. |
| 194 | * <p> |
| 195 | * Output: Nothing. |
| 196 | */ |
| 197 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 198 | public static final String ACTION_WIFI_IP_SETTINGS = |
| 199 | "android.settings.WIFI_IP_SETTINGS"; |
| 200 | |
| 201 | /** |
| 202 | * Activity Action: Show settings to allow configuration of Bluetooth. |
| 203 | * <p> |
| 204 | * In some cases, a matching Activity may not exist, so ensure you |
| 205 | * safeguard against this. |
| 206 | * <p> |
| 207 | * Input: Nothing. |
| 208 | * <p> |
| 209 | * Output: Nothing. |
| 210 | */ |
| 211 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 212 | public static final String ACTION_BLUETOOTH_SETTINGS = |
| 213 | "android.settings.BLUETOOTH_SETTINGS"; |
| 214 | |
| 215 | /** |
| 216 | * Activity Action: Show settings to allow configuration of date and time. |
| 217 | * <p> |
| 218 | * In some cases, a matching Activity may not exist, so ensure you |
| 219 | * safeguard against this. |
| 220 | * <p> |
| 221 | * Input: Nothing. |
| 222 | * <p> |
| 223 | * Output: Nothing. |
| 224 | */ |
| 225 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 226 | public static final String ACTION_DATE_SETTINGS = |
| 227 | "android.settings.DATE_SETTINGS"; |
| 228 | |
| 229 | /** |
| 230 | * Activity Action: Show settings to allow configuration of sound and volume. |
| 231 | * <p> |
| 232 | * In some cases, a matching Activity may not exist, so ensure you |
| 233 | * safeguard against this. |
| 234 | * <p> |
| 235 | * Input: Nothing. |
| 236 | * <p> |
| 237 | * Output: Nothing. |
| 238 | */ |
| 239 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 240 | public static final String ACTION_SOUND_SETTINGS = |
| 241 | "android.settings.SOUND_SETTINGS"; |
| 242 | |
| 243 | /** |
| 244 | * Activity Action: Show settings to allow configuration of display. |
| 245 | * <p> |
| 246 | * In some cases, a matching Activity may not exist, so ensure you |
| 247 | * safeguard against this. |
| 248 | * <p> |
| 249 | * Input: Nothing. |
| 250 | * <p> |
| 251 | * Output: Nothing. |
| 252 | */ |
| 253 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 254 | public static final String ACTION_DISPLAY_SETTINGS = |
| 255 | "android.settings.DISPLAY_SETTINGS"; |
| 256 | |
| 257 | /** |
| 258 | * Activity Action: Show settings to allow configuration of locale. |
| 259 | * <p> |
| 260 | * In some cases, a matching Activity may not exist, so ensure you |
| 261 | * safeguard against this. |
| 262 | * <p> |
| 263 | * Input: Nothing. |
| 264 | * <p> |
| 265 | * Output: Nothing. |
| 266 | */ |
| 267 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 268 | public static final String ACTION_LOCALE_SETTINGS = |
| 269 | "android.settings.LOCALE_SETTINGS"; |
| 270 | |
| 271 | /** |
| 272 | * Activity Action: Show settings to configure input methods, in particular |
| 273 | * allowing the user to enable input methods. |
| 274 | * <p> |
| 275 | * In some cases, a matching Activity may not exist, so ensure you |
| 276 | * safeguard against this. |
| 277 | * <p> |
| 278 | * Input: Nothing. |
| 279 | * <p> |
| 280 | * Output: Nothing. |
| 281 | */ |
| 282 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 283 | public static final String ACTION_INPUT_METHOD_SETTINGS = |
| 284 | "android.settings.INPUT_METHOD_SETTINGS"; |
| 285 | |
| 286 | /** |
| 287 | * Activity Action: Show settings to manage the user input dictionary. |
| 288 | * <p> |
| 289 | * In some cases, a matching Activity may not exist, so ensure you |
| 290 | * safeguard against this. |
| 291 | * <p> |
| 292 | * Input: Nothing. |
| 293 | * <p> |
| 294 | * Output: Nothing. |
| 295 | */ |
| 296 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 297 | public static final String ACTION_USER_DICTIONARY_SETTINGS = |
| 298 | "android.settings.USER_DICTIONARY_SETTINGS"; |
| 299 | |
| 300 | /** |
| 301 | * Activity Action: Show settings to allow configuration of application-related settings. |
| 302 | * <p> |
| 303 | * In some cases, a matching Activity may not exist, so ensure you |
| 304 | * safeguard against this. |
| 305 | * <p> |
| 306 | * Input: Nothing. |
| 307 | * <p> |
| 308 | * Output: Nothing. |
| 309 | */ |
| 310 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 311 | public static final String ACTION_APPLICATION_SETTINGS = |
| 312 | "android.settings.APPLICATION_SETTINGS"; |
| 313 | |
| 314 | /** |
| 315 | * Activity Action: Show settings to allow configuration of application |
| 316 | * development-related settings. |
| 317 | * <p> |
| 318 | * In some cases, a matching Activity may not exist, so ensure you safeguard |
| 319 | * against this. |
| 320 | * <p> |
| 321 | * Input: Nothing. |
| 322 | * <p> |
| 323 | * Output: Nothing. |
| 324 | */ |
| 325 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 326 | public static final String ACTION_APPLICATION_DEVELOPMENT_SETTINGS = |
| 327 | "android.settings.APPLICATION_DEVELOPMENT_SETTINGS"; |
| 328 | |
| 329 | /** |
| 330 | * Activity Action: Show settings to allow configuration of quick launch shortcuts. |
| 331 | * <p> |
| 332 | * In some cases, a matching Activity may not exist, so ensure you |
| 333 | * safeguard against this. |
| 334 | * <p> |
| 335 | * Input: Nothing. |
| 336 | * <p> |
| 337 | * Output: Nothing. |
| 338 | */ |
| 339 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 340 | public static final String ACTION_QUICK_LAUNCH_SETTINGS = |
| 341 | "android.settings.QUICK_LAUNCH_SETTINGS"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 342 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | /** |
| 344 | * Activity Action: Show settings to manage installed applications. |
| 345 | * <p> |
| 346 | * In some cases, a matching Activity may not exist, so ensure you |
| 347 | * safeguard against this. |
| 348 | * <p> |
| 349 | * Input: Nothing. |
| 350 | * <p> |
| 351 | * Output: Nothing. |
| 352 | */ |
| 353 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 354 | public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS = |
| 355 | "android.settings.MANAGE_APPLICATIONS_SETTINGS"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 356 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 357 | /** |
| 358 | * Activity Action: Show settings for system update functionality. |
| 359 | * <p> |
| 360 | * In some cases, a matching Activity may not exist, so ensure you |
| 361 | * safeguard against this. |
| 362 | * <p> |
| 363 | * Input: Nothing. |
| 364 | * <p> |
| 365 | * Output: Nothing. |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 366 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 367 | * @hide |
| 368 | */ |
| 369 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 370 | public static final String ACTION_SYSTEM_UPDATE_SETTINGS = |
| 371 | "android.settings.SYSTEM_UPDATE_SETTINGS"; |
| 372 | |
| 373 | /** |
| 374 | * Activity Action: Show settings to allow configuration of sync settings. |
| 375 | * <p> |
| 376 | * In some cases, a matching Activity may not exist, so ensure you |
| 377 | * safeguard against this. |
| 378 | * <p> |
Erik | eebc8e2 | 2010-02-18 13:27:19 -0800 | [diff] [blame] | 379 | * The account types available to add via the add account button may be restricted by adding an |
| 380 | * {@link #EXTRA_AUTHORITIES} extra to this Intent with one or more syncable content provider's |
| 381 | * authorities. Only account types which can sync with that content provider will be offered to |
| 382 | * the user. |
| 383 | * <p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 384 | * Input: Nothing. |
| 385 | * <p> |
| 386 | * Output: Nothing. |
| 387 | */ |
| 388 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 389 | public static final String ACTION_SYNC_SETTINGS = |
| 390 | "android.settings.SYNC_SETTINGS"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 391 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 392 | /** |
Erik | eebc8e2 | 2010-02-18 13:27:19 -0800 | [diff] [blame] | 393 | * Activity Action: Show add account screen for creating a new account. |
| 394 | * <p> |
| 395 | * In some cases, a matching Activity may not exist, so ensure you |
| 396 | * safeguard against this. |
| 397 | * <p> |
| 398 | * The account types available to add may be restricted by adding an {@link #EXTRA_AUTHORITIES} |
| 399 | * extra to the Intent with one or more syncable content provider's authorities. Only account |
| 400 | * types which can sync with that content provider will be offered to the user. |
| 401 | * <p> |
| 402 | * Input: Nothing. |
| 403 | * <p> |
| 404 | * Output: Nothing. |
| 405 | */ |
| 406 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 407 | public static final String ACTION_ADD_ACCOUNT = |
| 408 | "android.settings.ADD_ACCOUNT_SETTINGS"; |
| 409 | |
| 410 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | * Activity Action: Show settings for selecting the network operator. |
| 412 | * <p> |
| 413 | * In some cases, a matching Activity may not exist, so ensure you |
| 414 | * safeguard against this. |
| 415 | * <p> |
| 416 | * Input: Nothing. |
| 417 | * <p> |
| 418 | * Output: Nothing. |
| 419 | */ |
| 420 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 421 | public static final String ACTION_NETWORK_OPERATOR_SETTINGS = |
| 422 | "android.settings.NETWORK_OPERATOR_SETTINGS"; |
| 423 | |
| 424 | /** |
| 425 | * Activity Action: Show settings for selection of 2G/3G. |
| 426 | * <p> |
| 427 | * In some cases, a matching Activity may not exist, so ensure you |
| 428 | * safeguard against this. |
| 429 | * <p> |
| 430 | * Input: Nothing. |
| 431 | * <p> |
| 432 | * Output: Nothing. |
| 433 | */ |
| 434 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 435 | public static final String ACTION_DATA_ROAMING_SETTINGS = |
| 436 | "android.settings.DATA_ROAMING_SETTINGS"; |
| 437 | |
| 438 | /** |
| 439 | * Activity Action: Show settings for internal storage. |
| 440 | * <p> |
| 441 | * In some cases, a matching Activity may not exist, so ensure you |
| 442 | * safeguard against this. |
| 443 | * <p> |
| 444 | * Input: Nothing. |
| 445 | * <p> |
| 446 | * Output: Nothing. |
| 447 | */ |
| 448 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 449 | public static final String ACTION_INTERNAL_STORAGE_SETTINGS = |
| 450 | "android.settings.INTERNAL_STORAGE_SETTINGS"; |
| 451 | /** |
| 452 | * Activity Action: Show settings for memory card storage. |
| 453 | * <p> |
| 454 | * In some cases, a matching Activity may not exist, so ensure you |
| 455 | * safeguard against this. |
| 456 | * <p> |
| 457 | * Input: Nothing. |
| 458 | * <p> |
| 459 | * Output: Nothing. |
| 460 | */ |
| 461 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 462 | public static final String ACTION_MEMORY_CARD_SETTINGS = |
| 463 | "android.settings.MEMORY_CARD_SETTINGS"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 464 | |
Justin Mattson | ef34035 | 2010-01-13 21:05:46 -0800 | [diff] [blame] | 465 | /** |
| 466 | * Activity Action: Show settings for global search. |
| 467 | * <p> |
| 468 | * In some cases, a matching Activity may not exist, so ensure you |
| 469 | * safeguard against this. |
| 470 | * <p> |
| 471 | * Input: Nothing. |
| 472 | * <p> |
| 473 | * Output: Nothing |
| 474 | */ |
| 475 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 476 | public static final String ACTION_SEARCH_SETTINGS = |
| 477 | "android.search.action.SEARCH_SETTINGS"; |
| 478 | |
Daniel Sandler | 9d8b876 | 2010-01-22 20:50:15 -0500 | [diff] [blame] | 479 | /** |
| 480 | * Activity Action: Show general device information settings (serial |
| 481 | * number, software version, phone number, etc.). |
| 482 | * <p> |
| 483 | * In some cases, a matching Activity may not exist, so ensure you |
| 484 | * safeguard against this. |
| 485 | * <p> |
| 486 | * Input: Nothing. |
| 487 | * <p> |
| 488 | * Output: Nothing |
| 489 | */ |
| 490 | @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) |
| 491 | public static final String ACTION_DEVICE_INFO_SETTINGS = |
| 492 | "android.settings.DEVICE_INFO_SETTINGS"; |
| 493 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | // End of Intent actions for Settings |
| 495 | |
Erik | eebc8e2 | 2010-02-18 13:27:19 -0800 | [diff] [blame] | 496 | /** |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 497 | * @hide - Private call() method on SettingsProvider to read from 'system' table. |
| 498 | */ |
| 499 | public static final String CALL_METHOD_GET_SYSTEM = "GET_system"; |
| 500 | |
| 501 | /** |
| 502 | * @hide - Private call() method on SettingsProvider to read from 'secure' table. |
| 503 | */ |
| 504 | public static final String CALL_METHOD_GET_SECURE = "GET_secure"; |
| 505 | |
| 506 | /** |
Erik | eebc8e2 | 2010-02-18 13:27:19 -0800 | [diff] [blame] | 507 | * Activity Extra: Limit available options in launched activity based on the given authority. |
| 508 | * <p> |
| 509 | * This can be passed as an extra field in an Activity Intent with one or more syncable content |
| 510 | * provider's authorities as a String[]. This field is used by some intents to alter the |
| 511 | * behavior of the called activity. |
| 512 | * <p> |
| 513 | * Example: The {@link #ACTION_ADD_ACCOUNT} intent restricts the account types available based |
| 514 | * on the authority given. |
| 515 | */ |
| 516 | public static final String EXTRA_AUTHORITIES = |
| 517 | "authorities"; |
| 518 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 519 | private static final String JID_RESOURCE_PREFIX = "android"; |
| 520 | |
| 521 | public static final String AUTHORITY = "settings"; |
| 522 | |
| 523 | private static final String TAG = "Settings"; |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 524 | private static final boolean LOCAL_LOGV = Config.LOGV || false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 525 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 526 | public static class SettingNotFoundException extends AndroidException { |
| 527 | public SettingNotFoundException(String msg) { |
| 528 | super(msg); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Common base for tables of name/value settings. |
| 534 | */ |
| 535 | public static class NameValueTable implements BaseColumns { |
| 536 | public static final String NAME = "name"; |
| 537 | public static final String VALUE = "value"; |
| 538 | |
| 539 | protected static boolean putString(ContentResolver resolver, Uri uri, |
| 540 | String name, String value) { |
| 541 | // The database will take care of replacing duplicates. |
| 542 | try { |
| 543 | ContentValues values = new ContentValues(); |
| 544 | values.put(NAME, name); |
| 545 | values.put(VALUE, value); |
| 546 | resolver.insert(uri, values); |
| 547 | return true; |
| 548 | } catch (SQLException e) { |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 549 | Log.w(TAG, "Can't set key " + name + " in " + uri, e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | return false; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | public static Uri getUriFor(Uri uri, String name) { |
| 555 | return Uri.withAppendedPath(uri, name); |
| 556 | } |
| 557 | } |
| 558 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 559 | // Thread-safe. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 560 | private static class NameValueCache { |
| 561 | private final String mVersionSystemProperty; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 562 | private final Uri mUri; |
| 563 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 564 | private static final String[] SELECT_VALUE = |
| 565 | new String[] { Settings.NameValueTable.VALUE }; |
| 566 | private static final String NAME_EQ_PLACEHOLDER = "name=?"; |
| 567 | |
| 568 | // Must synchronize on 'this' to access mValues and mValuesVersion. |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 569 | private final HashMap<String, String> mValues = new HashMap<String, String>(); |
| 570 | private long mValuesVersion = 0; |
| 571 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 572 | // Initially null; set lazily and held forever. Synchronized on 'this'. |
| 573 | private IContentProvider mContentProvider = null; |
| 574 | |
| 575 | // The method we'll call (or null, to not use) on the provider |
| 576 | // for the fast path of retrieving settings. |
| 577 | private final String mCallCommand; |
| 578 | |
| 579 | public NameValueCache(String versionSystemProperty, Uri uri, String callCommand) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 580 | mVersionSystemProperty = versionSystemProperty; |
| 581 | mUri = uri; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 582 | mCallCommand = callCommand; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | } |
| 584 | |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 585 | public String getString(ContentResolver cr, String name) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 586 | long newValuesVersion = SystemProperties.getLong(mVersionSystemProperty, 0); |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 587 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 588 | synchronized (this) { |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 589 | if (mValuesVersion != newValuesVersion) { |
| 590 | if (LOCAL_LOGV) { |
| 591 | Log.v(TAG, "invalidate [" + mUri.getLastPathSegment() + "]: current " + |
| 592 | newValuesVersion + " != cached " + mValuesVersion); |
| 593 | } |
| 594 | |
| 595 | mValues.clear(); |
| 596 | mValuesVersion = newValuesVersion; |
| 597 | } |
| 598 | |
| 599 | if (mValues.containsKey(name)) { |
| 600 | return mValues.get(name); // Could be null, that's OK -- negative caching |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 601 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 602 | } |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 603 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 604 | IContentProvider cp = null; |
| 605 | synchronized (this) { |
| 606 | cp = mContentProvider; |
| 607 | if (cp == null) { |
| 608 | cp = mContentProvider = cr.acquireProvider(mUri.getAuthority()); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | // Try the fast path first, not using query(). If this |
| 613 | // fails (alternate Settings provider that doesn't support |
| 614 | // this interface?) then we fall back to the query/table |
| 615 | // interface. |
| 616 | if (mCallCommand != null) { |
| 617 | try { |
| 618 | Bundle b = cp.call(mCallCommand, name, null); |
| 619 | if (b != null) { |
| 620 | String value = b.getPairValue(); |
| 621 | synchronized (this) { |
| 622 | mValues.put(name, value); |
| 623 | } |
| 624 | return value; |
| 625 | } |
| 626 | // If the response Bundle is null, we fall through |
| 627 | // to the query interface below. |
| 628 | } catch (RemoteException e) { |
| 629 | // Not supported by the remote side? Fall through |
| 630 | // to query(). |
| 631 | } |
| 632 | } |
| 633 | |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 634 | Cursor c = null; |
| 635 | try { |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 636 | c = cp.query(mUri, SELECT_VALUE, NAME_EQ_PLACEHOLDER, |
| 637 | new String[]{name}, null); |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 638 | if (c == null) { |
| 639 | Log.w(TAG, "Can't get key " + name + " from " + mUri); |
| 640 | return null; |
| 641 | } |
| 642 | |
| 643 | String value = c.moveToNext() ? c.getString(0) : null; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 644 | synchronized (this) { |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 645 | mValues.put(name, value); |
| 646 | } |
| 647 | if (LOCAL_LOGV) { |
| 648 | Log.v(TAG, "cache miss [" + mUri.getLastPathSegment() + "]: " + |
| 649 | name + " = " + (value == null ? "(null)" : value)); |
| 650 | } |
| 651 | return value; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 652 | } catch (RemoteException e) { |
Dan Egnor | 799f721 | 2009-11-24 16:24:44 -0800 | [diff] [blame] | 653 | Log.w(TAG, "Can't get key " + name + " from " + mUri, e); |
| 654 | return null; // Return null, but don't cache it. |
| 655 | } finally { |
| 656 | if (c != null) c.close(); |
| 657 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 658 | } |
| 659 | } |
| 660 | |
| 661 | /** |
| 662 | * System settings, containing miscellaneous system preferences. This |
| 663 | * table holds simple name/value pairs. There are convenience |
| 664 | * functions for accessing individual settings entries. |
| 665 | */ |
| 666 | public static final class System extends NameValueTable { |
| 667 | public static final String SYS_PROP_SETTING_VERSION = "sys.settings_system_version"; |
| 668 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 669 | // Populated lazily, guarded by class object: |
| 670 | private static NameValueCache sNameValueCache = null; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 671 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 672 | private static final HashSet<String> MOVED_TO_SECURE; |
| 673 | static { |
| 674 | MOVED_TO_SECURE = new HashSet<String>(30); |
| 675 | MOVED_TO_SECURE.add(Secure.ADB_ENABLED); |
| 676 | MOVED_TO_SECURE.add(Secure.ANDROID_ID); |
| 677 | MOVED_TO_SECURE.add(Secure.BLUETOOTH_ON); |
| 678 | MOVED_TO_SECURE.add(Secure.DATA_ROAMING); |
| 679 | MOVED_TO_SECURE.add(Secure.DEVICE_PROVISIONED); |
| 680 | MOVED_TO_SECURE.add(Secure.HTTP_PROXY); |
| 681 | MOVED_TO_SECURE.add(Secure.INSTALL_NON_MARKET_APPS); |
| 682 | MOVED_TO_SECURE.add(Secure.LOCATION_PROVIDERS_ALLOWED); |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 683 | MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED); |
| 684 | MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE); |
| 685 | MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 686 | MOVED_TO_SECURE.add(Secure.LOGGING_ID); |
| 687 | MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED); |
| 688 | MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_LAST_UPDATE); |
| 689 | MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_REDIRECT_URL); |
| 690 | MOVED_TO_SECURE.add(Secure.SETTINGS_CLASSNAME); |
| 691 | MOVED_TO_SECURE.add(Secure.USB_MASS_STORAGE_ENABLED); |
| 692 | MOVED_TO_SECURE.add(Secure.USE_GOOGLE_MAIL); |
| 693 | MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON); |
| 694 | MOVED_TO_SECURE.add(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY); |
| 695 | MOVED_TO_SECURE.add(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT); |
| 696 | MOVED_TO_SECURE.add(Secure.WIFI_ON); |
| 697 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE); |
| 698 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_AP_COUNT); |
| 699 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS); |
| 700 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED); |
| 701 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS); |
| 702 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT); |
| 703 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_MAX_AP_CHECKS); |
| 704 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_ON); |
| 705 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_COUNT); |
| 706 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_DELAY_MS); |
| 707 | MOVED_TO_SECURE.add(Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS); |
| 708 | } |
| 709 | |
| 710 | /** |
| 711 | * Look up a name in the database. |
| 712 | * @param resolver to access the database with |
| 713 | * @param name to look up in the table |
| 714 | * @return the corresponding value, or null if not present |
| 715 | */ |
| 716 | public synchronized static String getString(ContentResolver resolver, String name) { |
| 717 | if (MOVED_TO_SECURE.contains(name)) { |
| 718 | Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System" |
| 719 | + " to android.provider.Settings.Secure, returning read-only value."); |
| 720 | return Secure.getString(resolver, name); |
| 721 | } |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 722 | if (sNameValueCache == null) { |
| 723 | sNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI, |
| 724 | CALL_METHOD_GET_SYSTEM); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 725 | } |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 726 | return sNameValueCache.getString(resolver, name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | /** |
| 730 | * Store a name/value pair into the database. |
| 731 | * @param resolver to access the database with |
| 732 | * @param name to store |
| 733 | * @param value to associate with the name |
| 734 | * @return true if the value was set, false on database errors |
| 735 | */ |
| 736 | public static boolean putString(ContentResolver resolver, String name, String value) { |
| 737 | if (MOVED_TO_SECURE.contains(name)) { |
| 738 | Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System" |
| 739 | + " to android.provider.Settings.Secure, value is unchanged."); |
| 740 | return false; |
| 741 | } |
| 742 | return putString(resolver, CONTENT_URI, name, value); |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * Construct the content URI for a particular name/value pair, |
| 747 | * useful for monitoring changes with a ContentObserver. |
| 748 | * @param name to look up in the table |
| 749 | * @return the corresponding content URI, or null if not present |
| 750 | */ |
| 751 | public static Uri getUriFor(String name) { |
| 752 | if (MOVED_TO_SECURE.contains(name)) { |
| 753 | Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System" |
| 754 | + " to android.provider.Settings.Secure, returning Secure URI."); |
| 755 | return Secure.getUriFor(Secure.CONTENT_URI, name); |
| 756 | } |
| 757 | return getUriFor(CONTENT_URI, name); |
| 758 | } |
| 759 | |
| 760 | /** |
| 761 | * Convenience function for retrieving a single system settings value |
| 762 | * as an integer. Note that internally setting values are always |
| 763 | * stored as strings; this function converts the string to an integer |
| 764 | * for you. The default value will be returned if the setting is |
| 765 | * not defined or not an integer. |
| 766 | * |
| 767 | * @param cr The ContentResolver to access. |
| 768 | * @param name The name of the setting to retrieve. |
| 769 | * @param def Value to return if the setting is not defined. |
| 770 | * |
| 771 | * @return The setting's current value, or 'def' if it is not defined |
| 772 | * or not a valid integer. |
| 773 | */ |
| 774 | public static int getInt(ContentResolver cr, String name, int def) { |
| 775 | String v = getString(cr, name); |
| 776 | try { |
| 777 | return v != null ? Integer.parseInt(v) : def; |
| 778 | } catch (NumberFormatException e) { |
| 779 | return def; |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * Convenience function for retrieving a single system settings value |
| 785 | * as an integer. Note that internally setting values are always |
| 786 | * stored as strings; this function converts the string to an integer |
| 787 | * for you. |
| 788 | * <p> |
| 789 | * This version does not take a default value. If the setting has not |
| 790 | * been set, or the string value is not a number, |
| 791 | * it throws {@link SettingNotFoundException}. |
| 792 | * |
| 793 | * @param cr The ContentResolver to access. |
| 794 | * @param name The name of the setting to retrieve. |
| 795 | * |
| 796 | * @throws SettingNotFoundException Thrown if a setting by the given |
| 797 | * name can't be found or the setting value is not an integer. |
| 798 | * |
| 799 | * @return The setting's current value. |
| 800 | */ |
| 801 | public static int getInt(ContentResolver cr, String name) |
| 802 | throws SettingNotFoundException { |
| 803 | String v = getString(cr, name); |
| 804 | try { |
| 805 | return Integer.parseInt(v); |
| 806 | } catch (NumberFormatException e) { |
| 807 | throw new SettingNotFoundException(name); |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | /** |
| 812 | * Convenience function for updating a single settings value as an |
| 813 | * integer. This will either create a new entry in the table if the |
| 814 | * given name does not exist, or modify the value of the existing row |
| 815 | * with that name. Note that internally setting values are always |
| 816 | * stored as strings, so this function converts the given value to a |
| 817 | * string before storing it. |
| 818 | * |
| 819 | * @param cr The ContentResolver to access. |
| 820 | * @param name The name of the setting to modify. |
| 821 | * @param value The new value for the setting. |
| 822 | * @return true if the value was set, false on database errors |
| 823 | */ |
| 824 | public static boolean putInt(ContentResolver cr, String name, int value) { |
| 825 | return putString(cr, name, Integer.toString(value)); |
| 826 | } |
| 827 | |
| 828 | /** |
| 829 | * Convenience function for retrieving a single system settings value |
| 830 | * as a {@code long}. Note that internally setting values are always |
| 831 | * stored as strings; this function converts the string to a {@code long} |
| 832 | * for you. The default value will be returned if the setting is |
| 833 | * not defined or not a {@code long}. |
| 834 | * |
| 835 | * @param cr The ContentResolver to access. |
| 836 | * @param name The name of the setting to retrieve. |
| 837 | * @param def Value to return if the setting is not defined. |
| 838 | * |
| 839 | * @return The setting's current value, or 'def' if it is not defined |
| 840 | * or not a valid {@code long}. |
| 841 | */ |
| 842 | public static long getLong(ContentResolver cr, String name, long def) { |
| 843 | String valString = getString(cr, name); |
| 844 | long value; |
| 845 | try { |
| 846 | value = valString != null ? Long.parseLong(valString) : def; |
| 847 | } catch (NumberFormatException e) { |
| 848 | value = def; |
| 849 | } |
| 850 | return value; |
| 851 | } |
| 852 | |
| 853 | /** |
| 854 | * Convenience function for retrieving a single system settings value |
| 855 | * as a {@code long}. Note that internally setting values are always |
| 856 | * stored as strings; this function converts the string to a {@code long} |
| 857 | * for you. |
| 858 | * <p> |
| 859 | * This version does not take a default value. If the setting has not |
| 860 | * been set, or the string value is not a number, |
| 861 | * it throws {@link SettingNotFoundException}. |
| 862 | * |
| 863 | * @param cr The ContentResolver to access. |
| 864 | * @param name The name of the setting to retrieve. |
| 865 | * |
| 866 | * @return The setting's current value. |
| 867 | * @throws SettingNotFoundException Thrown if a setting by the given |
| 868 | * name can't be found or the setting value is not an integer. |
| 869 | */ |
| 870 | public static long getLong(ContentResolver cr, String name) |
| 871 | throws SettingNotFoundException { |
| 872 | String valString = getString(cr, name); |
| 873 | try { |
| 874 | return Long.parseLong(valString); |
| 875 | } catch (NumberFormatException e) { |
| 876 | throw new SettingNotFoundException(name); |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * Convenience function for updating a single settings value as a long |
| 882 | * integer. This will either create a new entry in the table if the |
| 883 | * given name does not exist, or modify the value of the existing row |
| 884 | * with that name. Note that internally setting values are always |
| 885 | * stored as strings, so this function converts the given value to a |
| 886 | * string before storing it. |
| 887 | * |
| 888 | * @param cr The ContentResolver to access. |
| 889 | * @param name The name of the setting to modify. |
| 890 | * @param value The new value for the setting. |
| 891 | * @return true if the value was set, false on database errors |
| 892 | */ |
| 893 | public static boolean putLong(ContentResolver cr, String name, long value) { |
| 894 | return putString(cr, name, Long.toString(value)); |
| 895 | } |
| 896 | |
| 897 | /** |
| 898 | * Convenience function for retrieving a single system settings value |
| 899 | * as a floating point number. Note that internally setting values are |
| 900 | * always stored as strings; this function converts the string to an |
| 901 | * float for you. The default value will be returned if the setting |
| 902 | * is not defined or not a valid float. |
| 903 | * |
| 904 | * @param cr The ContentResolver to access. |
| 905 | * @param name The name of the setting to retrieve. |
| 906 | * @param def Value to return if the setting is not defined. |
| 907 | * |
| 908 | * @return The setting's current value, or 'def' if it is not defined |
| 909 | * or not a valid float. |
| 910 | */ |
| 911 | public static float getFloat(ContentResolver cr, String name, float def) { |
| 912 | String v = getString(cr, name); |
| 913 | try { |
| 914 | return v != null ? Float.parseFloat(v) : def; |
| 915 | } catch (NumberFormatException e) { |
| 916 | return def; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * Convenience function for retrieving a single system settings value |
| 922 | * as a float. Note that internally setting values are always |
| 923 | * stored as strings; this function converts the string to a float |
| 924 | * for you. |
| 925 | * <p> |
| 926 | * This version does not take a default value. If the setting has not |
| 927 | * been set, or the string value is not a number, |
| 928 | * it throws {@link SettingNotFoundException}. |
| 929 | * |
| 930 | * @param cr The ContentResolver to access. |
| 931 | * @param name The name of the setting to retrieve. |
| 932 | * |
| 933 | * @throws SettingNotFoundException Thrown if a setting by the given |
| 934 | * name can't be found or the setting value is not a float. |
| 935 | * |
| 936 | * @return The setting's current value. |
| 937 | */ |
| 938 | public static float getFloat(ContentResolver cr, String name) |
| 939 | throws SettingNotFoundException { |
| 940 | String v = getString(cr, name); |
| 941 | try { |
| 942 | return Float.parseFloat(v); |
| 943 | } catch (NumberFormatException e) { |
| 944 | throw new SettingNotFoundException(name); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | /** |
| 949 | * Convenience function for updating a single settings value as a |
| 950 | * floating point number. This will either create a new entry in the |
| 951 | * table if the given name does not exist, or modify the value of the |
| 952 | * existing row with that name. Note that internally setting values |
| 953 | * are always stored as strings, so this function converts the given |
| 954 | * value to a string before storing it. |
| 955 | * |
| 956 | * @param cr The ContentResolver to access. |
| 957 | * @param name The name of the setting to modify. |
| 958 | * @param value The new value for the setting. |
| 959 | * @return true if the value was set, false on database errors |
| 960 | */ |
| 961 | public static boolean putFloat(ContentResolver cr, String name, float value) { |
| 962 | return putString(cr, name, Float.toString(value)); |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Convenience function to read all of the current |
| 967 | * configuration-related settings into a |
| 968 | * {@link Configuration} object. |
| 969 | * |
| 970 | * @param cr The ContentResolver to access. |
| 971 | * @param outConfig Where to place the configuration settings. |
| 972 | */ |
| 973 | public static void getConfiguration(ContentResolver cr, Configuration outConfig) { |
| 974 | outConfig.fontScale = Settings.System.getFloat( |
| 975 | cr, FONT_SCALE, outConfig.fontScale); |
| 976 | if (outConfig.fontScale < 0) { |
| 977 | outConfig.fontScale = 1; |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | /** |
| 982 | * Convenience function to write a batch of configuration-related |
| 983 | * settings from a {@link Configuration} object. |
| 984 | * |
| 985 | * @param cr The ContentResolver to access. |
| 986 | * @param config The settings to write. |
| 987 | * @return true if the values were set, false on database errors |
| 988 | */ |
| 989 | public static boolean putConfiguration(ContentResolver cr, Configuration config) { |
| 990 | return Settings.System.putFloat(cr, FONT_SCALE, config.fontScale); |
| 991 | } |
| 992 | |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 993 | /** @hide */ |
| 994 | public static boolean hasInterestingConfigurationChanges(int changes) { |
| 995 | return (changes&ActivityInfo.CONFIG_FONT_SCALE) != 0; |
| 996 | } |
| 997 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 998 | public static boolean getShowGTalkServiceStatus(ContentResolver cr) { |
| 999 | return getInt(cr, SHOW_GTALK_SERVICE_STATUS, 0) != 0; |
| 1000 | } |
| 1001 | |
| 1002 | public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) { |
| 1003 | putInt(cr, SHOW_GTALK_SERVICE_STATUS, flag ? 1 : 0); |
| 1004 | } |
| 1005 | |
| 1006 | /** |
| 1007 | * The content:// style URL for this table |
| 1008 | */ |
| 1009 | public static final Uri CONTENT_URI = |
| 1010 | Uri.parse("content://" + AUTHORITY + "/system"); |
| 1011 | |
| 1012 | /** |
| 1013 | * Whether we keep the device on while the device is plugged in. |
| 1014 | * Supported values are: |
| 1015 | * <ul> |
| 1016 | * <li>{@code 0} to never stay on while plugged in</li> |
| 1017 | * <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li> |
| 1018 | * <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li> |
| 1019 | * </ul> |
| 1020 | * These values can be OR-ed together. |
| 1021 | */ |
| 1022 | public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in"; |
| 1023 | |
| 1024 | /** |
| 1025 | * What happens when the user presses the end call button if they're not |
| 1026 | * on a call.<br/> |
| 1027 | * <b>Values:</b><br/> |
| 1028 | * 0 - The end button does nothing.<br/> |
| 1029 | * 1 - The end button goes to the home screen.<br/> |
| 1030 | * 2 - The end button puts the device to sleep and locks the keyguard.<br/> |
| 1031 | * 3 - The end button goes to the home screen. If the user is already on the |
| 1032 | * home screen, it puts the device to sleep. |
| 1033 | */ |
| 1034 | public static final String END_BUTTON_BEHAVIOR = "end_button_behavior"; |
| 1035 | |
| 1036 | /** |
David Brown | 458e806 | 2010-03-08 21:52:11 -0800 | [diff] [blame] | 1037 | * END_BUTTON_BEHAVIOR value for "go home". |
| 1038 | * @hide |
| 1039 | */ |
| 1040 | public static final int END_BUTTON_BEHAVIOR_HOME = 0x1; |
| 1041 | |
| 1042 | /** |
| 1043 | * END_BUTTON_BEHAVIOR value for "go to sleep". |
| 1044 | * @hide |
| 1045 | */ |
| 1046 | public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2; |
| 1047 | |
| 1048 | /** |
| 1049 | * END_BUTTON_BEHAVIOR default value. |
| 1050 | * @hide |
| 1051 | */ |
| 1052 | public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP; |
| 1053 | |
| 1054 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1055 | * Whether Airplane Mode is on. |
| 1056 | */ |
| 1057 | public static final String AIRPLANE_MODE_ON = "airplane_mode_on"; |
| 1058 | |
| 1059 | /** |
| 1060 | * Constant for use in AIRPLANE_MODE_RADIOS to specify Bluetooth radio. |
| 1061 | */ |
| 1062 | public static final String RADIO_BLUETOOTH = "bluetooth"; |
| 1063 | |
| 1064 | /** |
| 1065 | * Constant for use in AIRPLANE_MODE_RADIOS to specify Wi-Fi radio. |
| 1066 | */ |
| 1067 | public static final String RADIO_WIFI = "wifi"; |
| 1068 | |
| 1069 | /** |
| 1070 | * Constant for use in AIRPLANE_MODE_RADIOS to specify Cellular radio. |
| 1071 | */ |
| 1072 | public static final String RADIO_CELL = "cell"; |
| 1073 | |
| 1074 | /** |
| 1075 | * A comma separated list of radios that need to be disabled when airplane mode |
| 1076 | * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are |
| 1077 | * included in the comma separated list. |
| 1078 | */ |
| 1079 | public static final String AIRPLANE_MODE_RADIOS = "airplane_mode_radios"; |
| 1080 | |
| 1081 | /** |
Mike Lockwood | bd5ddf0 | 2009-07-29 21:37:14 -0700 | [diff] [blame] | 1082 | * A comma separated list of radios that should to be disabled when airplane mode |
| 1083 | * is on, but can be manually reenabled by the user. For example, if RADIO_WIFI is |
| 1084 | * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi |
| 1085 | * will be turned off when entering airplane mode, but the user will be able to reenable |
| 1086 | * Wifi in the Settings app. |
| 1087 | * |
| 1088 | * {@hide} |
| 1089 | */ |
| 1090 | public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios"; |
| 1091 | |
| 1092 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1093 | * The policy for deciding when Wi-Fi should go to sleep (which will in |
| 1094 | * turn switch to using the mobile data as an Internet connection). |
| 1095 | * <p> |
| 1096 | * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT}, |
| 1097 | * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or |
| 1098 | * {@link #WIFI_SLEEP_POLICY_NEVER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1099 | */ |
| 1100 | public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy"; |
| 1101 | |
| 1102 | /** |
| 1103 | * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep |
| 1104 | * policy, which is to sleep shortly after the turning off |
| 1105 | * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1106 | */ |
| 1107 | public static final int WIFI_SLEEP_POLICY_DEFAULT = 0; |
| 1108 | |
| 1109 | /** |
| 1110 | * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when |
| 1111 | * the device is on battery, and never go to sleep when the device is |
| 1112 | * plugged in. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1113 | */ |
| 1114 | public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1115 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1116 | /** |
| 1117 | * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1118 | */ |
| 1119 | public static final int WIFI_SLEEP_POLICY_NEVER = 2; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1120 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1121 | /** |
| 1122 | * Whether to use static IP and other static network attributes. |
| 1123 | * <p> |
| 1124 | * Set to 1 for true and 0 for false. |
| 1125 | */ |
| 1126 | public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip"; |
| 1127 | |
| 1128 | /** |
| 1129 | * The static IP address. |
| 1130 | * <p> |
| 1131 | * Example: "192.168.1.51" |
| 1132 | */ |
| 1133 | public static final String WIFI_STATIC_IP = "wifi_static_ip"; |
| 1134 | |
| 1135 | /** |
| 1136 | * If using static IP, the gateway's IP address. |
| 1137 | * <p> |
| 1138 | * Example: "192.168.1.1" |
| 1139 | */ |
| 1140 | public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway"; |
| 1141 | |
| 1142 | /** |
| 1143 | * If using static IP, the net mask. |
| 1144 | * <p> |
| 1145 | * Example: "255.255.255.0" |
| 1146 | */ |
| 1147 | public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask"; |
| 1148 | |
| 1149 | /** |
| 1150 | * If using static IP, the primary DNS's IP address. |
| 1151 | * <p> |
| 1152 | * Example: "192.168.1.1" |
| 1153 | */ |
| 1154 | public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1"; |
| 1155 | |
| 1156 | /** |
| 1157 | * If using static IP, the secondary DNS's IP address. |
| 1158 | * <p> |
| 1159 | * Example: "192.168.1.2" |
| 1160 | */ |
| 1161 | public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2"; |
| 1162 | |
| 1163 | /** |
| 1164 | * The number of radio channels that are allowed in the local |
| 1165 | * 802.11 regulatory domain. |
| 1166 | * @hide |
| 1167 | */ |
| 1168 | public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels"; |
| 1169 | |
| 1170 | /** |
| 1171 | * Determines whether remote devices may discover and/or connect to |
| 1172 | * this device. |
| 1173 | * <P>Type: INT</P> |
| 1174 | * 2 -- discoverable and connectable |
| 1175 | * 1 -- connectable but not discoverable |
| 1176 | * 0 -- neither connectable nor discoverable |
| 1177 | */ |
| 1178 | public static final String BLUETOOTH_DISCOVERABILITY = |
| 1179 | "bluetooth_discoverability"; |
| 1180 | |
| 1181 | /** |
| 1182 | * Bluetooth discoverability timeout. If this value is nonzero, then |
| 1183 | * Bluetooth becomes discoverable for a certain number of seconds, |
| 1184 | * after which is becomes simply connectable. The value is in seconds. |
| 1185 | */ |
| 1186 | public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT = |
| 1187 | "bluetooth_discoverability_timeout"; |
| 1188 | |
| 1189 | /** |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1190 | * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_ENABLED} |
| 1191 | * instead |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1192 | */ |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1193 | @Deprecated |
| 1194 | public static final String LOCK_PATTERN_ENABLED = Secure.LOCK_PATTERN_ENABLED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1195 | |
| 1196 | /** |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1197 | * @deprecated Use {@link android.provider.Settings.Secure#LOCK_PATTERN_VISIBLE} |
| 1198 | * instead |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1199 | */ |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1200 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1201 | public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern"; |
| 1202 | |
| 1203 | /** |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1204 | * @deprecated Use |
| 1205 | * {@link android.provider.Settings.Secure#LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED} |
| 1206 | * instead |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1207 | */ |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 1208 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1209 | public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = |
| 1210 | "lock_pattern_tactile_feedback_enabled"; |
| 1211 | |
| 1212 | |
| 1213 | /** |
| 1214 | * A formatted string of the next alarm that is set, or the empty string |
| 1215 | * if there is no alarm set. |
| 1216 | */ |
| 1217 | public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted"; |
| 1218 | |
| 1219 | /** |
| 1220 | * Scaling factor for fonts, float. |
| 1221 | */ |
| 1222 | public static final String FONT_SCALE = "font_scale"; |
| 1223 | |
| 1224 | /** |
| 1225 | * Name of an application package to be debugged. |
| 1226 | */ |
| 1227 | public static final String DEBUG_APP = "debug_app"; |
| 1228 | |
| 1229 | /** |
| 1230 | * If 1, when launching DEBUG_APP it will wait for the debugger before |
| 1231 | * starting user code. If 0, it will run normally. |
| 1232 | */ |
| 1233 | public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger"; |
| 1234 | |
| 1235 | /** |
| 1236 | * Whether or not to dim the screen. 0=no 1=yes |
| 1237 | */ |
| 1238 | public static final String DIM_SCREEN = "dim_screen"; |
| 1239 | |
| 1240 | /** |
| 1241 | * The timeout before the screen turns off. |
| 1242 | */ |
| 1243 | public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout"; |
| 1244 | |
| 1245 | /** |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1246 | * If 0, the compatibility mode is off for all applications. |
| 1247 | * If 1, older applications run under compatibility mode. |
| 1248 | * TODO: remove this settings before code freeze (bug/1907571) |
| 1249 | * @hide |
| 1250 | */ |
| 1251 | public static final String COMPATIBILITY_MODE = "compatibility_mode"; |
| 1252 | |
| 1253 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1254 | * The screen backlight brightness between 0 and 255. |
| 1255 | */ |
| 1256 | public static final String SCREEN_BRIGHTNESS = "screen_brightness"; |
| 1257 | |
| 1258 | /** |
Dan Murphy | 951764b | 2009-08-27 14:59:03 -0500 | [diff] [blame] | 1259 | * Control whether to enable automatic brightness mode. |
Dan Murphy | 951764b | 2009-08-27 14:59:03 -0500 | [diff] [blame] | 1260 | */ |
| 1261 | public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode"; |
| 1262 | |
| 1263 | /** |
Mike Lockwood | dc3494e | 2009-10-14 21:17:09 -0700 | [diff] [blame] | 1264 | * SCREEN_BRIGHTNESS_MODE value for manual mode. |
Mike Lockwood | dc3494e | 2009-10-14 21:17:09 -0700 | [diff] [blame] | 1265 | */ |
| 1266 | public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0; |
| 1267 | |
| 1268 | /** |
| 1269 | * SCREEN_BRIGHTNESS_MODE value for manual mode. |
Mike Lockwood | dc3494e | 2009-10-14 21:17:09 -0700 | [diff] [blame] | 1270 | */ |
| 1271 | public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; |
| 1272 | |
| 1273 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1274 | * Control whether the process CPU usage meter should be shown. |
| 1275 | */ |
| 1276 | public static final String SHOW_PROCESSES = "show_processes"; |
| 1277 | |
| 1278 | /** |
| 1279 | * If 1, the activity manager will aggressively finish activities and |
| 1280 | * processes as soon as they are no longer needed. If 0, the normal |
| 1281 | * extended lifetime is used. |
| 1282 | */ |
| 1283 | public static final String ALWAYS_FINISH_ACTIVITIES = |
| 1284 | "always_finish_activities"; |
| 1285 | |
| 1286 | |
| 1287 | /** |
| 1288 | * Ringer mode. This is used internally, changing this value will not |
| 1289 | * change the ringer mode. See AudioManager. |
| 1290 | */ |
| 1291 | public static final String MODE_RINGER = "mode_ringer"; |
| 1292 | |
| 1293 | /** |
| 1294 | * Determines which streams are affected by ringer mode changes. The |
| 1295 | * stream type's bit should be set to 1 if it should be muted when going |
| 1296 | * into an inaudible ringer mode. |
| 1297 | */ |
| 1298 | public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected"; |
| 1299 | |
| 1300 | /** |
| 1301 | * Determines which streams are affected by mute. The |
| 1302 | * stream type's bit should be set to 1 if it should be muted when a mute request |
| 1303 | * is received. |
| 1304 | */ |
| 1305 | public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected"; |
| 1306 | |
| 1307 | /** |
| 1308 | * Whether vibrate is on for different events. This is used internally, |
| 1309 | * changing this value will not change the vibrate. See AudioManager. |
| 1310 | */ |
| 1311 | public static final String VIBRATE_ON = "vibrate_on"; |
| 1312 | |
| 1313 | /** |
| 1314 | * Ringer volume. This is used internally, changing this value will not |
| 1315 | * change the volume. See AudioManager. |
| 1316 | */ |
| 1317 | public static final String VOLUME_RING = "volume_ring"; |
| 1318 | |
| 1319 | /** |
| 1320 | * System/notifications volume. This is used internally, changing this |
| 1321 | * value will not change the volume. See AudioManager. |
| 1322 | */ |
| 1323 | public static final String VOLUME_SYSTEM = "volume_system"; |
| 1324 | |
| 1325 | /** |
| 1326 | * Voice call volume. This is used internally, changing this value will |
| 1327 | * not change the volume. See AudioManager. |
| 1328 | */ |
| 1329 | public static final String VOLUME_VOICE = "volume_voice"; |
| 1330 | |
| 1331 | /** |
| 1332 | * Music/media/gaming volume. This is used internally, changing this |
| 1333 | * value will not change the volume. See AudioManager. |
| 1334 | */ |
| 1335 | public static final String VOLUME_MUSIC = "volume_music"; |
| 1336 | |
| 1337 | /** |
| 1338 | * Alarm volume. This is used internally, changing this |
| 1339 | * value will not change the volume. See AudioManager. |
| 1340 | */ |
| 1341 | public static final String VOLUME_ALARM = "volume_alarm"; |
| 1342 | |
| 1343 | /** |
| 1344 | * Notification volume. This is used internally, changing this |
| 1345 | * value will not change the volume. See AudioManager. |
| 1346 | */ |
| 1347 | public static final String VOLUME_NOTIFICATION = "volume_notification"; |
| 1348 | |
| 1349 | /** |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 1350 | * Bluetooth Headset volume. This is used internally, changing this value will |
| 1351 | * not change the volume. See AudioManager. |
| 1352 | */ |
| 1353 | public static final String VOLUME_BLUETOOTH_SCO = "volume_bluetooth_sco"; |
| 1354 | |
| 1355 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1356 | * Whether the notifications should use the ring volume (value of 1) or |
| 1357 | * a separate notification volume (value of 0). In most cases, users |
| 1358 | * will have this enabled so the notification and ringer volumes will be |
| 1359 | * the same. However, power users can disable this and use the separate |
| 1360 | * notification volume control. |
| 1361 | * <p> |
| 1362 | * Note: This is a one-off setting that will be removed in the future |
| 1363 | * when there is profile support. For this reason, it is kept hidden |
| 1364 | * from the public APIs. |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1365 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1366 | * @hide |
| 1367 | */ |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1368 | public static final String NOTIFICATIONS_USE_RING_VOLUME = |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1369 | "notifications_use_ring_volume"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1370 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1371 | /** |
Daniel Sandler | 6329bf7 | 2010-02-26 15:17:44 -0500 | [diff] [blame] | 1372 | * Whether silent mode should allow vibration feedback. This is used |
| 1373 | * internally in AudioService and the Sound settings activity to |
| 1374 | * coordinate decoupling of vibrate and silent modes. This setting |
| 1375 | * will likely be removed in a future release with support for |
| 1376 | * audio/vibe feedback profiles. |
| 1377 | * |
| 1378 | * @hide |
| 1379 | */ |
| 1380 | public static final String VIBRATE_IN_SILENT = "vibrate_in_silent"; |
| 1381 | |
| 1382 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1383 | * The mapping of stream type (integer) to its setting. |
| 1384 | */ |
| 1385 | public static final String[] VOLUME_SETTINGS = { |
| 1386 | VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC, |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 1387 | VOLUME_ALARM, VOLUME_NOTIFICATION, VOLUME_BLUETOOTH_SCO |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1388 | }; |
| 1389 | |
| 1390 | /** |
| 1391 | * Appended to various volume related settings to record the previous |
| 1392 | * values before they the settings were affected by a silent/vibrate |
| 1393 | * ringer mode change. |
| 1394 | */ |
| 1395 | public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible"; |
| 1396 | |
| 1397 | /** |
| 1398 | * Persistent store for the system-wide default ringtone URI. |
| 1399 | * <p> |
| 1400 | * If you need to play the default ringtone at any given time, it is recommended |
| 1401 | * you give {@link #DEFAULT_RINGTONE_URI} to the media player. It will resolve |
| 1402 | * to the set default ringtone at the time of playing. |
| 1403 | * |
| 1404 | * @see #DEFAULT_RINGTONE_URI |
| 1405 | */ |
| 1406 | public static final String RINGTONE = "ringtone"; |
| 1407 | |
| 1408 | /** |
| 1409 | * A {@link Uri} that will point to the current default ringtone at any |
| 1410 | * given time. |
| 1411 | * <p> |
| 1412 | * If the current default ringtone is in the DRM provider and the caller |
| 1413 | * does not have permission, the exception will be a |
| 1414 | * FileNotFoundException. |
| 1415 | */ |
| 1416 | public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE); |
| 1417 | |
| 1418 | /** |
| 1419 | * Persistent store for the system-wide default notification sound. |
| 1420 | * |
| 1421 | * @see #RINGTONE |
| 1422 | * @see #DEFAULT_NOTIFICATION_URI |
| 1423 | */ |
| 1424 | public static final String NOTIFICATION_SOUND = "notification_sound"; |
| 1425 | |
| 1426 | /** |
| 1427 | * A {@link Uri} that will point to the current default notification |
| 1428 | * sound at any given time. |
| 1429 | * |
| 1430 | * @see #DEFAULT_RINGTONE_URI |
| 1431 | */ |
| 1432 | public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND); |
| 1433 | |
| 1434 | /** |
Patrick Scott | 3156bb00 | 2009-04-13 09:57:38 -0700 | [diff] [blame] | 1435 | * Persistent store for the system-wide default alarm alert. |
| 1436 | * |
| 1437 | * @see #RINGTONE |
| 1438 | * @see #DEFAULT_ALARM_ALERT_URI |
| 1439 | */ |
| 1440 | public static final String ALARM_ALERT = "alarm_alert"; |
| 1441 | |
| 1442 | /** |
| 1443 | * A {@link Uri} that will point to the current default alarm alert at |
| 1444 | * any given time. |
| 1445 | * |
| 1446 | * @see #DEFAULT_ALARM_ALERT_URI |
| 1447 | */ |
| 1448 | public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT); |
| 1449 | |
| 1450 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1451 | * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off |
| 1452 | */ |
| 1453 | public static final String TEXT_AUTO_REPLACE = "auto_replace"; |
| 1454 | |
| 1455 | /** |
| 1456 | * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off |
| 1457 | */ |
| 1458 | public static final String TEXT_AUTO_CAPS = "auto_caps"; |
| 1459 | |
| 1460 | /** |
| 1461 | * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This |
| 1462 | * feature converts two spaces to a "." and space. |
| 1463 | */ |
| 1464 | public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1465 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1466 | /** |
| 1467 | * Setting to showing password characters in text editors. 1 = On, 0 = Off |
| 1468 | */ |
| 1469 | public static final String TEXT_SHOW_PASSWORD = "show_password"; |
| 1470 | |
| 1471 | public static final String SHOW_GTALK_SERVICE_STATUS = |
| 1472 | "SHOW_GTALK_SERVICE_STATUS"; |
| 1473 | |
| 1474 | /** |
| 1475 | * Name of activity to use for wallpaper on the home screen. |
| 1476 | */ |
| 1477 | public static final String WALLPAPER_ACTIVITY = "wallpaper_activity"; |
| 1478 | |
| 1479 | /** |
| 1480 | * Value to specify if the user prefers the date, time and time zone |
| 1481 | * to be automatically fetched from the network (NITZ). 1=yes, 0=no |
| 1482 | */ |
| 1483 | public static final String AUTO_TIME = "auto_time"; |
| 1484 | |
| 1485 | /** |
| 1486 | * Display times as 12 or 24 hours |
| 1487 | * 12 |
| 1488 | * 24 |
| 1489 | */ |
| 1490 | public static final String TIME_12_24 = "time_12_24"; |
| 1491 | |
| 1492 | /** |
| 1493 | * Date format string |
| 1494 | * mm/dd/yyyy |
| 1495 | * dd/mm/yyyy |
| 1496 | * yyyy/mm/dd |
| 1497 | */ |
| 1498 | public static final String DATE_FORMAT = "date_format"; |
| 1499 | |
| 1500 | /** |
| 1501 | * Whether the setup wizard has been run before (on first boot), or if |
| 1502 | * it still needs to be run. |
| 1503 | * |
| 1504 | * nonzero = it has been run in the past |
| 1505 | * 0 = it has not been run in the past |
| 1506 | */ |
| 1507 | public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run"; |
| 1508 | |
| 1509 | /** |
| 1510 | * Scaling factor for normal window animations. Setting to 0 will disable window |
| 1511 | * animations. |
| 1512 | */ |
| 1513 | public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale"; |
| 1514 | |
| 1515 | /** |
| 1516 | * Scaling factor for activity transition animations. Setting to 0 will disable window |
| 1517 | * animations. |
| 1518 | */ |
| 1519 | public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale"; |
| 1520 | |
| 1521 | /** |
| 1522 | * Scaling factor for normal window animations. Setting to 0 will disable window |
| 1523 | * animations. |
| 1524 | * @hide |
| 1525 | */ |
| 1526 | public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations"; |
| 1527 | |
| 1528 | /** |
| 1529 | * Control whether the accelerometer will be used to change screen |
| 1530 | * orientation. If 0, it will not be used unless explicitly requested |
| 1531 | * by the application; if 1, it will be used by default unless explicitly |
| 1532 | * disabled by the application. |
| 1533 | */ |
| 1534 | public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation"; |
| 1535 | |
| 1536 | /** |
| 1537 | * Whether the audible DTMF tones are played by the dialer when dialing. The value is |
| 1538 | * boolean (1 or 0). |
| 1539 | */ |
| 1540 | public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone"; |
| 1541 | |
| 1542 | /** |
David Krause | d0f6715 | 2009-06-13 18:01:13 -0500 | [diff] [blame] | 1543 | * CDMA only settings |
| 1544 | * DTMF tone type played by the dialer when dialing. |
| 1545 | * 0 = Normal |
| 1546 | * 1 = Long |
| 1547 | * @hide |
| 1548 | */ |
| 1549 | public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type"; |
| 1550 | |
| 1551 | /** |
| 1552 | * CDMA only settings |
| 1553 | * Emergency Tone 0 = Off |
| 1554 | * 1 = Alert |
| 1555 | * 2 = Vibrate |
| 1556 | * @hide |
| 1557 | */ |
| 1558 | public static final String EMERGENCY_TONE = "emergency_tone"; |
| 1559 | |
| 1560 | /** |
| 1561 | * CDMA only settings |
| 1562 | * Whether the auto retry is enabled. The value is |
| 1563 | * boolean (1 or 0). |
| 1564 | * @hide |
| 1565 | */ |
| 1566 | public static final String CALL_AUTO_RETRY = "call_auto_retry"; |
| 1567 | |
| 1568 | /** |
| 1569 | * Whether the hearing aid is enabled. The value is |
| 1570 | * boolean (1 or 0). |
| 1571 | * @hide |
| 1572 | */ |
| 1573 | public static final String HEARING_AID = "hearing_aid"; |
| 1574 | |
| 1575 | /** |
| 1576 | * CDMA only settings |
| 1577 | * TTY Mode |
| 1578 | * 0 = OFF |
| 1579 | * 1 = FULL |
| 1580 | * 2 = VCO |
| 1581 | * 3 = HCO |
| 1582 | * @hide |
| 1583 | */ |
| 1584 | public static final String TTY_MODE = "tty_mode"; |
| 1585 | |
| 1586 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1587 | * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is |
| 1588 | * boolean (1 or 0). |
| 1589 | */ |
| 1590 | public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1591 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1592 | /** |
| 1593 | * Whether the haptic feedback (long presses, ...) are enabled. The value is |
| 1594 | * boolean (1 or 0). |
| 1595 | */ |
| 1596 | public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled"; |
Sanjay Jeyakumar | 21bf241 | 2009-07-09 13:31:48 -0700 | [diff] [blame] | 1597 | |
Mike LeBeau | 48603e7 | 2009-06-05 00:27:00 +0100 | [diff] [blame] | 1598 | /** |
| 1599 | * Whether live web suggestions while the user types into search dialogs are |
| 1600 | * enabled. Browsers and other search UIs should respect this, as it allows |
| 1601 | * a user to avoid sending partial queries to a search engine, if it poses |
| 1602 | * any privacy concern. The value is boolean (1 or 0). |
| 1603 | */ |
| 1604 | public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1605 | |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 1606 | /** |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 1607 | * Whether the notification LED should repeatedly flash when a notification is |
| 1608 | * pending. The value is boolean (1 or 0). |
| 1609 | * @hide |
| 1610 | */ |
| 1611 | public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse"; |
| 1612 | |
| 1613 | /** |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 1614 | * Let user pick default install location. |
| 1615 | * @hide |
| 1616 | */ |
| 1617 | public static final String SET_INSTALL_LOCATION = "set_install_location"; |
| 1618 | |
| 1619 | /** |
| 1620 | * Default install location value. |
| 1621 | * 0 = auto, let system decide |
| 1622 | * 1 = internal |
| 1623 | * 2 = sdcard |
| 1624 | * @hide |
| 1625 | */ |
| 1626 | public static final String DEFAULT_INSTALL_LOCATION = "default_install_location"; |
| 1627 | |
| 1628 | /** |
Dianne Hackborn | 90d2db3 | 2010-02-11 22:19:06 -0800 | [diff] [blame] | 1629 | * Show pointer location on screen? |
| 1630 | * 0 = no |
| 1631 | * 1 = yes |
| 1632 | * @hide |
| 1633 | */ |
| 1634 | public static final String POINTER_LOCATION = "pointer_location"; |
| 1635 | |
| 1636 | /** |
Daniel Sandler | 0e9d2af | 2010-01-25 11:33:03 -0500 | [diff] [blame] | 1637 | * Whether to play a sound for low-battery alerts. |
| 1638 | * @hide |
| 1639 | */ |
| 1640 | public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled"; |
| 1641 | |
| 1642 | /** |
| 1643 | * Whether to play a sound for dock events. |
| 1644 | * @hide |
| 1645 | */ |
| 1646 | public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled"; |
| 1647 | |
| 1648 | /** |
| 1649 | * Whether to play sounds when the keyguard is shown and dismissed. |
| 1650 | * @hide |
| 1651 | */ |
| 1652 | public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled"; |
| 1653 | |
| 1654 | /** |
| 1655 | * URI for the low battery sound file. |
| 1656 | * @hide |
| 1657 | */ |
| 1658 | public static final String LOW_BATTERY_SOUND = "low_battery_sound"; |
| 1659 | |
| 1660 | /** |
| 1661 | * URI for the desk dock "in" event sound. |
| 1662 | * @hide |
| 1663 | */ |
| 1664 | public static final String DESK_DOCK_SOUND = "desk_dock_sound"; |
| 1665 | |
| 1666 | /** |
| 1667 | * URI for the desk dock "out" event sound. |
| 1668 | * @hide |
| 1669 | */ |
| 1670 | public static final String DESK_UNDOCK_SOUND = "desk_undock_sound"; |
| 1671 | |
| 1672 | /** |
| 1673 | * URI for the car dock "in" event sound. |
| 1674 | * @hide |
| 1675 | */ |
| 1676 | public static final String CAR_DOCK_SOUND = "car_dock_sound"; |
| 1677 | |
| 1678 | /** |
| 1679 | * URI for the car dock "out" event sound. |
| 1680 | * @hide |
| 1681 | */ |
| 1682 | public static final String CAR_UNDOCK_SOUND = "car_undock_sound"; |
| 1683 | |
| 1684 | /** |
| 1685 | * URI for the "device locked" (keyguard shown) sound. |
| 1686 | * @hide |
| 1687 | */ |
| 1688 | public static final String LOCK_SOUND = "lock_sound"; |
| 1689 | |
| 1690 | /** |
| 1691 | * URI for the "device unlocked" (keyguard dismissed) sound. |
| 1692 | * @hide |
| 1693 | */ |
| 1694 | public static final String UNLOCK_SOUND = "unlock_sound"; |
| 1695 | |
| 1696 | /** |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 1697 | * Settings to backup. This is here so that it's in the same place as the settings |
| 1698 | * keys and easy to update. |
| 1699 | * @hide |
| 1700 | */ |
| 1701 | public static final String[] SETTINGS_TO_BACKUP = { |
| 1702 | STAY_ON_WHILE_PLUGGED_IN, |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 1703 | WIFI_SLEEP_POLICY, |
| 1704 | WIFI_USE_STATIC_IP, |
| 1705 | WIFI_STATIC_IP, |
| 1706 | WIFI_STATIC_GATEWAY, |
| 1707 | WIFI_STATIC_NETMASK, |
| 1708 | WIFI_STATIC_DNS1, |
| 1709 | WIFI_STATIC_DNS2, |
| 1710 | BLUETOOTH_DISCOVERABILITY, |
| 1711 | BLUETOOTH_DISCOVERABILITY_TIMEOUT, |
| 1712 | DIM_SCREEN, |
| 1713 | SCREEN_OFF_TIMEOUT, |
| 1714 | SCREEN_BRIGHTNESS, |
Christopher Tate | 362aca6 | 2009-09-25 15:58:03 -0700 | [diff] [blame] | 1715 | SCREEN_BRIGHTNESS_MODE, |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 1716 | VIBRATE_ON, |
| 1717 | NOTIFICATIONS_USE_RING_VOLUME, |
Amith Yamasani | 8823c0a8 | 2009-07-07 14:30:17 -0700 | [diff] [blame] | 1718 | MODE_RINGER, |
| 1719 | MODE_RINGER_STREAMS_AFFECTED, |
| 1720 | MUTE_STREAMS_AFFECTED, |
| 1721 | VOLUME_VOICE, |
| 1722 | VOLUME_SYSTEM, |
| 1723 | VOLUME_RING, |
| 1724 | VOLUME_MUSIC, |
| 1725 | VOLUME_ALARM, |
| 1726 | VOLUME_NOTIFICATION, |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 1727 | VOLUME_BLUETOOTH_SCO, |
Amith Yamasani | 8823c0a8 | 2009-07-07 14:30:17 -0700 | [diff] [blame] | 1728 | VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE, |
| 1729 | VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE, |
| 1730 | VOLUME_RING + APPEND_FOR_LAST_AUDIBLE, |
| 1731 | VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE, |
| 1732 | VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE, |
| 1733 | VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE, |
Eric Laurent | 484d288 | 2009-12-08 09:05:45 -0800 | [diff] [blame] | 1734 | VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE, |
Daniel Sandler | 1c7fa48 | 2010-03-10 09:45:01 -0500 | [diff] [blame] | 1735 | VIBRATE_IN_SILENT, |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 1736 | TEXT_AUTO_REPLACE, |
| 1737 | TEXT_AUTO_CAPS, |
| 1738 | TEXT_AUTO_PUNCTUATE, |
| 1739 | TEXT_SHOW_PASSWORD, |
| 1740 | AUTO_TIME, |
| 1741 | TIME_12_24, |
| 1742 | DATE_FORMAT, |
| 1743 | ACCELEROMETER_ROTATION, |
| 1744 | DTMF_TONE_WHEN_DIALING, |
| 1745 | DTMF_TONE_TYPE_WHEN_DIALING, |
| 1746 | EMERGENCY_TONE, |
| 1747 | CALL_AUTO_RETRY, |
| 1748 | HEARING_AID, |
| 1749 | TTY_MODE, |
| 1750 | SOUND_EFFECTS_ENABLED, |
| 1751 | HAPTIC_FEEDBACK_ENABLED, |
Christopher Tate | 14c2d79 | 2010-02-25 16:49:44 -0800 | [diff] [blame] | 1752 | POWER_SOUNDS_ENABLED, |
| 1753 | DOCK_SOUNDS_ENABLED, |
| 1754 | LOCKSCREEN_SOUNDS_ENABLED, |
Amith Yamasani | ae3ed70 | 2009-12-01 19:02:05 -0800 | [diff] [blame] | 1755 | SHOW_WEB_SUGGESTIONS, |
| 1756 | NOTIFICATION_LIGHT_PULSE |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 1757 | }; |
| 1758 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1759 | // Settings moved to Settings.Secure |
| 1760 | |
| 1761 | /** |
Mike Lockwood | 460ae0c | 2009-04-02 22:33:27 -0700 | [diff] [blame] | 1762 | * @deprecated Use {@link android.provider.Settings.Secure#ADB_ENABLED} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1763 | * instead |
| 1764 | */ |
| 1765 | @Deprecated |
| 1766 | public static final String ADB_ENABLED = Secure.ADB_ENABLED; |
| 1767 | |
| 1768 | /** |
| 1769 | * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead |
| 1770 | */ |
| 1771 | @Deprecated |
| 1772 | public static final String ANDROID_ID = Secure.ANDROID_ID; |
| 1773 | |
| 1774 | /** |
| 1775 | * @deprecated Use {@link android.provider.Settings.Secure#BLUETOOTH_ON} instead |
| 1776 | */ |
| 1777 | @Deprecated |
| 1778 | public static final String BLUETOOTH_ON = Secure.BLUETOOTH_ON; |
| 1779 | |
| 1780 | /** |
| 1781 | * @deprecated Use {@link android.provider.Settings.Secure#DATA_ROAMING} instead |
| 1782 | */ |
| 1783 | @Deprecated |
| 1784 | public static final String DATA_ROAMING = Secure.DATA_ROAMING; |
| 1785 | |
| 1786 | /** |
| 1787 | * @deprecated Use {@link android.provider.Settings.Secure#DEVICE_PROVISIONED} instead |
| 1788 | */ |
| 1789 | @Deprecated |
| 1790 | public static final String DEVICE_PROVISIONED = Secure.DEVICE_PROVISIONED; |
| 1791 | |
| 1792 | /** |
| 1793 | * @deprecated Use {@link android.provider.Settings.Secure#HTTP_PROXY} instead |
| 1794 | */ |
| 1795 | @Deprecated |
| 1796 | public static final String HTTP_PROXY = Secure.HTTP_PROXY; |
| 1797 | |
| 1798 | /** |
| 1799 | * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead |
| 1800 | */ |
| 1801 | @Deprecated |
| 1802 | public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1803 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1804 | /** |
| 1805 | * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED} |
| 1806 | * instead |
| 1807 | */ |
| 1808 | @Deprecated |
| 1809 | public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED; |
| 1810 | |
| 1811 | /** |
| 1812 | * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead |
| 1813 | */ |
| 1814 | @Deprecated |
| 1815 | public static final String LOGGING_ID = Secure.LOGGING_ID; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1816 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1817 | /** |
| 1818 | * @deprecated Use {@link android.provider.Settings.Secure#NETWORK_PREFERENCE} instead |
| 1819 | */ |
| 1820 | @Deprecated |
| 1821 | public static final String NETWORK_PREFERENCE = Secure.NETWORK_PREFERENCE; |
| 1822 | |
| 1823 | /** |
| 1824 | * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED} |
| 1825 | * instead |
| 1826 | */ |
| 1827 | @Deprecated |
| 1828 | public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED; |
| 1829 | |
| 1830 | /** |
| 1831 | * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE} |
| 1832 | * instead |
| 1833 | */ |
| 1834 | @Deprecated |
| 1835 | public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE; |
| 1836 | |
| 1837 | /** |
| 1838 | * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL} |
| 1839 | * instead |
| 1840 | */ |
| 1841 | @Deprecated |
| 1842 | public static final String PARENTAL_CONTROL_REDIRECT_URL = |
| 1843 | Secure.PARENTAL_CONTROL_REDIRECT_URL; |
| 1844 | |
| 1845 | /** |
| 1846 | * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead |
| 1847 | */ |
| 1848 | @Deprecated |
| 1849 | public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME; |
| 1850 | |
| 1851 | /** |
| 1852 | * @deprecated Use {@link android.provider.Settings.Secure#USB_MASS_STORAGE_ENABLED} instead |
| 1853 | */ |
| 1854 | @Deprecated |
| 1855 | public static final String USB_MASS_STORAGE_ENABLED = Secure.USB_MASS_STORAGE_ENABLED; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1856 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1857 | /** |
| 1858 | * @deprecated Use {@link android.provider.Settings.Secure#USE_GOOGLE_MAIL} instead |
| 1859 | */ |
| 1860 | @Deprecated |
| 1861 | public static final String USE_GOOGLE_MAIL = Secure.USE_GOOGLE_MAIL; |
| 1862 | |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1863 | /** |
| 1864 | * @deprecated Use |
| 1865 | * {@link android.provider.Settings.Secure#WIFI_MAX_DHCP_RETRY_COUNT} instead |
| 1866 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1867 | @Deprecated |
| 1868 | public static final String WIFI_MAX_DHCP_RETRY_COUNT = Secure.WIFI_MAX_DHCP_RETRY_COUNT; |
| 1869 | |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1870 | /** |
| 1871 | * @deprecated Use |
| 1872 | * {@link android.provider.Settings.Secure#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead |
| 1873 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1874 | @Deprecated |
| 1875 | public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = |
| 1876 | Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS; |
| 1877 | |
| 1878 | /** |
| 1879 | * @deprecated Use |
| 1880 | * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead |
| 1881 | */ |
| 1882 | @Deprecated |
| 1883 | public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = |
| 1884 | Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON; |
| 1885 | |
| 1886 | /** |
| 1887 | * @deprecated Use |
| 1888 | * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead |
| 1889 | */ |
| 1890 | @Deprecated |
| 1891 | public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = |
| 1892 | Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1893 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1894 | /** |
| 1895 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_NUM_OPEN_NETWORKS_KEPT} |
| 1896 | * instead |
| 1897 | */ |
| 1898 | @Deprecated |
| 1899 | public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Secure.WIFI_NUM_OPEN_NETWORKS_KEPT; |
| 1900 | |
| 1901 | /** |
| 1902 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_ON} instead |
| 1903 | */ |
| 1904 | @Deprecated |
| 1905 | public static final String WIFI_ON = Secure.WIFI_ON; |
| 1906 | |
| 1907 | /** |
| 1908 | * @deprecated Use |
| 1909 | * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE} |
| 1910 | * instead |
| 1911 | */ |
| 1912 | @Deprecated |
| 1913 | public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE = |
| 1914 | Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE; |
| 1915 | |
| 1916 | /** |
| 1917 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead |
| 1918 | */ |
| 1919 | @Deprecated |
| 1920 | public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT; |
| 1921 | |
| 1922 | /** |
| 1923 | * @deprecated Use |
| 1924 | * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead |
| 1925 | */ |
| 1926 | @Deprecated |
| 1927 | public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS = |
| 1928 | Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 1929 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1930 | /** |
| 1931 | * @deprecated Use |
| 1932 | * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead |
| 1933 | */ |
| 1934 | @Deprecated |
| 1935 | public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED = |
| 1936 | Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED; |
| 1937 | |
| 1938 | /** |
| 1939 | * @deprecated Use |
| 1940 | * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS} |
| 1941 | * instead |
| 1942 | */ |
| 1943 | @Deprecated |
| 1944 | public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS = |
| 1945 | Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS; |
| 1946 | |
| 1947 | /** |
| 1948 | * @deprecated Use |
| 1949 | * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead |
| 1950 | */ |
| 1951 | @Deprecated |
| 1952 | public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT = |
| 1953 | Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT; |
| 1954 | |
| 1955 | /** |
| 1956 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS} |
| 1957 | * instead |
| 1958 | */ |
| 1959 | @Deprecated |
| 1960 | public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS; |
| 1961 | |
| 1962 | /** |
| 1963 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ON} instead |
| 1964 | */ |
| 1965 | @Deprecated |
| 1966 | public static final String WIFI_WATCHDOG_ON = Secure.WIFI_WATCHDOG_ON; |
| 1967 | |
| 1968 | /** |
| 1969 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead |
| 1970 | */ |
| 1971 | @Deprecated |
| 1972 | public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT; |
| 1973 | |
| 1974 | /** |
| 1975 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS} |
| 1976 | * instead |
| 1977 | */ |
| 1978 | @Deprecated |
| 1979 | public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS; |
| 1980 | |
| 1981 | /** |
| 1982 | * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS} |
| 1983 | * instead |
| 1984 | */ |
| 1985 | @Deprecated |
| 1986 | public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = |
| 1987 | Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS; |
| 1988 | } |
| 1989 | |
| 1990 | /** |
| 1991 | * Secure system settings, containing system preferences that applications |
| 1992 | * can read but are not allowed to write. These are for preferences that |
| 1993 | * the user must explicitly modify through the system UI or specialized |
| 1994 | * APIs for those values, not modified directly by applications. |
| 1995 | */ |
| 1996 | public static final class Secure extends NameValueTable { |
| 1997 | public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version"; |
| 1998 | |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 1999 | // Populated lazily, guarded by class object: |
| 2000 | private static NameValueCache sNameValueCache = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2001 | |
| 2002 | /** |
| 2003 | * Look up a name in the database. |
| 2004 | * @param resolver to access the database with |
| 2005 | * @param name to look up in the table |
| 2006 | * @return the corresponding value, or null if not present |
| 2007 | */ |
| 2008 | public synchronized static String getString(ContentResolver resolver, String name) { |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 2009 | if (sNameValueCache == null) { |
| 2010 | sNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI, |
| 2011 | CALL_METHOD_GET_SECURE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2012 | } |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 2013 | return sNameValueCache.getString(resolver, name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | /** |
| 2017 | * Store a name/value pair into the database. |
| 2018 | * @param resolver to access the database with |
| 2019 | * @param name to store |
| 2020 | * @param value to associate with the name |
| 2021 | * @return true if the value was set, false on database errors |
| 2022 | */ |
| 2023 | public static boolean putString(ContentResolver resolver, |
| 2024 | String name, String value) { |
| 2025 | return putString(resolver, CONTENT_URI, name, value); |
| 2026 | } |
| 2027 | |
| 2028 | /** |
| 2029 | * Construct the content URI for a particular name/value pair, |
| 2030 | * useful for monitoring changes with a ContentObserver. |
| 2031 | * @param name to look up in the table |
| 2032 | * @return the corresponding content URI, or null if not present |
| 2033 | */ |
| 2034 | public static Uri getUriFor(String name) { |
| 2035 | return getUriFor(CONTENT_URI, name); |
| 2036 | } |
| 2037 | |
| 2038 | /** |
| 2039 | * Convenience function for retrieving a single secure settings value |
| 2040 | * as an integer. Note that internally setting values are always |
| 2041 | * stored as strings; this function converts the string to an integer |
| 2042 | * for you. The default value will be returned if the setting is |
| 2043 | * not defined or not an integer. |
| 2044 | * |
| 2045 | * @param cr The ContentResolver to access. |
| 2046 | * @param name The name of the setting to retrieve. |
| 2047 | * @param def Value to return if the setting is not defined. |
| 2048 | * |
| 2049 | * @return The setting's current value, or 'def' if it is not defined |
| 2050 | * or not a valid integer. |
| 2051 | */ |
| 2052 | public static int getInt(ContentResolver cr, String name, int def) { |
| 2053 | String v = getString(cr, name); |
| 2054 | try { |
| 2055 | return v != null ? Integer.parseInt(v) : def; |
| 2056 | } catch (NumberFormatException e) { |
| 2057 | return def; |
| 2058 | } |
| 2059 | } |
| 2060 | |
| 2061 | /** |
| 2062 | * Convenience function for retrieving a single secure settings value |
| 2063 | * as an integer. Note that internally setting values are always |
| 2064 | * stored as strings; this function converts the string to an integer |
| 2065 | * for you. |
| 2066 | * <p> |
| 2067 | * This version does not take a default value. If the setting has not |
| 2068 | * been set, or the string value is not a number, |
| 2069 | * it throws {@link SettingNotFoundException}. |
| 2070 | * |
| 2071 | * @param cr The ContentResolver to access. |
| 2072 | * @param name The name of the setting to retrieve. |
| 2073 | * |
| 2074 | * @throws SettingNotFoundException Thrown if a setting by the given |
| 2075 | * name can't be found or the setting value is not an integer. |
| 2076 | * |
| 2077 | * @return The setting's current value. |
| 2078 | */ |
| 2079 | public static int getInt(ContentResolver cr, String name) |
| 2080 | throws SettingNotFoundException { |
| 2081 | String v = getString(cr, name); |
| 2082 | try { |
| 2083 | return Integer.parseInt(v); |
| 2084 | } catch (NumberFormatException e) { |
| 2085 | throw new SettingNotFoundException(name); |
| 2086 | } |
| 2087 | } |
| 2088 | |
| 2089 | /** |
| 2090 | * Convenience function for updating a single settings value as an |
| 2091 | * integer. This will either create a new entry in the table if the |
| 2092 | * given name does not exist, or modify the value of the existing row |
| 2093 | * with that name. Note that internally setting values are always |
| 2094 | * stored as strings, so this function converts the given value to a |
| 2095 | * string before storing it. |
| 2096 | * |
| 2097 | * @param cr The ContentResolver to access. |
| 2098 | * @param name The name of the setting to modify. |
| 2099 | * @param value The new value for the setting. |
| 2100 | * @return true if the value was set, false on database errors |
| 2101 | */ |
| 2102 | public static boolean putInt(ContentResolver cr, String name, int value) { |
| 2103 | return putString(cr, name, Integer.toString(value)); |
| 2104 | } |
| 2105 | |
| 2106 | /** |
| 2107 | * Convenience function for retrieving a single secure settings value |
| 2108 | * as a {@code long}. Note that internally setting values are always |
| 2109 | * stored as strings; this function converts the string to a {@code long} |
| 2110 | * for you. The default value will be returned if the setting is |
| 2111 | * not defined or not a {@code long}. |
| 2112 | * |
| 2113 | * @param cr The ContentResolver to access. |
| 2114 | * @param name The name of the setting to retrieve. |
| 2115 | * @param def Value to return if the setting is not defined. |
| 2116 | * |
| 2117 | * @return The setting's current value, or 'def' if it is not defined |
| 2118 | * or not a valid {@code long}. |
| 2119 | */ |
| 2120 | public static long getLong(ContentResolver cr, String name, long def) { |
| 2121 | String valString = getString(cr, name); |
| 2122 | long value; |
| 2123 | try { |
| 2124 | value = valString != null ? Long.parseLong(valString) : def; |
| 2125 | } catch (NumberFormatException e) { |
| 2126 | value = def; |
| 2127 | } |
| 2128 | return value; |
| 2129 | } |
| 2130 | |
| 2131 | /** |
| 2132 | * Convenience function for retrieving a single secure settings value |
| 2133 | * as a {@code long}. Note that internally setting values are always |
| 2134 | * stored as strings; this function converts the string to a {@code long} |
| 2135 | * for you. |
| 2136 | * <p> |
| 2137 | * This version does not take a default value. If the setting has not |
| 2138 | * been set, or the string value is not a number, |
| 2139 | * it throws {@link SettingNotFoundException}. |
| 2140 | * |
| 2141 | * @param cr The ContentResolver to access. |
| 2142 | * @param name The name of the setting to retrieve. |
| 2143 | * |
| 2144 | * @return The setting's current value. |
| 2145 | * @throws SettingNotFoundException Thrown if a setting by the given |
| 2146 | * name can't be found or the setting value is not an integer. |
| 2147 | */ |
| 2148 | public static long getLong(ContentResolver cr, String name) |
| 2149 | throws SettingNotFoundException { |
| 2150 | String valString = getString(cr, name); |
| 2151 | try { |
| 2152 | return Long.parseLong(valString); |
| 2153 | } catch (NumberFormatException e) { |
| 2154 | throw new SettingNotFoundException(name); |
| 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | /** |
| 2159 | * Convenience function for updating a secure settings value as a long |
| 2160 | * integer. This will either create a new entry in the table if the |
| 2161 | * given name does not exist, or modify the value of the existing row |
| 2162 | * with that name. Note that internally setting values are always |
| 2163 | * stored as strings, so this function converts the given value to a |
| 2164 | * string before storing it. |
| 2165 | * |
| 2166 | * @param cr The ContentResolver to access. |
| 2167 | * @param name The name of the setting to modify. |
| 2168 | * @param value The new value for the setting. |
| 2169 | * @return true if the value was set, false on database errors |
| 2170 | */ |
| 2171 | public static boolean putLong(ContentResolver cr, String name, long value) { |
| 2172 | return putString(cr, name, Long.toString(value)); |
| 2173 | } |
| 2174 | |
| 2175 | /** |
| 2176 | * Convenience function for retrieving a single secure settings value |
| 2177 | * as a floating point number. Note that internally setting values are |
| 2178 | * always stored as strings; this function converts the string to an |
| 2179 | * float for you. The default value will be returned if the setting |
| 2180 | * is not defined or not a valid float. |
| 2181 | * |
| 2182 | * @param cr The ContentResolver to access. |
| 2183 | * @param name The name of the setting to retrieve. |
| 2184 | * @param def Value to return if the setting is not defined. |
| 2185 | * |
| 2186 | * @return The setting's current value, or 'def' if it is not defined |
| 2187 | * or not a valid float. |
| 2188 | */ |
| 2189 | public static float getFloat(ContentResolver cr, String name, float def) { |
| 2190 | String v = getString(cr, name); |
| 2191 | try { |
| 2192 | return v != null ? Float.parseFloat(v) : def; |
| 2193 | } catch (NumberFormatException e) { |
| 2194 | return def; |
| 2195 | } |
| 2196 | } |
| 2197 | |
| 2198 | /** |
| 2199 | * Convenience function for retrieving a single secure settings value |
| 2200 | * as a float. Note that internally setting values are always |
| 2201 | * stored as strings; this function converts the string to a float |
| 2202 | * for you. |
| 2203 | * <p> |
| 2204 | * This version does not take a default value. If the setting has not |
| 2205 | * been set, or the string value is not a number, |
| 2206 | * it throws {@link SettingNotFoundException}. |
| 2207 | * |
| 2208 | * @param cr The ContentResolver to access. |
| 2209 | * @param name The name of the setting to retrieve. |
| 2210 | * |
| 2211 | * @throws SettingNotFoundException Thrown if a setting by the given |
| 2212 | * name can't be found or the setting value is not a float. |
| 2213 | * |
| 2214 | * @return The setting's current value. |
| 2215 | */ |
| 2216 | public static float getFloat(ContentResolver cr, String name) |
| 2217 | throws SettingNotFoundException { |
| 2218 | String v = getString(cr, name); |
| 2219 | try { |
| 2220 | return Float.parseFloat(v); |
| 2221 | } catch (NumberFormatException e) { |
| 2222 | throw new SettingNotFoundException(name); |
| 2223 | } |
| 2224 | } |
| 2225 | |
| 2226 | /** |
| 2227 | * Convenience function for updating a single settings value as a |
| 2228 | * floating point number. This will either create a new entry in the |
| 2229 | * table if the given name does not exist, or modify the value of the |
| 2230 | * existing row with that name. Note that internally setting values |
| 2231 | * are always stored as strings, so this function converts the given |
| 2232 | * value to a string before storing it. |
| 2233 | * |
| 2234 | * @param cr The ContentResolver to access. |
| 2235 | * @param name The name of the setting to modify. |
| 2236 | * @param value The new value for the setting. |
| 2237 | * @return true if the value was set, false on database errors |
| 2238 | */ |
| 2239 | public static boolean putFloat(ContentResolver cr, String name, float value) { |
| 2240 | return putString(cr, name, Float.toString(value)); |
| 2241 | } |
| 2242 | |
| 2243 | /** |
| 2244 | * The content:// style URL for this table |
| 2245 | */ |
| 2246 | public static final Uri CONTENT_URI = |
| 2247 | Uri.parse("content://" + AUTHORITY + "/secure"); |
| 2248 | |
| 2249 | /** |
| 2250 | * Whether ADB is enabled. |
| 2251 | */ |
| 2252 | public static final String ADB_ENABLED = "adb_enabled"; |
| 2253 | |
| 2254 | /** |
| 2255 | * Setting to allow mock locations and location provider status to be injected into the |
| 2256 | * LocationManager service for testing purposes during application development. These |
| 2257 | * locations and status values override actual location and status information generated |
| 2258 | * by network, gps, or other location providers. |
| 2259 | */ |
| 2260 | public static final String ALLOW_MOCK_LOCATION = "mock_location"; |
| 2261 | |
| 2262 | /** |
Doug Zongker | d8893db | 2010-01-26 12:29:44 -0800 | [diff] [blame] | 2263 | * A 64-bit number (as a hex string) that is randomly |
| 2264 | * generated on the device's first boot and should remain |
| 2265 | * constant for the lifetime of the device. (The value may |
| 2266 | * change if a factory reset is performed on the device.) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2267 | */ |
| 2268 | public static final String ANDROID_ID = "android_id"; |
| 2269 | |
| 2270 | /** |
| 2271 | * Whether bluetooth is enabled/disabled |
| 2272 | * 0=disabled. 1=enabled. |
| 2273 | */ |
| 2274 | public static final String BLUETOOTH_ON = "bluetooth_on"; |
| 2275 | |
| 2276 | /** |
| 2277 | * Get the key that retrieves a bluetooth headset's priority. |
| 2278 | * @hide |
| 2279 | */ |
| 2280 | public static final String getBluetoothHeadsetPriorityKey(String address) { |
| 2281 | return ("bluetooth_headset_priority_" + address.toUpperCase()); |
| 2282 | } |
| 2283 | |
| 2284 | /** |
| 2285 | * Get the key that retrieves a bluetooth a2dp sink's priority. |
| 2286 | * @hide |
| 2287 | */ |
| 2288 | public static final String getBluetoothA2dpSinkPriorityKey(String address) { |
| 2289 | return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase()); |
| 2290 | } |
| 2291 | |
| 2292 | /** |
| 2293 | * Whether or not data roaming is enabled. (0 = false, 1 = true) |
| 2294 | */ |
| 2295 | public static final String DATA_ROAMING = "data_roaming"; |
| 2296 | |
| 2297 | /** |
| 2298 | * Setting to record the input method used by default, holding the ID |
| 2299 | * of the desired method. |
| 2300 | */ |
| 2301 | public static final String DEFAULT_INPUT_METHOD = "default_input_method"; |
| 2302 | |
| 2303 | /** |
| 2304 | * Whether the device has been provisioned (0 = false, 1 = true) |
| 2305 | */ |
| 2306 | public static final String DEVICE_PROVISIONED = "device_provisioned"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2307 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2308 | /** |
| 2309 | * List of input methods that are currently enabled. This is a string |
| 2310 | * containing the IDs of all enabled input methods, each ID separated |
| 2311 | * by ':'. |
| 2312 | */ |
| 2313 | public static final String ENABLED_INPUT_METHODS = "enabled_input_methods"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2314 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2315 | /** |
| 2316 | * Host name and port for a user-selected proxy. |
| 2317 | */ |
| 2318 | public static final String HTTP_PROXY = "http_proxy"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2319 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2320 | /** |
| 2321 | * Whether the package installer should allow installation of apps downloaded from |
| 2322 | * sources other than the Android Market (vending machine). |
| 2323 | * |
| 2324 | * 1 = allow installing from other sources |
| 2325 | * 0 = only allow installing from the Android Market |
| 2326 | */ |
| 2327 | public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2328 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2329 | /** |
| 2330 | * Comma-separated list of location providers that activities may access. |
| 2331 | */ |
| 2332 | public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2333 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2334 | /** |
Amith Yamasani | 156c435 | 2010-03-05 17:10:03 -0800 | [diff] [blame] | 2335 | * Whether autolock is enabled (0 = false, 1 = true) |
| 2336 | */ |
| 2337 | public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock"; |
| 2338 | |
| 2339 | /** |
| 2340 | * Whether lock pattern is visible as user enters (0 = false, 1 = true) |
| 2341 | */ |
| 2342 | public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern"; |
| 2343 | |
| 2344 | /** |
| 2345 | * Whether lock pattern will vibrate as user enters (0 = false, 1 = true) |
| 2346 | */ |
| 2347 | public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = |
| 2348 | "lock_pattern_tactile_feedback_enabled"; |
| 2349 | |
| 2350 | /** |
Mike Lockwood | bcab8df | 2009-06-25 16:39:09 -0400 | [diff] [blame] | 2351 | * Whether assisted GPS should be enabled or not. |
| 2352 | * @hide |
| 2353 | */ |
| 2354 | public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled"; |
| 2355 | |
| 2356 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2357 | * The Logging ID (a unique 64-bit value) as a hex string. |
| 2358 | * Used as a pseudonymous identifier for logging. |
| 2359 | * @deprecated This identifier is poorly initialized and has |
| 2360 | * many collisions. It should not be used. |
| 2361 | */ |
| 2362 | @Deprecated |
| 2363 | public static final String LOGGING_ID = "logging_id"; |
| 2364 | |
| 2365 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2366 | * User preference for which network(s) should be used. Only the |
| 2367 | * connectivity service should touch this. |
| 2368 | */ |
| 2369 | public static final String NETWORK_PREFERENCE = "network_preference"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2370 | |
| 2371 | /** |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 2372 | * Used to disable Tethering on a device - defaults to true |
| 2373 | * @hide |
| 2374 | */ |
| 2375 | public static final String TETHER_SUPPORTED = "tether_supported"; |
| 2376 | |
| 2377 | /** |
Dan Egnor | 1c9131c | 2010-02-13 10:38:55 -0800 | [diff] [blame] | 2378 | * No longer supported. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2379 | */ |
| 2380 | public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2381 | |
| 2382 | /** |
Dan Egnor | 1c9131c | 2010-02-13 10:38:55 -0800 | [diff] [blame] | 2383 | * No longer supported. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2384 | */ |
| 2385 | public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2386 | |
| 2387 | /** |
Dan Egnor | 1c9131c | 2010-02-13 10:38:55 -0800 | [diff] [blame] | 2388 | * No longer supported. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2389 | */ |
| 2390 | public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2391 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2392 | /** |
| 2393 | * Settings classname to launch when Settings is clicked from All |
| 2394 | * Applications. Needed because of user testing between the old |
| 2395 | * and new Settings apps. |
| 2396 | */ |
| 2397 | // TODO: 881807 |
| 2398 | public static final String SETTINGS_CLASSNAME = "settings_classname"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2399 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2400 | /** |
| 2401 | * USB Mass Storage Enabled |
| 2402 | */ |
| 2403 | public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2404 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2405 | /** |
| 2406 | * If this setting is set (to anything), then all references |
| 2407 | * to Gmail on the device must change to Google Mail. |
| 2408 | */ |
| 2409 | public static final String USE_GOOGLE_MAIL = "use_google_mail"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2410 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2411 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 2412 | * If accessibility is enabled. |
| 2413 | */ |
| 2414 | public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled"; |
| 2415 | |
| 2416 | /** |
| 2417 | * List of the enabled accessibility providers. |
| 2418 | */ |
| 2419 | public static final String ENABLED_ACCESSIBILITY_SERVICES = |
| 2420 | "enabled_accessibility_services"; |
| 2421 | |
| 2422 | /** |
Jean-Michel Trivi | f62ba45 | 2009-06-04 14:55:24 -0700 | [diff] [blame] | 2423 | * Setting to always use the default text-to-speech settings regardless |
| 2424 | * of the application settings. |
| 2425 | * 1 = override application settings, |
| 2426 | * 0 = use application settings (if specified). |
| 2427 | */ |
| 2428 | public static final String TTS_USE_DEFAULTS = "tts_use_defaults"; |
| 2429 | |
| 2430 | /** |
| 2431 | * Default text-to-speech engine speech rate. 100 = 1x |
| 2432 | */ |
| 2433 | public static final String TTS_DEFAULT_RATE = "tts_default_rate"; |
| 2434 | |
| 2435 | /** |
| 2436 | * Default text-to-speech engine pitch. 100 = 1x |
| 2437 | */ |
| 2438 | public static final String TTS_DEFAULT_PITCH = "tts_default_pitch"; |
| 2439 | |
| 2440 | /** |
| 2441 | * Default text-to-speech engine. |
| 2442 | */ |
| 2443 | public static final String TTS_DEFAULT_SYNTH = "tts_default_synth"; |
| 2444 | |
| 2445 | /** |
Jean-Michel Trivi | f478267 | 2009-06-09 16:22:48 -0700 | [diff] [blame] | 2446 | * Default text-to-speech language. |
| 2447 | */ |
| 2448 | public static final String TTS_DEFAULT_LANG = "tts_default_lang"; |
| 2449 | |
| 2450 | /** |
Jean-Michel Trivi | a6fcc95 | 2009-06-19 14:06:01 -0700 | [diff] [blame] | 2451 | * Default text-to-speech country. |
| 2452 | */ |
| 2453 | public static final String TTS_DEFAULT_COUNTRY = "tts_default_country"; |
| 2454 | |
| 2455 | /** |
| 2456 | * Default text-to-speech locale variant. |
| 2457 | */ |
| 2458 | public static final String TTS_DEFAULT_VARIANT = "tts_default_variant"; |
| 2459 | |
| 2460 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2461 | * Whether to notify the user of open networks. |
| 2462 | * <p> |
| 2463 | * If not connected and the scan results have an open network, we will |
| 2464 | * put this notification up. If we attempt to connect to a network or |
| 2465 | * the open network(s) disappear, we remove the notification. When we |
| 2466 | * show the notification, we will not show it again for |
| 2467 | * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time. |
| 2468 | */ |
| 2469 | public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = |
| 2470 | "wifi_networks_available_notification_on"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2471 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2472 | /** |
| 2473 | * Delay (in seconds) before repeating the Wi-Fi networks available notification. |
| 2474 | * Connecting to a network will reset the timer. |
| 2475 | */ |
| 2476 | public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = |
| 2477 | "wifi_networks_available_repeat_delay"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2478 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2479 | /** |
| 2480 | * The number of radio channels that are allowed in the local |
| 2481 | * 802.11 regulatory domain. |
| 2482 | * @hide |
| 2483 | */ |
| 2484 | public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2485 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2486 | /** |
| 2487 | * When the number of open networks exceeds this number, the |
| 2488 | * least-recently-used excess networks will be removed. |
| 2489 | */ |
| 2490 | public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2491 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2492 | /** |
| 2493 | * Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this. |
| 2494 | */ |
| 2495 | public static final String WIFI_ON = "wifi_on"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2496 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2497 | /** |
Irfan Sheriff | 5321aef | 2010-02-12 12:35:59 -0800 | [diff] [blame] | 2498 | * Whether the Wi-Fi AP should be on. |
| 2499 | * |
| 2500 | * @hide |
| 2501 | */ |
| 2502 | public static final String WIFI_AP_ON = "wifi_ap_on"; |
| 2503 | |
| 2504 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2505 | * The acceptable packet loss percentage (range 0 - 100) before trying |
| 2506 | * another AP on the same network. |
| 2507 | */ |
| 2508 | public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE = |
| 2509 | "wifi_watchdog_acceptable_packet_loss_percentage"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2510 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2511 | /** |
| 2512 | * The number of access points required for a network in order for the |
| 2513 | * watchdog to monitor it. |
| 2514 | */ |
| 2515 | public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2516 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2517 | /** |
| 2518 | * The delay between background checks. |
| 2519 | */ |
| 2520 | public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS = |
| 2521 | "wifi_watchdog_background_check_delay_ms"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2522 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2523 | /** |
| 2524 | * Whether the Wi-Fi watchdog is enabled for background checking even |
| 2525 | * after it thinks the user has connected to a good access point. |
| 2526 | */ |
| 2527 | public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED = |
| 2528 | "wifi_watchdog_background_check_enabled"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2529 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2530 | /** |
| 2531 | * The timeout for a background ping |
| 2532 | */ |
| 2533 | public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS = |
| 2534 | "wifi_watchdog_background_check_timeout_ms"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2535 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2536 | /** |
| 2537 | * The number of initial pings to perform that *may* be ignored if they |
| 2538 | * fail. Again, if these fail, they will *not* be used in packet loss |
| 2539 | * calculation. For example, one network always seemed to time out for |
| 2540 | * the first couple pings, so this is set to 3 by default. |
| 2541 | */ |
| 2542 | public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT = |
| 2543 | "wifi_watchdog_initial_ignored_ping_count"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2544 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2545 | /** |
| 2546 | * The maximum number of access points (per network) to attempt to test. |
| 2547 | * If this number is reached, the watchdog will no longer monitor the |
| 2548 | * initial connection state for the network. This is a safeguard for |
| 2549 | * networks containing multiple APs whose DNS does not respond to pings. |
| 2550 | */ |
| 2551 | public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2552 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2553 | /** |
| 2554 | * Whether the Wi-Fi watchdog is enabled. |
| 2555 | */ |
| 2556 | public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on"; |
| 2557 | |
| 2558 | /** |
| 2559 | * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2560 | */ |
| 2561 | public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list"; |
| 2562 | |
| 2563 | /** |
| 2564 | * The number of pings to test if an access point is a good connection. |
| 2565 | */ |
| 2566 | public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2567 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2568 | /** |
| 2569 | * The delay between pings. |
| 2570 | */ |
| 2571 | public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2572 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2573 | /** |
| 2574 | * The timeout per ping. |
| 2575 | */ |
| 2576 | public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2577 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2578 | /** |
| 2579 | * The maximum number of times we will retry a connection to an access |
| 2580 | * point for which we have failed in acquiring an IP address from DHCP. |
| 2581 | * A value of N means that we will make N+1 connection attempts in all. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2582 | */ |
| 2583 | public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count"; |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2584 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2585 | /** |
| 2586 | * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile |
| 2587 | * data connectivity to be established after a disconnect from Wi-Fi. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2588 | */ |
| 2589 | public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = |
| 2590 | "wifi_mobile_data_transition_wakelock_timeout_ms"; |
| 2591 | |
| 2592 | /** |
| 2593 | * Whether background data usage is allowed by the user. See |
| 2594 | * ConnectivityManager for more info. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2595 | */ |
| 2596 | public static final String BACKGROUND_DATA = "background_data"; |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 2597 | |
| 2598 | /** |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 2599 | * Whether mobile data connections are allowed by the user. See |
| 2600 | * ConnectivityManager for more info. |
| 2601 | * @hide |
| 2602 | */ |
| 2603 | public static final String MOBILE_DATA = "mobile_data"; |
| 2604 | |
| 2605 | /** |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 2606 | * The CDMA roaming mode 0 = Home Networks, CDMA default |
| 2607 | * 1 = Roaming on Affiliated networks |
| 2608 | * 2 = Roaming on any networks |
| 2609 | * @hide |
| 2610 | */ |
| 2611 | public static final String CDMA_ROAMING_MODE = "roaming_settings"; |
| 2612 | |
| 2613 | /** |
| 2614 | * The CDMA subscription mode 0 = RUIM/SIM (default) |
| 2615 | * 1 = NV |
| 2616 | * @hide |
| 2617 | */ |
| 2618 | public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode"; |
| 2619 | |
| 2620 | /** |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 2621 | * The preferred network mode 7 = Global |
| 2622 | * 6 = EvDo only |
| 2623 | * 5 = CDMA w/o EvDo |
| 2624 | * 4 = CDMA / EvDo auto |
| 2625 | * 3 = GSM / WCDMA auto |
| 2626 | * 2 = WCDMA only |
| 2627 | * 1 = GSM only |
| 2628 | * 0 = GSM / WCDMA preferred |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 2629 | * @hide |
| 2630 | */ |
| 2631 | public static final String PREFERRED_NETWORK_MODE = |
| 2632 | "preferred_network_mode"; |
| 2633 | |
| 2634 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2635 | * The preferred TTY mode 0 = TTy Off, CDMA default |
| 2636 | * 1 = TTY Full |
| 2637 | * 2 = TTY HCO |
| 2638 | * 3 = TTY VCO |
| 2639 | * @hide |
| 2640 | */ |
| 2641 | public static final String PREFERRED_TTY_MODE = |
| 2642 | "preferred_tty_mode"; |
| 2643 | |
| 2644 | |
| 2645 | /** |
Wink Saville | 04e71b3 | 2009-04-02 11:00:54 -0700 | [diff] [blame] | 2646 | * CDMA Cell Broadcast SMS |
| 2647 | * 0 = CDMA Cell Broadcast SMS disabled |
| 2648 | * 1 = CDMA Cell Broadcast SMS enabled |
| 2649 | * @hide |
| 2650 | */ |
| 2651 | public static final String CDMA_CELL_BROADCAST_SMS = |
| 2652 | "cdma_cell_broadcast_sms"; |
| 2653 | |
| 2654 | /** |
| 2655 | * The cdma subscription 0 = Subscription from RUIM, when available |
| 2656 | * 1 = Subscription from NV |
| 2657 | * @hide |
| 2658 | */ |
| 2659 | public static final String PREFERRED_CDMA_SUBSCRIPTION = |
| 2660 | "preferred_cdma_subscription"; |
| 2661 | |
| 2662 | /** |
| 2663 | * Whether the enhanced voice privacy mode is enabled. |
| 2664 | * 0 = normal voice privacy |
| 2665 | * 1 = enhanced voice privacy |
| 2666 | * @hide |
| 2667 | */ |
| 2668 | public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled"; |
| 2669 | |
| 2670 | /** |
| 2671 | * Whether the TTY mode mode is enabled. |
| 2672 | * 0 = disabled |
| 2673 | * 1 = enabled |
| 2674 | * @hide |
| 2675 | */ |
| 2676 | public static final String TTY_MODE_ENABLED = "tty_mode_enabled"; |
Mike Lockwood | bd2a712 | 2009-04-02 23:41:33 -0700 | [diff] [blame] | 2677 | |
| 2678 | /** |
Amith Yamasani | 630cd06 | 2009-06-19 12:07:02 -0700 | [diff] [blame] | 2679 | * Flag for allowing service provider to use location information to improve products and |
| 2680 | * services. |
| 2681 | * Type: int ( 0 = disallow, 1 = allow ) |
| 2682 | * @hide |
| 2683 | */ |
| 2684 | public static final String USE_LOCATION_FOR_SERVICES = "use_location"; |
| 2685 | |
| 2686 | /** |
Christopher Tate | 8031a3d | 2009-07-06 16:36:05 -0700 | [diff] [blame] | 2687 | * Controls whether settings backup is enabled. |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 2688 | * Type: int ( 0 = disabled, 1 = enabled ) |
| 2689 | * @hide |
| 2690 | */ |
| 2691 | public static final String BACKUP_ENABLED = "backup_enabled"; |
| 2692 | |
| 2693 | /** |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 2694 | * Controls whether application data is automatically restored from backup |
| 2695 | * at install time. |
| 2696 | * Type: int ( 0 = disabled, 1 = enabled ) |
| 2697 | * @hide |
| 2698 | */ |
| 2699 | public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore"; |
| 2700 | |
| 2701 | /** |
Christopher Tate | 8031a3d | 2009-07-06 16:36:05 -0700 | [diff] [blame] | 2702 | * Indicates whether settings backup has been fully provisioned. |
| 2703 | * Type: int ( 0 = unprovisioned, 1 = fully provisioned ) |
| 2704 | * @hide |
| 2705 | */ |
| 2706 | public static final String BACKUP_PROVISIONED = "backup_provisioned"; |
| 2707 | |
| 2708 | /** |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 2709 | * Component of the transport to use for backup/restore. |
| 2710 | * @hide |
| 2711 | */ |
| 2712 | public static final String BACKUP_TRANSPORT = "backup_transport"; |
Sanjay Jeyakumar | 21bf241 | 2009-07-09 13:31:48 -0700 | [diff] [blame] | 2713 | |
Dianne Hackborn | d7cd29d | 2009-07-01 11:22:45 -0700 | [diff] [blame] | 2714 | /** |
| 2715 | * Version for which the setup wizard was last shown. Bumped for |
| 2716 | * each release when there is new setup information to show. |
| 2717 | * @hide |
| 2718 | */ |
| 2719 | public static final String LAST_SETUP_SHOWN = "last_setup_shown"; |
Dianne Hackborn | cf09829 | 2009-07-01 19:55:20 -0700 | [diff] [blame] | 2720 | |
| 2721 | /** |
Doug Zongker | f688889 | 2010-01-06 16:38:14 -0800 | [diff] [blame] | 2722 | * How frequently (in seconds) to check the memory status of the |
| 2723 | * device. |
| 2724 | * @hide |
| 2725 | */ |
| 2726 | public static final String MEMCHECK_INTERVAL = "memcheck_interval"; |
| 2727 | |
| 2728 | /** |
| 2729 | * Max frequency (in seconds) to log memory check stats, in realtime |
| 2730 | * seconds. This allows for throttling of logs when the device is |
| 2731 | * running for large amounts of time. |
| 2732 | * @hide |
| 2733 | */ |
| 2734 | public static final String MEMCHECK_LOG_REALTIME_INTERVAL = |
| 2735 | "memcheck_log_realtime_interval"; |
| 2736 | |
| 2737 | /** |
| 2738 | * Boolean indicating whether rebooting due to system memory checks |
| 2739 | * is enabled. |
| 2740 | * @hide |
| 2741 | */ |
| 2742 | public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled"; |
| 2743 | |
| 2744 | /** |
| 2745 | * How many bytes the system process must be below to avoid scheduling |
| 2746 | * a soft reboot. This reboot will happen when it is next determined |
| 2747 | * to be a good time. |
| 2748 | * @hide |
| 2749 | */ |
| 2750 | public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft"; |
| 2751 | |
| 2752 | /** |
| 2753 | * How many bytes the system process must be below to avoid scheduling |
| 2754 | * a hard reboot. This reboot will happen immediately. |
| 2755 | * @hide |
| 2756 | */ |
| 2757 | public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard"; |
| 2758 | |
| 2759 | /** |
| 2760 | * How many bytes the phone process must be below to avoid scheduling |
| 2761 | * a soft restart. This restart will happen when it is next determined |
| 2762 | * to be a good time. |
| 2763 | * @hide |
| 2764 | */ |
| 2765 | public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft"; |
| 2766 | |
| 2767 | /** |
| 2768 | * How many bytes the phone process must be below to avoid scheduling |
| 2769 | * a hard restart. This restart will happen immediately. |
| 2770 | * @hide |
| 2771 | */ |
| 2772 | public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard"; |
| 2773 | |
| 2774 | /** |
| 2775 | * Boolean indicating whether restarting the phone process due to |
| 2776 | * memory checks is enabled. |
| 2777 | * @hide |
| 2778 | */ |
| 2779 | public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled"; |
| 2780 | |
| 2781 | /** |
| 2782 | * First time during the day it is okay to kill processes |
| 2783 | * or reboot the device due to low memory situations. This number is |
| 2784 | * in seconds since midnight. |
| 2785 | * @hide |
| 2786 | */ |
| 2787 | public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time"; |
| 2788 | |
| 2789 | /** |
| 2790 | * Last time during the day it is okay to kill processes |
| 2791 | * or reboot the device due to low memory situations. This number is |
| 2792 | * in seconds since midnight. |
| 2793 | * @hide |
| 2794 | */ |
| 2795 | public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time"; |
| 2796 | |
| 2797 | /** |
| 2798 | * How long the screen must have been off in order to kill processes |
| 2799 | * or reboot. This number is in seconds. A value of -1 means to |
| 2800 | * entirely disregard whether the screen is on. |
| 2801 | * @hide |
| 2802 | */ |
| 2803 | public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off"; |
| 2804 | |
| 2805 | /** |
| 2806 | * How much time there must be until the next alarm in order to kill processes |
| 2807 | * or reboot. This number is in seconds. Note: this value must be |
| 2808 | * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will |
| 2809 | * always see an alarm scheduled within its time. |
| 2810 | * @hide |
| 2811 | */ |
| 2812 | public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm"; |
| 2813 | |
| 2814 | /** |
| 2815 | * How frequently to check whether it is a good time to restart things, |
| 2816 | * if the device is in a bad state. This number is in seconds. Note: |
| 2817 | * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else |
| 2818 | * the alarm to schedule the recheck will always appear within the |
| 2819 | * minimum "do not execute now" time. |
| 2820 | * @hide |
| 2821 | */ |
| 2822 | public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval"; |
| 2823 | |
| 2824 | /** |
| 2825 | * How frequently (in DAYS) to reboot the device. If 0, no reboots |
| 2826 | * will occur. |
| 2827 | * @hide |
| 2828 | */ |
| 2829 | public static final String REBOOT_INTERVAL = "reboot_interval"; |
| 2830 | |
| 2831 | /** |
| 2832 | * First time during the day it is okay to force a reboot of the |
| 2833 | * device (if REBOOT_INTERVAL is set). This number is |
| 2834 | * in seconds since midnight. |
| 2835 | * @hide |
| 2836 | */ |
| 2837 | public static final String REBOOT_START_TIME = "reboot_start_time"; |
| 2838 | |
| 2839 | /** |
| 2840 | * The window of time (in seconds) after each REBOOT_INTERVAL in which |
| 2841 | * a reboot can be executed. If 0, a reboot will always be executed at |
| 2842 | * exactly the given time. Otherwise, it will only be executed if |
| 2843 | * the device is idle within the window. |
| 2844 | * @hide |
| 2845 | */ |
| 2846 | public static final String REBOOT_WINDOW = "reboot_window"; |
| 2847 | |
| 2848 | /** |
Doug Zongker | 43866e0 | 2010-01-07 12:09:54 -0800 | [diff] [blame] | 2849 | * Threshold values for the duration and level of a discharge cycle, under |
| 2850 | * which we log discharge cycle info. |
| 2851 | * @hide |
| 2852 | */ |
| 2853 | public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD = |
| 2854 | "battery_discharge_duration_threshold"; |
| 2855 | /** @hide */ |
| 2856 | public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold"; |
| 2857 | |
| 2858 | /** |
| 2859 | * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents |
| 2860 | * on application crashes and ANRs. If this is disabled, the crash/ANR dialog |
| 2861 | * will never display the "Report" button. |
| 2862 | * Type: int ( 0 = disallow, 1 = allow ) |
| 2863 | * @hide |
| 2864 | */ |
| 2865 | public static final String SEND_ACTION_APP_ERROR = "send_action_app_error"; |
| 2866 | |
| 2867 | /** |
| 2868 | * Nonzero causes Log.wtf() to crash. |
| 2869 | * @hide |
| 2870 | */ |
| 2871 | public static final String WTF_IS_FATAL = "wtf_is_fatal"; |
| 2872 | |
| 2873 | /** |
| 2874 | * Maximum age of entries kept by {@link android.os.IDropBox}. |
| 2875 | * @hide |
| 2876 | */ |
| 2877 | public static final String DROPBOX_AGE_SECONDS = |
| 2878 | "dropbox_age_seconds"; |
| 2879 | /** |
| 2880 | * Maximum amount of disk space used by {@link android.os.IDropBox} no matter what. |
| 2881 | * @hide |
| 2882 | */ |
| 2883 | public static final String DROPBOX_QUOTA_KB = |
| 2884 | "dropbox_quota_kb"; |
| 2885 | /** |
| 2886 | * Percent of free disk (excluding reserve) which {@link android.os.IDropBox} will use. |
| 2887 | * @hide |
| 2888 | */ |
| 2889 | public static final String DROPBOX_QUOTA_PERCENT = |
| 2890 | "dropbox_quota_percent"; |
| 2891 | /** |
| 2892 | * Percent of total disk which {@link android.os.IDropBox} will never dip into. |
| 2893 | * @hide |
| 2894 | */ |
| 2895 | public static final String DROPBOX_RESERVE_PERCENT = |
| 2896 | "dropbox_reserve_percent"; |
| 2897 | /** |
| 2898 | * Prefix for per-tag dropbox disable/enable settings. |
| 2899 | * @hide |
| 2900 | */ |
| 2901 | public static final String DROPBOX_TAG_PREFIX = |
| 2902 | "dropbox:"; |
Dan Egnor | a455d19 | 2010-03-12 08:52:28 -0800 | [diff] [blame] | 2903 | /** |
| 2904 | * Lines of logcat to include with system crash/ANR/etc. reports, |
| 2905 | * as a prefix of the dropbox tag of the report type. |
| 2906 | * For example, "logcat_for_system_server_anr" controls the lines |
| 2907 | * of logcat captured with system server ANR reports. 0 to disable. |
| 2908 | * @hide |
| 2909 | */ |
| 2910 | public static final String ERROR_LOGCAT_PREFIX = |
| 2911 | "logcat_for_"; |
Doug Zongker | 43866e0 | 2010-01-07 12:09:54 -0800 | [diff] [blame] | 2912 | |
| 2913 | |
| 2914 | /** |
| 2915 | * Screen timeout in milliseconds corresponding to the |
| 2916 | * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest |
| 2917 | * possible screen timeout behavior.) |
| 2918 | * @hide |
| 2919 | */ |
| 2920 | public static final String SHORT_KEYLIGHT_DELAY_MS = |
| 2921 | "short_keylight_delay_ms"; |
| 2922 | |
| 2923 | /** |
| 2924 | * The interval in minutes after which the amount of free storage left on the |
| 2925 | * device is logged to the event log |
| 2926 | * @hide |
| 2927 | */ |
| 2928 | public static final String SYS_FREE_STORAGE_LOG_INTERVAL = |
| 2929 | "sys_free_storage_log_interval"; |
| 2930 | |
| 2931 | /** |
| 2932 | * Threshold for the amount of change in disk free space required to report the amount of |
| 2933 | * free space. Used to prevent spamming the logs when the disk free space isn't changing |
| 2934 | * frequently. |
| 2935 | * @hide |
| 2936 | */ |
| 2937 | public static final String DISK_FREE_CHANGE_REPORTING_THRESHOLD = |
| 2938 | "disk_free_change_reporting_threshold"; |
| 2939 | |
| 2940 | |
| 2941 | /** |
| 2942 | * Minimum percentage of free storage on the device that is used to determine if |
| 2943 | * the device is running low on storage. |
| 2944 | * Say this value is set to 10, the device is considered running low on storage |
| 2945 | * if 90% or more of the device storage is filled up. |
| 2946 | * @hide |
| 2947 | */ |
| 2948 | public static final String SYS_STORAGE_THRESHOLD_PERCENTAGE = |
| 2949 | "sys_storage_threshold_percentage"; |
| 2950 | |
| 2951 | /** |
| 2952 | * The interval in milliseconds after which Wi-Fi is considered idle. |
| 2953 | * When idle, it is possible for the device to be switched from Wi-Fi to |
| 2954 | * the mobile data network. |
| 2955 | * @hide |
| 2956 | */ |
| 2957 | public static final String WIFI_IDLE_MS = "wifi_idle_ms"; |
| 2958 | |
| 2959 | /** |
Doug Zongker | edc5189 | 2010-01-07 13:51:16 -0800 | [diff] [blame] | 2960 | * The interval in milliseconds at which to check packet counts on the |
| 2961 | * mobile data interface when screen is on, to detect possible data |
| 2962 | * connection problems. |
| 2963 | * @hide |
| 2964 | */ |
| 2965 | public static final String PDP_WATCHDOG_POLL_INTERVAL_MS = |
| 2966 | "pdp_watchdog_poll_interval_ms"; |
| 2967 | |
| 2968 | /** |
| 2969 | * The interval in milliseconds at which to check packet counts on the |
| 2970 | * mobile data interface when screen is off, to detect possible data |
| 2971 | * connection problems. |
| 2972 | * @hide |
| 2973 | */ |
| 2974 | public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS = |
| 2975 | "pdp_watchdog_long_poll_interval_ms"; |
| 2976 | |
| 2977 | /** |
| 2978 | * The interval in milliseconds at which to check packet counts on the |
| 2979 | * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} |
| 2980 | * outgoing packets has been reached without incoming packets. |
| 2981 | * @hide |
| 2982 | */ |
| 2983 | public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS = |
| 2984 | "pdp_watchdog_error_poll_interval_ms"; |
| 2985 | |
| 2986 | /** |
| 2987 | * The number of outgoing packets sent without seeing an incoming packet |
| 2988 | * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT} |
| 2989 | * device is logged to the event log |
| 2990 | * @hide |
| 2991 | */ |
| 2992 | public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT = |
| 2993 | "pdp_watchdog_trigger_packet_count"; |
| 2994 | |
| 2995 | /** |
| 2996 | * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS}) |
| 2997 | * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before |
| 2998 | * attempting data connection recovery. |
| 2999 | * @hide |
| 3000 | */ |
| 3001 | public static final String PDP_WATCHDOG_ERROR_POLL_COUNT = |
| 3002 | "pdp_watchdog_error_poll_count"; |
| 3003 | |
| 3004 | /** |
| 3005 | * The number of failed PDP reset attempts before moving to something more |
| 3006 | * drastic: re-registering to the network. |
| 3007 | * @hide |
| 3008 | */ |
| 3009 | public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT = |
| 3010 | "pdp_watchdog_max_pdp_reset_fail_count"; |
| 3011 | |
| 3012 | /** |
| 3013 | * Address to ping as a last sanity check before attempting any recovery. |
| 3014 | * Unset or set to "0.0.0.0" to skip this check. |
| 3015 | * @hide |
| 3016 | */ |
| 3017 | public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address"; |
| 3018 | |
| 3019 | /** |
| 3020 | * The "-w deadline" parameter for the ping, ie, the max time in |
| 3021 | * seconds to spend pinging. |
| 3022 | * @hide |
| 3023 | */ |
| 3024 | public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline"; |
| 3025 | |
| 3026 | /** |
| 3027 | * The interval in milliseconds at which to check gprs registration |
| 3028 | * after the first registration mismatch of gprs and voice service, |
| 3029 | * to detect possible data network registration problems. |
| 3030 | * |
| 3031 | * @hide |
| 3032 | */ |
| 3033 | public static final String GPRS_REGISTER_CHECK_PERIOD_MS = |
| 3034 | "gprs_register_check_period_ms"; |
| 3035 | |
| 3036 | /** |
| 3037 | * The length of time in milli-seconds that automatic small adjustments to |
| 3038 | * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded. |
| 3039 | * @hide |
| 3040 | */ |
| 3041 | public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing"; |
| 3042 | |
| 3043 | /** |
| 3044 | * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment |
| 3045 | * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been |
| 3046 | * exceeded. |
| 3047 | * @hide |
| 3048 | */ |
| 3049 | public static final String NITZ_UPDATE_DIFF = "nitz_update_diff"; |
| 3050 | |
| 3051 | /** |
| 3052 | * The maximum reconnect delay for short network outages or when the network is suspended |
| 3053 | * due to phone use. |
| 3054 | * @hide |
| 3055 | */ |
| 3056 | public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS = |
| 3057 | "sync_max_retry_delay_in_seconds"; |
| 3058 | |
| 3059 | /** |
| 3060 | * The interval in milliseconds at which to check the number of SMS sent |
| 3061 | * out without asking for use permit, to limit the un-authorized SMS |
| 3062 | * usage. |
| 3063 | * @hide |
| 3064 | */ |
| 3065 | public static final String SMS_OUTGOING_CHECK_INTERVAL_MS = |
| 3066 | "sms_outgoing_check_interval_ms"; |
| 3067 | |
| 3068 | /** |
| 3069 | * The number of outgoing SMS sent without asking for user permit |
| 3070 | * (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS} |
| 3071 | * @hide |
| 3072 | */ |
| 3073 | public static final String SMS_OUTGOING_CHECK_MAX_COUNT = |
| 3074 | "sms_outgoing_check_max_count"; |
| 3075 | |
| 3076 | /** |
Doug Zongker | aed8f8e | 2010-01-07 18:07:50 -0800 | [diff] [blame] | 3077 | * The number of promoted sources in GlobalSearch. |
| 3078 | * @hide |
| 3079 | */ |
| 3080 | public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources"; |
| 3081 | /** |
| 3082 | * The maximum number of suggestions returned by GlobalSearch. |
| 3083 | * @hide |
| 3084 | */ |
| 3085 | public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display"; |
| 3086 | /** |
| 3087 | * The number of suggestions GlobalSearch will ask each non-web search source for. |
| 3088 | * @hide |
| 3089 | */ |
| 3090 | public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source"; |
| 3091 | /** |
| 3092 | * The number of suggestions the GlobalSearch will ask the web search source for. |
| 3093 | * @hide |
| 3094 | */ |
| 3095 | public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT = |
| 3096 | "search_web_results_override_limit"; |
| 3097 | /** |
| 3098 | * The number of milliseconds that GlobalSearch will wait for suggestions from |
| 3099 | * promoted sources before continuing with all other sources. |
| 3100 | * @hide |
| 3101 | */ |
| 3102 | public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS = |
| 3103 | "search_promoted_source_deadline_millis"; |
| 3104 | /** |
| 3105 | * The number of milliseconds before GlobalSearch aborts search suggesiton queries. |
| 3106 | * @hide |
| 3107 | */ |
| 3108 | public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis"; |
| 3109 | /** |
| 3110 | * The maximum number of milliseconds that GlobalSearch shows the previous results |
| 3111 | * after receiving a new query. |
| 3112 | * @hide |
| 3113 | */ |
| 3114 | public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis"; |
| 3115 | /** |
| 3116 | * The maximum age of log data used for shortcuts in GlobalSearch. |
| 3117 | * @hide |
| 3118 | */ |
| 3119 | public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis"; |
| 3120 | /** |
| 3121 | * The maximum age of log data used for source ranking in GlobalSearch. |
| 3122 | * @hide |
| 3123 | */ |
| 3124 | public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS = |
| 3125 | "search_max_source_event_age_millis"; |
| 3126 | /** |
| 3127 | * The minimum number of impressions needed to rank a source in GlobalSearch. |
| 3128 | * @hide |
| 3129 | */ |
| 3130 | public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING = |
| 3131 | "search_min_impressions_for_source_ranking"; |
| 3132 | /** |
| 3133 | * The minimum number of clicks needed to rank a source in GlobalSearch. |
| 3134 | * @hide |
| 3135 | */ |
| 3136 | public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING = |
| 3137 | "search_min_clicks_for_source_ranking"; |
| 3138 | /** |
| 3139 | * The maximum number of shortcuts shown by GlobalSearch. |
| 3140 | * @hide |
| 3141 | */ |
| 3142 | public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned"; |
| 3143 | /** |
| 3144 | * The size of the core thread pool for suggestion queries in GlobalSearch. |
| 3145 | * @hide |
| 3146 | */ |
| 3147 | public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE = |
| 3148 | "search_query_thread_core_pool_size"; |
| 3149 | /** |
| 3150 | * The maximum size of the thread pool for suggestion queries in GlobalSearch. |
| 3151 | * @hide |
| 3152 | */ |
| 3153 | public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE = |
| 3154 | "search_query_thread_max_pool_size"; |
| 3155 | /** |
| 3156 | * The size of the core thread pool for shortcut refreshing in GlobalSearch. |
| 3157 | * @hide |
| 3158 | */ |
| 3159 | public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE = |
| 3160 | "search_shortcut_refresh_core_pool_size"; |
| 3161 | /** |
| 3162 | * The maximum size of the thread pool for shortcut refreshing in GlobalSearch. |
| 3163 | * @hide |
| 3164 | */ |
| 3165 | public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE = |
| 3166 | "search_shortcut_refresh_max_pool_size"; |
| 3167 | /** |
| 3168 | * The maximun time that excess threads in the GlobalSeach thread pools will |
| 3169 | * wait before terminating. |
| 3170 | * @hide |
| 3171 | */ |
| 3172 | public static final String SEARCH_THREAD_KEEPALIVE_SECONDS = |
| 3173 | "search_thread_keepalive_seconds"; |
| 3174 | /** |
| 3175 | * The maximum number of concurrent suggestion queries to each source. |
| 3176 | * @hide |
| 3177 | */ |
| 3178 | public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT = |
| 3179 | "search_per_source_concurrent_query_limit"; |
| 3180 | |
San Mehat | 87734d3 | 2010-01-08 12:53:06 -0800 | [diff] [blame] | 3181 | /** |
| 3182 | * Whether or not alert sounds are played on MountService events. (0 = false, 1 = true) |
| 3183 | * @hide |
| 3184 | */ |
| 3185 | public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd"; |
| 3186 | |
| 3187 | /** |
| 3188 | * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true) |
| 3189 | * @hide |
| 3190 | */ |
| 3191 | public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart"; |
| 3192 | |
| 3193 | /** |
| 3194 | * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true) |
| 3195 | * @hide |
| 3196 | */ |
| 3197 | public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt"; |
| 3198 | |
| 3199 | /** |
| 3200 | * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true) |
| 3201 | * @hide |
| 3202 | */ |
| 3203 | public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled"; |
Doug Zongker | aed8f8e | 2010-01-07 18:07:50 -0800 | [diff] [blame] | 3204 | |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 3205 | /** |
| 3206 | * If nonzero, ANRs in invisible background processes bring up a dialog. |
| 3207 | * Otherwise, the process will be silently killed. |
| 3208 | * @hide |
| 3209 | */ |
| 3210 | public static final String ANR_SHOW_BACKGROUND = "anr_show_background"; |
Erik | eebc8e2 | 2010-02-18 13:27:19 -0800 | [diff] [blame] | 3211 | |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 3212 | /** |
| 3213 | * The {@link ComponentName} string of the service to be used as the voice recognition |
| 3214 | * service. |
Erik | eebc8e2 | 2010-02-18 13:27:19 -0800 | [diff] [blame] | 3215 | * |
Mike LeBeau | 5d34e9b | 2010-02-10 19:34:56 -0800 | [diff] [blame] | 3216 | * @hide |
| 3217 | */ |
| 3218 | public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service"; |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 3219 | |
Doug Zongker | aed8f8e | 2010-01-07 18:07:50 -0800 | [diff] [blame] | 3220 | /** |
David Brown | 458e806 | 2010-03-08 21:52:11 -0800 | [diff] [blame] | 3221 | * What happens when the user presses the Power button while in-call |
| 3222 | * and the screen is on.<br/> |
| 3223 | * <b>Values:</b><br/> |
| 3224 | * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/> |
| 3225 | * 2 - The Power button hangs up the current call.<br/> |
| 3226 | * |
| 3227 | * @hide |
| 3228 | */ |
| 3229 | public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior"; |
| 3230 | |
| 3231 | /** |
| 3232 | * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen". |
| 3233 | * @hide |
| 3234 | */ |
| 3235 | public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1; |
| 3236 | |
| 3237 | /** |
| 3238 | * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up". |
| 3239 | * @hide |
| 3240 | */ |
| 3241 | public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2; |
| 3242 | |
| 3243 | /** |
| 3244 | * INCALL_POWER_BUTTON_BEHAVIOR default value. |
| 3245 | * @hide |
| 3246 | */ |
| 3247 | public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT = |
| 3248 | INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF; |
| 3249 | |
| 3250 | /** |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 3251 | * @hide |
| 3252 | */ |
| 3253 | public static final String[] SETTINGS_TO_BACKUP = { |
Amith Yamasani | 8823c0a8 | 2009-07-07 14:30:17 -0700 | [diff] [blame] | 3254 | ADB_ENABLED, |
| 3255 | ALLOW_MOCK_LOCATION, |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 3256 | PARENTAL_CONTROL_ENABLED, |
| 3257 | PARENTAL_CONTROL_REDIRECT_URL, |
| 3258 | USB_MASS_STORAGE_ENABLED, |
| 3259 | ACCESSIBILITY_ENABLED, |
Christopher Tate | 14c2d79 | 2010-02-25 16:49:44 -0800 | [diff] [blame] | 3260 | BACKUP_AUTO_RESTORE, |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 3261 | ENABLED_ACCESSIBILITY_SERVICES, |
| 3262 | TTS_USE_DEFAULTS, |
| 3263 | TTS_DEFAULT_RATE, |
| 3264 | TTS_DEFAULT_PITCH, |
| 3265 | TTS_DEFAULT_SYNTH, |
| 3266 | TTS_DEFAULT_LANG, |
| 3267 | TTS_DEFAULT_COUNTRY, |
| 3268 | WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, |
| 3269 | WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, |
| 3270 | WIFI_NUM_ALLOWED_CHANNELS, |
| 3271 | WIFI_NUM_OPEN_NETWORKS_KEPT, |
San Mehat | 87734d3 | 2010-01-08 12:53:06 -0800 | [diff] [blame] | 3272 | MOUNT_PLAY_NOTIFICATION_SND, |
| 3273 | MOUNT_UMS_AUTOSTART, |
| 3274 | MOUNT_UMS_PROMPT, |
| 3275 | MOUNT_UMS_NOTIFY_ENABLED |
-b master | 501eec9 | 2009-07-06 13:53:11 -0700 | [diff] [blame] | 3276 | }; |
| 3277 | |
| 3278 | /** |
Mike Lockwood | bd2a712 | 2009-04-02 23:41:33 -0700 | [diff] [blame] | 3279 | * Helper method for determining if a location provider is enabled. |
| 3280 | * @param cr the content resolver to use |
| 3281 | * @param provider the location provider to query |
| 3282 | * @return true if the provider is enabled |
Mike Lockwood | bd2a712 | 2009-04-02 23:41:33 -0700 | [diff] [blame] | 3283 | */ |
| 3284 | public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) { |
| 3285 | String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED); |
| 3286 | if (allowedProviders != null) { |
| 3287 | return (allowedProviders.equals(provider) || |
| 3288 | allowedProviders.contains("," + provider + ",") || |
| 3289 | allowedProviders.startsWith(provider + ",") || |
| 3290 | allowedProviders.endsWith("," + provider)); |
| 3291 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3292 | return false; |
Mike Lockwood | bd2a712 | 2009-04-02 23:41:33 -0700 | [diff] [blame] | 3293 | } |
| 3294 | |
| 3295 | /** |
| 3296 | * Thread-safe method for enabling or disabling a single location provider. |
| 3297 | * @param cr the content resolver to use |
| 3298 | * @param provider the location provider to enable or disable |
| 3299 | * @param enabled true if the provider should be enabled |
Mike Lockwood | bd2a712 | 2009-04-02 23:41:33 -0700 | [diff] [blame] | 3300 | */ |
| 3301 | public static final void setLocationProviderEnabled(ContentResolver cr, |
| 3302 | String provider, boolean enabled) { |
| 3303 | // to ensure thread safety, we write the provider name with a '+' or '-' |
| 3304 | // and let the SettingsProvider handle it rather than reading and modifying |
| 3305 | // the list of enabled providers. |
| 3306 | if (enabled) { |
| 3307 | provider = "+" + provider; |
| 3308 | } else { |
| 3309 | provider = "-" + provider; |
| 3310 | } |
| 3311 | putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider); |
| 3312 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3313 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3314 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3315 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3316 | * User-defined bookmarks and shortcuts. The target of each bookmark is an |
| 3317 | * Intent URL, allowing it to be either a web page or a particular |
| 3318 | * application activity. |
| 3319 | * |
| 3320 | * @hide |
| 3321 | */ |
| 3322 | public static final class Bookmarks implements BaseColumns |
| 3323 | { |
| 3324 | private static final String TAG = "Bookmarks"; |
| 3325 | |
| 3326 | /** |
| 3327 | * The content:// style URL for this table |
| 3328 | */ |
| 3329 | public static final Uri CONTENT_URI = |
| 3330 | Uri.parse("content://" + AUTHORITY + "/bookmarks"); |
| 3331 | |
| 3332 | /** |
| 3333 | * The row ID. |
| 3334 | * <p>Type: INTEGER</p> |
| 3335 | */ |
| 3336 | public static final String ID = "_id"; |
| 3337 | |
| 3338 | /** |
| 3339 | * Descriptive name of the bookmark that can be displayed to the user. |
| 3340 | * If this is empty, the title should be resolved at display time (use |
| 3341 | * {@link #getTitle(Context, Cursor)} any time you want to display the |
| 3342 | * title of a bookmark.) |
| 3343 | * <P> |
| 3344 | * Type: TEXT |
| 3345 | * </P> |
| 3346 | */ |
| 3347 | public static final String TITLE = "title"; |
| 3348 | |
| 3349 | /** |
| 3350 | * Arbitrary string (displayed to the user) that allows bookmarks to be |
| 3351 | * organized into categories. There are some special names for |
| 3352 | * standard folders, which all start with '@'. The label displayed for |
| 3353 | * the folder changes with the locale (via {@link #getLabelForFolder}) but |
| 3354 | * the folder name does not change so you can consistently query for |
| 3355 | * the folder regardless of the current locale. |
| 3356 | * |
| 3357 | * <P>Type: TEXT</P> |
| 3358 | * |
| 3359 | */ |
| 3360 | public static final String FOLDER = "folder"; |
| 3361 | |
| 3362 | /** |
| 3363 | * The Intent URL of the bookmark, describing what it points to. This |
| 3364 | * value is given to {@link android.content.Intent#getIntent} to create |
| 3365 | * an Intent that can be launched. |
| 3366 | * <P>Type: TEXT</P> |
| 3367 | */ |
| 3368 | public static final String INTENT = "intent"; |
| 3369 | |
| 3370 | /** |
| 3371 | * Optional shortcut character associated with this bookmark. |
| 3372 | * <P>Type: INTEGER</P> |
| 3373 | */ |
| 3374 | public static final String SHORTCUT = "shortcut"; |
| 3375 | |
| 3376 | /** |
| 3377 | * The order in which the bookmark should be displayed |
| 3378 | * <P>Type: INTEGER</P> |
| 3379 | */ |
| 3380 | public static final String ORDERING = "ordering"; |
| 3381 | |
| 3382 | private static final String[] sIntentProjection = { INTENT }; |
| 3383 | private static final String[] sShortcutProjection = { ID, SHORTCUT }; |
| 3384 | private static final String sShortcutSelection = SHORTCUT + "=?"; |
| 3385 | |
| 3386 | /** |
| 3387 | * Convenience function to retrieve the bookmarked Intent for a |
| 3388 | * particular shortcut key. |
| 3389 | * |
| 3390 | * @param cr The ContentResolver to query. |
| 3391 | * @param shortcut The shortcut key. |
| 3392 | * |
| 3393 | * @return Intent The bookmarked URL, or null if there is no bookmark |
| 3394 | * matching the given shortcut. |
| 3395 | */ |
| 3396 | public static Intent getIntentForShortcut(ContentResolver cr, char shortcut) |
| 3397 | { |
| 3398 | Intent intent = null; |
| 3399 | |
| 3400 | Cursor c = cr.query(CONTENT_URI, |
| 3401 | sIntentProjection, sShortcutSelection, |
| 3402 | new String[] { String.valueOf((int) shortcut) }, ORDERING); |
| 3403 | // Keep trying until we find a valid shortcut |
| 3404 | try { |
| 3405 | while (intent == null && c.moveToNext()) { |
| 3406 | try { |
| 3407 | String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT)); |
| 3408 | intent = Intent.getIntent(intentURI); |
| 3409 | } catch (java.net.URISyntaxException e) { |
| 3410 | // The stored URL is bad... ignore it. |
| 3411 | } catch (IllegalArgumentException e) { |
| 3412 | // Column not found |
Dianne Hackborn | a33e3f7 | 2009-09-29 17:28:24 -0700 | [diff] [blame] | 3413 | Log.w(TAG, "Intent column not found", e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3414 | } |
| 3415 | } |
| 3416 | } finally { |
| 3417 | if (c != null) c.close(); |
| 3418 | } |
| 3419 | |
| 3420 | return intent; |
| 3421 | } |
| 3422 | |
| 3423 | /** |
| 3424 | * Add a new bookmark to the system. |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3425 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3426 | * @param cr The ContentResolver to query. |
| 3427 | * @param intent The desired target of the bookmark. |
| 3428 | * @param title Bookmark title that is shown to the user; null if none |
| 3429 | * or it should be resolved to the intent's title. |
| 3430 | * @param folder Folder in which to place the bookmark; null if none. |
| 3431 | * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If |
| 3432 | * this is non-zero and there is an existing bookmark entry |
| 3433 | * with this same shortcut, then that existing shortcut is |
| 3434 | * cleared (the bookmark is not removed). |
| 3435 | * @return The unique content URL for the new bookmark entry. |
| 3436 | */ |
| 3437 | public static Uri add(ContentResolver cr, |
| 3438 | Intent intent, |
| 3439 | String title, |
| 3440 | String folder, |
| 3441 | char shortcut, |
| 3442 | int ordering) |
| 3443 | { |
| 3444 | // If a shortcut is supplied, and it is already defined for |
| 3445 | // another bookmark, then remove the old definition. |
| 3446 | if (shortcut != 0) { |
| 3447 | Cursor c = cr.query(CONTENT_URI, |
| 3448 | sShortcutProjection, sShortcutSelection, |
| 3449 | new String[] { String.valueOf((int) shortcut) }, null); |
| 3450 | try { |
| 3451 | if (c.moveToFirst()) { |
| 3452 | while (c.getCount() > 0) { |
| 3453 | if (!c.deleteRow()) { |
| 3454 | Log.w(TAG, "Could not delete existing shortcut row"); |
| 3455 | } |
| 3456 | } |
| 3457 | } |
| 3458 | } finally { |
| 3459 | if (c != null) c.close(); |
| 3460 | } |
| 3461 | } |
| 3462 | |
| 3463 | ContentValues values = new ContentValues(); |
| 3464 | if (title != null) values.put(TITLE, title); |
| 3465 | if (folder != null) values.put(FOLDER, folder); |
| 3466 | values.put(INTENT, intent.toURI()); |
| 3467 | if (shortcut != 0) values.put(SHORTCUT, (int) shortcut); |
| 3468 | values.put(ORDERING, ordering); |
| 3469 | return cr.insert(CONTENT_URI, values); |
| 3470 | } |
| 3471 | |
| 3472 | /** |
| 3473 | * Return the folder name as it should be displayed to the user. This |
| 3474 | * takes care of localizing special folders. |
| 3475 | * |
| 3476 | * @param r Resources object for current locale; only need access to |
| 3477 | * system resources. |
| 3478 | * @param folder The value found in the {@link #FOLDER} column. |
| 3479 | * |
| 3480 | * @return CharSequence The label for this folder that should be shown |
| 3481 | * to the user. |
| 3482 | */ |
| 3483 | public static CharSequence getLabelForFolder(Resources r, String folder) { |
| 3484 | return folder; |
| 3485 | } |
| 3486 | |
| 3487 | /** |
| 3488 | * Return the title as it should be displayed to the user. This takes |
| 3489 | * care of localizing bookmarks that point to activities. |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3490 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3491 | * @param context A context. |
| 3492 | * @param cursor A cursor pointing to the row whose title should be |
| 3493 | * returned. The cursor must contain at least the {@link #TITLE} |
| 3494 | * and {@link #INTENT} columns. |
| 3495 | * @return A title that is localized and can be displayed to the user, |
| 3496 | * or the empty string if one could not be found. |
| 3497 | */ |
| 3498 | public static CharSequence getTitle(Context context, Cursor cursor) { |
| 3499 | int titleColumn = cursor.getColumnIndex(TITLE); |
| 3500 | int intentColumn = cursor.getColumnIndex(INTENT); |
| 3501 | if (titleColumn == -1 || intentColumn == -1) { |
| 3502 | throw new IllegalArgumentException( |
| 3503 | "The cursor must contain the TITLE and INTENT columns."); |
| 3504 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3505 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3506 | String title = cursor.getString(titleColumn); |
| 3507 | if (!TextUtils.isEmpty(title)) { |
| 3508 | return title; |
| 3509 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3510 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3511 | String intentUri = cursor.getString(intentColumn); |
| 3512 | if (TextUtils.isEmpty(intentUri)) { |
| 3513 | return ""; |
| 3514 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3515 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3516 | Intent intent; |
| 3517 | try { |
| 3518 | intent = Intent.getIntent(intentUri); |
| 3519 | } catch (URISyntaxException e) { |
| 3520 | return ""; |
| 3521 | } |
Jaikumar Ganesh | 9bfbfbd | 2009-05-15 12:05:56 -0700 | [diff] [blame] | 3522 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3523 | PackageManager packageManager = context.getPackageManager(); |
| 3524 | ResolveInfo info = packageManager.resolveActivity(intent, 0); |
| 3525 | return info != null ? info.loadLabel(packageManager) : ""; |
| 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3530 | * Returns the device ID that we should use when connecting to the mobile gtalk server. |
| 3531 | * This is a string like "android-0x1242", where the hex string is the Android ID obtained |
| 3532 | * from the GoogleLoginService. |
| 3533 | * |
| 3534 | * @param androidId The Android ID for this device. |
| 3535 | * @return The device ID that should be used when connecting to the mobile gtalk server. |
| 3536 | * @hide |
| 3537 | */ |
| 3538 | public static String getGTalkDeviceId(long androidId) { |
| 3539 | return "android-" + Long.toHexString(androidId); |
| 3540 | } |
| 3541 | } |