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