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