| sunnyshao | 15ec2cf | 2018-03-29 19:50:20 +0800 | [diff] [blame] | 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.content.Context; |
| 20 | import android.provider.SearchIndexableResource; |
| 21 | |
| 22 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
| 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 |
| 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) { |
| sunnyshao | 15ec2cf | 2018-03-29 19:50:20 +0800 | [diff] [blame] | 68 | if (PrivacySettingsUtils.isAdminUser(context)) { |
| Fan Zhang | 16de45d | 2018-04-30 13:41:56 -0700 | [diff] [blame^] | 69 | PrivacySettingsUtils.updatePrivacyBuffer(context, |
| 70 | PrivacySettingsConfigData.getInstance()); |
| sunnyshao | 15ec2cf | 2018-03-29 19:50:20 +0800 | [diff] [blame] | 71 | } |
| sunnyshao | 15ec2cf | 2018-03-29 19:50:20 +0800 | [diff] [blame] | 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 | } |