Add padlocks to more preferences that can be disabled by policy.

Change-Id: I7cc999dd1d46c20c888e0ba67053564e4d50946b
This commit is contained in:
Sudheer Shanka
2016-01-18 11:17:23 +00:00
parent 4ccc2c3537
commit 9c32468cd5
12 changed files with 149 additions and 49 deletions

View File

@@ -46,6 +46,7 @@ import com.android.settings.Utils;
import com.android.settings.applications.InstalledAppDetails;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.location.RecentLocationApps;
import java.util.ArrayList;
@@ -53,6 +54,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
/**
* System location settings (Settings > Location). The screen has three parts:
* <ul>
@@ -373,9 +376,15 @@ public class LocationSettings extends LocationSettingsBase
// corner cases, the location might still be enabled. In such case the master switch should
// be disabled but checked.
final boolean enabled = (mode != android.provider.Settings.Secure.LOCATION_MODE_OFF);
EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(),
UserManager.DISALLOW_SHARE_LOCATION, UserHandle.myUserId());
// Disable the whole switch bar instead of the switch itself. If we disabled the switch
// only, it would be re-enabled again if the switch bar is not disabled.
mSwitchBar.setEnabled(!restricted);
if (admin != null) {
mSwitchBar.setDisabledByAdmin(admin);
} else {
mSwitchBar.setEnabled(!restricted);
}
mLocationMode.setEnabled(enabled && !restricted);
mCategoryRecentLocationRequests.setEnabled(enabled);