Remove dead code
Bug: 118883513
Test: manually
Change-Id: I0bbdfac91cbe26d08445178b5690c2e9171a39c8
diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java
index c751c39..d32e85f 100644
--- a/packages/SettingsLib/src/com/android/settingslib/Utils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java
@@ -56,37 +56,25 @@
public static void updateLocationEnabled(Context context, boolean enabled, int userId,
int source) {
+ LocationManager locationManager = context.getSystemService(LocationManager.class);
+
Settings.Secure.putIntForUser(
context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source,
userId);
- Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION);
- final int oldMode = Settings.Secure.getIntForUser(context.getContentResolver(),
- Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, userId);
+ Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION);
+ final int oldMode = locationManager.isLocationEnabled()
+ ? Settings.Secure.LOCATION_MODE_ON
+ : Settings.Secure.LOCATION_MODE_OFF;
final int newMode = enabled
- ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY
+ ? Settings.Secure.LOCATION_MODE_ON
: Settings.Secure.LOCATION_MODE_OFF;
intent.putExtra(CURRENT_MODE_KEY, oldMode);
intent.putExtra(NEW_MODE_KEY, newMode);
context.sendBroadcastAsUser(
intent, UserHandle.of(userId), android.Manifest.permission.WRITE_SECURE_SETTINGS);
- LocationManager locationManager =
- (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
- locationManager.setLocationEnabledForUser(enabled, UserHandle.of(userId));
- }
- public static boolean updateLocationMode(Context context, int oldMode, int newMode, int userId,
- int source) {
- Settings.Secure.putIntForUser(
- context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source,
- userId);
- Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION);
- intent.putExtra(CURRENT_MODE_KEY, oldMode);
- intent.putExtra(NEW_MODE_KEY, newMode);
- context.sendBroadcastAsUser(
- intent, UserHandle.of(userId), android.Manifest.permission.WRITE_SECURE_SETTINGS);
- return Settings.Secure.putIntForUser(
- context.getContentResolver(), Settings.Secure.LOCATION_MODE, newMode, userId);
+ locationManager.setLocationEnabledForUser(enabled, UserHandle.of(userId));
}
/**
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java
index 92ebe44..4d76e44 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java
@@ -38,7 +38,6 @@
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
-import android.provider.Settings.Secure;
import android.telephony.ServiceState;
import android.text.TextUtils;
@@ -86,25 +85,6 @@
}
@Test
- public void testUpdateLocationMode_sendBroadcast() {
- int currentUserId = ActivityManager.getCurrentUser();
- Utils.updateLocationMode(
- mContext,
- Secure.LOCATION_MODE_OFF,
- Secure.LOCATION_MODE_HIGH_ACCURACY,
- currentUserId,
- Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS);
-
- verify(mContext).sendBroadcastAsUser(
- argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)),
- ArgumentMatchers.eq(UserHandle.of(currentUserId)),
- ArgumentMatchers.eq(WRITE_SECURE_SETTINGS));
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN))
- .isEqualTo(Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS);
- }
-
- @Test
public void testUpdateLocationEnabled_sendBroadcast() {
int currentUserId = ActivityManager.getCurrentUser();
Utils.updateLocationEnabled(mContext, true, currentUserId,