Loading res/values/strings.xml +0 −2 Original line number Diff line number Diff line Loading @@ -2827,8 +2827,6 @@ <string name="location_title">My Location</string> <!-- [CHAR LIMIT=30] Title for managed profile location switch --> <string name="managed_profile_location_switch_title">Location for work profile</string> <!-- [CHAR LIMIT=30] Text to show on managed profile location switch if MDM has locked down location access for managed profile--> <string name="managed_profile_location_switch_lockdown">Turned off by your company</string> <!-- [CHAR LIMIT=30] Location settings screen, setting preference screen box label for location mode --> <string name="location_mode_title">Mode</string> <!-- [CHAR LIMIT=30] Location settings screen, high accuracy location mode --> Loading res/xml/location_settings.xml +2 −2 Original line number Diff line number Diff line Loading @@ -27,10 +27,10 @@ android:summary="@string/location_mode_location_off_title" /> <!-- This preference category gets removed if there is no managed profile --> <SwitchPreference <com.android.settingslib.RestrictedSwitchPreference android:key="managed_profile_location_switch" android:title="@string/managed_profile_location_switch_title" android:summary="@string/managed_profile_location_switch_lockdown" settings:useAdminDisabledSummary="true" android:persistent="false" android:enabled="false" android:selectable="true" /> Loading src/com/android/settings/location/LocationSettings.java +23 −40 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; import android.support.v14.preference.SwitchPreference; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; Loading @@ -47,6 +46,7 @@ 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.RestrictedSwitchPreference; import com.android.settingslib.location.RecentLocationApps; import java.util.ArrayList; Loading Loading @@ -104,7 +104,7 @@ public class LocationSettings extends LocationSettingsBase private Switch mSwitch; private boolean mValidListener = false; private UserHandle mManagedProfile; private SwitchPreference mManagedProfileSwitch; private RestrictedSwitchPreference mManagedProfileSwitch; private Preference mLocationMode; private PreferenceCategory mCategoryRecentLocationRequests; /** Receives UPDATE_INTENT */ Loading Loading @@ -253,7 +253,7 @@ public class LocationSettings extends LocationSettingsBase root.removePreference(root.findPreference(KEY_MANAGED_PROFILE_SWITCH)); mManagedProfileSwitch = null; } else { mManagedProfileSwitch = (SwitchPreference)root mManagedProfileSwitch = (RestrictedSwitchPreference)root .findPreference(KEY_MANAGED_PROFILE_SWITCH); mManagedProfileSwitch.setOnPreferenceClickListener(null); } Loading @@ -263,16 +263,18 @@ public class LocationSettings extends LocationSettingsBase if (mManagedProfileSwitch == null) { return; } boolean enabled = mainSwitchOn; int summaryResId = R.string.switch_off_text; mManagedProfileSwitch.setOnPreferenceClickListener(null); final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(), UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile.getIdentifier()); if (mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile) && getAdminRestrictingManagedProfile() != null) { summaryResId = R.string.managed_profile_location_switch_lockdown; enabled = false; } && admin != null) { mManagedProfileSwitch.setDisabledByAdmin(admin); mManagedProfileSwitch.setChecked(false); } else { boolean enabled = mainSwitchOn; mManagedProfileSwitch.setEnabled(enabled); mManagedProfileSwitch.setOnPreferenceClickListener(null); int summaryResId = R.string.switch_off_text; if (!enabled) { mManagedProfileSwitch.setChecked(false); } else { Loading @@ -280,10 +282,12 @@ public class LocationSettings extends LocationSettingsBase mManagedProfileSwitch.setChecked(!isRestricted); summaryResId = (isRestricted ? R.string.switch_off_text : R.string.switch_on_text); mManagedProfileSwitch.setOnPreferenceClickListener(mManagedProfileSwitchClickListener); mManagedProfileSwitch.setOnPreferenceClickListener( mManagedProfileSwitchClickListener); } mManagedProfileSwitch.setSummary(summaryResId); } } /** * Add the settings injected by external apps into the "App Settings" category. Hides the Loading Loading @@ -418,27 +422,6 @@ public class LocationSettings extends LocationSettingsBase } } private ComponentName getAdminRestrictingManagedProfile() { if (mManagedProfile == null) { return null; } DevicePolicyManager dpm = (DevicePolicyManager)getActivity().getSystemService( Context.DEVICE_POLICY_SERVICE); if (dpm == null) { return null; } List<ComponentName> 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; Loading Loading
res/values/strings.xml +0 −2 Original line number Diff line number Diff line Loading @@ -2827,8 +2827,6 @@ <string name="location_title">My Location</string> <!-- [CHAR LIMIT=30] Title for managed profile location switch --> <string name="managed_profile_location_switch_title">Location for work profile</string> <!-- [CHAR LIMIT=30] Text to show on managed profile location switch if MDM has locked down location access for managed profile--> <string name="managed_profile_location_switch_lockdown">Turned off by your company</string> <!-- [CHAR LIMIT=30] Location settings screen, setting preference screen box label for location mode --> <string name="location_mode_title">Mode</string> <!-- [CHAR LIMIT=30] Location settings screen, high accuracy location mode --> Loading
res/xml/location_settings.xml +2 −2 Original line number Diff line number Diff line Loading @@ -27,10 +27,10 @@ android:summary="@string/location_mode_location_off_title" /> <!-- This preference category gets removed if there is no managed profile --> <SwitchPreference <com.android.settingslib.RestrictedSwitchPreference android:key="managed_profile_location_switch" android:title="@string/managed_profile_location_switch_title" android:summary="@string/managed_profile_location_switch_lockdown" settings:useAdminDisabledSummary="true" android:persistent="false" android:enabled="false" android:selectable="true" /> Loading
src/com/android/settings/location/LocationSettings.java +23 −40 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; import android.support.v14.preference.SwitchPreference; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; Loading @@ -47,6 +46,7 @@ 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.RestrictedSwitchPreference; import com.android.settingslib.location.RecentLocationApps; import java.util.ArrayList; Loading Loading @@ -104,7 +104,7 @@ public class LocationSettings extends LocationSettingsBase private Switch mSwitch; private boolean mValidListener = false; private UserHandle mManagedProfile; private SwitchPreference mManagedProfileSwitch; private RestrictedSwitchPreference mManagedProfileSwitch; private Preference mLocationMode; private PreferenceCategory mCategoryRecentLocationRequests; /** Receives UPDATE_INTENT */ Loading Loading @@ -253,7 +253,7 @@ public class LocationSettings extends LocationSettingsBase root.removePreference(root.findPreference(KEY_MANAGED_PROFILE_SWITCH)); mManagedProfileSwitch = null; } else { mManagedProfileSwitch = (SwitchPreference)root mManagedProfileSwitch = (RestrictedSwitchPreference)root .findPreference(KEY_MANAGED_PROFILE_SWITCH); mManagedProfileSwitch.setOnPreferenceClickListener(null); } Loading @@ -263,16 +263,18 @@ public class LocationSettings extends LocationSettingsBase if (mManagedProfileSwitch == null) { return; } boolean enabled = mainSwitchOn; int summaryResId = R.string.switch_off_text; mManagedProfileSwitch.setOnPreferenceClickListener(null); final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(), UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile.getIdentifier()); if (mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile) && getAdminRestrictingManagedProfile() != null) { summaryResId = R.string.managed_profile_location_switch_lockdown; enabled = false; } && admin != null) { mManagedProfileSwitch.setDisabledByAdmin(admin); mManagedProfileSwitch.setChecked(false); } else { boolean enabled = mainSwitchOn; mManagedProfileSwitch.setEnabled(enabled); mManagedProfileSwitch.setOnPreferenceClickListener(null); int summaryResId = R.string.switch_off_text; if (!enabled) { mManagedProfileSwitch.setChecked(false); } else { Loading @@ -280,10 +282,12 @@ public class LocationSettings extends LocationSettingsBase mManagedProfileSwitch.setChecked(!isRestricted); summaryResId = (isRestricted ? R.string.switch_off_text : R.string.switch_on_text); mManagedProfileSwitch.setOnPreferenceClickListener(mManagedProfileSwitchClickListener); mManagedProfileSwitch.setOnPreferenceClickListener( mManagedProfileSwitchClickListener); } mManagedProfileSwitch.setSummary(summaryResId); } } /** * Add the settings injected by external apps into the "App Settings" category. Hides the Loading Loading @@ -418,27 +422,6 @@ public class LocationSettings extends LocationSettingsBase } } private ComponentName getAdminRestrictingManagedProfile() { if (mManagedProfile == null) { return null; } DevicePolicyManager dpm = (DevicePolicyManager)getActivity().getSystemService( Context.DEVICE_POLICY_SERVICE); if (dpm == null) { return null; } List<ComponentName> 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; Loading