diff options
author | Lifu Tang <lifu@google.com> | 2019-04-05 13:47:21 -0700 |
---|---|---|
committer | Lifu Tang <lifu@google.com> | 2019-04-09 21:10:44 -0700 |
commit | e531bd01fd6883e3e041a7e4a5c334342fcdc232 (patch) | |
tree | 8b623bbe4d56fbc610119a030040379bcecd18e2 /src/com/android/settings/location | |
parent | f1cea95f3e564c4066a55d2aa27b319bca5b256f (diff) | |
download | packages_apps_Settings-e531bd01fd6883e3e041a7e4a5c334342fcdc232.tar.gz packages_apps_Settings-e531bd01fd6883e3e041a7e4a5c334342fcdc232.tar.bz2 packages_apps_Settings-e531bd01fd6883e3e041a7e4a5c334342fcdc232.zip |
Address UI change request for injected services
- Remove icons from injected items
- Create a separate section for work profile
Bug: 129948280
Test: build, flash, and test manually
Change-Id: Ia64af349c8dd1575d629debd574cdb3ae6eb650d
Diffstat (limited to 'src/com/android/settings/location')
-rw-r--r-- | src/com/android/settings/location/LocationServicePreferenceController.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java index e60426109a..70246cbe3a 100644 --- a/src/com/android/settings/location/LocationServicePreferenceController.java +++ b/src/com/android/settings/location/LocationServicePreferenceController.java @@ -34,6 +34,7 @@ import com.android.settingslib.core.lifecycle.events.OnPause; import com.android.settingslib.core.lifecycle.events.OnResume; import java.util.List; +import java.util.Map; public class LocationServicePreferenceController extends LocationBasePreferenceController implements LifecycleObserver, OnResume, OnPause { @@ -41,14 +42,17 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC private static final String TAG = "LocationServicePrefCtrl"; /** Key for preference category "Location services" */ private static final String KEY_LOCATION_SERVICES = "location_services"; + /** Key for preference category "Location services for work" */ + private static final String KEY_LOCATION_SERVICES_MANAGED = "location_services_managed_profile"; @VisibleForTesting static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED = new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED); private PreferenceCategory mCategoryLocationServices; + private PreferenceCategory mCategoryLocationServicesManaged; private final LocationSettings mFragment; private final AppSettingsInjector mInjector; - /** Receives UPDATE_INTENT */ + /** Receives UPDATE_INTENT */ @VisibleForTesting BroadcastReceiver mInjectedSettingsReceiver; @@ -74,29 +78,36 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC } @Override - public boolean isAvailable() { - // If managed profile has lock-down on location access then its injected location services - // must not be shown. - return mInjector.hasInjectedSettings(mLocationEnabler.isManagedProfileRestrictedByBase() - ? UserHandle.myUserId() : UserHandle.USER_CURRENT); - } - - @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES); + mCategoryLocationServicesManaged = screen.findPreference(KEY_LOCATION_SERVICES_MANAGED); } @Override public void updateState(Preference preference) { mCategoryLocationServices.removeAll(); - final List<Preference> prefs = getLocationServices(); - for (Preference pref : prefs) { - if (pref instanceof RestrictedAppPreference) { - ((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled(); + mCategoryLocationServicesManaged.removeAll(); + final Map<Integer, List<Preference>> prefs = getLocationServices(); + boolean showPrimary = false; + boolean showManaged = false; + for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) { + for (Preference pref : entry.getValue()) { + if (pref instanceof RestrictedAppPreference) { + ((RestrictedAppPreference) pref).checkRestrictionAndSetDisabled(); + } + } + if (entry.getKey() == UserHandle.myUserId()) { + LocationSettings.addPreferencesSorted(entry.getValue(), mCategoryLocationServices); + showPrimary = true; + } else { + LocationSettings.addPreferencesSorted(entry.getValue(), + mCategoryLocationServicesManaged); + showManaged = true; } } - LocationSettings.addPreferencesSorted(prefs, mCategoryLocationServices); + mCategoryLocationServices.setVisible(showPrimary); + mCategoryLocationServicesManaged.setVisible(showManaged); } @Override @@ -128,7 +139,7 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC mContext.unregisterReceiver(mInjectedSettingsReceiver); } - private List<Preference> getLocationServices() { + private Map<Integer, List<Preference>> getLocationServices() { // If location access is locked down by device policy then we only show injected settings // for the primary profile. final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId()); |