Merge "Separate personal/work tab in LocationSettings"
This commit is contained in:
@@ -3770,6 +3770,8 @@
|
|||||||
<string name="location_recent_location_requests_see_all">See all</string>
|
<string name="location_recent_location_requests_see_all">See all</string>
|
||||||
<!-- Location settings screen, sub category for location services [CHAR LIMIT=30] -->
|
<!-- Location settings screen, sub category for location services [CHAR LIMIT=30] -->
|
||||||
<string name="location_category_location_services">Location services</string>
|
<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 -->
|
<!-- Security & location settings screen, section header for settings relating to location -->
|
||||||
<string name="location_title">My Location</string>
|
<string name="location_title">My Location</string>
|
||||||
|
@@ -72,7 +72,8 @@
|
|||||||
<!-- This preference gets removed if there is no managed profile -->
|
<!-- This preference gets removed if there is no managed profile -->
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="location_services_managed_profile"
|
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>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
71
res/xml/location_settings_personal.xml
Normal file
71
res/xml/location_settings_personal.xml
Normal file
@@ -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>
|
74
res/xml/location_settings_workprofile.xml
Normal file
74
res/xml/location_settings_workprofile.xml
Normal file
@@ -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>
|
@@ -41,7 +41,7 @@ public class AccountWorkProfileDashboardFragment extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.ACCOUNT;
|
return SettingsEnums.ACCOUNT_WORK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,6 +21,7 @@ import android.util.ArrayMap;
|
|||||||
import com.android.settings.accounts.AccountDashboardFragment;
|
import com.android.settings.accounts.AccountDashboardFragment;
|
||||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||||
import com.android.settings.deviceinfo.StorageDashboardFragment;
|
import com.android.settings.deviceinfo.StorageDashboardFragment;
|
||||||
|
import com.android.settings.location.LocationSettings;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -43,5 +44,7 @@ public class ProfileFragmentBridge {
|
|||||||
ProfileSelectManageApplications.class.getName());
|
ProfileSelectManageApplications.class.getName());
|
||||||
FRAGMENT_MAP.put(StorageDashboardFragment.class.getName(),
|
FRAGMENT_MAP.put(StorageDashboardFragment.class.getName(),
|
||||||
ProfileSelectStorageFragment.class.getName());
|
ProfileSelectStorageFragment.class.getName());
|
||||||
|
FRAGMENT_MAP.put(LocationSettings.class.getName(),
|
||||||
|
ProfileSelectLocationFragment.class.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -39,19 +39,12 @@ import java.util.Map;
|
|||||||
public class LocationServicePreferenceController extends LocationBasePreferenceController
|
public class LocationServicePreferenceController extends LocationBasePreferenceController
|
||||||
implements LifecycleObserver, OnResume, OnPause {
|
implements LifecycleObserver, OnResume, OnPause {
|
||||||
|
|
||||||
private static final String TAG = "LocationServicePrefCtrl";
|
private static final String TAG = "LocationPrefCtrl";
|
||||||
/** 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";
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
|
static final IntentFilter INTENT_FILTER_INJECTED_SETTING_CHANGED =
|
||||||
new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
|
new IntentFilter(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
|
||||||
|
|
||||||
private PreferenceCategory mCategoryLocationServices;
|
protected PreferenceCategory mCategoryLocationServices;
|
||||||
private PreferenceCategory mCategoryLocationServicesManaged;
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
AppSettingsInjector mInjector;
|
AppSettingsInjector mInjector;
|
||||||
/** Receives UPDATE_INTENT */
|
/** Receives UPDATE_INTENT */
|
||||||
@@ -71,21 +64,14 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
|
|||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
|
mCategoryLocationServices = screen.findPreference(getPreferenceKey());
|
||||||
mCategoryLocationServicesManaged = screen.findPreference(KEY_LOCATION_SERVICES_MANAGED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
if (mCategoryLocationServices != null) {
|
mCategoryLocationServices.removeAll();
|
||||||
mCategoryLocationServices.removeAll();
|
|
||||||
}
|
|
||||||
if (mCategoryLocationServicesManaged != null) {
|
|
||||||
mCategoryLocationServicesManaged.removeAll();
|
|
||||||
}
|
|
||||||
final Map<Integer, List<Preference>> prefs = getLocationServices();
|
final Map<Integer, List<Preference>> prefs = getLocationServices();
|
||||||
boolean showPrimary = false;
|
boolean show = false;
|
||||||
boolean showManaged = false;
|
|
||||||
for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
|
for (Map.Entry<Integer, List<Preference>> entry : prefs.entrySet()) {
|
||||||
for (Preference pref : entry.getValue()) {
|
for (Preference pref : entry.getValue()) {
|
||||||
if (pref instanceof RestrictedAppPreference) {
|
if (pref instanceof RestrictedAppPreference) {
|
||||||
@@ -97,21 +83,10 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
|
|||||||
LocationSettings.addPreferencesSorted(entry.getValue(),
|
LocationSettings.addPreferencesSorted(entry.getValue(),
|
||||||
mCategoryLocationServices);
|
mCategoryLocationServices);
|
||||||
}
|
}
|
||||||
showPrimary = true;
|
show = true;
|
||||||
} else {
|
|
||||||
if (mCategoryLocationServicesManaged != null) {
|
|
||||||
LocationSettings.addPreferencesSorted(entry.getValue(),
|
|
||||||
mCategoryLocationServicesManaged);
|
|
||||||
}
|
|
||||||
showManaged = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mCategoryLocationServices != null) {
|
mCategoryLocationServices.setVisible(show);
|
||||||
mCategoryLocationServices.setVisible(showPrimary);
|
|
||||||
}
|
|
||||||
if (mCategoryLocationServicesManaged != null) {
|
|
||||||
mCategoryLocationServicesManaged.setVisible(showManaged);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,7 +118,7 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
|
|||||||
mContext.unregisterReceiver(mInjectedSettingsReceiver);
|
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
|
// If location access is locked down by device policy then we only show injected settings
|
||||||
// for the primary profile.
|
// for the primary profile.
|
||||||
final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
|
final int profileUserId = Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
|
||||||
|
@@ -87,6 +87,7 @@ public class LocationSettings extends DashboardFragment {
|
|||||||
use(LocationServicePreferenceController.class).init(this);
|
use(LocationServicePreferenceController.class).init(this);
|
||||||
use(LocationFooterPreferenceController.class).init(this);
|
use(LocationFooterPreferenceController.class).init(this);
|
||||||
use(LocationForWorkPreferenceController.class).init(this);
|
use(LocationForWorkPreferenceController.class).init(this);
|
||||||
|
use(LocationServiceForWorkPreferenceController.class).init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
@@ -32,6 +32,7 @@ com.android.settings.bluetooth.DevicePickerFragment
|
|||||||
com.android.settings.dashboard.profileselector.ProfileSelectAccountFragment
|
com.android.settings.dashboard.profileselector.ProfileSelectAccountFragment
|
||||||
com.android.settings.dashboard.profileselector.ProfileSelectManageApplications
|
com.android.settings.dashboard.profileselector.ProfileSelectManageApplications
|
||||||
com.android.settings.dashboard.profileselector.ProfileSelectStorageFragment
|
com.android.settings.dashboard.profileselector.ProfileSelectStorageFragment
|
||||||
|
com.android.settings.dashboard.profileselector.ProfileSelectLocationFragment
|
||||||
com.android.settings.datausage.AppDataUsage
|
com.android.settings.datausage.AppDataUsage
|
||||||
com.android.settings.datausage.DataUsageList
|
com.android.settings.datausage.DataUsageList
|
||||||
com.android.settings.datausage.DataUsageSummary
|
com.android.settings.datausage.DataUsageSummary
|
||||||
@@ -54,6 +55,8 @@ com.android.settings.inputmethod.InputMethodAndSubtypeEnabler
|
|||||||
com.android.settings.inputmethod.KeyboardLayoutPickerFragment
|
com.android.settings.inputmethod.KeyboardLayoutPickerFragment
|
||||||
com.android.settings.inputmethod.SpellCheckersSettings
|
com.android.settings.inputmethod.SpellCheckersSettings
|
||||||
com.android.settings.localepicker.LocaleListEditor
|
com.android.settings.localepicker.LocaleListEditor
|
||||||
|
com.android.settings.location.LocationPersonalSettings
|
||||||
|
com.android.settings.location.LocationWorkProfileSettings
|
||||||
com.android.settings.network.ApnEditor
|
com.android.settings.network.ApnEditor
|
||||||
com.android.settings.network.ApnSettings
|
com.android.settings.network.ApnSettings
|
||||||
com.android.settings.network.telephony.NetworkSelectSettings
|
com.android.settings.network.telephony.NetworkSelectSettings
|
||||||
|
@@ -15,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.location;
|
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 com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
@@ -63,6 +60,8 @@ import java.util.Map;
|
|||||||
@Config(shadows = ShadowUserManager.class)
|
@Config(shadows = ShadowUserManager.class)
|
||||||
public class LocationServicePreferenceControllerTest {
|
public class LocationServicePreferenceControllerTest {
|
||||||
|
|
||||||
|
private static final String KEY_LOCATION_SERVICES = "location_service";
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private LocationSettings mFragment;
|
private LocationSettings mFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -93,10 +92,7 @@ public class LocationServicePreferenceControllerTest {
|
|||||||
mController.mInjector = mSettingsInjector;
|
mController.mInjector = mSettingsInjector;
|
||||||
final String key = mController.getPreferenceKey();
|
final String key = mController.getPreferenceKey();
|
||||||
when(mScreen.findPreference(key)).thenReturn(mCategoryPrimary);
|
when(mScreen.findPreference(key)).thenReturn(mCategoryPrimary);
|
||||||
when(mScreen.findPreference(KEY_LOCATION_SERVICES_MANAGED)).thenReturn(
|
|
||||||
mCategoryManaged);
|
|
||||||
when(mCategoryPrimary.getKey()).thenReturn(key);
|
when(mCategoryPrimary.getKey()).thenReturn(key);
|
||||||
when(mCategoryManaged.getKey()).thenReturn(KEY_LOCATION_SERVICES_MANAGED);
|
|
||||||
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user