blob: cf26b1bf08f9da9e18b65da8c1eb6e4903bca59c [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 /**
Mike Lockwoodbd5ddf02009-07-29 21:37:14 -0700882 * A comma separated list of radios that should to be disabled when airplane mode
883 * is on, but can be manually reenabled by the user. For example, if RADIO_WIFI is
884 * added to both AIRPLANE_MODE_RADIOS and AIRPLANE_MODE_TOGGLEABLE_RADIOS, then Wifi
885 * will be turned off when entering airplane mode, but the user will be able to reenable
886 * Wifi in the Settings app.
887 *
888 * {@hide}
889 */
890 public static final String AIRPLANE_MODE_TOGGLEABLE_RADIOS = "airplane_mode_toggleable_radios";
891
892 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800893 * The policy for deciding when Wi-Fi should go to sleep (which will in
894 * turn switch to using the mobile data as an Internet connection).
895 * <p>
896 * Set to one of {@link #WIFI_SLEEP_POLICY_DEFAULT},
897 * {@link #WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED}, or
898 * {@link #WIFI_SLEEP_POLICY_NEVER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899 */
900 public static final String WIFI_SLEEP_POLICY = "wifi_sleep_policy";
901
902 /**
903 * Value for {@link #WIFI_SLEEP_POLICY} to use the default Wi-Fi sleep
904 * policy, which is to sleep shortly after the turning off
905 * according to the {@link #STAY_ON_WHILE_PLUGGED_IN} setting.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800906 */
907 public static final int WIFI_SLEEP_POLICY_DEFAULT = 0;
908
909 /**
910 * Value for {@link #WIFI_SLEEP_POLICY} to use the default policy when
911 * the device is on battery, and never go to sleep when the device is
912 * plugged in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800913 */
914 public static final int WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED = 1;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -0700915
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800916 /**
917 * Value for {@link #WIFI_SLEEP_POLICY} to never go to sleep.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800918 */
919 public static final int WIFI_SLEEP_POLICY_NEVER = 2;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -0700920
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800921 /**
922 * Whether to use static IP and other static network attributes.
923 * <p>
924 * Set to 1 for true and 0 for false.
925 */
926 public static final String WIFI_USE_STATIC_IP = "wifi_use_static_ip";
927
928 /**
929 * The static IP address.
930 * <p>
931 * Example: "192.168.1.51"
932 */
933 public static final String WIFI_STATIC_IP = "wifi_static_ip";
934
935 /**
936 * If using static IP, the gateway's IP address.
937 * <p>
938 * Example: "192.168.1.1"
939 */
940 public static final String WIFI_STATIC_GATEWAY = "wifi_static_gateway";
941
942 /**
943 * If using static IP, the net mask.
944 * <p>
945 * Example: "255.255.255.0"
946 */
947 public static final String WIFI_STATIC_NETMASK = "wifi_static_netmask";
948
949 /**
950 * If using static IP, the primary DNS's IP address.
951 * <p>
952 * Example: "192.168.1.1"
953 */
954 public static final String WIFI_STATIC_DNS1 = "wifi_static_dns1";
955
956 /**
957 * If using static IP, the secondary DNS's IP address.
958 * <p>
959 * Example: "192.168.1.2"
960 */
961 public static final String WIFI_STATIC_DNS2 = "wifi_static_dns2";
962
963 /**
964 * The number of radio channels that are allowed in the local
965 * 802.11 regulatory domain.
966 * @hide
967 */
968 public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels";
969
970 /**
971 * Determines whether remote devices may discover and/or connect to
972 * this device.
973 * <P>Type: INT</P>
974 * 2 -- discoverable and connectable
975 * 1 -- connectable but not discoverable
976 * 0 -- neither connectable nor discoverable
977 */
978 public static final String BLUETOOTH_DISCOVERABILITY =
979 "bluetooth_discoverability";
980
981 /**
982 * Bluetooth discoverability timeout. If this value is nonzero, then
983 * Bluetooth becomes discoverable for a certain number of seconds,
984 * after which is becomes simply connectable. The value is in seconds.
985 */
986 public static final String BLUETOOTH_DISCOVERABILITY_TIMEOUT =
987 "bluetooth_discoverability_timeout";
988
989 /**
990 * Whether autolock is enabled (0 = false, 1 = true)
991 */
992 public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
993
994 /**
995 * Whether lock pattern is visible as user enters (0 = false, 1 = true)
996 */
997 public static final String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
998
999 /**
1000 * Whether lock pattern will vibrate as user enters (0 = false, 1 = true)
1001 */
1002 public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
1003 "lock_pattern_tactile_feedback_enabled";
1004
1005
1006 /**
1007 * A formatted string of the next alarm that is set, or the empty string
1008 * if there is no alarm set.
1009 */
1010 public static final String NEXT_ALARM_FORMATTED = "next_alarm_formatted";
1011
1012 /**
1013 * Scaling factor for fonts, float.
1014 */
1015 public static final String FONT_SCALE = "font_scale";
1016
1017 /**
1018 * Name of an application package to be debugged.
1019 */
1020 public static final String DEBUG_APP = "debug_app";
1021
1022 /**
1023 * If 1, when launching DEBUG_APP it will wait for the debugger before
1024 * starting user code. If 0, it will run normally.
1025 */
1026 public static final String WAIT_FOR_DEBUGGER = "wait_for_debugger";
1027
1028 /**
1029 * Whether or not to dim the screen. 0=no 1=yes
1030 */
1031 public static final String DIM_SCREEN = "dim_screen";
1032
1033 /**
1034 * The timeout before the screen turns off.
1035 */
1036 public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
1037
1038 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001039 * If 0, the compatibility mode is off for all applications.
1040 * If 1, older applications run under compatibility mode.
1041 * TODO: remove this settings before code freeze (bug/1907571)
1042 * @hide
1043 */
1044 public static final String COMPATIBILITY_MODE = "compatibility_mode";
1045
1046 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001047 * The screen backlight brightness between 0 and 255.
1048 */
1049 public static final String SCREEN_BRIGHTNESS = "screen_brightness";
1050
1051 /**
1052 * Control whether the process CPU usage meter should be shown.
1053 */
1054 public static final String SHOW_PROCESSES = "show_processes";
1055
1056 /**
1057 * If 1, the activity manager will aggressively finish activities and
1058 * processes as soon as they are no longer needed. If 0, the normal
1059 * extended lifetime is used.
1060 */
1061 public static final String ALWAYS_FINISH_ACTIVITIES =
1062 "always_finish_activities";
1063
1064
1065 /**
1066 * Ringer mode. This is used internally, changing this value will not
1067 * change the ringer mode. See AudioManager.
1068 */
1069 public static final String MODE_RINGER = "mode_ringer";
1070
1071 /**
1072 * Determines which streams are affected by ringer mode changes. The
1073 * stream type's bit should be set to 1 if it should be muted when going
1074 * into an inaudible ringer mode.
1075 */
1076 public static final String MODE_RINGER_STREAMS_AFFECTED = "mode_ringer_streams_affected";
1077
1078 /**
1079 * Determines which streams are affected by mute. The
1080 * stream type's bit should be set to 1 if it should be muted when a mute request
1081 * is received.
1082 */
1083 public static final String MUTE_STREAMS_AFFECTED = "mute_streams_affected";
1084
1085 /**
1086 * Whether vibrate is on for different events. This is used internally,
1087 * changing this value will not change the vibrate. See AudioManager.
1088 */
1089 public static final String VIBRATE_ON = "vibrate_on";
1090
1091 /**
1092 * Ringer volume. This is used internally, changing this value will not
1093 * change the volume. See AudioManager.
1094 */
1095 public static final String VOLUME_RING = "volume_ring";
1096
1097 /**
1098 * System/notifications volume. This is used internally, changing this
1099 * value will not change the volume. See AudioManager.
1100 */
1101 public static final String VOLUME_SYSTEM = "volume_system";
1102
1103 /**
1104 * Voice call volume. This is used internally, changing this value will
1105 * not change the volume. See AudioManager.
1106 */
1107 public static final String VOLUME_VOICE = "volume_voice";
1108
1109 /**
1110 * Music/media/gaming volume. This is used internally, changing this
1111 * value will not change the volume. See AudioManager.
1112 */
1113 public static final String VOLUME_MUSIC = "volume_music";
1114
1115 /**
1116 * Alarm volume. This is used internally, changing this
1117 * value will not change the volume. See AudioManager.
1118 */
1119 public static final String VOLUME_ALARM = "volume_alarm";
1120
1121 /**
1122 * Notification volume. This is used internally, changing this
1123 * value will not change the volume. See AudioManager.
1124 */
1125 public static final String VOLUME_NOTIFICATION = "volume_notification";
1126
1127 /**
1128 * Whether the notifications should use the ring volume (value of 1) or
1129 * a separate notification volume (value of 0). In most cases, users
1130 * will have this enabled so the notification and ringer volumes will be
1131 * the same. However, power users can disable this and use the separate
1132 * notification volume control.
1133 * <p>
1134 * Note: This is a one-off setting that will be removed in the future
1135 * when there is profile support. For this reason, it is kept hidden
1136 * from the public APIs.
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001137 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001138 * @hide
1139 */
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001140 public static final String NOTIFICATIONS_USE_RING_VOLUME =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001141 "notifications_use_ring_volume";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001142
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001143 /**
1144 * The mapping of stream type (integer) to its setting.
1145 */
1146 public static final String[] VOLUME_SETTINGS = {
1147 VOLUME_VOICE, VOLUME_SYSTEM, VOLUME_RING, VOLUME_MUSIC,
1148 VOLUME_ALARM, VOLUME_NOTIFICATION
1149 };
1150
1151 /**
1152 * Appended to various volume related settings to record the previous
1153 * values before they the settings were affected by a silent/vibrate
1154 * ringer mode change.
1155 */
1156 public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
1157
1158 /**
1159 * Persistent store for the system-wide default ringtone URI.
1160 * <p>
1161 * If you need to play the default ringtone at any given time, it is recommended
1162 * you give {@link #DEFAULT_RINGTONE_URI} to the media player. It will resolve
1163 * to the set default ringtone at the time of playing.
1164 *
1165 * @see #DEFAULT_RINGTONE_URI
1166 */
1167 public static final String RINGTONE = "ringtone";
1168
1169 /**
1170 * A {@link Uri} that will point to the current default ringtone at any
1171 * given time.
1172 * <p>
1173 * If the current default ringtone is in the DRM provider and the caller
1174 * does not have permission, the exception will be a
1175 * FileNotFoundException.
1176 */
1177 public static final Uri DEFAULT_RINGTONE_URI = getUriFor(RINGTONE);
1178
1179 /**
1180 * Persistent store for the system-wide default notification sound.
1181 *
1182 * @see #RINGTONE
1183 * @see #DEFAULT_NOTIFICATION_URI
1184 */
1185 public static final String NOTIFICATION_SOUND = "notification_sound";
1186
1187 /**
1188 * A {@link Uri} that will point to the current default notification
1189 * sound at any given time.
1190 *
1191 * @see #DEFAULT_RINGTONE_URI
1192 */
1193 public static final Uri DEFAULT_NOTIFICATION_URI = getUriFor(NOTIFICATION_SOUND);
1194
1195 /**
Patrick Scott3156bb002009-04-13 09:57:38 -07001196 * Persistent store for the system-wide default alarm alert.
1197 *
1198 * @see #RINGTONE
1199 * @see #DEFAULT_ALARM_ALERT_URI
1200 */
1201 public static final String ALARM_ALERT = "alarm_alert";
1202
1203 /**
1204 * A {@link Uri} that will point to the current default alarm alert at
1205 * any given time.
1206 *
1207 * @see #DEFAULT_ALARM_ALERT_URI
1208 */
1209 public static final Uri DEFAULT_ALARM_ALERT_URI = getUriFor(ALARM_ALERT);
1210
1211 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 * Setting to enable Auto Replace (AutoText) in text editors. 1 = On, 0 = Off
1213 */
1214 public static final String TEXT_AUTO_REPLACE = "auto_replace";
1215
1216 /**
1217 * Setting to enable Auto Caps in text editors. 1 = On, 0 = Off
1218 */
1219 public static final String TEXT_AUTO_CAPS = "auto_caps";
1220
1221 /**
1222 * Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
1223 * feature converts two spaces to a "." and space.
1224 */
1225 public static final String TEXT_AUTO_PUNCTUATE = "auto_punctuate";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001226
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001227 /**
1228 * Setting to showing password characters in text editors. 1 = On, 0 = Off
1229 */
1230 public static final String TEXT_SHOW_PASSWORD = "show_password";
1231
1232 public static final String SHOW_GTALK_SERVICE_STATUS =
1233 "SHOW_GTALK_SERVICE_STATUS";
1234
1235 /**
1236 * Name of activity to use for wallpaper on the home screen.
1237 */
1238 public static final String WALLPAPER_ACTIVITY = "wallpaper_activity";
1239
1240 /**
1241 * Value to specify if the user prefers the date, time and time zone
1242 * to be automatically fetched from the network (NITZ). 1=yes, 0=no
1243 */
1244 public static final String AUTO_TIME = "auto_time";
1245
1246 /**
1247 * Display times as 12 or 24 hours
1248 * 12
1249 * 24
1250 */
1251 public static final String TIME_12_24 = "time_12_24";
1252
1253 /**
1254 * Date format string
1255 * mm/dd/yyyy
1256 * dd/mm/yyyy
1257 * yyyy/mm/dd
1258 */
1259 public static final String DATE_FORMAT = "date_format";
1260
1261 /**
1262 * Whether the setup wizard has been run before (on first boot), or if
1263 * it still needs to be run.
1264 *
1265 * nonzero = it has been run in the past
1266 * 0 = it has not been run in the past
1267 */
1268 public static final String SETUP_WIZARD_HAS_RUN = "setup_wizard_has_run";
1269
1270 /**
1271 * Scaling factor for normal window animations. Setting to 0 will disable window
1272 * animations.
1273 */
1274 public static final String WINDOW_ANIMATION_SCALE = "window_animation_scale";
1275
1276 /**
1277 * Scaling factor for activity transition animations. Setting to 0 will disable window
1278 * animations.
1279 */
1280 public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
1281
1282 /**
1283 * Scaling factor for normal window animations. Setting to 0 will disable window
1284 * animations.
1285 * @hide
1286 */
1287 public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
1288
1289 /**
1290 * Control whether the accelerometer will be used to change screen
1291 * orientation. If 0, it will not be used unless explicitly requested
1292 * by the application; if 1, it will be used by default unless explicitly
1293 * disabled by the application.
1294 */
1295 public static final String ACCELEROMETER_ROTATION = "accelerometer_rotation";
1296
1297 /**
1298 * Whether the audible DTMF tones are played by the dialer when dialing. The value is
1299 * boolean (1 or 0).
1300 */
1301 public static final String DTMF_TONE_WHEN_DIALING = "dtmf_tone";
1302
1303 /**
David Kraused0f67152009-06-13 18:01:13 -05001304 * CDMA only settings
1305 * DTMF tone type played by the dialer when dialing.
1306 * 0 = Normal
1307 * 1 = Long
1308 * @hide
1309 */
1310 public static final String DTMF_TONE_TYPE_WHEN_DIALING = "dtmf_tone_type";
1311
1312 /**
1313 * CDMA only settings
1314 * Emergency Tone 0 = Off
1315 * 1 = Alert
1316 * 2 = Vibrate
1317 * @hide
1318 */
1319 public static final String EMERGENCY_TONE = "emergency_tone";
1320
1321 /**
1322 * CDMA only settings
1323 * Whether the auto retry is enabled. The value is
1324 * boolean (1 or 0).
1325 * @hide
1326 */
1327 public static final String CALL_AUTO_RETRY = "call_auto_retry";
1328
1329 /**
1330 * Whether the hearing aid is enabled. The value is
1331 * boolean (1 or 0).
1332 * @hide
1333 */
1334 public static final String HEARING_AID = "hearing_aid";
1335
1336 /**
1337 * CDMA only settings
1338 * TTY Mode
1339 * 0 = OFF
1340 * 1 = FULL
1341 * 2 = VCO
1342 * 3 = HCO
1343 * @hide
1344 */
1345 public static final String TTY_MODE = "tty_mode";
1346
1347 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001348 * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
1349 * boolean (1 or 0).
1350 */
1351 public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001352
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001353 /**
1354 * Whether the haptic feedback (long presses, ...) are enabled. The value is
1355 * boolean (1 or 0).
1356 */
1357 public static final String HAPTIC_FEEDBACK_ENABLED = "haptic_feedback_enabled";
Sanjay Jeyakumar21bf2412009-07-09 13:31:48 -07001358
Mike LeBeau48603e72009-06-05 00:27:00 +01001359 /**
1360 * Whether live web suggestions while the user types into search dialogs are
1361 * enabled. Browsers and other search UIs should respect this, as it allows
1362 * a user to avoid sending partial queries to a search engine, if it poses
1363 * any privacy concern. The value is boolean (1 or 0).
1364 */
1365 public static final String SHOW_WEB_SUGGESTIONS = "show_web_suggestions";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001366
-b master501eec92009-07-06 13:53:11 -07001367 /**
1368 * Settings to backup. This is here so that it's in the same place as the settings
1369 * keys and easy to update.
1370 * @hide
1371 */
1372 public static final String[] SETTINGS_TO_BACKUP = {
1373 STAY_ON_WHILE_PLUGGED_IN,
1374 END_BUTTON_BEHAVIOR,
1375 WIFI_SLEEP_POLICY,
1376 WIFI_USE_STATIC_IP,
1377 WIFI_STATIC_IP,
1378 WIFI_STATIC_GATEWAY,
1379 WIFI_STATIC_NETMASK,
1380 WIFI_STATIC_DNS1,
1381 WIFI_STATIC_DNS2,
1382 BLUETOOTH_DISCOVERABILITY,
1383 BLUETOOTH_DISCOVERABILITY_TIMEOUT,
1384 DIM_SCREEN,
1385 SCREEN_OFF_TIMEOUT,
1386 SCREEN_BRIGHTNESS,
1387 VIBRATE_ON,
1388 NOTIFICATIONS_USE_RING_VOLUME,
Amith Yamasani8823c0a82009-07-07 14:30:17 -07001389 MODE_RINGER,
1390 MODE_RINGER_STREAMS_AFFECTED,
1391 MUTE_STREAMS_AFFECTED,
1392 VOLUME_VOICE,
1393 VOLUME_SYSTEM,
1394 VOLUME_RING,
1395 VOLUME_MUSIC,
1396 VOLUME_ALARM,
1397 VOLUME_NOTIFICATION,
1398 VOLUME_VOICE + APPEND_FOR_LAST_AUDIBLE,
1399 VOLUME_SYSTEM + APPEND_FOR_LAST_AUDIBLE,
1400 VOLUME_RING + APPEND_FOR_LAST_AUDIBLE,
1401 VOLUME_MUSIC + APPEND_FOR_LAST_AUDIBLE,
1402 VOLUME_ALARM + APPEND_FOR_LAST_AUDIBLE,
1403 VOLUME_NOTIFICATION + APPEND_FOR_LAST_AUDIBLE,
-b master501eec92009-07-06 13:53:11 -07001404 TEXT_AUTO_REPLACE,
1405 TEXT_AUTO_CAPS,
1406 TEXT_AUTO_PUNCTUATE,
1407 TEXT_SHOW_PASSWORD,
1408 AUTO_TIME,
1409 TIME_12_24,
1410 DATE_FORMAT,
1411 ACCELEROMETER_ROTATION,
1412 DTMF_TONE_WHEN_DIALING,
1413 DTMF_TONE_TYPE_WHEN_DIALING,
1414 EMERGENCY_TONE,
1415 CALL_AUTO_RETRY,
1416 HEARING_AID,
1417 TTY_MODE,
1418 SOUND_EFFECTS_ENABLED,
1419 HAPTIC_FEEDBACK_ENABLED,
1420 SHOW_WEB_SUGGESTIONS
1421 };
1422
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001423 // Settings moved to Settings.Secure
1424
1425 /**
Mike Lockwood460ae0c2009-04-02 22:33:27 -07001426 * @deprecated Use {@link android.provider.Settings.Secure#ADB_ENABLED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001427 * instead
1428 */
1429 @Deprecated
1430 public static final String ADB_ENABLED = Secure.ADB_ENABLED;
1431
1432 /**
1433 * @deprecated Use {@link android.provider.Settings.Secure#ANDROID_ID} instead
1434 */
1435 @Deprecated
1436 public static final String ANDROID_ID = Secure.ANDROID_ID;
1437
1438 /**
1439 * @deprecated Use {@link android.provider.Settings.Secure#BLUETOOTH_ON} instead
1440 */
1441 @Deprecated
1442 public static final String BLUETOOTH_ON = Secure.BLUETOOTH_ON;
1443
1444 /**
1445 * @deprecated Use {@link android.provider.Settings.Secure#DATA_ROAMING} instead
1446 */
1447 @Deprecated
1448 public static final String DATA_ROAMING = Secure.DATA_ROAMING;
1449
1450 /**
1451 * @deprecated Use {@link android.provider.Settings.Secure#DEVICE_PROVISIONED} instead
1452 */
1453 @Deprecated
1454 public static final String DEVICE_PROVISIONED = Secure.DEVICE_PROVISIONED;
1455
1456 /**
1457 * @deprecated Use {@link android.provider.Settings.Secure#HTTP_PROXY} instead
1458 */
1459 @Deprecated
1460 public static final String HTTP_PROXY = Secure.HTTP_PROXY;
1461
1462 /**
1463 * @deprecated Use {@link android.provider.Settings.Secure#INSTALL_NON_MARKET_APPS} instead
1464 */
1465 @Deprecated
1466 public static final String INSTALL_NON_MARKET_APPS = Secure.INSTALL_NON_MARKET_APPS;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001467
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001468 /**
1469 * @deprecated Use {@link android.provider.Settings.Secure#LOCATION_PROVIDERS_ALLOWED}
1470 * instead
1471 */
1472 @Deprecated
1473 public static final String LOCATION_PROVIDERS_ALLOWED = Secure.LOCATION_PROVIDERS_ALLOWED;
1474
1475 /**
1476 * @deprecated Use {@link android.provider.Settings.Secure#LOGGING_ID} instead
1477 */
1478 @Deprecated
1479 public static final String LOGGING_ID = Secure.LOGGING_ID;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001480
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001481 /**
1482 * @deprecated Use {@link android.provider.Settings.Secure#NETWORK_PREFERENCE} instead
1483 */
1484 @Deprecated
1485 public static final String NETWORK_PREFERENCE = Secure.NETWORK_PREFERENCE;
1486
1487 /**
1488 * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_ENABLED}
1489 * instead
1490 */
1491 @Deprecated
1492 public static final String PARENTAL_CONTROL_ENABLED = Secure.PARENTAL_CONTROL_ENABLED;
1493
1494 /**
1495 * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_LAST_UPDATE}
1496 * instead
1497 */
1498 @Deprecated
1499 public static final String PARENTAL_CONTROL_LAST_UPDATE = Secure.PARENTAL_CONTROL_LAST_UPDATE;
1500
1501 /**
1502 * @deprecated Use {@link android.provider.Settings.Secure#PARENTAL_CONTROL_REDIRECT_URL}
1503 * instead
1504 */
1505 @Deprecated
1506 public static final String PARENTAL_CONTROL_REDIRECT_URL =
1507 Secure.PARENTAL_CONTROL_REDIRECT_URL;
1508
1509 /**
1510 * @deprecated Use {@link android.provider.Settings.Secure#SETTINGS_CLASSNAME} instead
1511 */
1512 @Deprecated
1513 public static final String SETTINGS_CLASSNAME = Secure.SETTINGS_CLASSNAME;
1514
1515 /**
1516 * @deprecated Use {@link android.provider.Settings.Secure#USB_MASS_STORAGE_ENABLED} instead
1517 */
1518 @Deprecated
1519 public static final String USB_MASS_STORAGE_ENABLED = Secure.USB_MASS_STORAGE_ENABLED;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001520
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001521 /**
1522 * @deprecated Use {@link android.provider.Settings.Secure#USE_GOOGLE_MAIL} instead
1523 */
1524 @Deprecated
1525 public static final String USE_GOOGLE_MAIL = Secure.USE_GOOGLE_MAIL;
1526
1527// /**
1528// * @deprecated Use {@link android.provider.Settings.Secure#WIFI_MAX_DHCP_RETRY_COUNT}
1529// * instead
1530// */
1531 @Deprecated
1532 public static final String WIFI_MAX_DHCP_RETRY_COUNT = Secure.WIFI_MAX_DHCP_RETRY_COUNT;
1533
1534// /**
1535// * @deprecated Use
1536// * {@link android.provider.Settings.Secure#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS}
1537// * instead
1538// */
1539 @Deprecated
1540 public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
1541 Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
1542
1543 /**
1544 * @deprecated Use
1545 * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON} instead
1546 */
1547 @Deprecated
1548 public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
1549 Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
1550
1551 /**
1552 * @deprecated Use
1553 * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} instead
1554 */
1555 @Deprecated
1556 public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
1557 Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001558
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001559 /**
1560 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_NUM_OPEN_NETWORKS_KEPT}
1561 * instead
1562 */
1563 @Deprecated
1564 public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = Secure.WIFI_NUM_OPEN_NETWORKS_KEPT;
1565
1566 /**
1567 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_ON} instead
1568 */
1569 @Deprecated
1570 public static final String WIFI_ON = Secure.WIFI_ON;
1571
1572 /**
1573 * @deprecated Use
1574 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE}
1575 * instead
1576 */
1577 @Deprecated
1578 public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
1579 Secure.WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE;
1580
1581 /**
1582 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_AP_COUNT} instead
1583 */
1584 @Deprecated
1585 public static final String WIFI_WATCHDOG_AP_COUNT = Secure.WIFI_WATCHDOG_AP_COUNT;
1586
1587 /**
1588 * @deprecated Use
1589 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS} instead
1590 */
1591 @Deprecated
1592 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
1593 Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS;
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001594
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001595 /**
1596 * @deprecated Use
1597 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED} instead
1598 */
1599 @Deprecated
1600 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
1601 Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED;
1602
1603 /**
1604 * @deprecated Use
1605 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS}
1606 * instead
1607 */
1608 @Deprecated
1609 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
1610 Secure.WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS;
1611
1612 /**
1613 * @deprecated Use
1614 * {@link android.provider.Settings.Secure#WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT} instead
1615 */
1616 @Deprecated
1617 public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
1618 Secure.WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT;
1619
1620 /**
1621 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_MAX_AP_CHECKS}
1622 * instead
1623 */
1624 @Deprecated
1625 public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = Secure.WIFI_WATCHDOG_MAX_AP_CHECKS;
1626
1627 /**
1628 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_ON} instead
1629 */
1630 @Deprecated
1631 public static final String WIFI_WATCHDOG_ON = Secure.WIFI_WATCHDOG_ON;
1632
1633 /**
1634 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_COUNT} instead
1635 */
1636 @Deprecated
1637 public static final String WIFI_WATCHDOG_PING_COUNT = Secure.WIFI_WATCHDOG_PING_COUNT;
1638
1639 /**
1640 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_DELAY_MS}
1641 * instead
1642 */
1643 @Deprecated
1644 public static final String WIFI_WATCHDOG_PING_DELAY_MS = Secure.WIFI_WATCHDOG_PING_DELAY_MS;
1645
1646 /**
1647 * @deprecated Use {@link android.provider.Settings.Secure#WIFI_WATCHDOG_PING_TIMEOUT_MS}
1648 * instead
1649 */
1650 @Deprecated
1651 public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS =
1652 Secure.WIFI_WATCHDOG_PING_TIMEOUT_MS;
1653 }
1654
1655 /**
1656 * Secure system settings, containing system preferences that applications
1657 * can read but are not allowed to write. These are for preferences that
1658 * the user must explicitly modify through the system UI or specialized
1659 * APIs for those values, not modified directly by applications.
1660 */
1661 public static final class Secure extends NameValueTable {
1662 public static final String SYS_PROP_SETTING_VERSION = "sys.settings_secure_version";
1663
1664 private static volatile NameValueCache mNameValueCache = null;
1665
1666 /**
1667 * Look up a name in the database.
1668 * @param resolver to access the database with
1669 * @param name to look up in the table
1670 * @return the corresponding value, or null if not present
1671 */
1672 public synchronized static String getString(ContentResolver resolver, String name) {
1673 if (mNameValueCache == null) {
1674 mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
1675 }
1676 return mNameValueCache.getString(resolver, name);
1677 }
1678
1679 /**
1680 * Store a name/value pair into the database.
1681 * @param resolver to access the database with
1682 * @param name to store
1683 * @param value to associate with the name
1684 * @return true if the value was set, false on database errors
1685 */
1686 public static boolean putString(ContentResolver resolver,
1687 String name, String value) {
1688 return putString(resolver, CONTENT_URI, name, value);
1689 }
1690
1691 /**
1692 * Construct the content URI for a particular name/value pair,
1693 * useful for monitoring changes with a ContentObserver.
1694 * @param name to look up in the table
1695 * @return the corresponding content URI, or null if not present
1696 */
1697 public static Uri getUriFor(String name) {
1698 return getUriFor(CONTENT_URI, name);
1699 }
1700
1701 /**
1702 * Convenience function for retrieving a single secure settings value
1703 * as an integer. Note that internally setting values are always
1704 * stored as strings; this function converts the string to an integer
1705 * for you. The default value will be returned if the setting is
1706 * not defined or not an integer.
1707 *
1708 * @param cr The ContentResolver to access.
1709 * @param name The name of the setting to retrieve.
1710 * @param def Value to return if the setting is not defined.
1711 *
1712 * @return The setting's current value, or 'def' if it is not defined
1713 * or not a valid integer.
1714 */
1715 public static int getInt(ContentResolver cr, String name, int def) {
1716 String v = getString(cr, name);
1717 try {
1718 return v != null ? Integer.parseInt(v) : def;
1719 } catch (NumberFormatException e) {
1720 return def;
1721 }
1722 }
1723
1724 /**
1725 * Convenience function for retrieving a single secure settings value
1726 * as an integer. Note that internally setting values are always
1727 * stored as strings; this function converts the string to an integer
1728 * for you.
1729 * <p>
1730 * This version does not take a default value. If the setting has not
1731 * been set, or the string value is not a number,
1732 * it throws {@link SettingNotFoundException}.
1733 *
1734 * @param cr The ContentResolver to access.
1735 * @param name The name of the setting to retrieve.
1736 *
1737 * @throws SettingNotFoundException Thrown if a setting by the given
1738 * name can't be found or the setting value is not an integer.
1739 *
1740 * @return The setting's current value.
1741 */
1742 public static int getInt(ContentResolver cr, String name)
1743 throws SettingNotFoundException {
1744 String v = getString(cr, name);
1745 try {
1746 return Integer.parseInt(v);
1747 } catch (NumberFormatException e) {
1748 throw new SettingNotFoundException(name);
1749 }
1750 }
1751
1752 /**
1753 * Convenience function for updating a single settings value as an
1754 * integer. This will either create a new entry in the table if the
1755 * given name does not exist, or modify the value of the existing row
1756 * with that name. Note that internally setting values are always
1757 * stored as strings, so this function converts the given value to a
1758 * string before storing it.
1759 *
1760 * @param cr The ContentResolver to access.
1761 * @param name The name of the setting to modify.
1762 * @param value The new value for the setting.
1763 * @return true if the value was set, false on database errors
1764 */
1765 public static boolean putInt(ContentResolver cr, String name, int value) {
1766 return putString(cr, name, Integer.toString(value));
1767 }
1768
1769 /**
1770 * Convenience function for retrieving a single secure settings value
1771 * as a {@code long}. Note that internally setting values are always
1772 * stored as strings; this function converts the string to a {@code long}
1773 * for you. The default value will be returned if the setting is
1774 * not defined or not a {@code long}.
1775 *
1776 * @param cr The ContentResolver to access.
1777 * @param name The name of the setting to retrieve.
1778 * @param def Value to return if the setting is not defined.
1779 *
1780 * @return The setting's current value, or 'def' if it is not defined
1781 * or not a valid {@code long}.
1782 */
1783 public static long getLong(ContentResolver cr, String name, long def) {
1784 String valString = getString(cr, name);
1785 long value;
1786 try {
1787 value = valString != null ? Long.parseLong(valString) : def;
1788 } catch (NumberFormatException e) {
1789 value = def;
1790 }
1791 return value;
1792 }
1793
1794 /**
1795 * Convenience function for retrieving a single secure settings value
1796 * as a {@code long}. Note that internally setting values are always
1797 * stored as strings; this function converts the string to a {@code long}
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 * @return The setting's current value.
1808 * @throws SettingNotFoundException Thrown if a setting by the given
1809 * name can't be found or the setting value is not an integer.
1810 */
1811 public static long getLong(ContentResolver cr, String name)
1812 throws SettingNotFoundException {
1813 String valString = getString(cr, name);
1814 try {
1815 return Long.parseLong(valString);
1816 } catch (NumberFormatException e) {
1817 throw new SettingNotFoundException(name);
1818 }
1819 }
1820
1821 /**
1822 * Convenience function for updating a secure settings value as a long
1823 * integer. This will either create a new entry in the table if the
1824 * given name does not exist, or modify the value of the existing row
1825 * with that name. Note that internally setting values are always
1826 * stored as strings, so this function converts the given value to a
1827 * string before storing it.
1828 *
1829 * @param cr The ContentResolver to access.
1830 * @param name The name of the setting to modify.
1831 * @param value The new value for the setting.
1832 * @return true if the value was set, false on database errors
1833 */
1834 public static boolean putLong(ContentResolver cr, String name, long value) {
1835 return putString(cr, name, Long.toString(value));
1836 }
1837
1838 /**
1839 * Convenience function for retrieving a single secure settings value
1840 * as a floating point number. Note that internally setting values are
1841 * always stored as strings; this function converts the string to an
1842 * float for you. The default value will be returned if the setting
1843 * is not defined or not a valid float.
1844 *
1845 * @param cr The ContentResolver to access.
1846 * @param name The name of the setting to retrieve.
1847 * @param def Value to return if the setting is not defined.
1848 *
1849 * @return The setting's current value, or 'def' if it is not defined
1850 * or not a valid float.
1851 */
1852 public static float getFloat(ContentResolver cr, String name, float def) {
1853 String v = getString(cr, name);
1854 try {
1855 return v != null ? Float.parseFloat(v) : def;
1856 } catch (NumberFormatException e) {
1857 return def;
1858 }
1859 }
1860
1861 /**
1862 * Convenience function for retrieving a single secure settings value
1863 * as a float. Note that internally setting values are always
1864 * stored as strings; this function converts the string to a float
1865 * for you.
1866 * <p>
1867 * This version does not take a default value. If the setting has not
1868 * been set, or the string value is not a number,
1869 * it throws {@link SettingNotFoundException}.
1870 *
1871 * @param cr The ContentResolver to access.
1872 * @param name The name of the setting to retrieve.
1873 *
1874 * @throws SettingNotFoundException Thrown if a setting by the given
1875 * name can't be found or the setting value is not a float.
1876 *
1877 * @return The setting's current value.
1878 */
1879 public static float getFloat(ContentResolver cr, String name)
1880 throws SettingNotFoundException {
1881 String v = getString(cr, name);
1882 try {
1883 return Float.parseFloat(v);
1884 } catch (NumberFormatException e) {
1885 throw new SettingNotFoundException(name);
1886 }
1887 }
1888
1889 /**
1890 * Convenience function for updating a single settings value as a
1891 * floating point number. This will either create a new entry in the
1892 * table if the given name does not exist, or modify the value of the
1893 * existing row with that name. Note that internally setting values
1894 * are always stored as strings, so this function converts the given
1895 * value to a string before storing it.
1896 *
1897 * @param cr The ContentResolver to access.
1898 * @param name The name of the setting to modify.
1899 * @param value The new value for the setting.
1900 * @return true if the value was set, false on database errors
1901 */
1902 public static boolean putFloat(ContentResolver cr, String name, float value) {
1903 return putString(cr, name, Float.toString(value));
1904 }
1905
1906 /**
1907 * The content:// style URL for this table
1908 */
1909 public static final Uri CONTENT_URI =
1910 Uri.parse("content://" + AUTHORITY + "/secure");
1911
1912 /**
1913 * Whether ADB is enabled.
1914 */
1915 public static final String ADB_ENABLED = "adb_enabled";
1916
1917 /**
1918 * Setting to allow mock locations and location provider status to be injected into the
1919 * LocationManager service for testing purposes during application development. These
1920 * locations and status values override actual location and status information generated
1921 * by network, gps, or other location providers.
1922 */
1923 public static final String ALLOW_MOCK_LOCATION = "mock_location";
1924
1925 /**
1926 * The Android ID (a unique 64-bit value) as a hex string.
1927 * Identical to that obtained by calling
1928 * GoogleLoginService.getAndroidId(); it is also placed here
1929 * so you can get it without binding to a service.
1930 */
1931 public static final String ANDROID_ID = "android_id";
1932
1933 /**
1934 * Whether bluetooth is enabled/disabled
1935 * 0=disabled. 1=enabled.
1936 */
1937 public static final String BLUETOOTH_ON = "bluetooth_on";
1938
1939 /**
1940 * Get the key that retrieves a bluetooth headset's priority.
1941 * @hide
1942 */
1943 public static final String getBluetoothHeadsetPriorityKey(String address) {
1944 return ("bluetooth_headset_priority_" + address.toUpperCase());
1945 }
1946
1947 /**
1948 * Get the key that retrieves a bluetooth a2dp sink's priority.
1949 * @hide
1950 */
1951 public static final String getBluetoothA2dpSinkPriorityKey(String address) {
1952 return ("bluetooth_a2dp_sink_priority_" + address.toUpperCase());
1953 }
1954
1955 /**
1956 * Whether or not data roaming is enabled. (0 = false, 1 = true)
1957 */
1958 public static final String DATA_ROAMING = "data_roaming";
1959
1960 /**
1961 * Setting to record the input method used by default, holding the ID
1962 * of the desired method.
1963 */
1964 public static final String DEFAULT_INPUT_METHOD = "default_input_method";
1965
1966 /**
1967 * Whether the device has been provisioned (0 = false, 1 = true)
1968 */
1969 public static final String DEVICE_PROVISIONED = "device_provisioned";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001970
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001971 /**
1972 * List of input methods that are currently enabled. This is a string
1973 * containing the IDs of all enabled input methods, each ID separated
1974 * by ':'.
1975 */
1976 public static final String ENABLED_INPUT_METHODS = "enabled_input_methods";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001977
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001978 /**
1979 * Host name and port for a user-selected proxy.
1980 */
1981 public static final String HTTP_PROXY = "http_proxy";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001982
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001983 /**
1984 * Whether the package installer should allow installation of apps downloaded from
1985 * sources other than the Android Market (vending machine).
1986 *
1987 * 1 = allow installing from other sources
1988 * 0 = only allow installing from the Android Market
1989 */
1990 public static final String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001991
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001992 /**
1993 * Comma-separated list of location providers that activities may access.
1994 */
1995 public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07001996
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001997 /**
Mike Lockwoodbcab8df2009-06-25 16:39:09 -04001998 * Whether assisted GPS should be enabled or not.
1999 * @hide
2000 */
2001 public static final String ASSISTED_GPS_ENABLED = "assisted_gps_enabled";
2002
2003 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002004 * The Logging ID (a unique 64-bit value) as a hex string.
2005 * Used as a pseudonymous identifier for logging.
2006 * @deprecated This identifier is poorly initialized and has
2007 * many collisions. It should not be used.
2008 */
2009 @Deprecated
2010 public static final String LOGGING_ID = "logging_id";
2011
2012 /**
2013 * The Logging ID (a unique 64-bit value) as a hex string.
2014 * Used as a pseudonymous identifier for logging.
2015 * @hide
2016 */
2017 public static final String LOGGING_ID2 = "logging_id2";
2018
2019 /**
2020 * User preference for which network(s) should be used. Only the
2021 * connectivity service should touch this.
2022 */
2023 public static final String NETWORK_PREFERENCE = "network_preference";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002024
2025 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002026 */
2027 public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002028
2029 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002030 */
2031 public static final String PARENTAL_CONTROL_LAST_UPDATE = "parental_control_last_update";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002032
2033 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002034 */
2035 public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002036
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002037 /**
2038 * Settings classname to launch when Settings is clicked from All
2039 * Applications. Needed because of user testing between the old
2040 * and new Settings apps.
2041 */
2042 // TODO: 881807
2043 public static final String SETTINGS_CLASSNAME = "settings_classname";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002044
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002045 /**
2046 * USB Mass Storage Enabled
2047 */
2048 public static final String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002049
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002050 /**
2051 * If this setting is set (to anything), then all references
2052 * to Gmail on the device must change to Google Mail.
2053 */
2054 public static final String USE_GOOGLE_MAIL = "use_google_mail";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002055
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002056 /**
svetoslavganov75986cf2009-05-14 22:28:01 -07002057 * If accessibility is enabled.
2058 */
2059 public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
2060
2061 /**
2062 * List of the enabled accessibility providers.
2063 */
2064 public static final String ENABLED_ACCESSIBILITY_SERVICES =
2065 "enabled_accessibility_services";
2066
2067 /**
Jean-Michel Trivif62ba452009-06-04 14:55:24 -07002068 * Setting to always use the default text-to-speech settings regardless
2069 * of the application settings.
2070 * 1 = override application settings,
2071 * 0 = use application settings (if specified).
2072 */
2073 public static final String TTS_USE_DEFAULTS = "tts_use_defaults";
2074
2075 /**
2076 * Default text-to-speech engine speech rate. 100 = 1x
2077 */
2078 public static final String TTS_DEFAULT_RATE = "tts_default_rate";
2079
2080 /**
2081 * Default text-to-speech engine pitch. 100 = 1x
2082 */
2083 public static final String TTS_DEFAULT_PITCH = "tts_default_pitch";
2084
2085 /**
2086 * Default text-to-speech engine.
2087 */
2088 public static final String TTS_DEFAULT_SYNTH = "tts_default_synth";
2089
2090 /**
Jean-Michel Trivif4782672009-06-09 16:22:48 -07002091 * Default text-to-speech language.
2092 */
2093 public static final String TTS_DEFAULT_LANG = "tts_default_lang";
2094
2095 /**
Jean-Michel Trivia6fcc952009-06-19 14:06:01 -07002096 * Default text-to-speech country.
2097 */
2098 public static final String TTS_DEFAULT_COUNTRY = "tts_default_country";
2099
2100 /**
2101 * Default text-to-speech locale variant.
2102 */
2103 public static final String TTS_DEFAULT_VARIANT = "tts_default_variant";
2104
2105 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002106 * Whether to notify the user of open networks.
2107 * <p>
2108 * If not connected and the scan results have an open network, we will
2109 * put this notification up. If we attempt to connect to a network or
2110 * the open network(s) disappear, we remove the notification. When we
2111 * show the notification, we will not show it again for
2112 * {@link android.provider.Settings.Secure#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} time.
2113 */
2114 public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
2115 "wifi_networks_available_notification_on";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002116
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002117 /**
2118 * Delay (in seconds) before repeating the Wi-Fi networks available notification.
2119 * Connecting to a network will reset the timer.
2120 */
2121 public static final String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY =
2122 "wifi_networks_available_repeat_delay";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002123
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002124 /**
2125 * The number of radio channels that are allowed in the local
2126 * 802.11 regulatory domain.
2127 * @hide
2128 */
2129 public static final String WIFI_NUM_ALLOWED_CHANNELS = "wifi_num_allowed_channels";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002130
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002131 /**
2132 * When the number of open networks exceeds this number, the
2133 * least-recently-used excess networks will be removed.
2134 */
2135 public static final String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002136
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002137 /**
2138 * Whether the Wi-Fi should be on. Only the Wi-Fi service should touch this.
2139 */
2140 public static final String WIFI_ON = "wifi_on";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002141
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002142 /**
2143 * The acceptable packet loss percentage (range 0 - 100) before trying
2144 * another AP on the same network.
2145 */
2146 public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
2147 "wifi_watchdog_acceptable_packet_loss_percentage";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002148
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002149 /**
2150 * The number of access points required for a network in order for the
2151 * watchdog to monitor it.
2152 */
2153 public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002154
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002155 /**
2156 * The delay between background checks.
2157 */
2158 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
2159 "wifi_watchdog_background_check_delay_ms";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002160
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002161 /**
2162 * Whether the Wi-Fi watchdog is enabled for background checking even
2163 * after it thinks the user has connected to a good access point.
2164 */
2165 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
2166 "wifi_watchdog_background_check_enabled";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002167
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002168 /**
2169 * The timeout for a background ping
2170 */
2171 public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
2172 "wifi_watchdog_background_check_timeout_ms";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002173
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002174 /**
2175 * The number of initial pings to perform that *may* be ignored if they
2176 * fail. Again, if these fail, they will *not* be used in packet loss
2177 * calculation. For example, one network always seemed to time out for
2178 * the first couple pings, so this is set to 3 by default.
2179 */
2180 public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
2181 "wifi_watchdog_initial_ignored_ping_count";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002182
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002183 /**
2184 * The maximum number of access points (per network) to attempt to test.
2185 * If this number is reached, the watchdog will no longer monitor the
2186 * initial connection state for the network. This is a safeguard for
2187 * networks containing multiple APs whose DNS does not respond to pings.
2188 */
2189 public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002190
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002191 /**
2192 * Whether the Wi-Fi watchdog is enabled.
2193 */
2194 public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on";
2195
2196 /**
2197 * 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 -08002198 */
2199 public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
2200
2201 /**
2202 * The number of pings to test if an access point is a good connection.
2203 */
2204 public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002205
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002206 /**
2207 * The delay between pings.
2208 */
2209 public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002210
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002211 /**
2212 * The timeout per ping.
2213 */
2214 public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002215
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002216 /**
2217 * The maximum number of times we will retry a connection to an access
2218 * point for which we have failed in acquiring an IP address from DHCP.
2219 * 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 -08002220 */
2221 public static final String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002222
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002223 /**
2224 * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
2225 * data connectivity to be established after a disconnect from Wi-Fi.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002226 */
2227 public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
2228 "wifi_mobile_data_transition_wakelock_timeout_ms";
2229
2230 /**
2231 * Whether background data usage is allowed by the user. See
2232 * ConnectivityManager for more info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002233 */
2234 public static final String BACKGROUND_DATA = "background_data";
Wink Saville04e71b32009-04-02 11:00:54 -07002235
2236 /**
2237 * The CDMA roaming mode 0 = Home Networks, CDMA default
2238 * 1 = Roaming on Affiliated networks
2239 * 2 = Roaming on any networks
2240 * @hide
2241 */
2242 public static final String CDMA_ROAMING_MODE = "roaming_settings";
2243
2244 /**
2245 * The CDMA subscription mode 0 = RUIM/SIM (default)
2246 * 1 = NV
2247 * @hide
2248 */
2249 public static final String CDMA_SUBSCRIPTION_MODE = "subscription_mode";
2250
2251 /**
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002252 * The preferred network mode 7 = Global
2253 * 6 = EvDo only
2254 * 5 = CDMA w/o EvDo
2255 * 4 = CDMA / EvDo auto
2256 * 3 = GSM / WCDMA auto
2257 * 2 = WCDMA only
2258 * 1 = GSM only
2259 * 0 = GSM / WCDMA preferred
Wink Saville04e71b32009-04-02 11:00:54 -07002260 * @hide
2261 */
2262 public static final String PREFERRED_NETWORK_MODE =
2263 "preferred_network_mode";
2264
2265 /**
Wink Savillee9b06d72009-05-18 21:47:50 -07002266 * The preferred TTY mode 0 = TTy Off, CDMA default
2267 * 1 = TTY Full
2268 * 2 = TTY HCO
2269 * 3 = TTY VCO
2270 * @hide
2271 */
2272 public static final String PREFERRED_TTY_MODE =
2273 "preferred_tty_mode";
2274
2275
2276 /**
Wink Saville04e71b32009-04-02 11:00:54 -07002277 * CDMA Cell Broadcast SMS
2278 * 0 = CDMA Cell Broadcast SMS disabled
2279 * 1 = CDMA Cell Broadcast SMS enabled
2280 * @hide
2281 */
2282 public static final String CDMA_CELL_BROADCAST_SMS =
2283 "cdma_cell_broadcast_sms";
2284
2285 /**
2286 * The cdma subscription 0 = Subscription from RUIM, when available
2287 * 1 = Subscription from NV
2288 * @hide
2289 */
2290 public static final String PREFERRED_CDMA_SUBSCRIPTION =
2291 "preferred_cdma_subscription";
2292
2293 /**
2294 * Whether the enhanced voice privacy mode is enabled.
2295 * 0 = normal voice privacy
2296 * 1 = enhanced voice privacy
2297 * @hide
2298 */
2299 public static final String ENHANCED_VOICE_PRIVACY_ENABLED = "enhanced_voice_privacy_enabled";
2300
2301 /**
2302 * Whether the TTY mode mode is enabled.
2303 * 0 = disabled
2304 * 1 = enabled
2305 * @hide
2306 */
2307 public static final String TTY_MODE_ENABLED = "tty_mode_enabled";
Mike Lockwoodbd2a7122009-04-02 23:41:33 -07002308
2309 /**
Amith Yamasani630cd062009-06-19 12:07:02 -07002310 * Flag for allowing service provider to use location information to improve products and
2311 * services.
2312 * Type: int ( 0 = disallow, 1 = allow )
2313 * @hide
2314 */
2315 public static final String USE_LOCATION_FOR_SERVICES = "use_location";
2316
2317 /**
Christopher Tate8031a3d2009-07-06 16:36:05 -07002318 * Controls whether settings backup is enabled.
Dianne Hackborncf098292009-07-01 19:55:20 -07002319 * Type: int ( 0 = disabled, 1 = enabled )
2320 * @hide
2321 */
2322 public static final String BACKUP_ENABLED = "backup_enabled";
2323
2324 /**
Christopher Tate8031a3d2009-07-06 16:36:05 -07002325 * Indicates whether settings backup has been fully provisioned.
2326 * Type: int ( 0 = unprovisioned, 1 = fully provisioned )
2327 * @hide
2328 */
2329 public static final String BACKUP_PROVISIONED = "backup_provisioned";
2330
2331 /**
Dianne Hackborncf098292009-07-01 19:55:20 -07002332 * Component of the transport to use for backup/restore.
2333 * @hide
2334 */
2335 public static final String BACKUP_TRANSPORT = "backup_transport";
Sanjay Jeyakumar21bf2412009-07-09 13:31:48 -07002336
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07002337 /**
2338 * Version for which the setup wizard was last shown. Bumped for
2339 * each release when there is new setup information to show.
2340 * @hide
2341 */
2342 public static final String LAST_SETUP_SHOWN = "last_setup_shown";
Dianne Hackborncf098292009-07-01 19:55:20 -07002343
2344 /**
-b master501eec92009-07-06 13:53:11 -07002345 * @hide
2346 */
2347 public static final String[] SETTINGS_TO_BACKUP = {
Amith Yamasani8823c0a82009-07-07 14:30:17 -07002348 ADB_ENABLED,
2349 ALLOW_MOCK_LOCATION,
-b master501eec92009-07-06 13:53:11 -07002350 INSTALL_NON_MARKET_APPS,
2351 PARENTAL_CONTROL_ENABLED,
2352 PARENTAL_CONTROL_REDIRECT_URL,
2353 USB_MASS_STORAGE_ENABLED,
2354 ACCESSIBILITY_ENABLED,
2355 ENABLED_ACCESSIBILITY_SERVICES,
2356 TTS_USE_DEFAULTS,
2357 TTS_DEFAULT_RATE,
2358 TTS_DEFAULT_PITCH,
2359 TTS_DEFAULT_SYNTH,
2360 TTS_DEFAULT_LANG,
2361 TTS_DEFAULT_COUNTRY,
2362 WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
2363 WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,
2364 WIFI_NUM_ALLOWED_CHANNELS,
2365 WIFI_NUM_OPEN_NETWORKS_KEPT,
2366 BACKGROUND_DATA,
2367 PREFERRED_NETWORK_MODE,
2368 PREFERRED_TTY_MODE,
2369 CDMA_CELL_BROADCAST_SMS,
2370 PREFERRED_CDMA_SUBSCRIPTION,
2371 ENHANCED_VOICE_PRIVACY_ENABLED
2372 };
2373
2374 /**
Mike Lockwoodbd2a7122009-04-02 23:41:33 -07002375 * Helper method for determining if a location provider is enabled.
2376 * @param cr the content resolver to use
2377 * @param provider the location provider to query
2378 * @return true if the provider is enabled
2379 *
2380 * @hide
2381 */
2382 public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
2383 String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED);
2384 if (allowedProviders != null) {
2385 return (allowedProviders.equals(provider) ||
2386 allowedProviders.contains("," + provider + ",") ||
2387 allowedProviders.startsWith(provider + ",") ||
2388 allowedProviders.endsWith("," + provider));
2389 }
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002390 return false;
Mike Lockwoodbd2a7122009-04-02 23:41:33 -07002391 }
2392
2393 /**
2394 * Thread-safe method for enabling or disabling a single location provider.
2395 * @param cr the content resolver to use
2396 * @param provider the location provider to enable or disable
2397 * @param enabled true if the provider should be enabled
2398 *
2399 * @hide
2400 */
2401 public static final void setLocationProviderEnabled(ContentResolver cr,
2402 String provider, boolean enabled) {
2403 // to ensure thread safety, we write the provider name with a '+' or '-'
2404 // and let the SettingsProvider handle it rather than reading and modifying
2405 // the list of enabled providers.
2406 if (enabled) {
2407 provider = "+" + provider;
2408 } else {
2409 provider = "-" + provider;
2410 }
2411 putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider);
2412 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002413 }
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002414
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002415 /**
2416 * Gservices settings, containing the network names for Google's
2417 * various services. This table holds simple name/addr pairs.
2418 * Addresses can be accessed through the getString() method.
2419 *
2420 * TODO: This should move to partner/google/... somewhere.
2421 *
2422 * @hide
2423 */
2424 public static final class Gservices extends NameValueTable {
2425 public static final String SYS_PROP_SETTING_VERSION = "sys.settings_gservices_version";
2426
2427 /**
2428 * Intent action broadcast when the Gservices table is updated by the server.
2429 * This is broadcast once after settings change (so many values may have been updated).
2430 */
2431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2432 public static final String CHANGED_ACTION =
2433 "com.google.gservices.intent.action.GSERVICES_CHANGED";
2434
Dan Egnorabc25e32009-05-13 19:22:08 -07002435 /**
2436 * Intent action to override Gservices for testing. (Requires WRITE_GSERVICES permission.)
2437 */
2438 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2439 public static final String OVERRIDE_ACTION =
2440 "com.google.gservices.intent.action.GSERVICES_OVERRIDE";
2441
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002442 private static volatile NameValueCache mNameValueCache = null;
2443 private static final Object mNameValueCacheLock = new Object();
2444
2445 /**
2446 * Look up a name in the database.
2447 * @param resolver to access the database with
2448 * @param name to look up in the table
2449 * @return the corresponding value, or null if not present
2450 */
2451 public static String getString(ContentResolver resolver, String name) {
2452 synchronized (mNameValueCacheLock) {
2453 if (mNameValueCache == null) {
2454 mNameValueCache = new NameValueCache(SYS_PROP_SETTING_VERSION, CONTENT_URI);
2455 }
2456 return mNameValueCache.getString(resolver, name);
2457 }
2458 }
2459
2460 /**
2461 * Store a name/value pair into the database.
2462 * @param resolver to access the database with
2463 * @param name to store
2464 * @param value to associate with the name
2465 * @return true if the value was set, false on database errors
2466 */
2467 public static boolean putString(ContentResolver resolver,
2468 String name, String value) {
2469 return putString(resolver, CONTENT_URI, name, value);
2470 }
2471
2472 /**
2473 * Look up the value for name in the database, convert it to an int using Integer.parseInt
2474 * and return it. If it is null or if a NumberFormatException is caught during the
2475 * conversion then return defValue.
2476 */
2477 public static int getInt(ContentResolver resolver, String name, int defValue) {
2478 String valString = getString(resolver, name);
2479 int value;
2480 try {
2481 value = valString != null ? Integer.parseInt(valString) : defValue;
2482 } catch (NumberFormatException e) {
2483 value = defValue;
2484 }
2485 return value;
2486 }
2487
2488 /**
2489 * Look up the value for name in the database, convert it to a long using Long.parseLong
2490 * and return it. If it is null or if a NumberFormatException is caught during the
2491 * conversion then return defValue.
2492 */
2493 public static long getLong(ContentResolver resolver, String name, long defValue) {
2494 String valString = getString(resolver, name);
2495 long value;
2496 try {
2497 value = valString != null ? Long.parseLong(valString) : defValue;
2498 } catch (NumberFormatException e) {
2499 value = defValue;
2500 }
2501 return value;
2502 }
2503
2504 /**
2505 * Construct the content URI for a particular name/value pair,
2506 * useful for monitoring changes with a ContentObserver.
2507 * @param name to look up in the table
2508 * @return the corresponding content URI, or null if not present
2509 */
2510 public static Uri getUriFor(String name) {
2511 return getUriFor(CONTENT_URI, name);
2512 }
2513
2514 /**
2515 * The content:// style URL for this table
2516 */
2517 public static final Uri CONTENT_URI =
2518 Uri.parse("content://" + AUTHORITY + "/gservices");
2519
2520 /**
2521 * MMS - URL to use for HTTP "x-wap-profile" header
2522 */
2523 public static final String MMS_X_WAP_PROFILE_URL
2524 = "mms_x_wap_profile_url";
2525
2526 /**
2527 * YouTube - the flag to indicate whether to use proxy
2528 */
2529 public static final String YOUTUBE_USE_PROXY
2530 = "youtube_use_proxy";
2531
2532 /**
2533 * MMS - maximum message size in bytes for a MMS message.
2534 */
2535 public static final String MMS_MAXIMUM_MESSAGE_SIZE
2536 = "mms_maximum_message_size";
2537
2538 /**
2539 * Event tags from the kernel event log to upload during checkin.
2540 */
2541 public static final String CHECKIN_EVENTS = "checkin_events";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07002542
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002543 /**
Dianne Hackborn9fdbf6a2009-07-19 14:18:51 -07002544 * Comma-separated list of service names to dump and upload during checkin.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002545 */
2546 public static final String CHECKIN_DUMPSYS_LIST = "checkin_dumpsys_list";
2547
2548 /**
Dianne Hackborn9fdbf6a2009-07-19 14:18:51 -07002549 * Comma-separated list of packages to specify for each service that is
2550 * dumped (currently only meaningful for user activity).
2551 */
2552 public static final String CHECKIN_PACKAGE_LIST = "checkin_package_list";
2553
2554 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002555 * The interval (in seconds) between periodic checkin attempts.
2556 */
2557 public static final String CHECKIN_INTERVAL = "checkin_interval";
2558
2559 /**
2560 * Boolean indicating if the market app should force market only checkins on
2561 * install/uninstall. Any non-0 value is considered true.
2562 */
2563 public static final String MARKET_FORCE_CHECKIN = "market_force_checkin";
2564
2565 /**
2566 * How frequently (in seconds) to check the memory status of the
2567 * device.
2568 */
2569 public static final String MEMCHECK_INTERVAL = "memcheck_interval";
2570
2571 /**
2572 * Max frequency (in seconds) to log memory check stats, in realtime
2573 * seconds. This allows for throttling of logs when the device is
2574 * running for large amounts of time.
2575 */
2576 public static final String MEMCHECK_LOG_REALTIME_INTERVAL =
2577 "memcheck_log_realtime_interval";
2578
2579 /**
2580 * Boolean indicating whether rebooting due to system memory checks
2581 * is enabled.
2582 */
2583 public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled";
2584
2585 /**
2586 * How many bytes the system process must be below to avoid scheduling
2587 * a soft reboot. This reboot will happen when it is next determined
2588 * to be a good time.
2589 */
2590 public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft";
2591
2592 /**
2593 * How many bytes the system process must be below to avoid scheduling
2594 * a hard reboot. This reboot will happen immediately.
2595 */
2596 public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard";
2597
2598 /**
2599 * How many bytes the phone process must be below to avoid scheduling
2600 * a soft restart. This restart will happen when it is next determined
2601 * to be a good time.
2602 */
2603 public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft";
2604
2605 /**
2606 * How many bytes the phone process must be below to avoid scheduling
2607 * a hard restart. This restart will happen immediately.
2608 */
2609 public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard";
2610
2611 /**
2612 * Boolean indicating whether restarting the phone process due to
2613 * memory checks is enabled.
2614 */
2615 public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled";
2616
2617 /**
2618 * First time during the day it is okay to kill processes
2619 * or reboot the device due to low memory situations. This number is
2620 * in seconds since midnight.
2621 */
2622 public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time";
2623
2624 /**
2625 * Last time during the day it is okay to kill processes
2626 * or reboot the device due to low memory situations. This number is
2627 * in seconds since midnight.
2628 */
2629 public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time";
2630
2631 /**
2632 * How long the screen must have been off in order to kill processes
2633 * or reboot. This number is in seconds. A value of -1 means to
2634 * entirely disregard whether the screen is on.
2635 */
2636 public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off";
2637
2638 /**
2639 * How much time there must be until the next alarm in order to kill processes
2640 * or reboot. This number is in seconds. Note: this value must be
2641 * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will
2642 * always see an alarm scheduled within its time.
2643 */
2644 public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm";
2645
2646 /**
2647 * How frequently to check whether it is a good time to restart things,
2648 * if the device is in a bad state. This number is in seconds. Note:
2649 * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else
2650 * the alarm to schedule the recheck will always appear within the
2651 * minimum "do not execute now" time.
2652 */
2653 public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval";
2654
2655 /**
2656 * How frequently (in DAYS) to reboot the device. If 0, no reboots
2657 * will occur.
2658 */
2659 public static final String REBOOT_INTERVAL = "reboot_interval";
2660
2661 /**
2662 * First time during the day it is okay to force a reboot of the
2663 * device (if REBOOT_INTERVAL is set). This number is
2664 * in seconds since midnight.
2665 */
2666 public static final String REBOOT_START_TIME = "reboot_start_time";
2667
2668 /**
2669 * The window of time (in seconds) after each REBOOT_INTERVAL in which
2670 * a reboot can be executed. If 0, a reboot will always be executed at
2671 * exactly the given time. Otherwise, it will only be executed if
2672 * the device is idle within the window.
2673 */
2674 public static final String REBOOT_WINDOW = "reboot_window";
2675
2676 /**
2677 * The minimum version of the server that is required in order for the device to accept
2678 * the server's recommendations about the initial sync settings to use. When this is unset,
2679 * blank or can't be interpreted as an integer then we will not ask the server for a
2680 * recommendation.
2681 */
2682 public static final String GMAIL_CONFIG_INFO_MIN_SERVER_VERSION =
2683 "gmail_config_info_min_server_version";
2684
2685 /**
2686 * Controls whether Gmail offers a preview button for images.
2687 */
2688 public static final String GMAIL_DISALLOW_IMAGE_PREVIEWS = "gmail_disallow_image_previews";
2689
2690 /**
Cedric Beustafb6c8e2009-03-24 22:35:42 -07002691 * The maximal size in bytes allowed for attachments when composing messages in Gmail
2692 */
2693 public static final String GMAIL_MAX_ATTACHMENT_SIZE = "gmail_max_attachment_size_bytes";
2694
2695 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002696 * The timeout in milliseconds that Gmail uses when opening a connection and reading
2697 * from it. A missing value or a value of -1 instructs Gmail to use the defaults provided
2698 * by GoogleHttpClient.
2699 */
2700 public static final String GMAIL_TIMEOUT_MS = "gmail_timeout_ms";
2701
2702 /**
2703 * Controls whether Gmail will request an expedited sync when a message is sent. Value must
2704 * be an integer where non-zero means true. Defaults to 1.
2705 */
2706 public static final String GMAIL_SEND_IMMEDIATELY = "gmail_send_immediately";
2707
2708 /**
2709 * Controls whether gmail buffers server responses. Possible values are "memory", for a
2710 * memory-based buffer, or "file", for a temp-file-based buffer. All other values
2711 * (including not set) disable buffering.
2712 */
2713 public static final String GMAIL_BUFFER_SERVER_RESPONSE = "gmail_buffer_server_response";
2714
2715 /**
Cynthia Wong85427f712009-06-10 14:42:42 -07002716 * The maximum size in bytes allowed for the provider to gzip a protocol buffer uploaded to
2717 * the server.
2718 */
2719 public static final String GMAIL_MAX_GZIP_SIZE = "gmail_max_gzip_size_bytes";
2720
2721 /**
Cynthia Wong44e4aaf2009-04-08 13:32:09 -07002722 * Controls whether Gmail will discard uphill operations that repeatedly fail. Value must be
2723 * an integer where non-zero means true. Defaults to 1.
2724 */
2725 public static final String GMAIL_DISCARD_ERROR_UPHILL_OP = "gmail_discard_error_uphill_op";
2726
2727 /**
Cynthia Wong04f0b052009-07-07 11:14:21 -07002728 * Controls how many attempts Gmail will try to upload an uphill operations before it
2729 * abandons the operation. Defaults to 20.
2730 */
Cynthia Wong0d54b022009-08-10 16:39:36 -07002731 public static final String GMAIL_NUM_RETRY_UPHILL_OP = "gmail_num_retry_uphill_op";
2732
2733 /**
2734 * How much time in seconds Gmail will try to upload an uphill operations before it
2735 * abandons the operation. Defaults to 36400 (one day).
2736 */
2737 public static final String GMAIL_WAIT_TIME_RETRY_UPHILL_OP =
2738 "gmail_wait_time_retry_uphill_op";
Cynthia Wong04f0b052009-07-07 11:14:21 -07002739
2740 /**
Cynthia Wong278a8022009-07-10 13:27:03 -07002741 * Controls if the protocol buffer version of the protocol will use a multipart request for
2742 * attachment uploads. Value must be an integer where non-zero means true. Defaults to 0.
2743 */
2744 public static final String GMAIL_USE_MULTIPART_PROTOBUF = "gmail_use_multipart_protobuf";
2745
2746 /**
Wei Huangceca25f2009-06-19 13:08:39 -07002747 * the transcoder URL for mobile devices.
2748 */
2749 public static final String TRANSCODER_URL = "mobile_transcoder_url";
2750
2751 /**
2752 * URL that points to the privacy terms of the Google Talk service.
2753 */
Tom Taylor2c0a01a2009-06-22 15:17:59 -07002754 public static final String GTALK_TERMS_OF_SERVICE_URL = "gtalk_terms_of_service_url";
Wei Huangceca25f2009-06-19 13:08:39 -07002755
2756 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002757 * Hostname of the GTalk server.
2758 */
2759 public static final String GTALK_SERVICE_HOSTNAME = "gtalk_hostname";
2760
2761 /**
2762 * Secure port of the GTalk server.
2763 */
2764 public static final String GTALK_SERVICE_SECURE_PORT = "gtalk_secure_port";
2765
2766 /**
2767 * The server configurable RMQ acking interval
2768 */
2769 public static final String GTALK_SERVICE_RMQ_ACK_INTERVAL = "gtalk_rmq_ack_interval";
2770
2771 /**
2772 * The minimum reconnect delay for short network outages or when the network is suspended
2773 * due to phone use.
2774 */
2775 public static final String GTALK_SERVICE_MIN_RECONNECT_DELAY_SHORT =
2776 "gtalk_min_reconnect_delay_short";
2777
2778 /**
2779 * The reconnect variant range for short network outages or when the network is suspended
2780 * due to phone use. A random number between 0 and this constant is computed and
2781 * added to {@link #GTALK_SERVICE_MIN_RECONNECT_DELAY_SHORT} to form the initial reconnect
2782 * delay.
2783 */
2784 public static final String GTALK_SERVICE_RECONNECT_VARIANT_SHORT =
2785 "gtalk_reconnect_variant_short";
2786
2787 /**
2788 * The minimum reconnect delay for long network outages
2789 */
2790 public static final String GTALK_SERVICE_MIN_RECONNECT_DELAY_LONG =
2791 "gtalk_min_reconnect_delay_long";
2792
2793 /**
2794 * The reconnect variant range for long network outages. A random number between 0 and this
2795 * constant is computed and added to {@link #GTALK_SERVICE_MIN_RECONNECT_DELAY_LONG} to
2796 * form the initial reconnect delay.
2797 */
2798 public static final String GTALK_SERVICE_RECONNECT_VARIANT_LONG =
2799 "gtalk_reconnect_variant_long";
2800
2801 /**
2802 * The maximum reconnect delay time, in milliseconds.
2803 */
2804 public static final String GTALK_SERVICE_MAX_RECONNECT_DELAY =
2805 "gtalk_max_reconnect_delay";
2806
2807 /**
2808 * The network downtime that is considered "short" for the above calculations,
2809 * in milliseconds.
2810 */
2811 public static final String GTALK_SERVICE_SHORT_NETWORK_DOWNTIME =
2812 "gtalk_short_network_downtime";
2813
2814 /**
2815 * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2816 * will reset the heartbeat timer. The away heartbeat should be used when the user is
2817 * logged into the GTalk app, but not actively using it.
2818 */
2819 public static final String GTALK_SERVICE_AWAY_HEARTBEAT_INTERVAL_MS =
2820 "gtalk_heartbeat_ping_interval_ms"; // keep the string backward compatible
2821
2822 /**
2823 * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2824 * will reset the heartbeat timer. The active heartbeat should be used when the user is
2825 * actively using the GTalk app.
2826 */
2827 public static final String GTALK_SERVICE_ACTIVE_HEARTBEAT_INTERVAL_MS =
2828 "gtalk_active_heartbeat_ping_interval_ms";
2829
2830 /**
2831 * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2832 * will reset the heartbeat timer. The sync heartbeat should be used when the user isn't
2833 * logged into the GTalk app, but auto-sync is enabled.
2834 */
2835 public static final String GTALK_SERVICE_SYNC_HEARTBEAT_INTERVAL_MS =
2836 "gtalk_sync_heartbeat_ping_interval_ms";
2837
2838 /**
2839 * How frequently we send heartbeat pings to the GTalk server. Receiving a server packet
2840 * will reset the heartbeat timer. The no sync heartbeat should be used when the user isn't
2841 * logged into the GTalk app, and auto-sync is not enabled.
2842 */
2843 public static final String GTALK_SERVICE_NOSYNC_HEARTBEAT_INTERVAL_MS =
2844 "gtalk_nosync_heartbeat_ping_interval_ms";
2845
2846 /**
Tom Taylor2debd562009-07-14 11:27:20 -07002847 * The maximum heartbeat interval used while on the WIFI network.
Wei Huange87b2f02009-06-02 15:16:04 -07002848 */
2849 public static final String GTALK_SERVICE_WIFI_MAX_HEARTBEAT_INTERVAL_MS =
2850 "gtalk_wifi_max_heartbeat_ping_interval_ms";
2851
2852 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002853 * How long we wait to receive a heartbeat ping acknowledgement (or another packet)
2854 * from the GTalk server, before deeming the connection dead.
2855 */
2856 public static final String GTALK_SERVICE_HEARTBEAT_ACK_TIMEOUT_MS =
2857 "gtalk_heartbeat_ack_timeout_ms";
2858
2859 /**
2860 * How long after screen is turned off before we consider the user to be idle.
2861 */
2862 public static final String GTALK_SERVICE_IDLE_TIMEOUT_MS =
2863 "gtalk_idle_timeout_ms";
2864
2865 /**
2866 * By default, GTalkService will always connect to the server regardless of the auto-sync
2867 * setting. However, if this parameter is true, then GTalkService will only connect
2868 * if auto-sync is enabled. Using the GTalk app will trigger the connection too.
2869 */
2870 public static final String GTALK_SERVICE_CONNECT_ON_AUTO_SYNC =
2871 "gtalk_connect_on_auto_sync";
2872
2873 /**
2874 * GTalkService holds a wakelock while broadcasting the intent for data message received.
2875 * It then automatically release the wakelock after a timeout. This setting controls what
2876 * the timeout should be.
2877 */
2878 public static final String GTALK_DATA_MESSAGE_WAKELOCK_MS =
2879 "gtalk_data_message_wakelock_ms";
2880
2881 /**
2882 * The socket read timeout used to control how long ssl handshake wait for reads before
2883 * timing out. This is needed so the ssl handshake doesn't hang for a long time in some
2884 * circumstances.
2885 */
2886 public static final String GTALK_SSL_HANDSHAKE_TIMEOUT_MS =
2887 "gtalk_ssl_handshake_timeout_ms";
2888
2889 /**
Costin Manolachef967afd2009-04-17 17:37:29 -07002890 * Compress the gtalk stream.
2891 */
2892 public static final String GTALK_COMPRESS = "gtalk_compress";
2893
2894 /**
Wei Huang58eef7e2009-05-22 13:30:03 -07002895 * This is the timeout for which Google Talk will send the message using bareJID. In a
2896 * established chat between two XMPP endpoints, Google Talk uses fullJID in the format
2897 * of user@domain/resource in order to send the message to the specific client. However,
2898 * if Google Talk hasn't received a message from that client after some time, it would
2899 * fall back to use the bareJID, which would broadcast the message to all clients for
2900 * the other user.
2901 */
2902 public static final String GTALK_USE_BARE_JID_TIMEOUT_MS = "gtalk_use_barejid_timeout_ms";
2903
2904 /**
Ye Wen44c6e3e2009-06-19 12:48:16 -07002905 * This is the threshold of retry number when there is an authentication expired failure
2906 * for Google Talk. In some situation, e.g. when a Google Apps account is disabled chat
2907 * service, the connection keeps failing. This threshold controls when we should stop
2908 * the retrying.
2909 */
2910 public static final String GTALK_MAX_RETRIES_FOR_AUTH_EXPIRED =
2911 "gtalk_max_retries_for_auth_expired";
2912
2913 /**
Wei Huang1c5e4032009-07-09 10:39:12 -07002914 * This is the url for getting the app token for server-to-device push messaging.
Wei Huang8ad22462009-06-24 18:32:45 -07002915 */
Wei Huang1c5e4032009-07-09 10:39:12 -07002916 public static final String PUSH_MESSAGING_REGISTRATION_URL =
2917 "push_messaging_registration_url";
Tom Taylor2debd562009-07-14 11:27:20 -07002918
2919 /**
2920 * This is gdata url to lookup album and picture info from picasa web.
2921 */
2922 public static final String GTALK_PICASA_ALBUM_URL =
2923 "gtalk_picasa_album_url";
2924
2925 /**
2926 * This is the url to lookup picture info from flickr.
2927 */
2928 public static final String GTALK_FLICKR_PHOTO_INFO_URL =
2929 "gtalk_flickr_photo_info_url";
2930
2931 /**
2932 * This is the url to lookup an actual picture from flickr.
2933 */
2934 public static final String GTALK_FLICKR_PHOTO_URL =
2935 "gtalk_flickr_photo_url";
2936
2937 /**
2938 * This is the gdata url to lookup info on a youtube video.
2939 */
2940 public static final String GTALK_YOUTUBE_VIDEO_URL =
2941 "gtalk_youtube_video_url";
2942
2943
2944 /**
2945 * This is the url for getting the app token for server-to-device data messaging.
2946 */
2947 public static final String DATA_MESSAGE_GET_APP_TOKEN_URL =
2948 "data_messaging_get_app_token_url";
2949
Wei Huang8ad22462009-06-24 18:32:45 -07002950 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002951 * Enable use of ssl session caching.
2952 * 'db' - save each session in a (per process) database
2953 * 'file' - save each session in a (per process) file
2954 * not set or any other value - normal java in-memory caching
2955 */
2956 public static final String SSL_SESSION_CACHE = "ssl_session_cache";
2957
2958 /**
2959 * How many bytes long a message has to be, in order to be gzipped.
2960 */
2961 public static final String SYNC_MIN_GZIP_BYTES =
2962 "sync_min_gzip_bytes";
2963
2964 /**
2965 * The hash value of the current provisioning settings
2966 */
2967 public static final String PROVISIONING_DIGEST = "digest";
2968
2969 /**
2970 * Provisioning keys to block from server update
2971 */
2972 public static final String PROVISIONING_OVERRIDE = "override";
2973
2974 /**
2975 * "Generic" service name for authentication requests.
2976 */
2977 public static final String GOOGLE_LOGIN_GENERIC_AUTH_SERVICE
2978 = "google_login_generic_auth_service";
2979
2980 /**
2981 * Frequency in milliseconds at which we should sync the locally installed Vending Machine
2982 * content with the server.
2983 */
2984 public static final String VENDING_SYNC_FREQUENCY_MS = "vending_sync_frequency_ms";
2985
2986 /**
2987 * Support URL that is opened in a browser when user clicks on 'Help and Info' in Vending
2988 * Machine.
2989 */
2990 public static final String VENDING_SUPPORT_URL = "vending_support_url";
2991
2992 /**
2993 * Indicates if Vending Machine requires a SIM to be in the phone to allow a purchase.
2994 *
2995 * true = SIM is required
2996 * false = SIM is not required
2997 */
2998 public static final String VENDING_REQUIRE_SIM_FOR_PURCHASE =
2999 "vending_require_sim_for_purchase";
3000
3001 /**
Christian Sonntag058779c2009-08-07 10:50:06 -07003002 * Indicates the Vending Machine backup state. It is set if the
3003 * Vending application has been backed up at least once.
3004 */
3005 public static final String VENDING_BACKUP_STATE = "vending_backup_state";
3006
3007 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003008 * The current version id of the Vending Machine terms of service.
3009 */
3010 public static final String VENDING_TOS_VERSION = "vending_tos_version";
3011
3012 /**
3013 * URL that points to the terms of service for Vending Machine.
3014 */
3015 public static final String VENDING_TOS_URL = "vending_tos_url";
3016
3017 /**
lknguyenf965d162009-07-22 18:12:56 -07003018 * URL to navigate to in browser (not Market) when the terms of service
3019 * for Vending Machine could not be accessed due to bad network
3020 * connection.
3021 */
3022 public static final String VENDING_TOS_MISSING_URL = "vending_tos_missing_url";
3023
3024 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003025 * Whether to use sierraqa instead of sierra tokens for the purchase flow in
3026 * Vending Machine.
3027 *
3028 * true = use sierraqa
3029 * false = use sierra (default)
3030 */
3031 public static final String VENDING_USE_CHECKOUT_QA_SERVICE =
3032 "vending_use_checkout_qa_service";
3033
3034 /**
Mark Womack78ef4562009-03-25 16:10:13 -07003035 * Default value to use for all/free/priced filter in Market.
3036 * Valid values: ALL, FREE, PAID (case insensitive)
3037 */
3038 public static final String VENDING_DEFAULT_FILTER = "vending_default_filter";
3039 /**
3040 * Ranking type value to use for the first category tab (currently popular)
3041 */
3042 public static final String VENDING_TAB_1_RANKING_TYPE = "vending_tab_1_ranking_type";
3043
3044 /**
3045 * Title string to use for first category tab.
3046 */
3047 public static final String VENDING_TAB_1_TITLE = "vending_tab_1_title";
3048
3049 /**
3050 * Ranking type value to use for the second category tab (currently newest)
3051 */
3052 public static final String VENDING_TAB_2_RANKING_TYPE = "vending_tab_2_ranking_type";
3053
3054 /**
3055 * Title string to use for second category tab.
3056 */
3057 public static final String VENDING_TAB_2_TITLE = "vending_tab_2_title";
3058
3059 /**
Linda Nguyenabd7eba2009-06-18 18:52:59 -07003060 * Frequency in milliseconds at which we should request MCS heartbeats
3061 * from the Vending Machine client.
3062 */
3063 public static final String VENDING_HEARTBEAT_FREQUENCY_MS =
3064 "vending_heartbeat_frequency_ms";
3065
3066 /**
lknguyenb0cba432009-06-29 20:50:25 -07003067 * Frequency in milliseconds at which we should resend pending download
3068 * requests to the API Server from the Vending Machine client.
3069 */
3070 public static final String VENDING_PENDING_DOWNLOAD_RESEND_FREQUENCY_MS =
lknguyen09b33732009-06-30 13:52:45 -07003071 "vending_pd_resend_frequency_ms";
lknguyenb0cba432009-06-29 20:50:25 -07003072
3073 /**
Sanjay Jeyakumar21bf2412009-07-09 13:31:48 -07003074 * Frequency in milliseconds at which we should cycle through the promoted applications
3075 * on the home screen or the categories page.
3076 */
3077 public static final String VENDING_PROMO_REFRESH_FREQUENCY_MS =
3078 "vending_promo_refresh_freq_ms";
3079
3080 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003081 * URL that points to the legal terms of service to display in Settings.
3082 * <p>
3083 * This should be a https URL. For a pretty user-friendly URL, use
3084 * {@link #SETTINGS_TOS_PRETTY_URL}.
3085 */
3086 public static final String SETTINGS_TOS_URL = "settings_tos_url";
3087
3088 /**
3089 * URL that points to the legal terms of service to display in Settings.
3090 * <p>
3091 * This should be a pretty http URL. For the URL the device will access
3092 * via Settings, use {@link #SETTINGS_TOS_URL}.
3093 */
3094 public static final String SETTINGS_TOS_PRETTY_URL = "settings_tos_pretty_url";
3095
3096 /**
3097 * URL that points to the contributors to display in Settings.
3098 * <p>
3099 * This should be a https URL. For a pretty user-friendly URL, use
3100 * {@link #SETTINGS_CONTRIBUTORS_PRETTY_URL}.
3101 */
3102 public static final String SETTINGS_CONTRIBUTORS_URL = "settings_contributors_url";
3103
3104 /**
3105 * URL that points to the contributors to display in Settings.
3106 * <p>
3107 * This should be a pretty http URL. For the URL the device will access
3108 * via Settings, use {@link #SETTINGS_CONTRIBUTORS_URL}.
3109 */
3110 public static final String SETTINGS_CONTRIBUTORS_PRETTY_URL =
3111 "settings_contributors_pretty_url";
3112
3113 /**
3114 * URL that points to the Terms Of Service for the device.
3115 * <p>
3116 * This should be a pretty http URL.
3117 */
3118 public static final String SETUP_GOOGLE_TOS_URL = "setup_google_tos_url";
3119
3120 /**
3121 * URL that points to the Android privacy policy for the device.
3122 * <p>
3123 * This should be a pretty http URL.
3124 */
3125 public static final String SETUP_ANDROID_PRIVACY_URL = "setup_android_privacy_url";
3126
3127 /**
3128 * URL that points to the Google privacy policy for the device.
3129 * <p>
3130 * This should be a pretty http URL.
3131 */
3132 public static final String SETUP_GOOGLE_PRIVACY_URL = "setup_google_privacy_url";
3133
3134 /**
3135 * Request an MSISDN token for various Google services.
3136 */
3137 public static final String USE_MSISDN_TOKEN = "use_msisdn_token";
3138
3139 /**
3140 * RSA public key used to encrypt passwords stored in the database.
3141 */
3142 public static final String GLS_PUBLIC_KEY = "google_login_public_key";
3143
3144 /**
3145 * Only check parental control status if this is set to "true".
3146 */
3147 public static final String PARENTAL_CONTROL_CHECK_ENABLED =
3148 "parental_control_check_enabled";
3149
3150 /**
3151 * The list of applications we need to block if parental control is
3152 * enabled.
3153 */
3154 public static final String PARENTAL_CONTROL_APPS_LIST =
3155 "parental_control_apps_list";
3156
3157 /**
3158 * Duration in which parental control status is valid.
3159 */
3160 public static final String PARENTAL_CONTROL_TIMEOUT_IN_MS =
3161 "parental_control_timeout_in_ms";
3162
3163 /**
3164 * When parental control is off, we expect to get this string from the
3165 * litmus url.
3166 */
3167 public static final String PARENTAL_CONTROL_EXPECTED_RESPONSE =
3168 "parental_control_expected_response";
3169
3170 /**
3171 * When the litmus url returns a 302, declare parental control to be on
3172 * only if the redirect url matches this regular expression.
3173 */
3174 public static final String PARENTAL_CONTROL_REDIRECT_REGEX =
3175 "parental_control_redirect_regex";
3176
3177 /**
3178 * Threshold for the amount of change in disk free space required to report the amount of
3179 * free space. Used to prevent spamming the logs when the disk free space isn't changing
3180 * frequently.
3181 */
3182 public static final String DISK_FREE_CHANGE_REPORTING_THRESHOLD =
3183 "disk_free_change_reporting_threshold";
3184
3185 /**
3186 * Prefix for new Google services published by the checkin
3187 * server.
3188 */
3189 public static final String GOOGLE_SERVICES_PREFIX
3190 = "google_services:";
3191
3192 /**
3193 * The maximum reconnect delay for short network outages or when the network is suspended
3194 * due to phone use.
3195 */
3196 public static final String SYNC_MAX_RETRY_DELAY_IN_SECONDS =
3197 "sync_max_retry_delay_in_seconds";
3198
3199 /**
3200 * Minimum percentage of free storage on the device that is used to determine if
3201 * the device is running low on storage.
3202 * Say this value is set to 10, the device is considered running low on storage
3203 * if 90% or more of the device storage is filled up.
3204 */
3205 public static final String SYS_STORAGE_THRESHOLD_PERCENTAGE =
3206 "sys_storage_threshold_percentage";
3207
3208 /**
3209 * The interval in minutes after which the amount of free storage left on the
3210 * device is logged to the event log
3211 */
3212 public static final String SYS_FREE_STORAGE_LOG_INTERVAL =
3213 "sys_free_storage_log_interval";
3214
3215 /**
3216 * The interval in milliseconds at which to check the number of SMS sent
3217 * out without asking for use permit, to limit the un-authorized SMS
3218 * usage.
3219 */
jsh867641e2009-05-27 17:32:50 -07003220 public static final String SMS_OUTGOING_CHECK_INTERVAL_MS =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003221 "sms_outgoing_check_interval_ms";
3222
3223 /**
3224 * The number of outgoing SMS sent without asking for user permit
jsh867641e2009-05-27 17:32:50 -07003225 * (of {@link #SMS_OUTGOING_CHECK_INTERVAL_MS}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003226 */
3227 public static final String SMS_OUTGOING_CEHCK_MAX_COUNT =
3228 "sms_outgoing_check_max_count";
3229
3230 /**
3231 * The interval in milliseconds at which to check packet counts on the
3232 * mobile data interface when screen is on, to detect possible data
3233 * connection problems.
3234 */
3235 public static final String PDP_WATCHDOG_POLL_INTERVAL_MS =
3236 "pdp_watchdog_poll_interval_ms";
3237
3238 /**
3239 * The interval in milliseconds at which to check packet counts on the
3240 * mobile data interface when screen is off, to detect possible data
3241 * connection problems.
3242 */
3243 public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS =
3244 "pdp_watchdog_long_poll_interval_ms";
3245
3246 /**
3247 * The interval in milliseconds at which to check packet counts on the
3248 * mobile data interface after {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
3249 * outgoing packets has been reached without incoming packets.
3250 */
3251 public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS =
3252 "pdp_watchdog_error_poll_interval_ms";
3253
3254 /**
3255 * The number of outgoing packets sent without seeing an incoming packet
3256 * that triggers a countdown (of {@link #PDP_WATCHDOG_ERROR_POLL_COUNT}
3257 * device is logged to the event log
3258 */
3259 public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT =
3260 "pdp_watchdog_trigger_packet_count";
3261
3262 /**
3263 * The number of polls to perform (at {@link #PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS})
3264 * after hitting {@link #PDP_WATCHDOG_TRIGGER_PACKET_COUNT} before
3265 * attempting data connection recovery.
3266 */
3267 public static final String PDP_WATCHDOG_ERROR_POLL_COUNT =
3268 "pdp_watchdog_error_poll_count";
3269
3270 /**
3271 * The number of failed PDP reset attempts before moving to something more
3272 * drastic: re-registering to the network.
3273 */
3274 public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT =
3275 "pdp_watchdog_max_pdp_reset_fail_count";
3276
3277 /**
3278 * Address to ping as a last sanity check before attempting any recovery.
3279 * Unset or set to "0.0.0.0" to skip this check.
3280 */
3281 public static final String PDP_WATCHDOG_PING_ADDRESS = "pdp_watchdog_ping_address";
3282
3283 /**
3284 * The "-w deadline" parameter for the ping, ie, the max time in
3285 * seconds to spend pinging.
3286 */
3287 public static final String PDP_WATCHDOG_PING_DEADLINE = "pdp_watchdog_ping_deadline";
3288
3289 /**
3290 * The interval in milliseconds at which to check gprs registration
3291 * after the first registration mismatch of gprs and voice service,
3292 * to detect possible data network registration problems.
3293 *
3294 */
3295 public static final String GPRS_REGISTER_CHECK_PERIOD_MS =
3296 "gprs_register_check_period_ms";
3297
3298 /**
3299 * The interval in milliseconds after which Wi-Fi is considered idle.
3300 * When idle, it is possible for the device to be switched from Wi-Fi to
3301 * the mobile data network.
3302 */
3303 public static final String WIFI_IDLE_MS = "wifi_idle_ms";
3304
3305 /**
3306 * Screen timeout in milliseconds corresponding to the
3307 * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest
3308 * possible screen timeout behavior.)
3309 */
3310 public static final String SHORT_KEYLIGHT_DELAY_MS =
3311 "short_keylight_delay_ms";
3312
3313 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003314 * List of test suites (local disk filename) for the automatic instrumentation test runner.
3315 * The file format is similar to automated_suites.xml, see AutoTesterService.
3316 * If this setting is missing or empty, the automatic test runner will not start.
3317 */
3318 public static final String AUTOTEST_SUITES_FILE = "autotest_suites_file";
3319
3320 /**
3321 * Interval between synchronous checkins forced by the automatic test runner.
3322 * If you set this to a value smaller than CHECKIN_INTERVAL, then the test runner's
3323 * frequent checkins will prevent asynchronous background checkins from interfering
3324 * with any performance measurements.
3325 */
3326 public static final String AUTOTEST_CHECKIN_SECONDS = "autotest_checkin_seconds";
3327
3328 /**
3329 * Interval between reboots forced by the automatic test runner.
3330 */
3331 public static final String AUTOTEST_REBOOT_SECONDS = "autotest_reboot_seconds";
3332
3333
3334 /**
3335 * Threshold values for the duration and level of a discharge cycle, under
3336 * which we log discharge cycle info.
3337 */
3338 public static final String BATTERY_DISCHARGE_DURATION_THRESHOLD =
3339 "battery_discharge_duration_threshold";
3340 public static final String BATTERY_DISCHARGE_THRESHOLD = "battery_discharge_threshold";
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003341
The Android Open Source Project4df24232009-03-05 14:34:35 -08003342 /**
3343 * An email address that anr bugreports should be sent to.
3344 */
3345 public static final String ANR_BUGREPORT_RECIPIENT = "anr_bugreport_recipient";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003346
3347 /**
Amith Yamasani430555ac2009-06-11 22:35:39 -07003348 * Flag for allowing service provider to use location information to improve products and
3349 * services.
3350 * Type: int ( 0 = disallow, 1 = allow )
Amith Yamasani630cd062009-06-19 12:07:02 -07003351 * @deprecated
Amith Yamasani430555ac2009-06-11 22:35:39 -07003352 */
3353 public static final String USE_LOCATION_FOR_SERVICES = "use_location";
3354
3355 /**
Ken Shirriff326580d2009-08-10 14:21:46 -07003356 * The length of the calendar sync window into the future.
3357 * This specifies the number of days into the future for the sliding window sync.
3358 * Setting this to zero will disable sliding sync.
3359 */
3360 public static final String GOOGLE_CALENDAR_SYNC_WINDOW_DAYS =
3361 "google_calendar_sync_window_days";
3362
3363 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003364 * @deprecated
3365 * @hide
3366 */
3367 @Deprecated // Obviated by NameValueCache: just fetch the value directly.
3368 public static class QueryMap extends ContentQueryMap {
3369
3370 public QueryMap(ContentResolver contentResolver, Cursor cursor, boolean keepUpdated,
3371 Handler handlerForUpdateNotifications) {
3372 super(cursor, NAME, keepUpdated, handlerForUpdateNotifications);
3373 }
3374
3375 public QueryMap(ContentResolver contentResolver, boolean keepUpdated,
3376 Handler handlerForUpdateNotifications) {
3377 this(contentResolver,
3378 contentResolver.query(CONTENT_URI, null, null, null, null),
3379 keepUpdated, handlerForUpdateNotifications);
3380 }
3381
3382 public String getString(String name) {
3383 ContentValues cv = getValues(name);
3384 if (cv == null) return null;
3385 return cv.getAsString(VALUE);
3386 }
3387 }
3388
3389 }
3390
3391 /**
3392 * User-defined bookmarks and shortcuts. The target of each bookmark is an
3393 * Intent URL, allowing it to be either a web page or a particular
3394 * application activity.
3395 *
3396 * @hide
3397 */
3398 public static final class Bookmarks implements BaseColumns
3399 {
3400 private static final String TAG = "Bookmarks";
3401
3402 /**
3403 * The content:// style URL for this table
3404 */
3405 public static final Uri CONTENT_URI =
3406 Uri.parse("content://" + AUTHORITY + "/bookmarks");
3407
3408 /**
3409 * The row ID.
3410 * <p>Type: INTEGER</p>
3411 */
3412 public static final String ID = "_id";
3413
3414 /**
3415 * Descriptive name of the bookmark that can be displayed to the user.
3416 * If this is empty, the title should be resolved at display time (use
3417 * {@link #getTitle(Context, Cursor)} any time you want to display the
3418 * title of a bookmark.)
3419 * <P>
3420 * Type: TEXT
3421 * </P>
3422 */
3423 public static final String TITLE = "title";
3424
3425 /**
3426 * Arbitrary string (displayed to the user) that allows bookmarks to be
3427 * organized into categories. There are some special names for
3428 * standard folders, which all start with '@'. The label displayed for
3429 * the folder changes with the locale (via {@link #getLabelForFolder}) but
3430 * the folder name does not change so you can consistently query for
3431 * the folder regardless of the current locale.
3432 *
3433 * <P>Type: TEXT</P>
3434 *
3435 */
3436 public static final String FOLDER = "folder";
3437
3438 /**
3439 * The Intent URL of the bookmark, describing what it points to. This
3440 * value is given to {@link android.content.Intent#getIntent} to create
3441 * an Intent that can be launched.
3442 * <P>Type: TEXT</P>
3443 */
3444 public static final String INTENT = "intent";
3445
3446 /**
3447 * Optional shortcut character associated with this bookmark.
3448 * <P>Type: INTEGER</P>
3449 */
3450 public static final String SHORTCUT = "shortcut";
3451
3452 /**
3453 * The order in which the bookmark should be displayed
3454 * <P>Type: INTEGER</P>
3455 */
3456 public static final String ORDERING = "ordering";
3457
3458 private static final String[] sIntentProjection = { INTENT };
3459 private static final String[] sShortcutProjection = { ID, SHORTCUT };
3460 private static final String sShortcutSelection = SHORTCUT + "=?";
3461
3462 /**
3463 * Convenience function to retrieve the bookmarked Intent for a
3464 * particular shortcut key.
3465 *
3466 * @param cr The ContentResolver to query.
3467 * @param shortcut The shortcut key.
3468 *
3469 * @return Intent The bookmarked URL, or null if there is no bookmark
3470 * matching the given shortcut.
3471 */
3472 public static Intent getIntentForShortcut(ContentResolver cr, char shortcut)
3473 {
3474 Intent intent = null;
3475
3476 Cursor c = cr.query(CONTENT_URI,
3477 sIntentProjection, sShortcutSelection,
3478 new String[] { String.valueOf((int) shortcut) }, ORDERING);
3479 // Keep trying until we find a valid shortcut
3480 try {
3481 while (intent == null && c.moveToNext()) {
3482 try {
3483 String intentURI = c.getString(c.getColumnIndexOrThrow(INTENT));
3484 intent = Intent.getIntent(intentURI);
3485 } catch (java.net.URISyntaxException e) {
3486 // The stored URL is bad... ignore it.
3487 } catch (IllegalArgumentException e) {
3488 // Column not found
3489 Log.e(TAG, "Intent column not found", e);
3490 }
3491 }
3492 } finally {
3493 if (c != null) c.close();
3494 }
3495
3496 return intent;
3497 }
3498
3499 /**
3500 * Add a new bookmark to the system.
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003501 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003502 * @param cr The ContentResolver to query.
3503 * @param intent The desired target of the bookmark.
3504 * @param title Bookmark title that is shown to the user; null if none
3505 * or it should be resolved to the intent's title.
3506 * @param folder Folder in which to place the bookmark; null if none.
3507 * @param shortcut Shortcut that will invoke the bookmark; 0 if none. If
3508 * this is non-zero and there is an existing bookmark entry
3509 * with this same shortcut, then that existing shortcut is
3510 * cleared (the bookmark is not removed).
3511 * @return The unique content URL for the new bookmark entry.
3512 */
3513 public static Uri add(ContentResolver cr,
3514 Intent intent,
3515 String title,
3516 String folder,
3517 char shortcut,
3518 int ordering)
3519 {
3520 // If a shortcut is supplied, and it is already defined for
3521 // another bookmark, then remove the old definition.
3522 if (shortcut != 0) {
3523 Cursor c = cr.query(CONTENT_URI,
3524 sShortcutProjection, sShortcutSelection,
3525 new String[] { String.valueOf((int) shortcut) }, null);
3526 try {
3527 if (c.moveToFirst()) {
3528 while (c.getCount() > 0) {
3529 if (!c.deleteRow()) {
3530 Log.w(TAG, "Could not delete existing shortcut row");
3531 }
3532 }
3533 }
3534 } finally {
3535 if (c != null) c.close();
3536 }
3537 }
3538
3539 ContentValues values = new ContentValues();
3540 if (title != null) values.put(TITLE, title);
3541 if (folder != null) values.put(FOLDER, folder);
3542 values.put(INTENT, intent.toURI());
3543 if (shortcut != 0) values.put(SHORTCUT, (int) shortcut);
3544 values.put(ORDERING, ordering);
3545 return cr.insert(CONTENT_URI, values);
3546 }
3547
3548 /**
3549 * Return the folder name as it should be displayed to the user. This
3550 * takes care of localizing special folders.
3551 *
3552 * @param r Resources object for current locale; only need access to
3553 * system resources.
3554 * @param folder The value found in the {@link #FOLDER} column.
3555 *
3556 * @return CharSequence The label for this folder that should be shown
3557 * to the user.
3558 */
3559 public static CharSequence getLabelForFolder(Resources r, String folder) {
3560 return folder;
3561 }
3562
3563 /**
3564 * Return the title as it should be displayed to the user. This takes
3565 * care of localizing bookmarks that point to activities.
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003566 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003567 * @param context A context.
3568 * @param cursor A cursor pointing to the row whose title should be
3569 * returned. The cursor must contain at least the {@link #TITLE}
3570 * and {@link #INTENT} columns.
3571 * @return A title that is localized and can be displayed to the user,
3572 * or the empty string if one could not be found.
3573 */
3574 public static CharSequence getTitle(Context context, Cursor cursor) {
3575 int titleColumn = cursor.getColumnIndex(TITLE);
3576 int intentColumn = cursor.getColumnIndex(INTENT);
3577 if (titleColumn == -1 || intentColumn == -1) {
3578 throw new IllegalArgumentException(
3579 "The cursor must contain the TITLE and INTENT columns.");
3580 }
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003581
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003582 String title = cursor.getString(titleColumn);
3583 if (!TextUtils.isEmpty(title)) {
3584 return title;
3585 }
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003586
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003587 String intentUri = cursor.getString(intentColumn);
3588 if (TextUtils.isEmpty(intentUri)) {
3589 return "";
3590 }
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003591
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003592 Intent intent;
3593 try {
3594 intent = Intent.getIntent(intentUri);
3595 } catch (URISyntaxException e) {
3596 return "";
3597 }
Jaikumar Ganesh9bfbfbd2009-05-15 12:05:56 -07003598
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003599 PackageManager packageManager = context.getPackageManager();
3600 ResolveInfo info = packageManager.resolveActivity(intent, 0);
3601 return info != null ? info.loadLabel(packageManager) : "";
3602 }
3603 }
3604
3605 /**
3606 * Returns the GTalk JID resource associated with this device.
3607 *
3608 * @return String the JID resource of the device. It uses the device IMEI in the computation
3609 * of the JID resource. If IMEI is not ready (i.e. telephony module not ready), we'll return
3610 * an empty string.
3611 * @hide
3612 */
3613 // TODO: we shouldn't not have a permenant Jid resource, as that's an easy target for
3614 // spams. We should change it once a while, like when we resubscribe to the subscription feeds
3615 // server.
3616 // (also, should this live in GTalkService?)
3617 public static synchronized String getJidResource() {
3618 if (sJidResource != null) {
3619 return sJidResource;
3620 }
3621
3622 MessageDigest digest;
3623 try {
3624 digest = MessageDigest.getInstance("SHA-1");
3625 } catch (NoSuchAlgorithmException e) {
3626 throw new RuntimeException("this should never happen");
3627 }
3628
Wink Saville04e71b32009-04-02 11:00:54 -07003629 String deviceId = TelephonyManager.getDefault().getDeviceId();
3630 if (TextUtils.isEmpty(deviceId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003631 return "";
3632 }
3633
Wink Saville04e71b32009-04-02 11:00:54 -07003634 byte[] hashedDeviceId = digest.digest(deviceId.getBytes());
3635 String id = new String(Base64.encodeBase64(hashedDeviceId), 0, 12);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003636 id = id.replaceAll("/", "_");
3637 sJidResource = JID_RESOURCE_PREFIX + id;
3638 return sJidResource;
3639 }
3640
3641 /**
3642 * Returns the device ID that we should use when connecting to the mobile gtalk server.
3643 * This is a string like "android-0x1242", where the hex string is the Android ID obtained
3644 * from the GoogleLoginService.
3645 *
3646 * @param androidId The Android ID for this device.
3647 * @return The device ID that should be used when connecting to the mobile gtalk server.
3648 * @hide
3649 */
3650 public static String getGTalkDeviceId(long androidId) {
3651 return "android-" + Long.toHexString(androidId);
3652 }
3653}