• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.settings.backup;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.provider.SearchIndexableResource;
22 
23 import com.android.settings.R;
24 import com.android.settings.dashboard.DashboardFragment;
25 import com.android.settings.search.BaseSearchIndexProvider;
26 import com.android.settingslib.search.SearchIndexable;
27 
28 import java.util.Arrays;
29 import java.util.List;
30 
31 @SearchIndexable
32 public class PrivacySettings extends DashboardFragment {
33     private static final String TAG = "PrivacySettings";
34 
35     @Override
getMetricsCategory()36     public int getMetricsCategory() {
37         return SettingsEnums.PRIVACY;
38     }
39 
40     @Override
getLogTag()41     protected String getLogTag() {
42         return TAG;
43     }
44 
45     @Override
getPreferenceScreenResId()46     protected int getPreferenceScreenResId() {
47         return R.xml.privacy_settings;
48     }
49 
50     @Override
getHelpResource()51     public int getHelpResource() {
52         return R.string.help_url_backup_reset;
53     }
54 
55     @Override
onAttach(Context context)56     public void onAttach(Context context) {
57         super.onAttach(context);
58         updatePrivacySettingsConfigData(context);
59     }
60 
61     @Override
updatePreferenceStates()62     protected void updatePreferenceStates() {
63         updatePrivacySettingsConfigData(getContext());
64         super.updatePreferenceStates();
65     }
66 
updatePrivacySettingsConfigData(final Context context)67     private void updatePrivacySettingsConfigData(final Context context) {
68         if (PrivacySettingsUtils.isAdminUser(context)) {
69             PrivacySettingsUtils.updatePrivacyBuffer(context,
70                     PrivacySettingsConfigData.getInstance());
71         }
72     }
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 }
92