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