OSDN Git Service

Separate personal/work tab in LocationSettings
authorRaff Tsai <rafftsai@google.com>
Fri, 22 Nov 2019 08:36:21 +0000 (16:36 +0800)
committerRaff Tsai <rafftsai@google.com>
Tue, 26 Nov 2019 09:21:55 +0000 (17:21 +0800)
- Add LocationPersonalSettings for personal location Settings
- Add LocationWorkProfileSettings for workprofile location settings

Bug: 141601408
Test: manual
Change-Id: Iaaa3a1db5abe02881c4d8afdaec1013ab5552eb3

14 files changed:
res/values/strings.xml
res/xml/location_settings.xml
res/xml/location_settings_personal.xml [new file with mode: 0644]
res/xml/location_settings_workprofile.xml [new file with mode: 0644]
src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
src/com/android/settings/dashboard/profileselector/ProfileFragmentBridge.java
src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java [new file with mode: 0644]
src/com/android/settings/location/LocationPersonalSettings.java [new file with mode: 0644]
src/com/android/settings/location/LocationServiceForWorkPreferenceController.java [new file with mode: 0644]
src/com/android/settings/location/LocationServicePreferenceController.java
src/com/android/settings/location/LocationSettings.java
src/com/android/settings/location/LocationWorkProfileSettings.java [new file with mode: 0644]
tests/robotests/assets/grandfather_not_implementing_index_provider
tests/robotests/src/com/android/settings/location/LocationServicePreferenceControllerTest.java

index e0b165c..cf19906 100644 (file)
     <string name="location_recent_location_requests_see_all">See all</string>
     <!-- Location settings screen, sub category for location services [CHAR LIMIT=30] -->
     <string name="location_category_location_services">Location services</string>
+    <!-- Location settings screen, sub category for recent work profile app location requests [CHAR LIMIT=NONE] -->
+    <string name="location_category_recent_location_work_requests">Recent work app location requests</string>
 
     <!-- Security & location settings screen, section header for settings relating to location -->
     <string name="location_title">My Location</string>
index 2ad1554..932cb65 100644 (file)
@@ -72,7 +72,8 @@
         <!-- This preference gets removed if there is no managed profile -->
         <PreferenceCategory
             android:key="location_services_managed_profile"
-            android:title="@string/managed_profile_location_services"/>
+            android:title="@string/managed_profile_location_services"
+            settings:controller="com.android.settings.location.LocationServiceForWorkPreferenceController"/>
 
     </PreferenceCategory>
 
diff --git a/res/xml/location_settings_personal.xml b/res/xml/location_settings_personal.xml
new file mode 100644 (file)
index 0000000..f07d0e8
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2019 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="location_settings"
+    android:title="@string/location_settings_title"
+    settings:keywords="@string/keywords_location">
+
+    <PreferenceCategory
+        android:key="recent_location_requests"
+        android:title="@string/location_category_recent_location_requests"
+        settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
+
+    <Preference
+        android:key="recent_location_requests_see_all_button"
+        android:title="@string/location_recent_location_requests_see_all"
+        android:icon="@drawable/ic_chevron_right_24dp"
+        android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
+        settings:searchable="false"/>
+
+    <PreferenceCategory
+        android:key="location_advanced_settings"
+        android:layout="@layout/preference_category_no_label"
+        settings:initialExpandedChildrenCount="2">
+
+        <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+        <Preference
+            android:key="app_level_permissions"
+            android:title="@string/location_app_level_permissions"
+            settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
+        <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+                <extra android:name="android.intent.extra.PERMISSION_NAME"
+                       android:value="android.permission-group.LOCATION"/>
+            </intent>
+        </Preference>
+
+        <Preference
+            android:key="location_scanning"
+            android:title="@string/location_scanning_screen_title"
+            android:fragment="com.android.settings.location.ScanningSettings"
+            settings:controller="com.android.settings.location.LocationScanningPreferenceController"/>
+
+        <PreferenceCategory
+            android:key="location_services"
+            android:layout="@layout/preference_category_no_label"
+            settings:controller="com.android.settings.location.LocationServicePreferenceController"/>
+
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="location_footer"
+        android:layout="@layout/preference_category_no_label"
+        settings:allowDividerAbove="false"
+        settings:controller="com.android.settings.location.LocationFooterPreferenceController"/>
+</PreferenceScreen>
diff --git a/res/xml/location_settings_workprofile.xml b/res/xml/location_settings_workprofile.xml
new file mode 100644 (file)
index 0000000..cb1416d
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2019 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="location_settings"
+    android:title="@string/location_settings_title"
+    settings:keywords="@string/keywords_location">
+
+    <com.android.settingslib.RestrictedSwitchPreference
+        android:key="managed_profile_location_switch"
+        android:title="@string/managed_profile_location_switch_title"
+        settings:useAdminDisabledSummary="true"
+        settings:controller="com.android.settings.location.LocationForWorkPreferenceController"
+        android:enabled="false"
+        android:selectable="true"/>
+
+    <PreferenceCategory
+        android:key="recent_location_requests"
+        android:title="@string/location_category_recent_location_work_requests"
+        settings:controller="com.android.settings.location.RecentLocationRequestPreferenceController"/>
+
+    <Preference
+        android:key="recent_location_requests_see_all_button"
+        android:title="@string/location_recent_location_requests_see_all"
+        android:icon="@drawable/ic_chevron_right_24dp"
+        android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"
+        settings:searchable="false"/>
+
+    <PreferenceCategory
+        android:key="location_advanced_settings"
+        android:layout="@layout/preference_category_no_label"
+        settings:initialExpandedChildrenCount="2">
+
+        <!-- This preference category gets removed if new_recent_location_ui is disabled -->
+        <Preference
+            android:key="app_level_permissions"
+            android:title="@string/location_app_level_permissions"
+            settings:controller="com.android.settings.location.AppLocationPermissionPreferenceController">
+            <intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
+                <extra android:name="android.intent.extra.PERMISSION_NAME"
+                       android:value="android.permission-group.LOCATION"/>
+            </intent>
+        </Preference>
+
+        <PreferenceCategory
+            android:title="@string/managed_profile_location_services"
+            android:layout="@layout/preference_category_no_label"
+            android:key="location_services_managed_profile"
+            settings:controller="com.android.settings.location.LocationServiceForWorkPreferenceController"/>
+
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="location_footer"
+        android:layout="@layout/preference_category_no_label"
+        settings:allowDividerAbove="false"
+        settings:controller="com.android.settings.location.LocationFooterPreferenceController"/>
+</PreferenceScreen>
index a31340a..8dfa934 100644 (file)
@@ -41,7 +41,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
 
     @Override
     public int getMetricsCategory() {
-        return SettingsEnums.ACCOUNT;
+        return SettingsEnums.ACCOUNT_WORK;
     }
 
     @Override
index 047f740..816deca 100644 (file)
@@ -21,6 +21,7 @@ import android.util.ArrayMap;
 import com.android.settings.accounts.AccountDashboardFragment;
 import com.android.settings.applications.manageapplications.ManageApplications;
 import com.android.settings.deviceinfo.StorageDashboardFragment;
+import com.android.settings.location.LocationSettings;
 
 import java.util.Map;
 
@@ -43,5 +44,7 @@ public class ProfileFragmentBridge {
                 ProfileSelectManageApplications.class.getName());
         FRAGMENT_MAP.put(StorageDashboardFragment.class.getName(),
                 ProfileSelectStorageFragment.class.getName());
+        FRAGMENT_MAP.put(LocationSettings.class.getName(),
+                ProfileSelectLocationFragment.class.getName());
     }
 }
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java
new file mode 100644 (file)
index 0000000..b256157
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.dashboard.profileselector;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.location.LocationPersonalSettings;
+import com.android.settings.location.LocationSwitchBarController;
+import com.android.settings.location.LocationWorkProfileSettings;
+import com.android.settings.widget.SwitchBar;
+
+/**
+ * Location Setting page for personal/managed profile.
+ */
+public class ProfileSelectLocationFragment extends ProfileSelectFragment {
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        final SettingsActivity activity = (SettingsActivity) getActivity();
+        final SwitchBar switchBar = activity.getSwitchBar();
+        switchBar.setSwitchBarText(R.string.location_settings_master_switch_title,
+                R.string.location_settings_master_switch_title);
+        final LocationSwitchBarController switchBarController = new LocationSwitchBarController(
+                activity, switchBar, getSettingsLifecycle());
+        switchBar.show();
+    }
+
+    @Override
+    public Fragment[] getFragments() {
+        return new Fragment[]{
+                new LocationPersonalSettings(),
+                new LocationWorkProfileSettings()
+        };
+    }
+}
diff --git a/src/com/android/settings/location/LocationPersonalSettings.java b/src/com/android/settings/location/LocationPersonalSettings.java
new file mode 100644 (file)
index 0000000..503937e
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.location;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+
+/**
+ * Location Setting page for personal profile.
+ */
+public class LocationPersonalSettings extends DashboardFragment {
+
+    private static final String TAG = "LocationPersonal";
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.LOCATION;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.location_settings_personal;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+
+        use(AppLocationPermissionPreferenceController.class).init(this);
+        use(RecentLocationRequestPreferenceController.class).init(this);
+        use(LocationServicePreferenceController.class).init(this);
+        use(LocationFooterPreferenceController.class).init(this);
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_location_access;
+    }
+}
diff --git a/src/com/android/settings/location/LocationServiceForWorkPreferenceController.java b/src/com/android/settings/location/LocationServiceForWorkPreferenceController.java
new file mode 100644 (file)
index 0000000..6b172dd
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.location;
+
+import android.content.Context;
+import android.os.UserHandle;
+
+import androidx.preference.Preference;
+
+import com.android.settings.widget.RestrictedAppPreference;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Retrieve the Location Services used in profile user.
+ */
+public class LocationServiceForWorkPreferenceController extends
+        LocationServicePreferenceController {
+    private static final String TAG = "LocationWorkPrefCtrl";
+
+    public LocationServiceForWorkPreferenceController(Context context, String key) {
+        super(context, key);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        mCategoryLocationServices.removeAll();
+        final Map<Integer, List<Preference>> prefs = getLocationServices();
+        boolean show = 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);
+                show = true;
+            }
+        }
+        mCategoryLocationServices.setVisible(show);
+    }
+}
index 0902573..56a23bd 100644 (file)
@@ -39,19 +39,12 @@ import java.util.Map;
 public class LocationServicePreferenceController extends LocationBasePreferenceController
         implements LifecycleObserver, OnResume, OnPause {
 
-    private static final String TAG = "LocationServicePrefCtrl";
-    /** Key for preference category "Location services" */
-    @VisibleForTesting
-    static final String KEY_LOCATION_SERVICES = "location_services";
-    /** Key for preference category "Location services for work" */
-    @VisibleForTesting
-    static final String KEY_LOCATION_SERVICES_MANAGED = "location_services_managed_profile";
+    private static final String TAG = "LocationPrefCtrl";
     @VisibleForTesting
     static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
             new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
 
-    private PreferenceCategory mCategoryLocationServices;
-    private PreferenceCategory mCategoryLocationServicesManaged;
+    protected PreferenceCategory mCategoryLocationServices;
     @VisibleForTesting
     AppSettingsInjector mInjector;
     /** Receives UPDATE_INTENT */
@@ -71,21 +64,14 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
-        mCategoryLocationServicesManaged = screen.findPreference(KEY_LOCATION_SERVICES_MANAGED);
+        mCategoryLocationServices = screen.findPreference(getPreferenceKey());
     }
 
     @Override
     public void updateState(Preference preference) {
-        if (mCategoryLocationServices != null) {
-            mCategoryLocationServices.removeAll();
-        }
-        if (mCategoryLocationServicesManaged != null) {
-            mCategoryLocationServicesManaged.removeAll();
-        }
+        mCategoryLocationServices.removeAll();
         final Map<Integer, List<Preference>> prefs = getLocationServices();
-        boolean showPrimary = false;
-        boolean showManaged = false;
+        boolean show = false;
         for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
             for (Preference pref : entry.getValue()) {
                 if (pref instanceof RestrictedAppPreference) {
@@ -97,21 +83,10 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
                     LocationSettings.addPreferencesSorted(entry.getValue(),
                             mCategoryLocationServices);
                 }
-                showPrimary = true;
-            } else {
-                if (mCategoryLocationServicesManaged != null) {
-                    LocationSettings.addPreferencesSorted(entry.getValue(),
-                            mCategoryLocationServicesManaged);
-                }
-                showManaged = true;
+                show = true;
             }
         }
-        if (mCategoryLocationServices != null) {
-            mCategoryLocationServices.setVisible(showPrimary);
-        }
-        if (mCategoryLocationServicesManaged != null) {
-            mCategoryLocationServicesManaged.setVisible(showManaged);
-        }
+        mCategoryLocationServices.setVisible(show);
     }
 
     @Override
@@ -143,7 +118,7 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
         mContext.unregisterReceiver(mInjectedSettingsReceiver);
     }
 
-    private Map<Integer, List<Preference>> getLocationServices() {
+    protected 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());
index 3b4c4aa..26a4afd 100644 (file)
@@ -87,6 +87,7 @@ public class LocationSettings extends DashboardFragment {
         use(LocationServicePreferenceController.class).init(this);
         use(LocationFooterPreferenceController.class).init(this);
         use(LocationForWorkPreferenceController.class).init(this);
+        use(LocationServiceForWorkPreferenceController.class).init(this);
     }
 
     @Override
diff --git a/src/com/android/settings/location/LocationWorkProfileSettings.java b/src/com/android/settings/location/LocationWorkProfileSettings.java
new file mode 100644 (file)
index 0000000..2c52211
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.location;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+
+/**
+ * Location Setting page for managed profile.
+ */
+public class LocationWorkProfileSettings extends DashboardFragment {
+
+    private static final String TAG = "LocationWorkProfile";
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.LOCATION_WORK;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.location_settings_workprofile;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+
+        use(AppLocationPermissionPreferenceController.class).init(this);
+        use(RecentLocationRequestPreferenceController.class).init(this);
+        use(LocationServiceForWorkPreferenceController.class).init(this);
+        use(LocationFooterPreferenceController.class).init(this);
+        use(LocationForWorkPreferenceController.class).init(this);
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_location_access;
+    }
+}
index b69d72e..7b80645 100644 (file)
@@ -32,6 +32,7 @@ com.android.settings.bluetooth.DevicePickerFragment
 com.android.settings.dashboard.profileselector.ProfileSelectAccountFragment
 com.android.settings.dashboard.profileselector.ProfileSelectManageApplications
 com.android.settings.dashboard.profileselector.ProfileSelectStorageFragment
+com.android.settings.dashboard.profileselector.ProfileSelectLocationFragment
 com.android.settings.datausage.AppDataUsage
 com.android.settings.datausage.DataUsageList
 com.android.settings.datausage.DataUsageSummary
@@ -53,6 +54,8 @@ com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
 com.android.settings.inputmethod.KeyboardLayoutPickerFragment
 com.android.settings.inputmethod.SpellCheckersSettings
 com.android.settings.localepicker.LocaleListEditor
+com.android.settings.location.LocationPersonalSettings
+com.android.settings.location.LocationWorkProfileSettings
 com.android.settings.network.ApnEditor
 com.android.settings.network.ApnSettings
 com.android.settings.network.telephony.NetworkSelectSettings
index 29048ed..62c13af 100644 (file)
@@ -15,9 +15,6 @@
  */
 package com.android.settings.location;
 
-import static com.android.settings.location.LocationServicePreferenceController.KEY_LOCATION_SERVICES;
-import static com.android.settings.location.LocationServicePreferenceController.KEY_LOCATION_SERVICES_MANAGED;
-
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
@@ -63,6 +60,8 @@ import java.util.Map;
 @Config(shadows = ShadowUserManager.class)
 public class LocationServicePreferenceControllerTest {
 
+    private static final String KEY_LOCATION_SERVICES = "location_service";
+
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private LocationSettings mFragment;
     @Mock
@@ -93,10 +92,7 @@ public class LocationServicePreferenceControllerTest {
         mController.mInjector = mSettingsInjector;
         final String key = mController.getPreferenceKey();
         when(mScreen.findPreference(key)).thenReturn(mCategoryPrimary);
-        when(mScreen.findPreference(KEY_LOCATION_SERVICES_MANAGED)).thenReturn(
-                mCategoryManaged);
         when(mCategoryPrimary.getKey()).thenReturn(key);
-        when(mCategoryManaged.getKey()).thenReturn(KEY_LOCATION_SERVICES_MANAGED);
         when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
                 .thenReturn(mDevicePolicyManager);
     }