1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package com.android.settings.applications; 16 17 import android.app.ActivityManager; 18 import android.content.Context; 19 import android.os.Bundle; 20 import android.provider.SearchIndexableResource; 21 import android.support.v7.preference.Preference; 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.settings.search.Indexable; 27 import com.android.settingslib.core.AbstractPreferenceController; 28 import java.util.ArrayList; 29 import java.util.List; 30 31 public class SpecialAccessSettings extends DashboardFragment { 32 33 private static final String TAG = "SpecialAccessSettings"; 34 35 private static final String[] DISABLED_FEATURES_LOW_RAM = 36 new String[]{"notification_access", "zen_access", "enabled_vr_listeners", 37 "picture_in_picture"}; 38 39 @Override 40 protected String getLogTag() { 41 return TAG; 42 } 43 44 @Override 45 protected int getPreferenceScreenResId() { 46 return R.xml.special_access; 47 } 48 49 @Override 50 public void onCreate(Bundle icicle) { 51 super.onCreate(icicle); 52 53 if (ActivityManager.isLowRamDeviceStatic()) { 54 for (String disabledFeature : DISABLED_FEATURES_LOW_RAM) { 55 Preference pref = findPreference(disabledFeature); 56 if (pref != null) { 57 removePreference(disabledFeature); 58 } 59 } 60 } 61 } 62 63 @Override 64 protected List<AbstractPreferenceController> getPreferenceControllers(Context context) { 65 return null; 66 } 67 68 @Override 69 public int getMetricsCategory() { 70 return MetricsEvent.SPECIAL_ACCESS; 71 } 72 73 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 74 new BaseSearchIndexProvider() { 75 @Override 76 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 77 boolean enabled) { 78 final ArrayList<SearchIndexableResource> result = new ArrayList<>(); 79 80 final SearchIndexableResource sir = new SearchIndexableResource(context); 81 sir.xmlResId = R.xml.special_access; 82 result.add(sir); 83 return result; 84 } 85 }; 86 } 87