summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorLifu Tang <lifu@google.com>2013-08-27 17:09:55 -0700
committerLifu Tang <lifu@google.com>2013-08-28 13:41:20 -0700
commit4fb17c1c9847d8a1a7c2386f3f28b91616e73f4b (patch)
tree985099fef5c7cb277c3695e0bf40ed1c7fd470af /src/com
parent8df4caf168a793d7f17b31ba50e37479b0404022 (diff)
downloadpackages_apps_Settings-4fb17c1c9847d8a1a7c2386f3f28b91616e73f4b.zip
packages_apps_Settings-4fb17c1c9847d8a1a7c2386f3f28b91616e73f4b.tar.gz
packages_apps_Settings-4fb17c1c9847d8a1a7c2386f3f28b91616e73f4b.tar.bz2
Disallows setting when user restriction applies
- Fix b/10116533 Change-Id: Ib171f9545c1651fb36c408decefa47b3d82ba3ab
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/location/LocationMode.java5
-rw-r--r--src/com/android/settings/location/LocationSettings.java6
-rw-r--r--src/com/android/settings/location/LocationSettingsBase.java17
3 files changed, 19 insertions, 9 deletions
diff --git a/src/com/android/settings/location/LocationMode.java b/src/com/android/settings/location/LocationMode.java
index 70cee99..63ba6ea 100644
--- a/src/com/android/settings/location/LocationMode.java
+++ b/src/com/android/settings/location/LocationMode.java
@@ -110,7 +110,7 @@ public class LocationMode extends LocationSettingsBase
}
@Override
- public void onModeChanged(int mode) {
+ public void onModeChanged(int mode, boolean restricted) {
switch (mode) {
case Settings.Secure.LOCATION_MODE_OFF:
Intent intent = new Intent();
@@ -129,7 +129,8 @@ public class LocationMode extends LocationSettingsBase
default:
break;
}
- boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
+
+ boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF) && !restricted;
mHighAccuracy.setEnabled(enabled);
mBatterySaving.setEnabled(enabled);
mSensorsOnly.setEnabled(enabled);
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 818ec2b..815be41 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -28,7 +28,6 @@ import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
-import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.util.Log;
@@ -216,7 +215,7 @@ public class LocationSettings extends LocationSettingsBase
}
@Override
- public void onModeChanged(int mode) {
+ public void onModeChanged(int mode, boolean restricted) {
switch (mode) {
case Settings.Secure.LOCATION_MODE_OFF:
mLocationMode.setSummary(R.string.location_mode_location_off_title);
@@ -234,7 +233,8 @@ public class LocationSettings extends LocationSettingsBase
break;
}
- boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
+ boolean enabled = (mode != Settings.Secure.LOCATION_MODE_OFF) && !restricted;
+ mSwitch.setEnabled(!restricted);
mLocationMode.setEnabled(enabled);
if (enabled != mSwitch.isChecked()) {
diff --git a/src/com/android/settings/location/LocationSettingsBase.java b/src/com/android/settings/location/LocationSettingsBase.java
index 5637b25..630e1e4 100644
--- a/src/com/android/settings/location/LocationSettingsBase.java
+++ b/src/com/android/settings/location/LocationSettingsBase.java
@@ -71,11 +71,20 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
}
/** Called when location mode has changed. */
- public abstract void onModeChanged(int mode);
+ public abstract void onModeChanged(int mode, boolean restricted);
- public void setLocationMode(int mode) {
+ private boolean isRestricted() {
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
- if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
+ return um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION);
+ }
+
+ public void setLocationMode(int mode) {
+ if (isRestricted()) {
+ // Location toggling disabled by user restriction. Read the current location mode to
+ // update the location master switch.
+ mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
+ Settings.Secure.LOCATION_MODE_OFF);
+ onModeChanged(mode, true);
return;
}
Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE, mode);
@@ -85,6 +94,6 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment {
public void refreshLocationMode() {
int mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
Settings.Secure.LOCATION_MODE_OFF);
- onModeChanged(mode);
+ onModeChanged(mode, isRestricted());
}
}