Merge "Send broadcast when location mode is about to change DO NOT MERGE"
am: 1c05be48ae -s ours
Change-Id: Ia443491992c0b28a15d93ca344e9b20c0a111548
diff --git a/src/com/android/settings/location/LocationSettingsBase.java b/src/com/android/settings/location/LocationSettingsBase.java
index 1ea21b6..741d607 100644
--- a/src/com/android/settings/location/LocationSettingsBase.java
+++ b/src/com/android/settings/location/LocationSettingsBase.java
@@ -16,7 +16,6 @@
package com.android.settings.location;
-import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -29,14 +28,17 @@
import com.android.settings.SettingsPreferenceFragment;
-import static com.android.settingslib.Utils.updateLocationMode;
-
/**
* A base class that listens to location settings change and modifies location
* settings.
*/
public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
private static final String TAG = "LocationSettingsBase";
+ /** Broadcast intent action when the location mode is about to change. */
+ private static final String MODE_CHANGING_ACTION =
+ "com.android.settings.location.MODE_CHANGING";
+ private static final String CURRENT_MODE_KEY = "CURRENT_MODE";
+ private static final String NEW_MODE_KEY = "NEW_MODE";
private int mCurrentMode;
private BroadcastReceiver mReceiver;
@@ -88,6 +90,15 @@
return um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION);
}
+ public static boolean updateLocationMode(Context context, int oldMode, int newMode) {
+ Intent intent = new Intent(MODE_CHANGING_ACTION);
+ intent.putExtra(CURRENT_MODE_KEY, oldMode);
+ intent.putExtra(NEW_MODE_KEY, newMode);
+ context.sendBroadcast(intent, android.Manifest.permission.WRITE_SECURE_SETTINGS);
+ return Settings.Secure.putInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE,
+ newMode);
+ }
+
public void setLocationMode(int mode) {
Context context = getActivity();
if (isRestricted(context)) {
@@ -104,7 +115,7 @@
return;
}
- updateLocationMode(context, mCurrentMode, mode, ActivityManager.getCurrentUser());
+ updateLocationMode(context, mCurrentMode, mode);
refreshLocationMode();
}