Merge "Remove deprecated Settings APIs."

This commit is contained in:
TreeHugger Robot
2019-03-14 17:06:04 +00:00
committed by Android (Google) Code Review
5 changed files with 17 additions and 81 deletions

View File

@@ -39023,12 +39023,10 @@ package android.provider {
method public static long getLong(android.content.ContentResolver, String) throws android.provider.Settings.SettingNotFoundException;
method public static String getString(android.content.ContentResolver, String);
method public static android.net.Uri getUriFor(String);
method @Deprecated public static boolean isLocationProviderEnabled(android.content.ContentResolver, String);
method public static boolean putFloat(android.content.ContentResolver, String, float);
method public static boolean putInt(android.content.ContentResolver, String, int);
method public static boolean putLong(android.content.ContentResolver, String, long);
method public static boolean putString(android.content.ContentResolver, String, String);
method @Deprecated public static void setLocationProviderEnabled(android.content.ContentResolver, String, boolean);
field public static final String ACCESSIBILITY_DISPLAY_INVERSION_ENABLED = "accessibility_display_inversion_enabled";
field public static final String ACCESSIBILITY_ENABLED = "accessibility_enabled";
field @Deprecated public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";

View File

@@ -553,6 +553,11 @@ package android.provider {
field @Deprecated public static final String CONTACT_METADATA_SYNC = "contact_metadata_sync";
}
public static final class Settings.Secure extends android.provider.Settings.NameValueTable {
method @Deprecated public static boolean isLocationProviderEnabled(android.content.ContentResolver, String);
method @Deprecated public static void setLocationProviderEnabled(android.content.ContentResolver, String, boolean);
}
public static final class Settings.System extends android.provider.Settings.NameValueTable {
field public static final String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
field public static final String VOLUME_ALARM = "volume_alarm";

View File

@@ -9053,27 +9053,12 @@ public final class Settings {
* @return true if the provider is enabled
*
* @deprecated use {@link LocationManager#isProviderEnabled(String)}
* @removed no longer supported
*/
@Deprecated
public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
return isLocationProviderEnabledForUser(cr, provider, cr.getUserId());
}
/**
* Helper method for determining if a location provider is enabled.
* @param cr the content resolver to use
* @param provider the location provider to query
* @param userId the userId to query
* @return true if the provider is enabled
*
* @deprecated use {@link LocationManager#isProviderEnabled(String)}
* @hide
*/
@Deprecated
public static final boolean isLocationProviderEnabledForUser(
ContentResolver cr, String provider, int userId) {
public static boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
String allowedProviders = Settings.Secure.getStringForUser(cr,
LOCATION_PROVIDERS_ALLOWED, userId);
LOCATION_PROVIDERS_ALLOWED, cr.getUserId());
return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
}
@@ -9082,42 +9067,12 @@ 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 This API is deprecated. It requires WRITE_SECURE_SETTINGS permission to
* change location settings.
* @deprecated This API is deprecated
* @removed no longer supported
*/
@Deprecated
public static final void setLocationProviderEnabled(ContentResolver cr,
public static void setLocationProviderEnabled(ContentResolver cr,
String provider, boolean enabled) {
setLocationProviderEnabledForUser(cr, provider, enabled, cr.getUserId());
}
/**
* 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
* @return true if the value was set, false on database errors
*
* @deprecated use {@link LocationManager#setProviderEnabledForUser(String, boolean, int)}
* @hide
*/
@Deprecated
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 '-'
// and let the SettingsProvider handle it rather than reading and modifying
// the list of enabled providers.
if (enabled) {
provider = "+" + provider;
} else {
provider = "-" + provider;
}
return putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
userId);
}
}
}

View File

@@ -1360,10 +1360,10 @@ public class LocationManager {
@NonNull String provider, boolean enabled, @NonNull UserHandle userHandle) {
checkProvider(provider);
return Settings.Secure.setLocationProviderEnabledForUser(
return Settings.Secure.putStringForUser(
mContext.getContentResolver(),
provider,
enabled,
Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
(enabled ? "+" : "-") + provider,
userHandle.getIdentifier());
}

View File

@@ -16,10 +16,6 @@
package com.android.providers.settings;
import android.os.Process;
import com.android.internal.app.LocalePicker;
import com.android.internal.annotations.VisibleForTesting;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.IActivityManager;
@@ -30,7 +26,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.icu.util.ULocale;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.RingtoneManager;
import android.net.Uri;
@@ -38,13 +33,14 @@ import android.os.LocaleList;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArraySet;
import java.lang.IllegalArgumentException;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.LocalePicker;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
@@ -145,9 +141,6 @@ public class SettingsHelper {
if (Settings.System.SOUND_EFFECTS_ENABLED.equals(name)) {
setSoundEffects(Integer.parseInt(value) == 1);
// fall through to the ordinary write to settings
} else if (Settings.Secure.LOCATION_PROVIDERS_ALLOWED.equals(name)) {
setGpsLocation(value);
return;
} else if (Settings.Secure.BACKUP_AUTO_RESTORE.equals(name)) {
setAutoRestore(Integer.parseInt(value) == 1);
} else if (isAlreadyConfiguredCriticalAccessibilitySetting(name)) {
@@ -297,21 +290,6 @@ public class SettingsHelper {
} catch (RemoteException e) {}
}
private void setGpsLocation(String value) {
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
return;
}
final String GPS = LocationManager.GPS_PROVIDER;
boolean enabled =
GPS.equals(value) ||
value.startsWith(GPS + ",") ||
value.endsWith("," + GPS) ||
value.contains("," + GPS + ",");
LocationManager lm = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
lm.setProviderEnabledForUser(GPS, enabled, Process.myUserHandle());
}
private void setSoundEffects(boolean enable) {
if (enable) {
mAudioManager.loadSoundEffects();