blob: 684956e5a6e816bed2c95c695a00898005595c2f [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
19import android.content.Context;
20import android.provider.SearchIndexableResource;
21
22import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
23import 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() {
37 return MetricsEvent.PRIVACY;
38 }
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 =
75 new BaseSearchIndexProvider() {
76 @Override
77 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
78 boolean enabled) {
79 final SearchIndexableResource sir = new SearchIndexableResource(context);
80 sir.xmlResId = R.xml.privacy_settings;
81 return Arrays.asList(sir);
82 }
83
84 @Override
85 protected boolean isPageSearchEnabled(Context context) {
86 final BackupSettingsHelper backupHelper = new BackupSettingsHelper(context);
87 return !backupHelper.isBackupProvidedByManufacturer() &&
88 !backupHelper.isIntentProvidedByTransport();
89 }
90 };
91}