Remove LOCATION_GLOBAL_KILL_SWITCH logic from settings
This functionality is now handled by the location service, and legacy settings code can be removed. Full removal to follow later. Bug: 148963686 Test: presubmits Change-Id: I7de19f17759b0a13b96dd8960d2dbdb84ffd72d9
This commit is contained in:
@@ -13406,15 +13406,6 @@ public final class Settings {
|
||||
public static final String POWER_BUTTON_VERY_LONG_PRESS =
|
||||
"power_button_very_long_press";
|
||||
|
||||
/**
|
||||
* Global settings that shouldn't be persisted.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String[] TRANSIENT_SETTINGS = {
|
||||
LOCATION_GLOBAL_KILL_SWITCH,
|
||||
};
|
||||
|
||||
/**
|
||||
* Keys we no longer back up under the current schema, but want to continue to
|
||||
* process when restoring historical backup datasets.
|
||||
|
||||
@@ -891,9 +891,6 @@ class SettingsProtoDumpUtil {
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.LOCATION_SETTINGS_LINK_TO_PERMISSIONS_ENABLED,
|
||||
GlobalSettingsProto.Location.SETTINGS_LINK_TO_PERMISSIONS_ENABLED);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.LOCATION_GLOBAL_KILL_SWITCH,
|
||||
GlobalSettingsProto.Location.GLOBAL_KILL_SWITCH);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.GNSS_SATELLITE_BLACKLIST,
|
||||
GlobalSettingsProto.Location.GNSS_SATELLITE_BLACKLIST);
|
||||
|
||||
@@ -328,10 +328,6 @@ public class SettingsProvider extends ContentProvider {
|
||||
return SettingsState.getUserIdFromKey(key);
|
||||
}
|
||||
|
||||
public static String settingTypeToString(int type) {
|
||||
return SettingsState.settingTypeToString(type);
|
||||
}
|
||||
|
||||
public static String keyToString(int key) {
|
||||
return SettingsState.keyToString(key);
|
||||
}
|
||||
@@ -373,8 +369,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
case Settings.CALL_METHOD_GET_SECURE: {
|
||||
Setting setting = getSecureSetting(name, requestingUserId,
|
||||
/*enableOverride=*/ true);
|
||||
Setting setting = getSecureSetting(name, requestingUserId);
|
||||
return packageValueForCallResult(setting, isTrackingGeneration(args));
|
||||
}
|
||||
|
||||
@@ -581,7 +576,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private ArrayList<String> buildSettingsList(Cursor cursor) {
|
||||
final ArrayList<String> lines = new ArrayList<String>();
|
||||
final ArrayList<String> lines = new ArrayList<>();
|
||||
try {
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
lines.add(cursor.getString(1) + "=" + cursor.getString(2));
|
||||
@@ -1381,10 +1376,6 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private Setting getSecureSetting(String name, int requestingUserId) {
|
||||
return getSecureSetting(name, requestingUserId, /*enableOverride=*/ false);
|
||||
}
|
||||
|
||||
private Setting getSecureSetting(String name, int requestingUserId, boolean enableOverride) {
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "getSecureSetting(" + name + ", " + requestingUserId + ")");
|
||||
}
|
||||
@@ -1414,14 +1405,6 @@ public class SettingsProvider extends ContentProvider {
|
||||
return getSsaidSettingLocked(callingPkg, owningUserId);
|
||||
}
|
||||
}
|
||||
if (enableOverride) {
|
||||
if (Secure.LOCATION_MODE.equals(name)) {
|
||||
final Setting overridden = getLocationModeSetting(owningUserId);
|
||||
if (overridden != null) {
|
||||
return overridden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not the SSAID; do a straight lookup
|
||||
synchronized (mLock) {
|
||||
@@ -1511,35 +1494,6 @@ public class SettingsProvider extends ContentProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Setting getLocationModeSetting(int owningUserId) {
|
||||
synchronized (mLock) {
|
||||
final Setting setting = getGlobalSetting(
|
||||
Global.LOCATION_GLOBAL_KILL_SWITCH);
|
||||
if (!"1".equals(setting.getValue())) {
|
||||
return null;
|
||||
}
|
||||
// Global kill-switch is enabled. Return an empty value.
|
||||
final SettingsState settingsState = mSettingsRegistry.getSettingsLocked(
|
||||
SETTINGS_TYPE_SECURE, owningUserId);
|
||||
return settingsState.new Setting(
|
||||
Secure.LOCATION_MODE,
|
||||
"", // value
|
||||
"", // tag
|
||||
"", // default value
|
||||
"", // package name
|
||||
false, // from system
|
||||
"0" // id
|
||||
) {
|
||||
@Override
|
||||
public boolean update(String value, boolean setDefault, String packageName,
|
||||
String tag, boolean forceNonSystemPackage, boolean overrideableByRestore) {
|
||||
Slog.wtf(LOG_TAG, "update shouldn't be called on this instance.");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private boolean insertSecureSetting(String name, String value, String tag,
|
||||
boolean makeDefault, int requestingUserId, boolean forceNotify,
|
||||
boolean overrideableByRestore) {
|
||||
@@ -1808,12 +1762,8 @@ public class SettingsProvider extends ContentProvider {
|
||||
|
||||
private boolean hasWriteSecureSettingsPermission() {
|
||||
// Write secure settings is a more protected permission. If caller has it we are good.
|
||||
if (getContext().checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return getContext().checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
private void validateSystemSettingValue(String name, String value) {
|
||||
@@ -3174,12 +3124,6 @@ public class SettingsProvider extends ContentProvider {
|
||||
if (isGlobalSettingsKey(key) || isConfigSettingsKey(key)) {
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
if (Global.LOCATION_GLOBAL_KILL_SWITCH.equals(name)
|
||||
&& isGlobalSettingsKey(key)) {
|
||||
// When the global kill switch is updated, send the
|
||||
// change notification for the location setting.
|
||||
notifyLocationChangeForRunningUsers();
|
||||
}
|
||||
notifySettingChangeForRunningUsers(key, name);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
@@ -3257,26 +3201,6 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyLocationChangeForRunningUsers() {
|
||||
final List<UserInfo> users = mUserManager.getAliveUsers();
|
||||
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
final int userId = users.get(i).id;
|
||||
|
||||
if (!mUserManager.isUserRunning(UserHandle.of(userId))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Increment the generation first, so observers always see the new value
|
||||
final int key = makeKey(SETTINGS_TYPE_SECURE, userId);
|
||||
mGenerationRegistry.incrementGeneration(key);
|
||||
|
||||
final Uri uri = getNotificationUriFor(key, Secure.LOCATION_MODE);
|
||||
mHandler.obtainMessage(MyHandler.MSG_NOTIFY_URI_CHANGED,
|
||||
userId, 0, uri).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConfigSettingsKey(int key) {
|
||||
return getTypeFromKey(key) == SETTINGS_TYPE_CONFIG;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.providers.settings.SettingsOperationProto;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
@@ -47,7 +46,6 @@ import android.util.Xml;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
@@ -817,13 +815,6 @@ final class SettingsState {
|
||||
for (int i = 0; i < settingCount; i++) {
|
||||
Setting setting = settings.valueAt(i);
|
||||
|
||||
if (setting.isTransient()) {
|
||||
if (DEBUG_PERSISTENCE) {
|
||||
Slog.i(LOG_TAG, "[SKIPPED PERSISTING]" + setting.getName());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
writeSingleSetting(mVersion, serializer, setting.getId(), setting.getName(),
|
||||
setting.getValue(), setting.getDefaultValue(), setting.getPackageName(),
|
||||
setting.getTag(), setting.isDefaultFromSystem(),
|
||||
@@ -1109,8 +1100,7 @@ final class SettingsState {
|
||||
ATTR_DEFAULT_VALUE_BASE64);
|
||||
String isPreservedInRestoreString = parser.getAttributeValue(null,
|
||||
ATTR_PRESERVE_IN_RESTORE);
|
||||
boolean isPreservedInRestore = isPreservedInRestoreString != null
|
||||
&& Boolean.parseBoolean(isPreservedInRestoreString);
|
||||
boolean isPreservedInRestore = Boolean.parseBoolean(isPreservedInRestoreString);
|
||||
String tag = null;
|
||||
boolean fromSystem = false;
|
||||
if (defaultValue != null) {
|
||||
@@ -1308,14 +1298,6 @@ final class SettingsState {
|
||||
/* resetToDefault */ true);
|
||||
}
|
||||
|
||||
public boolean isTransient() {
|
||||
switch (getTypeFromKey(getKey())) {
|
||||
case SETTINGS_TYPE_GLOBAL:
|
||||
return ArrayUtils.contains(Global.TRANSIENT_SETTINGS, getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean update(String value, boolean setDefault, String packageName, String tag,
|
||||
boolean forceNonSystemPackage, boolean overrideableByRestore) {
|
||||
return update(value, setDefault, packageName, tag, forceNonSystemPackage,
|
||||
@@ -1444,7 +1426,7 @@ final class SettingsState {
|
||||
}
|
||||
|
||||
private static String fromBytes(byte[] bytes) {
|
||||
final StringBuffer sb = new StringBuffer(bytes.length / 2);
|
||||
final StringBuilder sb = new StringBuilder(bytes.length / 2);
|
||||
|
||||
final int last = bytes.length - 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user