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 a financed device. */ 31 public class PrivacySettingsFinancedPreference implements PrivacySettingsPreference { 32 private static final String KEY_EXPOSURE_CHANGES_CATEGORY = "exposure_changes_category"; 33 34 private final Context mContext; 35 PrivacySettingsFinancedPreference(Context context)36 public PrivacySettingsFinancedPreference(Context context) { 37 mContext = context.getApplicationContext(); 38 } 39 40 /** 41 * Returns the XML Res Id that is used for financed devices in the Privacy Settings screen. 42 */ 43 @Override getPreferenceScreenResId()44 public int getPreferenceScreenResId() { 45 return R.xml.financed_privacy_settings; 46 } 47 48 /** 49 * Returns the XML resources to index for a financed 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 a financed device. 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 controllers.addAll(exposureChangesCategoryControllers); 73 controllers.add(new PreferenceCategoryController(mContext, KEY_EXPOSURE_CHANGES_CATEGORY) 74 .setChildren(exposureChangesCategoryControllers)); 75 controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(mContext)); 76 return controllers; 77 } 78 } 79