1 /* 2 * Copyright (C) 2016 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.internal.logging.nano.MetricsProto.MetricsEvent; 23 import com.android.settings.R; 24 import com.android.settings.dashboard.DashboardFragment; 25 import com.android.settings.overlay.FeatureFactory; 26 import com.android.settings.search.BaseSearchIndexProvider; 27 import com.android.settings.widget.PreferenceCategoryController; 28 import com.android.settingslib.core.AbstractPreferenceController; 29 30 import java.util.ArrayList; 31 import java.util.Arrays; 32 import java.util.List; 33 34 public class EnterprisePrivacySettings extends DashboardFragment { 35 36 static final String TAG = "EnterprisePrivacySettings"; 37 38 @Override 39 public int getMetricsCategory() { 40 return MetricsEvent.ENTERPRISE_PRIVACY_SETTINGS; 41 } 42 43 @Override 44 protected String getLogTag() { 45 return TAG; 46 } 47 48 @Override 49 protected int getPreferenceScreenResId() { 50 return R.xml.enterprise_privacy_settings; 51 } 52 53 @Override 54 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 55 return buildPreferenceControllers(context, true /* async */); 56 } 57 58 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 59 boolean async) { 60 final List<AbstractPreferenceController> controllers = new ArrayList<>(); 61 controllers.add(new NetworkLogsPreferenceController(context)); 62 controllers.add(new BugReportsPreferenceController(context)); 63 controllers.add(new SecurityLogsPreferenceController(context)); 64 final List<AbstractPreferenceController> exposureChangesCategoryControllers = 65 new ArrayList<>(); 66 exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController( 67 context, async)); 68 exposureChangesCategoryControllers.add( 69 new AdminGrantedLocationPermissionsPreferenceController(context, async)); 70 exposureChangesCategoryControllers.add( 71 new AdminGrantedMicrophonePermissionPreferenceController(context, async)); 72 exposureChangesCategoryControllers.add(new AdminGrantedCameraPermissionPreferenceController( 73 context, async)); 74 exposureChangesCategoryControllers.add(new EnterpriseSetDefaultAppsPreferenceController( 75 context)); 76 exposureChangesCategoryControllers.add(new AlwaysOnVpnCurrentUserPreferenceController( 77 context)); 78 exposureChangesCategoryControllers.add(new AlwaysOnVpnManagedProfilePreferenceController( 79 context)); 80 exposureChangesCategoryControllers.add(new ImePreferenceController(context)); 81 exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(context)); 82 exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(context)); 83 exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController( 84 context)); 85 exposureChangesCategoryControllers.add(new BackupsEnabledPreferenceController(context)); 86 controllers.addAll(exposureChangesCategoryControllers); 87 controllers.add(new PreferenceCategoryController(context, "exposure_changes_category") 88 .setChildren(exposureChangesCategoryControllers)); 89 controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(context)); 90 controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context)); 91 return controllers; 92 } 93 94 public static boolean isPageEnabled(Context context) { 95 return FeatureFactory.getFactory(context) 96 .getEnterprisePrivacyFeatureProvider(context) 97 .hasDeviceOwner(); 98 } 99 100 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 101 new BaseSearchIndexProvider() { 102 @Override 103 protected boolean isPageSearchEnabled(Context context) { 104 return isPageEnabled(context); 105 } 106 107 @Override 108 public List<SearchIndexableResource> getXmlResourcesToIndex( 109 Context context, boolean enabled) { 110 final SearchIndexableResource sir = new SearchIndexableResource(context); 111 sir.xmlResId = R.xml.enterprise_privacy_settings; 112 return Arrays.asList(sir); 113 } 114 115 @Override 116 public List<AbstractPreferenceController> createPreferenceControllers( 117 Context context) { 118 return buildPreferenceControllers(context, false /* async */); 119 } 120 }; 121 } 122