blob: 9b342e747743f64ecee803f981378545612a2ab6 [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) {
68 final PrivacySettingsConfigData pData = new PrivacySettingsConfigData();
69 if (PrivacySettingsUtils.isAdminUser(context)) {
70 PrivacySettingsUtils.updatePrivacyBuffer(context, pData);
71 }
72
73 use(BackupDataPreferenceController.class).setPrivacySettingsConfigData(pData);
74 use(ConfigureAccountPreferenceController.class).setPrivacySettingsConfigData(pData);
75 use(DataManagementPreferenceController.class).setPrivacySettingsConfigData(pData);
76 use(AutoRestorePreferenceController.class).setPrivacySettingsConfigData(pData);
77 }
78
79 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
80 new BaseSearchIndexProvider() {
81 @Override
82 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
83 boolean enabled) {
84 final SearchIndexableResource sir = new SearchIndexableResource(context);
85 sir.xmlResId = R.xml.privacy_settings;
86 return Arrays.asList(sir);
87 }
88
89 @Override
90 protected boolean isPageSearchEnabled(Context context) {
91 final BackupSettingsHelper backupHelper = new BackupSettingsHelper(context);
92 return !backupHelper.isBackupProvidedByManufacturer() &&
93 !backupHelper.isIntentProvidedByTransport();
94 }
95 };
96}