SpecialAccessSettings.java revision 1d583e125faf3ae4c9cd82636d8f3ecf1cdec3aa
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
15package com.android.settings.applications;
16
17import android.app.ActivityManager;
18import android.content.Context;
19import android.os.Bundle;
20import android.provider.SearchIndexableResource;
21import android.support.v7.preference.Preference;
22
23import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
24import com.android.settings.R;
25import com.android.settings.dashboard.DashboardFragment;
26import com.android.settings.search.BaseSearchIndexProvider;
27import com.android.settings.search.Indexable;
28import com.android.settingslib.core.AbstractPreferenceController;
29
30import java.util.ArrayList;
31import java.util.List;
32
33public class SpecialAccessSettings extends DashboardFragment {
34
35    private static final String TAG = "SpecialAccessSettings";
36
37    private static final String[] DISABLED_FEATURES_LOW_RAM =
38            new String[] {"notification_access", "zen_access", "enabled_vr_listeners"};
39
40    @Override
41    protected String getLogTag() {
42        return TAG;
43    }
44
45    @Override
46    protected int getPreferenceScreenResId() {
47        return R.xml.special_access;
48    }
49
50    @Override
51    public void onCreate(Bundle icicle) {
52        super.onCreate(icicle);
53
54        if (ActivityManager.isLowRamDeviceStatic()) {
55            for (String disabledFeature : DISABLED_FEATURES_LOW_RAM) {
56                Preference pref = findPreference(disabledFeature);
57                if (pref != null) {
58                    removePreference(disabledFeature);
59                }
60            }
61        }
62    }
63
64    @Override
65    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
66        return null;
67    }
68
69    @Override
70    public int getMetricsCategory() {
71        return MetricsEvent.SPECIAL_ACCESS;
72    }
73
74    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
75            new BaseSearchIndexProvider() {
76                @Override
77                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
78                        boolean enabled) {
79                    final ArrayList<SearchIndexableResource> result = new ArrayList<>();
80
81                    final SearchIndexableResource sir = new SearchIndexableResource(context);
82                    sir.xmlResId = R.xml.special_access;
83                    result.add(sir);
84                    return result;
85                }
86            };
87}
88