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