blob: c07fdeeabe227fe9086cd3e98a413332fdc9238d [file] [log] [blame]
sunnyshao15ec2cf2018-03-29 19:50:20 +08001/*
2 * Copyright (C) 2009 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
17package com.android.settings.backup;
18
Fan Zhang31b21002019-01-16 13:49:47 -080019import android.app.settings.SettingsEnums;
sunnyshao15ec2cf2018-03-29 19:50:20 +080020import android.content.Context;
21import android.provider.SearchIndexableResource;
22
sunnyshao15ec2cf2018-03-29 19:50:20 +080023import com.android.settings.R;
24import com.android.settings.dashboard.DashboardFragment;
25import com.android.settings.search.BaseSearchIndexProvider;
26import com.android.settingslib.search.SearchIndexable;
27
28import java.util.Arrays;
29import java.util.List;
30
31@SearchIndexable
32public class PrivacySettings extends DashboardFragment {
33 private static final String TAG = "PrivacySettings";
34
35 @Override
36 public int getMetricsCategory() {
Fan Zhang31b21002019-01-16 13:49:47 -080037 return SettingsEnums.PRIVACY;
sunnyshao15ec2cf2018-03-29 19:50:20 +080038 }
39
40 @Override
41 protected String getLogTag() {
42 return TAG;
43 }
44
45 @Override
46 protected int getPreferenceScreenResId() {
47 return R.xml.privacy_settings;
48 }
49
50 @Override
51 public int getHelpResource() {
52 return R.string.help_url_backup_reset;
53 }
54
55 @Override
56 public void onAttach(Context context) {
57 super.onAttach(context);
58 updatePrivacySettingsConfigData(context);
59 }
60
61 @Override
62 protected void updatePreferenceStates() {
63 updatePrivacySettingsConfigData(getContext());
64 super.updatePreferenceStates();
65 }
66
67 private void updatePrivacySettingsConfigData(final Context context) {
sunnyshao15ec2cf2018-03-29 19:50:20 +080068 if (PrivacySettingsUtils.isAdminUser(context)) {
Fan Zhang16de45d2018-04-30 13:41:56 -070069 PrivacySettingsUtils.updatePrivacyBuffer(context,
70 PrivacySettingsConfigData.getInstance());
sunnyshao15ec2cf2018-03-29 19:50:20 +080071 }
sunnyshao15ec2cf2018-03-29 19:50:20 +080072 }
73
74 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
Raff Tsai1f30b1c2019-09-12 10:56:13 +080075 new BaseSearchIndexProvider(R.xml.privacy_settings) {
sunnyshao15ec2cf2018-03-29 19:50:20 +080076
77 @Override
78 protected boolean isPageSearchEnabled(Context context) {
79 final BackupSettingsHelper backupHelper = new BackupSettingsHelper(context);
80 return !backupHelper.isBackupProvidedByManufacturer() &&
81 !backupHelper.isIntentProvidedByTransport();
82 }
83 };
84}