diff --git a/res/values/strings.xml b/res/values/strings.xml index ecc465ec676..67b5eaa0b43 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2806,8 +2806,6 @@ My Location - - Work profile Location for work profile diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml index 2cd86f5d3c7..4ccc14a8d51 100644 --- a/res/xml/location_settings.xml +++ b/res/xml/location_settings.xml @@ -27,19 +27,13 @@ android:summary="@string/location_mode_location_off_title" /> - - - - - + admins = dpm.getActiveAdminsAsUser(mManagedProfile.getIdentifier()); + for (int i = 0; i < admins.size(); ++i) { + final ComponentName admin = admins.get(i); + Bundle restrictions = dpm.getUserRestrictions(admin, mManagedProfile.getIdentifier()); + if (restrictions != null && restrictions.getBoolean(UserManager.DISALLOW_SHARE_LOCATION, + false)) { + return admin; + } + } + return null; + } + + private boolean isManagedProfileRestrictedByBase() { + if (mManagedProfile == null) { + return false; + } + return mUm.hasBaseUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile); + } + + private Preference.OnPreferenceClickListener mManagedProfileSwitchClickListener = + new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + final boolean switchState = mManagedProfileSwitch.isChecked(); + mUm.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, + !switchState, mManagedProfile); + mManagedProfileSwitch.setSummary(switchState ? + R.string.switch_on_text : R.string.switch_off_text); + return true; + } + }; + private class PackageEntryClickedListener implements Preference.OnPreferenceClickListener { private String mPackage;