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

Commit 7f6f4572 authored by Tom O'Neill's avatar Tom O'Neill
Browse files

Remove or reduce visibility of deprecated methods

- Fix additional getInt() path, restores the location settings screen
functionality.

- Should fix "unresolved link" build breakages in
git_klp-dev-plus-aosp-without-vendor, which is much more persnickety than
klp-dev for some reason.

- Add warning that we may add additional location modes in the future.

- Finish fix for b/10461763 and b/10461474

Change-Id: Id7155e3a0d7526a377d446018ef3bdb057bad3a6
parent 4a9c7fec
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -11958,7 +11958,6 @@ package android.location {
    method protected abstract android.location.SettingInjectorService.Status getStatus();
    method protected final void onHandleIntent(android.content.Intent);
    field public static final java.lang.String ACTION_INJECTED_SETTING_CHANGED = "com.android.location.InjectedSettingChanged";
    field public static final deprecated java.lang.String UPDATE_INTENT = "com.android.location.InjectedSettingChanged";
  }
  public static final class SettingInjectorService.Status {
@@ -21299,8 +21298,6 @@ 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 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);
@@ -21310,8 +21307,6 @@ 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 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";
+21 −59
Original line number Diff line number Diff line
@@ -2895,6 +2895,11 @@ public final class Settings {

        /** @hide */
        public static int getIntForUser(ContentResolver cr, String name, int def, 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 getLocationModeForUser(cr, userHandle);
            }
            String v = getStringForUser(cr, name, userHandle);
            try {
                return v != null ? Integer.parseInt(v) : def;
@@ -2929,13 +2934,13 @@ public final class Settings {
        /** @hide */
        public static int getIntForUser(ContentResolver cr, String name, int userHandle)
                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);
            }
            String v = getStringForUser(cr, name, userHandle);
            try {
                return Integer.parseInt(v);
            } catch (NumberFormatException e) {
                throw new SettingNotFoundException(name);
@@ -3282,15 +3287,18 @@ public final class Settings {
        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}.
         * The degree of location access enabled by the user.
         * <p/>
         * When used with {@link #putInt(ContentResolver, String, int)}, must be one of {@link
         * #LOCATION_MODE_HIGH_ACCURACY}, {@link #LOCATION_MODE_SENSORS_ONLY}, {@link
         * #LOCATION_MODE_BATTERY_SAVING}, or {@link #LOCATION_MODE_OFF}. When used with {@link
         * #getInt(ContentResolver, String)}, the caller must gracefully handle additional location
         * modes that might be added in the future.
         */
        public static final String LOCATION_MODE = "location_mode";

        /**
         * Location access disabled
         * Location access disabled.
         */
        public static final int LOCATION_MODE_OFF = 0;
        /**
@@ -4420,20 +4428,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, 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}
         */
        @Deprecated
        public static final boolean setLocationModeForUser(ContentResolver cr, int mode, int userId) {
        private static final boolean setLocationModeForUser(ContentResolver cr, int mode,
                int userId) {
            synchronized (mLocationSettingsLock) {
                boolean gps = false;
                boolean network = false;
@@ -4461,40 +4464,16 @@ public final class Settings {
            }
        }

        /**
         * 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}.
         *
         * 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());
        }

        /**
         * 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}.
         *
         * 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) {
        private static final int getLocationModeForUser(ContentResolver cr, int userId) {
            synchronized (mLocationSettingsLock) {
                boolean gpsEnabled = Settings.Secure.isLocationProviderEnabledForUser(
                        cr, LocationManager.GPS_PROVIDER, userId);
@@ -4511,23 +4490,6 @@ public final class Settings {
                }
            }
        }

        /**
         * 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}.
         *
         * 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());
        }
    }

    /**
+1 −20
Original line number Diff line number Diff line
@@ -101,16 +101,6 @@ public abstract class SettingInjectorService extends IntentService {
     */
    public static final String SUMMARY_KEY = "summary";

    /**
     * TODO: delete after switching SettingsInjector to use {@link #SUMMARY_KEY}.
     *
     * @deprecated use {@link #SUMMARY_KEY}
     *
     * @hide
     */
    @Deprecated
    public static final String STATUS_KEY = "status";

    /**
     * Name of the bundle key for the string specifying whether the setting is currently enabled.
     *
@@ -132,14 +122,6 @@ public abstract class SettingInjectorService extends IntentService {
    public static final String ACTION_INJECTED_SETTING_CHANGED =
            "com.android.location.InjectedSettingChanged";

    /**
     * TODO: delete after switching callers to use {@link #ACTION_INJECTED_SETTING_CHANGED}.
     *
     * @deprecated use {@link #ACTION_INJECTED_SETTING_CHANGED}
     */
    @Deprecated
    public static final String UPDATE_INTENT = ACTION_INJECTED_SETTING_CHANGED;

    private final String mName;

    /**
@@ -170,7 +152,6 @@ public abstract class SettingInjectorService extends IntentService {
        Message message = Message.obtain();
        Bundle bundle = new Bundle();
        if (status != null) {
            bundle.putString(STATUS_KEY, status.summary);
            bundle.putString(SUMMARY_KEY, status.summary);
            bundle.putBoolean(ENABLED_KEY, status.enabled);
        }
@@ -214,7 +195,7 @@ public abstract class SettingInjectorService extends IntentService {
         * choosing to hide a setting. Instead you should provide a {@code enabled} value of false,
         * which will gray the setting out and disable the link from "Settings > Location"
         * to your setting activity. One reason why you might choose to do this is if
         * {@link android.provider.Settings.Secure#getLocationMode(android.content.ContentResolver)}
         * {@link android.provider.Settings.Secure#LOCATION_MODE}
         * is {@link android.provider.Settings.Secure#LOCATION_MODE_OFF}.
         *
         * It is possible that the user may click on the setting before you return a false value for