1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.enterprise; 18 19 import android.content.Context; 20 import android.provider.SearchIndexableResource; 21 22 import com.android.settings.R; 23 import com.android.settings.widget.PreferenceCategoryController; 24 import com.android.settingslib.core.AbstractPreferenceController; 25 26 import java.util.ArrayList; 27 import java.util.Collections; 28 import java.util.List; 29 30 /** Privacy Settings preferences for an Enterprise device. */ 31 public class PrivacySettingsEnterprisePreference implements PrivacySettingsPreference { 32 private static final String KEY_EXPOSURE_CHANGES_CATEGORY = "exposure_changes_category"; 33 34 private final Context mContext; 35 PrivacySettingsEnterprisePreference(Context context)36 public PrivacySettingsEnterprisePreference(Context context) { 37 mContext = context.getApplicationContext(); 38 } 39 40 /** 41 * Returns the XML Res Id that is used for an Enterprise device in the Privacy Settings screen. 42 */ 43 @Override getPreferenceScreenResId()44 public int getPreferenceScreenResId() { 45 return R.xml.enterprise_privacy_settings; 46 } 47 48 /** 49 * Returns the Enterprise XML resources to index for an Enterprise device. 50 */ 51 @Override getXmlResourcesToIndex()52 public List<SearchIndexableResource> getXmlResourcesToIndex() { 53 final SearchIndexableResource sir = new SearchIndexableResource(mContext); 54 sir.xmlResId = getPreferenceScreenResId(); 55 return Collections.singletonList(sir); 56 } 57 58 /** 59 * Returns the preference controllers used to populate the privacy preferences in the Privacy 60 * Settings screen for Enterprise devices. 61 */ 62 @Override createPreferenceControllers(boolean async)63 public List<AbstractPreferenceController> createPreferenceControllers(boolean async) { 64 final List<AbstractPreferenceController> controllers = new ArrayList<>(); 65 controllers.add(new NetworkLogsPreferenceController(mContext)); 66 controllers.add(new BugReportsPreferenceController(mContext)); 67 controllers.add(new SecurityLogsPreferenceController(mContext)); 68 final List<AbstractPreferenceController> exposureChangesCategoryControllers = 69 new ArrayList<>(); 70 exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController( 71 mContext, async)); 72 exposureChangesCategoryControllers.add( 73 new AdminGrantedLocationPermissionsPreferenceController(mContext, async)); 74 exposureChangesCategoryControllers.add( 75 new AdminGrantedMicrophonePermissionPreferenceController(mContext, async)); 76 exposureChangesCategoryControllers.add(new AdminGrantedCameraPermissionPreferenceController( 77 mContext, async)); 78 exposureChangesCategoryControllers.add(new EnterpriseSetDefaultAppsPreferenceController( 79 mContext)); 80 exposureChangesCategoryControllers.add(new AlwaysOnVpnCurrentUserPreferenceController( 81 mContext)); 82 exposureChangesCategoryControllers.add(new AlwaysOnVpnManagedProfilePreferenceController( 83 mContext)); 84 exposureChangesCategoryControllers.add(new ImePreferenceController(mContext)); 85 exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(mContext)); 86 exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController( 87 mContext)); 88 exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController( 89 mContext)); 90 controllers.addAll(exposureChangesCategoryControllers); 91 controllers.add(new PreferenceCategoryController(mContext, KEY_EXPOSURE_CHANGES_CATEGORY) 92 .setChildren(exposureChangesCategoryControllers)); 93 controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(mContext)); 94 controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(mContext)); 95 return controllers; 96 } 97 } 98