1 /* 2 * Copyright (C) 2017 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.security; 18 19 import static com.android.settings.security.EncryptionStatusPreferenceController.PREF_KEY_ENCRYPTION_DETAIL_PAGE; 20 21 import android.app.settings.SettingsEnums; 22 import android.content.Context; 23 24 import com.android.settings.R; 25 import com.android.settings.dashboard.DashboardFragment; 26 import com.android.settings.search.BaseSearchIndexProvider; 27 import com.android.settings.widget.PreferenceCategoryController; 28 import com.android.settingslib.core.AbstractPreferenceController; 29 import com.android.settingslib.core.lifecycle.Lifecycle; 30 import com.android.settingslib.search.SearchIndexable; 31 32 import java.util.ArrayList; 33 import java.util.Arrays; 34 import java.util.List; 35 36 /** 37 * Encryption and Credential settings. 38 */ 39 @SearchIndexable 40 public class EncryptionAndCredential extends DashboardFragment { 41 42 private static final String TAG = "EncryptionAndCredential"; 43 44 @Override getMetricsCategory()45 public int getMetricsCategory() { 46 return SettingsEnums.ENCRYPTION_AND_CREDENTIAL; 47 } 48 49 @Override getLogTag()50 protected String getLogTag() { 51 return TAG; 52 } 53 54 @Override createPreferenceControllers(Context context)55 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 56 return buildPreferenceControllers(context, getSettingsLifecycle()); 57 } 58 59 @Override getPreferenceScreenResId()60 protected int getPreferenceScreenResId() { 61 return R.xml.encryption_and_credential; 62 } 63 buildPreferenceControllers(Context context, Lifecycle lifecycle)64 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 65 Lifecycle lifecycle) { 66 final List<AbstractPreferenceController> controllers = new ArrayList<>(); 67 final EncryptionStatusPreferenceController encryptStatusController = 68 new EncryptionStatusPreferenceController(context, 69 PREF_KEY_ENCRYPTION_DETAIL_PAGE); 70 controllers.add(encryptStatusController); 71 controllers.add(new PreferenceCategoryController(context, 72 "encryption_and_credentials_status_category").setChildren( 73 Arrays.asList(encryptStatusController))); 74 controllers.add(new UserCredentialsPreferenceController(context)); 75 controllers.add(new ResetCredentialsPreferenceController(context, lifecycle)); 76 controllers.add(new InstallCertificatePreferenceController(context)); 77 return controllers; 78 } 79 80 @Override getHelpResource()81 public int getHelpResource() { 82 return R.string.help_url_encryption; 83 } 84 85 /** 86 * For Search. Please keep it in sync when updating "createPreferenceHierarchy()" 87 */ 88 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 89 new BaseSearchIndexProvider(R.xml.encryption_and_credential) { 90 @Override 91 public List<AbstractPreferenceController> createPreferenceControllers( 92 Context context) { 93 return buildPreferenceControllers(context, null /* lifecycle */); 94 } 95 96 @Override 97 protected boolean isPageSearchEnabled(Context context) { 98 return true; 99 } 100 }; 101 } 102