Move injected services for work into a new page

Screenshots: http://shortn/_0BiBfpkHfh

Bug: 180533061
Test: on device
Change-Id: Ie488c80856b4c4cc67789b8239005f6001ed9d87
This commit is contained in:
Yu-Han Yang
2021-03-05 13:57:46 -08:00
parent cdb3551be1
commit b04a984813
16 changed files with 196 additions and 37 deletions

View File

@@ -27,6 +27,9 @@ import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
/**
* Preference Controller for Location for Work Profile.
*/
public class LocationForWorkPreferenceController extends LocationBasePreferenceController {
private RestrictedSwitchPreference mPreference;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* Copyright (C) 2021 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.
@@ -27,13 +27,13 @@ import java.util.List;
import java.util.Map;
/**
* Retrieve the Location Services used in profile user.
* Retrieve the Location Services used in work profile user.
*/
public class LocationServiceForWorkPreferenceController extends
LocationServicePreferenceController {
public class LocationInjectedServicesForWorkPreferenceController extends
LocationInjectedServicesPreferenceController {
private static final String TAG = "LocationWorkPrefCtrl";
public LocationServiceForWorkPreferenceController(Context context, String key) {
public LocationInjectedServicesForWorkPreferenceController(Context context, String key) {
super(context, key);
}

View File

@@ -1,15 +1,17 @@
/*
* Copyright (C) 2017 The Android Open Source Project
* Copyright (C) 2021 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
* 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.
* 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;
@@ -36,7 +38,10 @@ import com.android.settingslib.core.lifecycle.events.OnResume;
import java.util.List;
import java.util.Map;
public class LocationServicePreferenceController extends LocationBasePreferenceController
/**
* Preference controller for the injected Location Services.
*/
public class LocationInjectedServicesPreferenceController extends LocationBasePreferenceController
implements LifecycleObserver, OnResume, OnPause {
private static final String TAG = "LocationPrefCtrl";
@@ -51,7 +56,7 @@ public class LocationServicePreferenceController extends LocationBasePreferenceC
@VisibleForTesting
BroadcastReceiver mInjectedSettingsReceiver;
public LocationServicePreferenceController(Context context, String key) {
public LocationInjectedServicesPreferenceController(Context context, String key) {
super(context, key);
}

View File

@@ -60,7 +60,7 @@ public class LocationServices extends DashboardFragment {
public void onAttach(Context context) {
super.onAttach(context);
use(LocationServicePreferenceController.class).init(this);
use(LocationInjectedServicesPreferenceController.class).init(this);
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2021 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;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
import java.util.List;
/**
* A page that configures the Location Services settings for work profile.
*/
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class LocationServicesForWork extends DashboardFragment {
private static final String TAG = "LocationServicesForWork";
@Override
public int getMetricsCategory() {
return SettingsEnums.LOCATION_SERVICES;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.location_services_workprofile;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
return buildPreferenceControllers(context);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(LocationInjectedServicesForWorkPreferenceController.class).init(this);
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
return controllers;
}
/**
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.location_services_workprofile) {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(Context
context) {
return buildPreferenceControllers(context);
}
};
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2021 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 com.android.settings.core.BasePreferenceController;
/**
* Preference controller for Location Services for Work Profile.
*/
public class LocationServicesForWorkPreferenceController extends BasePreferenceController {
public LocationServicesForWorkPreferenceController(Context context, String key) {
super(context, key);
}
@Override
public CharSequence getSummary() {
return null;
}
@AvailabilityStatus
public int getAvailabilityStatus() {
return AVAILABLE;
}
}

View File

@@ -23,12 +23,14 @@ import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class LocationScanningPreferenceController extends BasePreferenceController {
/**
* Preference controller for Location Services.
*/
public class LocationServicesPreferenceController extends BasePreferenceController {
private final WifiManager mWifiManager;
public LocationScanningPreferenceController(Context context, String key) {
public LocationServicesPreferenceController(Context context, String key) {
super(context, key);
mWifiManager = context.getSystemService(WifiManager.class);
}
@@ -57,4 +59,4 @@ public class LocationScanningPreferenceController extends BasePreferenceControll
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
}
}

View File

@@ -85,7 +85,7 @@ public class LocationSettings extends DashboardFragment {
use(RecentLocationAccessPreferenceController.class).init(this);
use(LocationFooterPreferenceController.class).init(this);
use(LocationForWorkPreferenceController.class).init(this);
use(LocationServiceForWorkPreferenceController.class).init(this);
use(LocationInjectedServicesForWorkPreferenceController.class).init(this);
}
@Override

View File

@@ -50,7 +50,6 @@ public class LocationWorkProfileSettings extends DashboardFragment {
super.onAttach(context);
use(AppLocationPermissionPreferenceController.class).init(this);
use(LocationServiceForWorkPreferenceController.class).init(this);
use(LocationFooterPreferenceController.class).init(this);
use(LocationForWorkPreferenceController.class).init(this);