Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b388151 authored by Tom O'Neill's avatar Tom O'Neill Committed by Android Git Automerger
Browse files

am a413551c: am 4a9c7fec: Merge "Address API council comments on location mode...

am a413551c: am 4a9c7fec: Merge "Address API council comments on location mode API council" into klp-dev

* commit 'a413551c':
  Address API council comments on location mode API council
parents 340c1c26 a413551c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -21311,8 +21311,8 @@ package android.provider {
    method public static float getFloat(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
    method public static int getInt(android.content.ContentResolver, java.lang.String, int);
    method public static int getInt(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
    method public static final int getLocationMode(android.content.ContentResolver);
    method public static final int getLocationModeForUser(android.content.ContentResolver, int);
    method public static final deprecated int getLocationMode(android.content.ContentResolver);
    method public static final deprecated int getLocationModeForUser(android.content.ContentResolver, int);
    method public static long getLong(android.content.ContentResolver, java.lang.String, long);
    method public static long getLong(android.content.ContentResolver, java.lang.String) throws android.provider.Settings.SettingNotFoundException;
    method public static java.lang.String getString(android.content.ContentResolver, java.lang.String);
@@ -21322,8 +21322,8 @@ package android.provider {
    method public static boolean putInt(android.content.ContentResolver, java.lang.String, int);
    method public static boolean putLong(android.content.ContentResolver, java.lang.String, long);
    method public static boolean putString(android.content.ContentResolver, java.lang.String, java.lang.String);
    method public static final void setLocationMode(android.content.ContentResolver, int);
    method public static final void setLocationModeForUser(android.content.ContentResolver, int, int);
    method public static final deprecated void setLocationMode(android.content.ContentResolver, int);
    method public static final deprecated boolean setLocationModeForUser(android.content.ContentResolver, int, int);
    method public static final deprecated void setLocationProviderEnabled(android.content.ContentResolver, java.lang.String, boolean);
    field public static final java.lang.String ACCESSIBILITY_ENABLED = "accessibility_enabled";
    field public static final java.lang.String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
@@ -21343,11 +21343,12 @@ package android.provider {
    field public static final deprecated java.lang.String HTTP_PROXY = "http_proxy";
    field public static final java.lang.String INPUT_METHOD_SELECTOR_VISIBILITY = "input_method_selector_visibility";
    field public static final deprecated java.lang.String INSTALL_NON_MARKET_APPS = "install_non_market_apps";
    field public static final java.lang.String LOCATION_MODE = "location_mode";
    field public static final int LOCATION_MODE_BATTERY_SAVING = 2; // 0x2
    field public static final int LOCATION_MODE_HIGH_ACCURACY = 3; // 0x3
    field public static final int LOCATION_MODE_OFF = 0; // 0x0
    field public static final int LOCATION_MODE_SENSORS_ONLY = 1; // 0x1
    field public static final java.lang.String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
    field public static final deprecated java.lang.String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";
    field public static final java.lang.String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
    field public static final deprecated java.lang.String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled";
    field public static final java.lang.String LOCK_PATTERN_VISIBLE = "lock_pattern_visible_pattern";
+57 −9
Original line number Diff line number Diff line
@@ -2931,6 +2931,11 @@ public final class Settings {
                throws SettingNotFoundException {
            String v = getStringForUser(cr, name, userHandle);
            try {
                if (LOCATION_MODE.equals(name)) {
                    // HACK ALERT: temporary hack to work around b/10491283.
                    // TODO: once b/10491283 fixed, remove this hack
                    return getLocationModeForUser(cr, userHandle);
                }
                return Integer.parseInt(v);
            } catch (NumberFormatException e) {
                throw new SettingNotFoundException(name);
@@ -2957,6 +2962,11 @@ public final class Settings {
        /** @hide */
        public static boolean putIntForUser(ContentResolver cr, String name, int value,
                int userHandle) {
            if (LOCATION_MODE.equals(name)) {
                // HACK ALERT: temporary hack to work around b/10491283.
                // TODO: once b/10491283 fixed, remove this hack
                return setLocationModeForUser(cr, value, userHandle);
            }
            return putStringForUser(cr, name, Integer.toString(value), userHandle);
        }

@@ -3265,9 +3275,20 @@ public final class Settings {

        /**
         * Comma-separated list of location providers that activities may access.
         *
         * @deprecated use {@link #LOCATION_MODE}
         */
        @Deprecated
        public static final String LOCATION_PROVIDERS_ALLOWED = "location_providers_allowed";

        /**
         * The degree of location access enabled by the user, for use with {@link
         * #putInt(ContentResolver, String, int)} and {@link #getInt(ContentResolver, String)}. Must
         * be one of {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
         */
        public static final String LOCATION_MODE = "location_mode";

        /**
         * Location access disabled
         */
@@ -4328,7 +4349,7 @@ public final class Settings {
         * @param cr the content resolver to use
         * @param provider the location provider to query
         * @return true if the provider is enabled
         * @deprecated use {@link #getLocationMode(ContentResolver)}
         * @deprecated use {@link #getInt(ContentResolver, String)} and {@link #LOCATION_MODE}
         */
        @Deprecated
        public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
@@ -4341,7 +4362,8 @@ public final class Settings {
         * @param provider the location provider to query
         * @param userId the userId to query
         * @return true if the provider is enabled
         * @deprecated use {@link #getLocationModeForUser(ContentResolver, int)}
         * @deprecated use {@link #getIntForUser(ContentResolver, String, int, int)} and
         *             {@link #LOCATION_MODE}
         * @hide
         */
        @Deprecated
@@ -4356,7 +4378,7 @@ public final class Settings {
         * @param cr the content resolver to use
         * @param provider the location provider to enable or disable
         * @param enabled true if the provider should be enabled
         * @deprecated use {@link #setLocationMode(ContentResolver, int)}
         * @deprecated use {@link #putInt(ContentResolver, String, int)} and {@link #LOCATION_MODE}
         */
        @Deprecated
        public static final void setLocationProviderEnabled(ContentResolver cr,
@@ -4366,15 +4388,18 @@ public final class Settings {

        /**
         * Thread-safe method for enabling or disabling a single location provider.
         *
         * @param cr the content resolver to use
         * @param provider the location provider to enable or disable
         * @param enabled true if the provider should be enabled
         * @param userId the userId for which to enable/disable providers
         * @deprecated use {@link #setLocationModeForUser(ContentResolver, int, int)}
         * @return true if the value was set, false on database errors
         * @deprecated use {@link #putIntForUser(ContentResolver, String, int, int)} and
         *             {@link #LOCATION_MODE}
         * @hide
         */
        @Deprecated
        public static final void setLocationProviderEnabledForUser(ContentResolver cr,
        public static final boolean setLocationProviderEnabledForUser(ContentResolver cr,
                String provider, boolean enabled, int userId) {
            synchronized (mLocationSettingsLock) {
                // to ensure thread safety, we write the provider name with a '+' or '-'
@@ -4385,7 +4410,7 @@ public final class Settings {
                } else {
                    provider = "-" + provider;
                }
                putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
                return putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
                        userId);
            }
        }
@@ -4395,13 +4420,20 @@ public final class Settings {
         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
         *
         * TODO: remove callers, make private
         *
         * @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 use {@link #putIntForUser(ContentResolver, String, int, int)} and
         *             {@link #LOCATION_MODE}
         */
        public static final void setLocationModeForUser(ContentResolver cr, int mode, int userId) {
        @Deprecated
        public static final boolean setLocationModeForUser(ContentResolver cr, int mode, int userId) {
            synchronized (mLocationSettingsLock) {
                boolean gps = false;
                boolean network = false;
@@ -4421,10 +4453,11 @@ public final class Settings {
                    default:
                        throw new IllegalArgumentException("Invalid location mode: " + mode);
                }
                Settings.Secure.setLocationProviderEnabledForUser(
                boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
                        cr, LocationManager.GPS_PROVIDER, gps, userId);
                Settings.Secure.setLocationProviderEnabledForUser(
                boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
                        cr, LocationManager.NETWORK_PROVIDER, network, userId);
                return gpsSuccess && nlpSuccess;
            }
        }

@@ -4433,11 +4466,15 @@ public final class Settings {
         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
         *
         * TODO: remove callers, delete
         *
         * @param cr the content resolver to use
         * @param mode such as {@link #LOCATION_MODE_HIGH_ACCURACY}
         *
         * @throws IllegalArgumentException if mode is not one of the supported values
         * @deprecated use {@link #putInt(ContentResolver, String, int)} and {@link #LOCATION_MODE}
         */
        @Deprecated
        public static final void setLocationMode(ContentResolver cr, int mode) {
            setLocationModeForUser(cr, mode, UserHandle.myUserId());
        }
@@ -4447,10 +4484,16 @@ public final class Settings {
         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
         *
         * TODO: remove callers, make private
         *
         * @param cr the content resolver to use
         * @param userId the userId for which to read the mode
         * @return the location mode
         *
         * @deprecated use {@link #getIntForUser(ContentResolver, String, int, int)} and
         *             {@link #LOCATION_MODE}
         */
        @Deprecated
        public static final int getLocationModeForUser(ContentResolver cr, int userId) {
            synchronized (mLocationSettingsLock) {
                boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser(
@@ -4474,9 +4517,14 @@ public final class Settings {
         * {@link #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY},
         * {@link #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}.
         *
         * TODO: remove callers, delete
         *
         * @param cr the content resolver to use
         * @return the location mode
         *
         * @deprecated use {@link #getInt(ContentResolver, String, int)} and {@link #LOCATION_MODE}
         */
        @Deprecated
        public static final int getLocationMode(ContentResolver cr) {
            return getLocationModeForUser(cr, UserHandle.myUserId());
        }
+4 −2
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ public class LocationController extends BroadcastReceiver {
        // setting won't be fully enabled until the user accepts the agreement.
        int mode = enabled
                ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY : Settings.Secure.LOCATION_MODE_OFF;
        Settings.Secure.setLocationMode(cr, mode);
        Settings.Secure.putInt(cr, Settings.Secure.LOCATION_MODE, mode);
    }

    /**
@@ -133,7 +133,9 @@ public class LocationController extends BroadcastReceiver {
     */
    public boolean isLocationEnabled() {
        ContentResolver resolver = mContext.getContentResolver();
        return Settings.Secure.getLocationMode(resolver) != Settings.Secure.LOCATION_MODE_OFF;
        int mode = Settings.Secure.getInt(resolver, Settings.Secure.LOCATION_MODE,
                Settings.Secure.LOCATION_MODE_OFF);
        return mode != Settings.Secure.LOCATION_MODE_OFF;
    }

    /**