Settings.java revision 2a091d7aa0c174986387e5d56bf97a87fe075bdb
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 * Show pointer location on screen? 1493 * 0 = no 1494 * 1 = yes 1495 * @hide 1496 */ 1497 public static final String POINTER_LOCATION = "pointer_location"; 1498 1499 /** 1500 * Whether to play a sound for low-battery alerts. 1501 * @hide 1502 */ 1503 public static final String POWER_SOUNDS_ENABLED = "power_sounds_enabled"; 1504 1505 /** 1506 * Whether to play a sound for dock events. 1507 * @hide 1508 */ 1509 public static final String DOCK_SOUNDS_ENABLED = "dock_sounds_enabled"; 1510 1511 /** 1512 * Whether to play sounds when the keyguard is shown and dismissed. 1513 * @hide 1514 */ 1515 public static final String LOCKSCREEN_SOUNDS_ENABLED = "lockscreen_sounds_enabled"; 1516 1517 /** 1518 * URI for the low battery sound file. 1519 * @hide 1520 */ 1521 public static final String LOW_BATTERY_SOUND = "low_battery_sound"; 1522 1523 /** 1524 * URI for the desk dock "in" event sound. 1525 * @hide 1526 */ 1527 public static final String DESK_DOCK_SOUND = "desk_dock_sound"; 1528 1529 /** 1530 * URI for the desk dock "out" event sound. 1531 * @hide 1532 */ 1533 public static final String DESK_UNDOCK_SOUND = "desk_undock_sound"; 1534 1535 /** 1536 * URI for the car dock "in" event sound. 1537 * @hide 1538 */ 1539 public static final String CAR_DOCK_SOUND = "car_dock_sound"; 1540 1541 /** 1542 * URI for the car dock "out" event sound. 1543 * @hide 1544 */ 1545 public static final String CAR_UNDOCK_SOUND = "car_undock_sound"; 1546 1547 /** 1548 * URI for the "device locked" (keyguard shown) sound. 1549 * @hide 1550 */ 1551 public static final String LOCK_SOUND = "lock_sound"; 1552 1553 /** 1554 * URI for the "device unlocked" (keyguard dismissed) sound. 1555 * @hide 1556 */ 1557 public static final String UNLOCK_SOUND = "unlock_sound"; 1558 1559 /** 1560 * Settings to backup. This is here so that it's in the same place as the settings 1561 * keys and easy to update. 1562 * @hide 1563 */ 1564 public static final String[] SETTINGS_TO_BACKUP = { 1565 STAY_ON_WHILE_PLUGGED_IN, 1566 WIFI_SLEEP_POLICY, 1567 WIFI_USE_STATIC_IP, 1568 WIFI_STATIC_IP, 1569 WIFI_STATIC_GATEWAY, 1570 WIFI_STATIC_NETMASK, 1571 WIFI_STATIC_DNS1, 1572 WIFI_STATIC_DNS2, 1573 BLUETOOTH_DISCOVERABILITY, 1574 BLUETOOTH_DISCOVERABILITY_TIMEOUT, 1575 DIM_SCREEN, 1576 SCREEN_OFF_TIMEOUT, 1577 SCREEN_BRIGHTNESS, 1578 SCREEN_BRIGHTNESS_MODE, 1579 VIBRATE_ON, 1580 NOTIFICATIONS_USE_RING_VOLUME, 1581 MODE_RINGER, 1582 MODE_RINGER_STREAMS_AFFECTED, 1583 MUTE_STREAMS_AFFECTED, 1584 VOLUME_VOICE, 1585 VOLUME_SYSTEM, 1586 VOLUME_RING, 1587 VOLUME_MUSIC, 1588 VOLUME_ALARM, 1589 VOLUME_NOTIFICATION, 1590 VOLUME_BLUETOOTH_SCO, 1591 VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE, 1592 VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE, 1593 VOLUME_RING + APPEND_FOR_LAST_AUDIBLE, 1594 VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE, 1595 VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE, 1596 VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE, 1597 VOLUME_BLUETOOTH_SCO + APPEND_FOR_LAST_AUDIBLE, 1598 TEXT_AUTO_REPLACE, 1599 TEXT_AUTO_CAPS, 1600 TEXT_AUTO_PUNCTUATE, 1601 TEXT_SHOW_PASSWORD, 1602 AUTO_TIME, 1603 TIME_12_24, 1604 DATE_FORMAT, 1605 ACCELEROMETER_ROTATION, 1606 DTMF_TONE_WHEN_DIALING, 1607 DTMF_TONE_TYPE_WHEN_DIALING, 1608 EMERGENCY_TONE, 1609 CALL_AUTO_RETRY, 1610 HEARING_AID, 1611 TTY_MODE, 1612 SOUND_EFFECTS_ENABLED, 1613 HAPTIC_FEEDBACK_ENABLED, 1614 SHOW_WEB_SUGGESTIONS, 1615 NOTIFICATION_LIGHT_PULSE 1616 }; 1617 1618 // Settings moved to Settings.Secure 1619 1620 /** 1621 * @deprecated Use {@link android.provider.Settings.Secure#ADB_ENABLED} 1622 * instead 1623 */ 1624 @Deprecated 1625 public static final String ADB_ENABLED = Secure.ADB_ENABLED; 1626 1627 /** 1628 * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead 1629 */ 1630 @Deprecated 1631 public static final String ANDROID_ID = Secure.ANDROID_ID; 1632 1633 /** 1634 * @deprecated Use {@link android.provider.Settings.Secure#BLUETOOTH_ON} instead 1635 */ 1636 @Deprecated 1637 public static final String BLUETOOTH_ON = Secure.BLUETOOTH_ON; 1638 1639 /** 1640 * @deprecated Use {@link android.provider.Settings.Secure#DATA_ROAMING} instead 1641 */ 1642 @Deprecated 1643 public static final String DATA_ROAMING = Secure.DATA_ROAMING; 1644 1645 /** 1646 * @deprecated Use {@link android.provider.Settings.Secure#DEVICE_PROVISIONED} instead 1647 */ 1648 @Deprecated 1649 public static final String DEVICE_PROVISIONED = Secure.DEVICE_PROVISIONED; 1650 1651 /** 1652 * @deprecated Use {@link android.provider.Settings.Secure#HTTP_PROXY} instead 1653 */ 1654 @Deprecated 1655 public static final String HTTP_PROXY = Secure.HTTP_PROXY; 1656 1657 /** 1658 * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead 1659 */ 1660 @Deprecated 1661 public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS; 1662 1663 /** 1664 * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED} 1665 * instead 1666 */ 1667 @Deprecated 1668 public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED; 1669 1670 /** 1671 * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead 1672 */ 1673 @Deprecated 1674 public static final String LOGGING_ID = Secure.LOGGING_ID; 1675 1676 /** 1677 * @deprecated Use {@link android.provider.Settings.Secure#NETWORK_PREFERENCE} instead 1678 */ 1679 @Deprecated 1680 public static final String NETWORK_PREFERENCE = Secure.NETWORK_PREFERENCE; 1681 1682 /** 1683 * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED} 1684 * instead 1685 */ 1686 @Deprecated 1687 public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED; 1688 1689 /** 1690 * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE} 1691 * instead 1692 */ 1693 @Deprecated 1694 public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE; 1695 1696 /** 1697 * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL} 1698 * instead 1699 */ 1700 @Deprecated 1701 public static final String PARENTAL_CONTROL_REDIRECT_URL = 1702 Secure.PARENTAL_CONTROL_REDIRECT_URL; 1703 1704 /** 1705 * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead 1706 */ 1707 @Deprecated 1708 public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME; 1709 1710 /** 1711 * @deprecated Use {@link android.provider.Settings.Secure#USB_MASS_STORAGE_ENABLED} instead 1712 */ 1713 @Deprecated 1714 public static final String USB_MASS_STORAGE_ENABLED = Secure.USB_MASS_STORAGE_ENABLED; 1715 1716 /** 1717 * @deprecated Use {@link android.provider.Settings.Secure#USE_GOOGLE_MAIL} instead 1718 */ 1719 @Deprecated 1720 public static final String USE_GOOGLE_MAIL = Secure.USE_GOOGLE_MAIL; 1721 1722 /** 1723 * @deprecated Use 1724 * {@link android.provider.Settings.Secure#WIFI_MAX_DHCP_RETRY_COUNT} instead 1725 */ 1726 @Deprecated 1727 public static final String WIFI_MAX_DHCP_RETRY_COUNT = Secure.WIFI_MAX_DHCP_RETRY_COUNT; 1728 1729 /** 1730 * @deprecated Use 1731 * {@link android.provider.Settings.Secure#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead 1732 */ 1733 @Deprecated 1734 public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = 1735 Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS; 1736 1737 /** 1738 * @deprecated Use 1739 * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead 1740 */ 1741 @Deprecated 1742 public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = 1743 Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON; 1744 1745 /** 1746 * @deprecated Use 1747 * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead 1748 */ 1749 @Deprecated 1750 public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = 1751 Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY; 1752 1753 /** 1754 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_NUM_OPEN_NETWORKS_KEPT} 1755 * instead 1756 */ 1757 @Deprecated 1758 public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Secure.WIFI_NUM_OPEN_NETWORKS_KEPT; 1759 1760 /** 1761 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_ON} instead 1762 */ 1763 @Deprecated 1764 public static final String WIFI_ON = Secure.WIFI_ON; 1765 1766 /** 1767 * @deprecated Use 1768 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE} 1769 * instead 1770 */ 1771 @Deprecated 1772 public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE = 1773 Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE; 1774 1775 /** 1776 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead 1777 */ 1778 @Deprecated 1779 public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT; 1780 1781 /** 1782 * @deprecated Use 1783 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead 1784 */ 1785 @Deprecated 1786 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS = 1787 Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS; 1788 1789 /** 1790 * @deprecated Use 1791 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead 1792 */ 1793 @Deprecated 1794 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED = 1795 Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED; 1796 1797 /** 1798 * @deprecated Use 1799 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS} 1800 * instead 1801 */ 1802 @Deprecated 1803 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS = 1804 Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS; 1805 1806 /** 1807 * @deprecated Use 1808 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead 1809 */ 1810 @Deprecated 1811 public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT = 1812 Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT; 1813 1814 /** 1815 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS} 1816 * instead 1817 */ 1818 @Deprecated 1819 public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS; 1820 1821 /** 1822 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ON} instead 1823 */ 1824 @Deprecated 1825 public static final String WIFI_WATCHDOG_ON = Secure.WIFI_WATCHDOG_ON; 1826 1827 /** 1828 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead 1829 */ 1830 @Deprecated 1831 public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT; 1832 1833 /** 1834 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS} 1835 * instead 1836 */ 1837 @Deprecated 1838 public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS; 1839 1840 /** 1841 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS} 1842 * instead 1843 */ 1844 @Deprecated 1845 public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = 1846 Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS; 1847 } 1848 1849 /** 1850 * Secure system settings, containing system preferences that applications 1851 * can read but are not allowed to write. These are for preferences that 1852 * the user must explicitly modify through the system UI or specialized 1853 * APIs for those values, not modified directly by applications. 1854 */ 1855 public static final class Secure extends NameValueTable { 1856 public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version"; 1857 1858 private static volatile NameValueCache mNameValueCache = null; 1859 1860 /** 1861 * Look up a name in the database. 1862 * @param resolver to access the database with 1863 * @param name to look up in the table 1864 * @return the corresponding value, or null if not present 1865 */ 1866 public synchronized static String getString(ContentResolver resolver, String name) { 1867 if (mNameValueCache == null) { 1868 mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI); 1869 } 1870 return mNameValueCache.getString(resolver, name); 1871 } 1872 1873 /** 1874 * Store a name/value pair into the database. 1875 * @param resolver to access the database with 1876 * @param name to store 1877 * @param value to associate with the name 1878 * @return true if the value was set, false on database errors 1879 */ 1880 public static boolean putString(ContentResolver resolver, 1881 String name, String value) { 1882 return putString(resolver, CONTENT_URI, name, value); 1883 } 1884 1885 /** 1886 * Construct the content URI for a particular name/value pair, 1887 * useful for monitoring changes with a ContentObserver. 1888 * @param name to look up in the table 1889 * @return the corresponding content URI, or null if not present 1890 */ 1891 public static Uri getUriFor(String name) { 1892 return getUriFor(CONTENT_URI, name); 1893 } 1894 1895 /** 1896 * Convenience function for retrieving a single secure settings value 1897 * as an integer. Note that internally setting values are always 1898 * stored as strings; this function converts the string to an integer 1899 * for you. The default value will be returned if the setting is 1900 * not defined or not an integer. 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 integer. 1908 */ 1909 public static int getInt(ContentResolver cr, String name, int def) { 1910 String v = getString(cr, name); 1911 try { 1912 return v != null ? Integer.parseInt(v) : def; 1913 } catch (NumberFormatException e) { 1914 return def; 1915 } 1916 } 1917 1918 /** 1919 * Convenience function for retrieving a single secure settings value 1920 * as an integer. Note that internally setting values are always 1921 * stored as strings; this function converts the string to an integer 1922 * for you. 1923 * <p> 1924 * This version does not take a default value. If the setting has not 1925 * been set, or the string value is not a number, 1926 * it throws {@link SettingNotFoundException}. 1927 * 1928 * @param cr The ContentResolver to access. 1929 * @param name The name of the setting to retrieve. 1930 * 1931 * @throws SettingNotFoundException Thrown if a setting by the given 1932 * name can't be found or the setting value is not an integer. 1933 * 1934 * @return The setting's current value. 1935 */ 1936 public static int getInt(ContentResolver cr, String name) 1937 throws SettingNotFoundException { 1938 String v = getString(cr, name); 1939 try { 1940 return Integer.parseInt(v); 1941 } catch (NumberFormatException e) { 1942 throw new SettingNotFoundException(name); 1943 } 1944 } 1945 1946 /** 1947 * Convenience function for updating a single settings value as an 1948 * integer. This will either create a new entry in the table if the 1949 * given name does not exist, or modify the value of the existing row 1950 * with that name. Note that internally setting values are always 1951 * stored as strings, so this function converts the given value to a 1952 * string before storing it. 1953 * 1954 * @param cr The ContentResolver to access. 1955 * @param name The name of the setting to modify. 1956 * @param value The new value for the setting. 1957 * @return true if the value was set, false on database errors 1958 */ 1959 public static boolean putInt(ContentResolver cr, String name, int value) { 1960 return putString(cr, name, Integer.toString(value)); 1961 } 1962 1963 /** 1964 * Convenience function for retrieving a single secure settings value 1965 * as a {@code long}. Note that internally setting values are always 1966 * stored as strings; this function converts the string to a {@code long} 1967 * for you. The default value will be returned if the setting is 1968 * not defined or not a {@code long}. 1969 * 1970 * @param cr The ContentResolver to access. 1971 * @param name The name of the setting to retrieve. 1972 * @param def Value to return if the setting is not defined. 1973 * 1974 * @return The setting's current value, or 'def' if it is not defined 1975 * or not a valid {@code long}. 1976 */ 1977 public static long getLong(ContentResolver cr, String name, long def) { 1978 String valString = getString(cr, name); 1979 long value; 1980 try { 1981 value = valString != null ? Long.parseLong(valString) : def; 1982 } catch (NumberFormatException e) { 1983 value = def; 1984 } 1985 return value; 1986 } 1987 1988 /** 1989 * Convenience function for retrieving a single secure settings value 1990 * as a {@code long}. Note that internally setting values are always 1991 * stored as strings; this function converts the string to a {@code long} 1992 * for you. 1993 * <p> 1994 * This version does not take a default value. If the setting has not 1995 * been set, or the string value is not a number, 1996 * it throws {@link SettingNotFoundException}. 1997 * 1998 * @param cr The ContentResolver to access. 1999 * @param name The name of the setting to retrieve. 2000 * 2001 * @return The setting's current value. 2002 * @throws SettingNotFoundException Thrown if a setting by the given 2003 * name can't be found or the setting value is not an integer. 2004 */ 2005 public static long getLong(ContentResolver cr, String name) 2006 throws SettingNotFoundException { 2007 String valString = getString(cr, name); 2008 try { 2009 return Long.parseLong(valString); 2010 } catch (NumberFormatException e) { 2011 throw new SettingNotFoundException(name); 2012 } 2013 } 2014 2015 /** 2016 * Convenience function for updating a secure settings value as a long 2017 * integer. This will either create a new entry in the table if the 2018 * given name does not exist, or modify the value of the existing row 2019 * with that name. Note that internally setting values are always 2020 * stored as strings, so this function converts the given value to a 2021 * 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 putLong(ContentResolver cr, String name, long value) { 2029 return putString(cr, name, Long.toString(value)); 2030 } 2031 2032 /** 2033 * Convenience function for retrieving a single secure settings value 2034 * as a floating point number. Note that internally setting values are 2035 * always stored as strings; this function converts the string to an 2036 * float for you. The default value will be returned if the setting 2037 * is not defined or not a valid float. 2038 * 2039 * @param cr The ContentResolver to access. 2040 * @param name The name of the setting to retrieve. 2041 * @param def Value to return if the setting is not defined. 2042 * 2043 * @return The setting's current value, or 'def' if it is not defined 2044 * or not a valid float. 2045 */ 2046 public static float getFloat(ContentResolver cr, String name, float def) { 2047 String v = getString(cr, name); 2048 try { 2049 return v != null ? Float.parseFloat(v) : def; 2050 } catch (NumberFormatException e) { 2051 return def; 2052 } 2053 } 2054 2055 /** 2056 * Convenience function for retrieving a single secure settings value 2057 * as a float. Note that internally setting values are always 2058 * stored as strings; this function converts the string to a float 2059 * for you. 2060 * <p> 2061 * This version does not take a default value. If the setting has not 2062 * been set, or the string value is not a number, 2063 * it throws {@link SettingNotFoundException}. 2064 * 2065 * @param cr The ContentResolver to access. 2066 * @param name The name of the setting to retrieve. 2067 * 2068 * @throws SettingNotFoundException Thrown if a setting by the given 2069 * name can't be found or the setting value is not a float. 2070 * 2071 * @return The setting's current value. 2072 */ 2073 public static float getFloat(ContentResolver cr, String name) 2074 throws SettingNotFoundException { 2075 String v = getString(cr, name); 2076 try { 2077 return Float.parseFloat(v); 2078 } catch (NumberFormatException e) { 2079 throw new SettingNotFoundException(name); 2080 } 2081 } 2082 2083 /** 2084 * Convenience function for updating a single settings value as a 2085 * floating point number. This will either create a new entry in the 2086 * table if the given name does not exist, or modify the value of the 2087 * existing row with that name. Note that internally setting values 2088 * are always stored as strings, so this function converts the given 2089 * value to a string before storing it. 2090 * 2091 * @param cr The ContentResolver to access. 2092 * @param name The name of the setting to modify. 2093 * @param value The new value for the setting. 2094 * @return true if the value was set, false on database errors 2095 */ 2096 public static boolean putFloat(ContentResolver cr, String name, float value) { 2097 return putString(cr, name, Float.toString(value)); 2098 } 2099 2100 /** 2101 * The content:// style URL for this table 2102 */ 2103 public static final Uri CONTENT_URI = 2104 Uri.parse("content://" + AUTHORITY + "/secure"); 2105 2106 /** 2107 * Whether ADB is enabled. 2108 */ 2109 public static final String ADB_ENABLED = "adb_enabled"; 2110 2111 /** 2112 * Setting to allow mock locations and location provider status to be injected into the 2113 * LocationManager service for testing purposes during application development. These 2114 * locations and status values override actual location and status information generated 2115 * by network, gps, or other location providers. 2116 */ 2117 public static final String ALLOW_MOCK_LOCATION = "mock_location"; 2118 2119 /** 2120 * A 64-bit number (as a hex string) that is randomly 2121 * generated on the device's first boot and should remain 2122 * constant for the lifetime of the device. (The value may 2123 * change if a factory reset is performed on the device.) 2124 */ 2125 public static final String ANDROID_ID = "android_id"; 2126 2127 /** 2128 * Whether bluetooth is enabled/disabled 2129 * 0=disabled. 1=enabled. 2130 */ 2131 public static final String BLUETOOTH_ON = "bluetooth_on"; 2132 2133 /** 2134 * Get the key that retrieves a bluetooth headset's priority. 2135 * @hide 2136 */ 2137 public static final String getBluetoothHeadsetPriorityKey(String address) { 2138 return ("bluetooth_headset_priority_" + address.toUpperCase()); 2139 } 2140 2141 /** 2142 * Get the key that retrieves a bluetooth a2dp sink's priority. 2143 * @hide 2144 */ 2145 public static final String getBluetoothA2dpSinkPriorityKey(String address) { 2146 return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase()); 2147 } 2148 2149 /** 2150 * Whether or not data roaming is enabled. (0 = false, 1 = true) 2151 */ 2152 public static final String DATA_ROAMING = "data_roaming"; 2153 2154 /** 2155 * Setting to record the input method used by default, holding the ID 2156 * of the desired method. 2157 */ 2158 public static final String DEFAULT_INPUT_METHOD = "default_input_method"; 2159 2160 /** 2161 * Whether the device has been provisioned (0 = false, 1 = true) 2162 */ 2163 public static final String DEVICE_PROVISIONED = "device_provisioned"; 2164 2165 /** 2166 * List of input methods that are currently enabled. This is a string 2167 * containing the IDs of all enabled input methods, each ID separated 2168 * by ':'. 2169 */ 2170 public static final String ENABLED_INPUT_METHODS = "enabled_input_methods"; 2171 2172 /** 2173 * Host name and port for a user-selected proxy. 2174 */ 2175 public static final String HTTP_PROXY = "http_proxy"; 2176 2177 /** 2178 * Whether the package installer should allow installation of apps downloaded from 2179 * sources other than the Android Market (vending machine). 2180 * 2181 * 1 = allow installing from other sources 2182 * 0 = only allow installing from the Android Market 2183 */ 2184 public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps"; 2185 2186 /** 2187 * Comma-separated list of location providers that activities may access. 2188 */ 2189 public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed"; 2190 2191 /** 2192 * Whether assisted GPS should be enabled or not. 2193 * @hide 2194 */ 2195 public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled"; 2196 2197 /** 2198 * The Logging ID (a unique 64-bit value) as a hex string. 2199 * Used as a pseudonymous identifier for logging. 2200 * @deprecated This identifier is poorly initialized and has 2201 * many collisions. It should not be used. 2202 */ 2203 @Deprecated 2204 public static final String LOGGING_ID = "logging_id"; 2205 2206 /** 2207 * User preference for which network(s) should be used. Only the 2208 * connectivity service should touch this. 2209 */ 2210 public static final String NETWORK_PREFERENCE = "network_preference"; 2211 2212 /** 2213 * Used to disable Tethering on a device - defaults to true 2214 * @hide 2215 */ 2216 public static final String TETHER_SUPPORTED = "tether_supported"; 2217 2218 /** 2219 * No longer supported. 2220 */ 2221 public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled"; 2222 2223 /** 2224 * No longer supported. 2225 */ 2226 public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update"; 2227 2228 /** 2229 * No longer supported. 2230 */ 2231 public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url"; 2232 2233 /** 2234 * Settings classname to launch when Settings is clicked from All 2235 * Applications. Needed because of user testing between the old 2236 * and new Settings apps. 2237 */ 2238 // TODO: 881807 2239 public static final String SETTINGS_CLASSNAME = "settings_classname"; 2240 2241 /** 2242 * USB Mass Storage Enabled 2243 */ 2244 public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled"; 2245 2246 /** 2247 * If this setting is set (to anything), then all references 2248 * to Gmail on the device must change to Google Mail. 2249 */ 2250 public static final String USE_GOOGLE_MAIL = "use_google_mail"; 2251 2252 /** 2253 * If accessibility is enabled. 2254 */ 2255 public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled"; 2256 2257 /** 2258 * List of the enabled accessibility providers. 2259 */ 2260 public static final String ENABLED_ACCESSIBILITY_SERVICES = 2261 "enabled_accessibility_services"; 2262 2263 /** 2264 * Setting to always use the default text-to-speech settings regardless 2265 * of the application settings. 2266 * 1 = override application settings, 2267 * 0 = use application settings (if specified). 2268 */ 2269 public static final String TTS_USE_DEFAULTS = "tts_use_defaults"; 2270 2271 /** 2272 * Default text-to-speech engine speech rate. 100 = 1x 2273 */ 2274 public static final String TTS_DEFAULT_RATE = "tts_default_rate"; 2275 2276 /** 2277 * Default text-to-speech engine pitch. 100 = 1x 2278 */ 2279 public static final String TTS_DEFAULT_PITCH = "tts_default_pitch"; 2280 2281 /** 2282 * Default text-to-speech engine. 2283 */ 2284 public static final String TTS_DEFAULT_SYNTH = "tts_default_synth"; 2285 2286 /** 2287 * Default text-to-speech language. 2288 */ 2289 public static final String TTS_DEFAULT_LANG = "tts_default_lang"; 2290 2291 /** 2292 * Default text-to-speech country. 2293 */ 2294 public static final String TTS_DEFAULT_COUNTRY = "tts_default_country"; 2295 2296 /** 2297 * Default text-to-speech locale variant. 2298 */ 2299 public static final String TTS_DEFAULT_VARIANT = "tts_default_variant"; 2300 2301 /** 2302 * Whether to notify the user of open networks. 2303 * <p> 2304 * If not connected and the scan results have an open network, we will 2305 * put this notification up. If we attempt to connect to a network or 2306 * the open network(s) disappear, we remove the notification. When we 2307 * show the notification, we will not show it again for 2308 * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time. 2309 */ 2310 public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = 2311 "wifi_networks_available_notification_on"; 2312 2313 /** 2314 * Delay (in seconds) before repeating the Wi-Fi networks available notification. 2315 * Connecting to a network will reset the timer. 2316 */ 2317 public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = 2318 "wifi_networks_available_repeat_delay"; 2319 2320 /** 2321 * The number of radio channels that are allowed in the local 2322 * 802.11 regulatory domain. 2323 * @hide 2324 */ 2325 public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels"; 2326 2327 /** 2328 * When the number of open networks exceeds this number, the 2329 * least-recently-used excess networks will be removed. 2330 */ 2331 public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept"; 2332 2333 /** 2334 * Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this. 2335 */ 2336 public static final String WIFI_ON = "wifi_on"; 2337 2338 /** 2339 * The acceptable packet loss percentage (range 0 - 100) before trying 2340 * another AP on the same network. 2341 */ 2342 public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE = 2343 "wifi_watchdog_acceptable_packet_loss_percentage"; 2344 2345 /** 2346 * The number of access points required for a network in order for the 2347 * watchdog to monitor it. 2348 */ 2349 public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count"; 2350 2351 /** 2352 * The delay between background checks. 2353 */ 2354 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS = 2355 "wifi_watchdog_background_check_delay_ms"; 2356 2357 /** 2358 * Whether the Wi-Fi watchdog is enabled for background checking even 2359 * after it thinks the user has connected to a good access point. 2360 */ 2361 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED = 2362 "wifi_watchdog_background_check_enabled"; 2363 2364 /** 2365 * The timeout for a background ping 2366 */ 2367 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS = 2368 "wifi_watchdog_background_check_timeout_ms"; 2369 2370 /** 2371 * The number of initial pings to perform that *may* be ignored if they 2372 * fail. Again, if these fail, they will *not* be used in packet loss 2373 * calculation. For example, one network always seemed to time out for 2374 * the first couple pings, so this is set to 3 by default. 2375 */ 2376 public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT = 2377 "wifi_watchdog_initial_ignored_ping_count"; 2378 2379 /** 2380 * The maximum number of access points (per network) to attempt to test. 2381 * If this number is reached, the watchdog will no longer monitor the 2382 * initial connection state for the network. This is a safeguard for 2383 * networks containing multiple APs whose DNS does not respond to pings. 2384 */ 2385 public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks"; 2386 2387 /** 2388 * Whether the Wi-Fi watchdog is enabled. 2389 */ 2390 public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on"; 2391 2392 /** 2393 * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled. 2394 */ 2395 public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list"; 2396 2397 /** 2398 * The number of pings to test if an access point is a good connection. 2399 */ 2400 public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count"; 2401 2402 /** 2403 * The delay between pings. 2404 */ 2405 public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms"; 2406 2407 /** 2408 * The timeout per ping. 2409 */ 2410 public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms"; 2411 2412 /** 2413 * The maximum number of times we will retry a connection to an access 2414 * point for which we have failed in acquiring an IP address from DHCP. 2415 * A value of N means that we will make N+1 connection attempts in all. 2416 */ 2417 public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count"; 2418 2419 /** 2420 * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile 2421 * data connectivity to be established after a disconnect from Wi-Fi. 2422 */ 2423 public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = 2424 "wifi_mobile_data_transition_wakelock_timeout_ms"; 2425 2426 /** 2427 * Whether background data usage is allowed by the user. See 2428 * ConnectivityManager for more info. 2429 */ 2430 public static final String BACKGROUND_DATA = "background_data"; 2431 2432 /** 2433 * The CDMA roaming mode 0 = Home Networks, CDMA default 2434 * 1 = Roaming on Affiliated networks 2435 * 2 = Roaming on any networks 2436 * @hide 2437 */ 2438 public static final String CDMA_ROAMING_MODE = "roaming_settings"; 2439 2440 /** 2441 * The CDMA subscription mode 0 = RUIM/SIM (default) 2442 * 1 = NV 2443 * @hide 2444 */ 2445 public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode"; 2446 2447 /** 2448 * The preferred network mode 7 = Global 2449 * 6 = EvDo only 2450 * 5 = CDMA w/o EvDo 2451 * 4 = CDMA / EvDo auto 2452 * 3 = GSM / WCDMA auto 2453 * 2 = WCDMA only 2454 * 1 = GSM only 2455 * 0 = GSM / WCDMA preferred 2456 * @hide 2457 */ 2458 public static final String PREFERRED_NETWORK_MODE = 2459 "preferred_network_mode"; 2460 2461 /** 2462 * The preferred TTY mode 0 = TTy Off, CDMA default 2463 * 1 = TTY Full 2464 * 2 = TTY HCO 2465 * 3 = TTY VCO 2466 * @hide 2467 */ 2468 public static final String PREFERRED_TTY_MODE = 2469 "preferred_tty_mode"; 2470 2471 2472 /** 2473 * CDMA Cell Broadcast SMS 2474 * 0 = CDMA Cell Broadcast SMS disabled 2475 * 1 = CDMA Cell Broadcast SMS enabled 2476 * @hide 2477 */ 2478 public static final String CDMA_CELL_BROADCAST_SMS = 2479 "cdma_cell_broadcast_sms"; 2480 2481 /** 2482 * The cdma subscription 0 = Subscription from RUIM, when available 2483 * 1 = Subscription from NV 2484 * @hide 2485 */ 2486 public static final String PREFERRED_CDMA_SUBSCRIPTION = 2487 "preferred_cdma_subscription"; 2488 2489 /** 2490 * Whether the enhanced voice privacy mode is enabled. 2491 * 0 = normal voice privacy 2492 * 1 = enhanced voice privacy 2493 * @hide 2494 */ 2495 public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled"; 2496 2497 /** 2498 * Whether the TTY mode mode is enabled. 2499 * 0 = disabled 2500 * 1 = enabled 2501 * @hide 2502 */ 2503 public static final String TTY_MODE_ENABLED = "tty_mode_enabled"; 2504 2505 /** 2506 * Flag for allowing service provider to use location information to improve products and 2507 * services. 2508 * Type: int ( 0 = disallow, 1 = allow ) 2509 * @hide 2510 */ 2511 public static final String USE_LOCATION_FOR_SERVICES = "use_location"; 2512 2513 /** 2514 * Controls whether settings backup is enabled. 2515 * Type: int ( 0 = disabled, 1 = enabled ) 2516 * @hide 2517 */ 2518 public static final String BACKUP_ENABLED = "backup_enabled"; 2519 2520 /** 2521 * Controls whether application data is automatically restored from backup 2522 * at install time. 2523 * Type: int ( 0 = disabled, 1 = enabled ) 2524 * @hide 2525 */ 2526 public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore"; 2527 2528 /** 2529 * Indicates whether settings backup has been fully provisioned. 2530 * Type: int ( 0 = unprovisioned, 1 = fully provisioned ) 2531 * @hide 2532 */ 2533 public static final String BACKUP_PROVISIONED = "backup_provisioned"; 2534 2535 /** 2536 * Component of the transport to use for backup/restore. 2537 * @hide 2538 */ 2539 public static final String BACKUP_TRANSPORT = "backup_transport"; 2540 2541 /** 2542 * Version for which the setup wizard was last shown. Bumped for 2543 * each release when there is new setup information to show. 2544 * @hide 2545 */ 2546 public static final String LAST_SETUP_SHOWN = "last_setup_shown"; 2547 2548 /** 2549 * How frequently (in seconds) to check the memory status of the 2550 * device. 2551 * @hide 2552 */ 2553 public static final String MEMCHECK_INTERVAL = "memcheck_interval"; 2554 2555 /** 2556 * Max frequency (in seconds) to log memory check stats, in realtime 2557 * seconds. This allows for throttling of logs when the device is 2558 * running for large amounts of time. 2559 * @hide 2560 */ 2561 public static final String MEMCHECK_LOG_REALTIME_INTERVAL = 2562 "memcheck_log_realtime_interval"; 2563 2564 /** 2565 * Boolean indicating whether rebooting due to system memory checks 2566 * is enabled. 2567 * @hide 2568 */ 2569 public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled"; 2570 2571 /** 2572 * How many bytes the system process must be below to avoid scheduling 2573 * a soft reboot. This reboot will happen when it is next determined 2574 * to be a good time. 2575 * @hide 2576 */ 2577 public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft"; 2578 2579 /** 2580 * How many bytes the system process must be below to avoid scheduling 2581 * a hard reboot. This reboot will happen immediately. 2582 * @hide 2583 */ 2584 public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard"; 2585 2586 /** 2587 * How many bytes the phone process must be below to avoid scheduling 2588 * a soft restart. This restart will happen when it is next determined 2589 * to be a good time. 2590 * @hide 2591 */ 2592 public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft"; 2593 2594 /** 2595 * How many bytes the phone process must be below to avoid scheduling 2596 * a hard restart. This restart will happen immediately. 2597 * @hide 2598 */ 2599 public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard"; 2600 2601 /** 2602 * Boolean indicating whether restarting the phone process due to 2603 * memory checks is enabled. 2604 * @hide 2605 */ 2606 public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled"; 2607 2608 /** 2609 * First time during the day it is okay to kill processes 2610 * or reboot the device due to low memory situations. This number is 2611 * in seconds since midnight. 2612 * @hide 2613 */ 2614 public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time"; 2615 2616 /** 2617 * Last time during the day it is okay to kill processes 2618 * or reboot the device due to low memory situations. This number is 2619 * in seconds since midnight. 2620 * @hide 2621 */ 2622 public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time"; 2623 2624 /** 2625 * How long the screen must have been off in order to kill processes 2626 * or reboot. This number is in seconds. A value of -1 means to 2627 * entirely disregard whether the screen is on. 2628 * @hide 2629 */ 2630 public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off"; 2631 2632 /** 2633 * How much time there must be until the next alarm in order to kill processes 2634 * or reboot. This number is in seconds. Note: this value must be 2635 * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will 2636 * always see an alarm scheduled within its time. 2637 * @hide 2638 */ 2639 public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm"; 2640 2641 /** 2642 * How frequently to check whether it is a good time to restart things, 2643 * if the device is in a bad state. This number is in seconds. Note: 2644 * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else 2645 * the alarm to schedule the recheck will always appear within the 2646 * minimum "do not execute now" time. 2647 * @hide 2648 */ 2649 public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval"; 2650 2651 /** 2652 * How frequently (in DAYS) to reboot the device. If 0, no reboots 2653 * will occur. 2654 * @hide 2655 */ 2656 public static final String REBOOT_INTERVAL = "reboot_interval"; 2657 2658 /** 2659 * First time during the day it is okay to force a reboot of the 2660 * device (if REBOOT_INTERVAL is set). This number is 2661 * in seconds since midnight. 2662 * @hide 2663 */ 2664 public static final String REBOOT_START_TIME = "reboot_start_time"; 2665 2666 /** 2667 * The window of time (in seconds) after each REBOOT_INTERVAL in which 2668 * a reboot can be executed. If 0, a reboot will always be executed at 2669 * exactly the given time. Otherwise, it will only be executed if 2670 * the device is idle within the window. 2671 * @hide 2672 */ 2673 public static final String REBOOT_WINDOW = "reboot_window"; 2674 2675 /** 2676 * Threshold values for the duration and level of a discharge cycle, under 2677 * which we log discharge cycle info. 2678 * @hide 2679 */ 2680 public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD = 2681 "battery_discharge_duration_threshold"; 2682 /** @hide */ 2683 public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold"; 2684 2685 /** 2686 * Flag for allowing ActivityManagerService to send ACTION_APP_ERROR intents 2687 * on application crashes and ANRs. If this is disabled, the crash/ANR dialog 2688 * will never display the "Report" button. 2689 * Type: int ( 0 = disallow, 1 = allow ) 2690 * @hide 2691 */ 2692 public static final String SEND_ACTION_APP_ERROR = "send_action_app_error"; 2693 2694 /** 2695 * Nonzero causes Log.wtf() to crash. 2696 * @hide 2697 */ 2698 public static final String WTF_IS_FATAL = "wtf_is_fatal"; 2699 2700 /** 2701 * Maximum age of entries kept by {@link android.os.IDropBox}. 2702 * @hide 2703 */ 2704 public static final String DROPBOX_AGE_SECONDS = 2705 "dropbox_age_seconds"; 2706 /** 2707 * Maximum amount of disk space used by {@link android.os.IDropBox} no matter what. 2708 * @hide 2709 */ 2710 public static final String DROPBOX_QUOTA_KB = 2711 "dropbox_quota_kb"; 2712 /** 2713 * Percent of free disk (excluding reserve) which {@link android.os.IDropBox} will use. 2714 * @hide 2715 */ 2716 public static final String DROPBOX_QUOTA_PERCENT = 2717 "dropbox_quota_percent"; 2718 /** 2719 * Percent of total disk which {@link android.os.IDropBox} will never dip into. 2720 * @hide 2721 */ 2722 public static final String DROPBOX_RESERVE_PERCENT = 2723 "dropbox_reserve_percent"; 2724 /** 2725 * Prefix for per-tag dropbox disable/enable settings. 2726 * @hide 2727 */ 2728 public static final String DROPBOX_TAG_PREFIX = 2729 "dropbox:"; 2730 2731 2732 /** 2733 * Screen timeout in milliseconds corresponding to the 2734 * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest 2735 * possible screen timeout behavior.) 2736 * @hide 2737 */ 2738 public static final String SHORT_KEYLIGHT_DELAY_MS = 2739 "short_keylight_delay_ms"; 2740 2741 /** 2742 * The interval in minutes after which the amount of free storage left on the 2743 * device is logged to the event log 2744 * @hide 2745 */ 2746 public static final String SYS_FREE_STORAGE_LOG_INTERVAL = 2747 "sys_free_storage_log_interval"; 2748 2749 /** 2750 * Threshold for the amount of change in disk free space required to report the amount of 2751 * free space. Used to prevent spamming the logs when the disk free space isn't changing 2752 * frequently. 2753 * @hide 2754 */ 2755 public static final String DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2756 "disk_free_change_reporting_threshold"; 2757 2758 2759 /** 2760 * Minimum percentage of free storage on the device that is used to determine if 2761 * the device is running low on storage. 2762 * Say this value is set to 10, the device is considered running low on storage 2763 * if 90% or more of the device storage is filled up. 2764 * @hide 2765 */ 2766 public static final String SYS_STORAGE_THRESHOLD_PERCENTAGE = 2767 "sys_storage_threshold_percentage"; 2768 2769 /** 2770 * The interval in milliseconds after which Wi-Fi is considered idle. 2771 * When idle, it is possible for the device to be switched from Wi-Fi to 2772 * the mobile data network. 2773 * @hide 2774 */ 2775 public static final String WIFI_IDLE_MS = "wifi_idle_ms"; 2776 2777 /** 2778 * The interval in milliseconds at which to check packet counts on the 2779 * mobile data interface when screen is on, to detect possible data 2780 * connection problems. 2781 * @hide 2782 */ 2783 public static final String PDP_WATCHDOG_POLL_INTERVAL_MS = 2784 "pdp_watchdog_poll_interval_ms"; 2785 2786 /** 2787 * The interval in milliseconds at which to check packet counts on the 2788 * mobile data interface when screen is off, to detect possible data 2789 * connection problems. 2790 * @hide 2791 */ 2792 public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS = 2793 "pdp_watchdog_long_poll_interval_ms"; 2794 2795 /** 2796 * The interval in milliseconds at which to check packet counts on the 2797 * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} 2798 * outgoing packets has been reached without incoming packets. 2799 * @hide 2800 */ 2801 public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS = 2802 "pdp_watchdog_error_poll_interval_ms"; 2803 2804 /** 2805 * The number of outgoing packets sent without seeing an incoming packet 2806 * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT} 2807 * device is logged to the event log 2808 * @hide 2809 */ 2810 public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT = 2811 "pdp_watchdog_trigger_packet_count"; 2812 2813 /** 2814 * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS}) 2815 * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before 2816 * attempting data connection recovery. 2817 * @hide 2818 */ 2819 public static final String PDP_WATCHDOG_ERROR_POLL_COUNT = 2820 "pdp_watchdog_error_poll_count"; 2821 2822 /** 2823 * The number of failed PDP reset attempts before moving to something more 2824 * drastic: re-registering to the network. 2825 * @hide 2826 */ 2827 public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT = 2828 "pdp_watchdog_max_pdp_reset_fail_count"; 2829 2830 /** 2831 * Address to ping as a last sanity check before attempting any recovery. 2832 * Unset or set to "0.0.0.0" to skip this check. 2833 * @hide 2834 */ 2835 public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address"; 2836 2837 /** 2838 * The "-w deadline" parameter for the ping, ie, the max time in 2839 * seconds to spend pinging. 2840 * @hide 2841 */ 2842 public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline"; 2843 2844 /** 2845 * The interval in milliseconds at which to check gprs registration 2846 * after the first registration mismatch of gprs and voice service, 2847 * to detect possible data network registration problems. 2848 * 2849 * @hide 2850 */ 2851 public static final String GPRS_REGISTER_CHECK_PERIOD_MS = 2852 "gprs_register_check_period_ms"; 2853 2854 /** 2855 * The length of time in milli-seconds that automatic small adjustments to 2856 * SystemClock are ignored if NITZ_UPDATE_DIFF is not exceeded. 2857 * @hide 2858 */ 2859 public static final String NITZ_UPDATE_SPACING = "nitz_update_spacing"; 2860 2861 /** 2862 * If the NITZ_UPDATE_DIFF time is exceeded then an automatic adjustment 2863 * to SystemClock will be allowed even if NITZ_UPDATE_SPACING has not been 2864 * exceeded. 2865 * @hide 2866 */ 2867 public static final String NITZ_UPDATE_DIFF = "nitz_update_diff"; 2868 2869 /** 2870 * The maximum reconnect delay for short network outages or when the network is suspended 2871 * due to phone use. 2872 * @hide 2873 */ 2874 public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS = 2875 "sync_max_retry_delay_in_seconds"; 2876 2877 /** 2878 * The interval in milliseconds at which to check the number of SMS sent 2879 * out without asking for use permit, to limit the un-authorized SMS 2880 * usage. 2881 * @hide 2882 */ 2883 public static final String SMS_OUTGOING_CHECK_INTERVAL_MS = 2884 "sms_outgoing_check_interval_ms"; 2885 2886 /** 2887 * The number of outgoing SMS sent without asking for user permit 2888 * (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS} 2889 * @hide 2890 */ 2891 public static final String SMS_OUTGOING_CHECK_MAX_COUNT = 2892 "sms_outgoing_check_max_count"; 2893 2894 /** 2895 * The number of promoted sources in GlobalSearch. 2896 * @hide 2897 */ 2898 public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources"; 2899 /** 2900 * The maximum number of suggestions returned by GlobalSearch. 2901 * @hide 2902 */ 2903 public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display"; 2904 /** 2905 * The number of suggestions GlobalSearch will ask each non-web search source for. 2906 * @hide 2907 */ 2908 public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source"; 2909 /** 2910 * The number of suggestions the GlobalSearch will ask the web search source for. 2911 * @hide 2912 */ 2913 public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT = 2914 "search_web_results_override_limit"; 2915 /** 2916 * The number of milliseconds that GlobalSearch will wait for suggestions from 2917 * promoted sources before continuing with all other sources. 2918 * @hide 2919 */ 2920 public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS = 2921 "search_promoted_source_deadline_millis"; 2922 /** 2923 * The number of milliseconds before GlobalSearch aborts search suggesiton queries. 2924 * @hide 2925 */ 2926 public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis"; 2927 /** 2928 * The maximum number of milliseconds that GlobalSearch shows the previous results 2929 * after receiving a new query. 2930 * @hide 2931 */ 2932 public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis"; 2933 /** 2934 * The maximum age of log data used for shortcuts in GlobalSearch. 2935 * @hide 2936 */ 2937 public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis"; 2938 /** 2939 * The maximum age of log data used for source ranking in GlobalSearch. 2940 * @hide 2941 */ 2942 public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS = 2943 "search_max_source_event_age_millis"; 2944 /** 2945 * The minimum number of impressions needed to rank a source in GlobalSearch. 2946 * @hide 2947 */ 2948 public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING = 2949 "search_min_impressions_for_source_ranking"; 2950 /** 2951 * The minimum number of clicks needed to rank a source in GlobalSearch. 2952 * @hide 2953 */ 2954 public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING = 2955 "search_min_clicks_for_source_ranking"; 2956 /** 2957 * The maximum number of shortcuts shown by GlobalSearch. 2958 * @hide 2959 */ 2960 public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned"; 2961 /** 2962 * The size of the core thread pool for suggestion queries in GlobalSearch. 2963 * @hide 2964 */ 2965 public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE = 2966 "search_query_thread_core_pool_size"; 2967 /** 2968 * The maximum size of the thread pool for suggestion queries in GlobalSearch. 2969 * @hide 2970 */ 2971 public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE = 2972 "search_query_thread_max_pool_size"; 2973 /** 2974 * The size of the core thread pool for shortcut refreshing in GlobalSearch. 2975 * @hide 2976 */ 2977 public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE = 2978 "search_shortcut_refresh_core_pool_size"; 2979 /** 2980 * The maximum size of the thread pool for shortcut refreshing in GlobalSearch. 2981 * @hide 2982 */ 2983 public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE = 2984 "search_shortcut_refresh_max_pool_size"; 2985 /** 2986 * The maximun time that excess threads in the GlobalSeach thread pools will 2987 * wait before terminating. 2988 * @hide 2989 */ 2990 public static final String SEARCH_THREAD_KEEPALIVE_SECONDS = 2991 "search_thread_keepalive_seconds"; 2992 /** 2993 * The maximum number of concurrent suggestion queries to each source. 2994 * @hide 2995 */ 2996 public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT = 2997 "search_per_source_concurrent_query_limit"; 2998 2999 /** 3000 * Whether or not alert sounds are played on MountService events. (0 = false, 1 = true) 3001 * @hide 3002 */ 3003 public static final String MOUNT_PLAY_NOTIFICATION_SND = "mount_play_not_snd"; 3004 3005 /** 3006 * Whether or not UMS auto-starts on UMS host detection. (0 = false, 1 = true) 3007 * @hide 3008 */ 3009 public static final String MOUNT_UMS_AUTOSTART = "mount_ums_autostart"; 3010 3011 /** 3012 * Whether or not a notification is displayed on UMS host detection. (0 = false, 1 = true) 3013 * @hide 3014 */ 3015 public static final String MOUNT_UMS_PROMPT = "mount_ums_prompt"; 3016 3017 /** 3018 * Whether or not a notification is displayed while UMS is enabled. (0 = false, 1 = true) 3019 * @hide 3020 */ 3021 public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled"; 3022 3023 /** 3024 * Whether or not a notification is displayed when a Tetherable interface is detected. 3025 * (0 = false, 1 = true) 3026 * @hide 3027 */ 3028 public static final String TETHER_NOTIFY = "tether_notify"; 3029 3030 /** 3031 * If nonzero, ANRs in invisible background processes bring up a dialog. 3032 * Otherwise, the process will be silently killed. 3033 * @hide 3034 */ 3035 public static final String ANR_SHOW_BACKGROUND = "anr_show_background"; 3036 3037 /** 3038 * The {@link ComponentName} string of the service to be used as the voice recognition 3039 * service. 3040 * 3041 * @hide 3042 */ 3043 public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service"; 3044 3045 /** 3046 * @hide 3047 */ 3048 public static final String[] SETTINGS_TO_BACKUP = { 3049 ADB_ENABLED, 3050 ALLOW_MOCK_LOCATION, 3051 PARENTAL_CONTROL_ENABLED, 3052 PARENTAL_CONTROL_REDIRECT_URL, 3053 USB_MASS_STORAGE_ENABLED, 3054 ACCESSIBILITY_ENABLED, 3055 ENABLED_ACCESSIBILITY_SERVICES, 3056 TTS_USE_DEFAULTS, 3057 TTS_DEFAULT_RATE, 3058 TTS_DEFAULT_PITCH, 3059 TTS_DEFAULT_SYNTH, 3060 TTS_DEFAULT_LANG, 3061 TTS_DEFAULT_COUNTRY, 3062 WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 3063 WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 3064 WIFI_NUM_ALLOWED_CHANNELS, 3065 WIFI_NUM_OPEN_NETWORKS_KEPT, 3066 MOUNT_PLAY_NOTIFICATION_SND, 3067 MOUNT_UMS_AUTOSTART, 3068 MOUNT_UMS_PROMPT, 3069 MOUNT_UMS_NOTIFY_ENABLED 3070 }; 3071 3072 /** 3073 * Helper method for determining if a location provider is enabled. 3074 * @param cr the content resolver to use 3075 * @param provider the location provider to query 3076 * @return true if the provider is enabled 3077 */ 3078 public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) { 3079 String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED); 3080 if (allowedProviders != null) { 3081 return (allowedProviders.equals(provider) || 3082 allowedProviders.contains("," + provider + ",") || 3083 allowedProviders.startsWith(provider + ",") || 3084 allowedProviders.endsWith("," + provider)); 3085 } 3086 return false; 3087 } 3088 3089 /** 3090 * Thread-safe method for enabling or disabling a single location provider. 3091 * @param cr the content resolver to use 3092 * @param provider the location provider to enable or disable 3093 * @param enabled true if the provider should be enabled 3094 */ 3095 public static final void setLocationProviderEnabled(ContentResolver cr, 3096 String provider, boolean enabled) { 3097 // to ensure thread safety, we write the provider name with a '+' or '-' 3098 // and let the SettingsProvider handle it rather than reading and modifying 3099 // the list of enabled providers. 3100 if (enabled) { 3101 provider = "+" + provider; 3102 } else { 3103 provider = "-" + provider; 3104 } 3105 putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider); 3106 } 3107 } 3108 3109 /** 3110 * User-defined bookmarks and shortcuts. The target of each bookmark is an 3111 * Intent URL, allowing it to be either a web page or a particular 3112 * application activity. 3113 * 3114 * @hide 3115 */ 3116 public static final class Bookmarks implements BaseColumns 3117 { 3118 private static final String TAG = "Bookmarks"; 3119 3120 /** 3121 * The content:// style URL for this table 3122 */ 3123 public static final Uri CONTENT_URI = 3124 Uri.parse("content://" + AUTHORITY + "/bookmarks"); 3125 3126 /** 3127 * The row ID. 3128 * <p>Type: INTEGER</p> 3129 */ 3130 public static final String ID = "_id"; 3131 3132 /** 3133 * Descriptive name of the bookmark that can be displayed to the user. 3134 * If this is empty, the title should be resolved at display time (use 3135 * {@link #getTitle(Context, Cursor)} any time you want to display the 3136 * title of a bookmark.) 3137 * <P> 3138 * Type: TEXT 3139 * </P> 3140 */ 3141 public static final String TITLE = "title"; 3142 3143 /** 3144 * Arbitrary string (displayed to the user) that allows bookmarks to be 3145 * organized into categories. There are some special names for 3146 * standard folders, which all start with '@'. The label displayed for 3147 * the folder changes with the locale (via {@link #getLabelForFolder}) but 3148 * the folder name does not change so you can consistently query for 3149 * the folder regardless of the current locale. 3150 * 3151 * <P>Type: TEXT</P> 3152 * 3153 */ 3154 public static final String FOLDER = "folder"; 3155 3156 /** 3157 * The Intent URL of the bookmark, describing what it points to. This 3158 * value is given to {@link android.content.Intent#getIntent} to create 3159 * an Intent that can be launched. 3160 * <P>Type: TEXT</P> 3161 */ 3162 public static final String INTENT = "intent"; 3163 3164 /** 3165 * Optional shortcut character associated with this bookmark. 3166 * <P>Type: INTEGER</P> 3167 */ 3168 public static final String SHORTCUT = "shortcut"; 3169 3170 /** 3171 * The order in which the bookmark should be displayed 3172 * <P>Type: INTEGER</P> 3173 */ 3174 public static final String ORDERING = "ordering"; 3175 3176 private static final String[] sIntentProjection = { INTENT }; 3177 private static final String[] sShortcutProjection = { ID, SHORTCUT }; 3178 private static final String sShortcutSelection = SHORTCUT + "=?"; 3179 3180 /** 3181 * Convenience function to retrieve the bookmarked Intent for a 3182 * particular shortcut key. 3183 * 3184 * @param cr The ContentResolver to query. 3185 * @param shortcut The shortcut key. 3186 * 3187 * @return Intent The bookmarked URL, or null if there is no bookmark 3188 * matching the given shortcut. 3189 */ 3190 public static Intent getIntentForShortcut(ContentResolver cr, char shortcut) 3191 { 3192 Intent intent = null; 3193 3194 Cursor c = cr.query(CONTENT_URI, 3195 sIntentProjection, sShortcutSelection, 3196 new String[] { String.valueOf((int) shortcut) }, ORDERING); 3197 // Keep trying until we find a valid shortcut 3198 try { 3199 while (intent == null && c.moveToNext()) { 3200 try { 3201 String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT)); 3202 intent = Intent.getIntent(intentURI); 3203 } catch (java.net.URISyntaxException e) { 3204 // The stored URL is bad... ignore it. 3205 } catch (IllegalArgumentException e) { 3206 // Column not found 3207 Log.w(TAG, "Intent column not found", e); 3208 } 3209 } 3210 } finally { 3211 if (c != null) c.close(); 3212 } 3213 3214 return intent; 3215 } 3216 3217 /** 3218 * Add a new bookmark to the system. 3219 * 3220 * @param cr The ContentResolver to query. 3221 * @param intent The desired target of the bookmark. 3222 * @param title Bookmark title that is shown to the user; null if none 3223 * or it should be resolved to the intent's title. 3224 * @param folder Folder in which to place the bookmark; null if none. 3225 * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If 3226 * this is non-zero and there is an existing bookmark entry 3227 * with this same shortcut, then that existing shortcut is 3228 * cleared (the bookmark is not removed). 3229 * @return The unique content URL for the new bookmark entry. 3230 */ 3231 public static Uri add(ContentResolver cr, 3232 Intent intent, 3233 String title, 3234 String folder, 3235 char shortcut, 3236 int ordering) 3237 { 3238 // If a shortcut is supplied, and it is already defined for 3239 // another bookmark, then remove the old definition. 3240 if (shortcut != 0) { 3241 Cursor c = cr.query(CONTENT_URI, 3242 sShortcutProjection, sShortcutSelection, 3243 new String[] { String.valueOf((int) shortcut) }, null); 3244 try { 3245 if (c.moveToFirst()) { 3246 while (c.getCount() > 0) { 3247 if (!c.deleteRow()) { 3248 Log.w(TAG, "Could not delete existing shortcut row"); 3249 } 3250 } 3251 } 3252 } finally { 3253 if (c != null) c.close(); 3254 } 3255 } 3256 3257 ContentValues values = new ContentValues(); 3258 if (title != null) values.put(TITLE, title); 3259 if (folder != null) values.put(FOLDER, folder); 3260 values.put(INTENT, intent.toURI()); 3261 if (shortcut != 0) values.put(SHORTCUT, (int) shortcut); 3262 values.put(ORDERING, ordering); 3263 return cr.insert(CONTENT_URI, values); 3264 } 3265 3266 /** 3267 * Return the folder name as it should be displayed to the user. This 3268 * takes care of localizing special folders. 3269 * 3270 * @param r Resources object for current locale; only need access to 3271 * system resources. 3272 * @param folder The value found in the {@link #FOLDER} column. 3273 * 3274 * @return CharSequence The label for this folder that should be shown 3275 * to the user. 3276 */ 3277 public static CharSequence getLabelForFolder(Resources r, String folder) { 3278 return folder; 3279 } 3280 3281 /** 3282 * Return the title as it should be displayed to the user. This takes 3283 * care of localizing bookmarks that point to activities. 3284 * 3285 * @param context A context. 3286 * @param cursor A cursor pointing to the row whose title should be 3287 * returned. The cursor must contain at least the {@link #TITLE} 3288 * and {@link #INTENT} columns. 3289 * @return A title that is localized and can be displayed to the user, 3290 * or the empty string if one could not be found. 3291 */ 3292 public static CharSequence getTitle(Context context, Cursor cursor) { 3293 int titleColumn = cursor.getColumnIndex(TITLE); 3294 int intentColumn = cursor.getColumnIndex(INTENT); 3295 if (titleColumn == -1 || intentColumn == -1) { 3296 throw new IllegalArgumentException( 3297 "The cursor must contain the TITLE and INTENT columns."); 3298 } 3299 3300 String title = cursor.getString(titleColumn); 3301 if (!TextUtils.isEmpty(title)) { 3302 return title; 3303 } 3304 3305 String intentUri = cursor.getString(intentColumn); 3306 if (TextUtils.isEmpty(intentUri)) { 3307 return ""; 3308 } 3309 3310 Intent intent; 3311 try { 3312 intent = Intent.getIntent(intentUri); 3313 } catch (URISyntaxException e) { 3314 return ""; 3315 } 3316 3317 PackageManager packageManager = context.getPackageManager(); 3318 ResolveInfo info = packageManager.resolveActivity(intent, 0); 3319 return info != null ? info.loadLabel(packageManager) : ""; 3320 } 3321 } 3322 3323 /** 3324 * Returns the device ID that we should use when connecting to the mobile gtalk server. 3325 * This is a string like "android-0x1242", where the hex string is the Android ID obtained 3326 * from the GoogleLoginService. 3327 * 3328 * @param androidId The Android ID for this device. 3329 * @return The device ID that should be used when connecting to the mobile gtalk server. 3330 * @hide 3331 */ 3332 public static String getGTalkDeviceId(long androidId) { 3333 return "android-" + Long.toHexString(androidId); 3334 } 3335} 3336