Merge "Remove dead code from settings"
diff --git a/src/com/android/settings/location/LocationEnabler.java b/src/com/android/settings/location/LocationEnabler.java
index e1bdf16..db53973 100644
--- a/src/com/android/settings/location/LocationEnabler.java
+++ b/src/com/android/settings/location/LocationEnabler.java
@@ -15,9 +15,7 @@
import static com.android.settingslib.RestrictedLockUtilsInternal.checkIfRestrictionEnforced;
import static com.android.settingslib.Utils.updateLocationEnabled;
-import static com.android.settingslib.Utils.updateLocationMode;
-import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -125,26 +123,6 @@
refreshLocationMode();
}
- void setLocationMode(int mode) {
- final int currentMode = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
- if (isRestricted()) {
- // Location toggling disabled by user restriction. Read the current location mode to
- // update the location master switch.
- if (Log.isLoggable(TAG, Log.INFO)) {
- Log.i(TAG, "Restricted user, not setting location mode");
- }
- if (mListener != null) {
- mListener.onLocationModeChanged(currentMode, true);
- }
- return;
- }
-
- updateLocationMode(mContext, currentMode, mode, ActivityManager.getCurrentUser(),
- Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
- refreshLocationMode();
- }
-
boolean isEnabled(int mode) {
return mode != Settings.Secure.LOCATION_MODE_OFF && !isRestricted();
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java b/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
index 806e2ec..fbae2f4 100644
--- a/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
@@ -142,57 +142,6 @@
}
@Test
- public void setLocationMode_restricted_shouldSetCurrentMode() {
- when(mUserManager.hasUserRestriction(anyString())).thenReturn(true);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
-
- mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
-
- verify(mListener).onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, true);
- }
-
- @Test
- public void setLocationMode_notRestricted_shouldUpdateSecureSettings() {
- when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
-
- mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
-
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING))
- .isEqualTo(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
- }
-
- @Test
- public void setLocationMode_notRestricted_shouldRefreshLocation() {
- when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
-
- mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
-
- verify(mEnabler).refreshLocationMode();
- }
-
- @Test
- public void setLocationMode_notRestricted_shouldBroadcastUpdateAndSetChanger() {
- when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_BATTERY_SAVING);
- mEnabler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
-
- verify(mContext).sendBroadcastAsUser(
- argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)),
- eq(UserHandle.of(ActivityManager.getCurrentUser())),
- eq(WRITE_SECURE_SETTINGS));
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN))
- .isEqualTo(Settings.Secure.LOCATION_CHANGER_SYSTEM_SETTINGS);
- }
-
- @Test
public void setLocationEnabled_notRestricted_shouldRefreshLocation() {
when(mUserManager.hasUserRestriction(anyString())).thenReturn(false);
Settings.Secure.putInt(mContext.getContentResolver(),
diff --git a/tests/uitests/src/com/android/settings/ui/LocationSettingsTests.java b/tests/uitests/src/com/android/settings/ui/LocationSettingsTests.java
index b4a1baa..8e391f3 100644
--- a/tests/uitests/src/com/android/settings/ui/LocationSettingsTests.java
+++ b/tests/uitests/src/com/android/settings/ui/LocationSettingsTests.java
@@ -95,7 +95,7 @@
public void testLocationDeviceOnlyMode() throws Exception {
// Changing the value from default before testing the toggle to Device only mode
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
+ Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_ON);
dismissAlertDialogs();
Thread.sleep(TIMEOUT);
verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
@@ -114,7 +114,7 @@
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_SENSORS_ONLY);
Thread.sleep(TIMEOUT);
- verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
+ verifyLocationSettingsMode(Settings.Secure.LOCATION_MODE_ON);
}
@MediumTest
@@ -145,7 +145,7 @@
private void verifyLocationSettingsMode(int mode) throws Exception {
int modeIntValue = 1;
String textMode = "Device only";
- if (mode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY) {
+ if (mode == Settings.Secure.LOCATION_MODE_ON) {
modeIntValue = 3;
textMode = "High accuracy";
}
@@ -169,7 +169,7 @@
dismissAlertDialogs();
mDevice.wait(Until.findObject(By.desc("Navigate up")), TIMEOUT).click();
Thread.sleep(TIMEOUT);
- if (mode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY ||
+ if (mode == Settings.Secure.LOCATION_MODE_ON ||
mode == Settings.Secure.LOCATION_MODE_BATTERY_SAVING) {
dismissAlertDialogs();
}
@@ -190,7 +190,7 @@
}
else {
Settings.Secure.putInt(getInstrumentation().getContext().getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
+ Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_ON);
}
dismissAlertDialogs();
// Load location settings