diff options
Diffstat (limited to 'core/java/android/provider/Settings.java')
| -rw-r--r-- | core/java/android/provider/Settings.java | 111 |
1 files changed, 6 insertions, 105 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 16f9a43de28d..12da8ed4d2a4 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5030,10 +5030,6 @@ public final class Settings { public static boolean putStringForUser(@NonNull ContentResolver resolver, @NonNull String name, @Nullable String value, @Nullable String tag, boolean makeDefault, @UserIdInt int userHandle) { - if (LOCATION_MODE.equals(name)) { - // Map LOCATION_MODE to underlying location provider storage API - return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle); - } if (MOVED_TO_GLOBAL.contains(name)) { Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.Secure" + " to android.provider.Settings.Global"); @@ -5186,10 +5182,6 @@ public final class Settings { /** @hide */ @UnsupportedAppUsage public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) { - if (LOCATION_MODE.equals(name)) { - // Map from to underlying location provider storage API to location mode - return getLocationModeForUser(cr, userHandle); - } String v = getStringForUser(cr, name, userHandle); try { return v != null ? Integer.parseInt(v) : def; @@ -5224,10 +5216,6 @@ public final class Settings { /** @hide */ public static int getIntForUser(ContentResolver cr, String name, int userHandle) throws SettingNotFoundException { - if (LOCATION_MODE.equals(name)) { - // Map from to underlying location provider storage API to location mode - return getLocationModeForUser(cr, userHandle); - } String v = getStringForUser(cr, name, userHandle); try { return Integer.parseInt(v); @@ -5810,9 +5798,8 @@ public final class Settings { * this value being present in settings.db or on ContentObserver notifications on the * corresponding Uri. * - * @deprecated use {@link #LOCATION_MODE} and - * {@link LocationManager#MODE_CHANGED_ACTION} (or - * {@link LocationManager#PROVIDERS_CHANGED_ACTION}) + * @deprecated Providers should not be controlled individually. See {@link #LOCATION_MODE} + * documentation for information on reading/writing location information. */ @Deprecated public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed"; @@ -5830,9 +5817,7 @@ public final class Settings { * notifications for the corresponding Uri. Use {@link LocationManager#MODE_CHANGED_ACTION} * to receive changes in this value. * - * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To - * get the status of a location provider, use - * {@link LocationManager#isProviderEnabled(String)}. + * @deprecated To check location mode, use {@link LocationManager#isLocationEnabled()}. */ @Deprecated public static final String LOCATION_MODE = "location_mode"; @@ -5861,9 +5846,7 @@ public final class Settings { /** * Location access disabled. * - * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To - * get the status of a location provider, use - * {@link LocationManager#isProviderEnabled(String)}. + * @deprecated See {@link #LOCATION_MODE}. */ @Deprecated public static final int LOCATION_MODE_OFF = 0; @@ -5883,9 +5866,7 @@ public final class Settings { * with {@link android.location.Criteria#POWER_HIGH} may be downgraded to * {@link android.location.Criteria#POWER_MEDIUM}. * - * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To - * get the status of a location provider, use - * {@link LocationManager#isProviderEnabled(String)}. + * @deprecated See {@link #LOCATION_MODE}. */ @Deprecated public static final int LOCATION_MODE_BATTERY_SAVING = 2; @@ -5893,9 +5874,7 @@ public final class Settings { /** * Best-effort location computation allowed. * - * @deprecated To check location status, use {@link LocationManager#isLocationEnabled()}. To - * get the status of a location provider, use - * {@link LocationManager#isProviderEnabled(String)}. + * @deprecated See {@link #LOCATION_MODE}. */ @Deprecated public static final int LOCATION_MODE_HIGH_ACCURACY = 3; @@ -8778,84 +8757,6 @@ public final class Settings { userId); } } - - /** - * Thread-safe method for setting the location mode to one of - * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, - * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. - * Necessary because the mode is a composite of the underlying location provider - * settings. - * - * @param cr the content resolver to use - * @param mode such as {@link #LOCATION_MODE_HIGH_ACCURACY} - * @param userId the userId for which to change mode - * @return true if the value was set, false on database errors - * - * @throws IllegalArgumentException if mode is not one of the supported values - * - * @deprecated To enable/disable location, use - * {@link LocationManager#setLocationEnabledForUser(boolean, int)}. - * To enable/disable a specific location provider, use - * {@link LocationManager#setProviderEnabledForUser(String, boolean, int)}. - */ - @Deprecated - private static boolean setLocationModeForUser( - ContentResolver cr, int mode, int userId) { - synchronized (mLocationSettingsLock) { - boolean gps = false; - boolean network = false; - switch (mode) { - case LOCATION_MODE_OFF: - break; - case LOCATION_MODE_SENSORS_ONLY: - gps = true; - break; - case LOCATION_MODE_BATTERY_SAVING: - network = true; - break; - case LOCATION_MODE_HIGH_ACCURACY: - gps = true; - network = true; - break; - default: - throw new IllegalArgumentException("Invalid location mode: " + mode); - } - - boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser( - cr, LocationManager.NETWORK_PROVIDER, network, userId); - boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser( - cr, LocationManager.GPS_PROVIDER, gps, userId); - return gpsSuccess && nlpSuccess; - } - } - - /** - * Thread-safe method for reading the location mode, returns one of - * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, - * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. Necessary - * because the mode is a composite of the underlying location provider settings. - * - * @param cr the content resolver to use - * @param userId the userId for which to read the mode - * @return the location mode - */ - private static final int getLocationModeForUser(ContentResolver cr, int userId) { - synchronized (mLocationSettingsLock) { - boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser( - cr, LocationManager.GPS_PROVIDER, userId); - boolean networkEnabled = Settings.Secure.isLocationProviderEnabledForUser( - cr, LocationManager.NETWORK_PROVIDER, userId); - if (gpsEnabled && networkEnabled) { - return LOCATION_MODE_HIGH_ACCURACY; - } else if (gpsEnabled) { - return LOCATION_MODE_SENSORS_ONLY; - } else if (networkEnabled) { - return LOCATION_MODE_BATTERY_SAVING; - } else { - return LOCATION_MODE_OFF; - } - } - } } /** |
