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