1 /*
2  * Copyright (C) 2019 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.car.developeroptions.fuelgauge.batterysaver;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.os.Bundle;
22 import android.provider.SearchIndexableResource;
23 
24 import com.android.car.developeroptions.R;
25 import com.android.car.developeroptions.dashboard.DashboardFragment;
26 import com.android.car.developeroptions.search.BaseSearchIndexProvider;
27 import com.android.car.developeroptions.search.Indexable;
28 import com.android.settingslib.search.SearchIndexable;
29 
30 import java.util.Arrays;
31 import java.util.List;
32 
33 /**
34  * Battery saver settings page
35  */
36 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
37 public class BatterySaverSettings extends DashboardFragment {
38     private static final String TAG = "BatterySaverSettings";
39 
40     @Override
onActivityCreated(Bundle savedInstanceState)41     public void onActivityCreated(Bundle savedInstanceState) {
42         super.onActivityCreated(savedInstanceState);
43     }
44 
45     @Override
getMetricsCategory()46     public int getMetricsCategory() {
47         return SettingsEnums.FUELGAUGE_BATTERY_SAVER;
48     }
49 
50     @Override
getPreferenceScreenResId()51     protected int getPreferenceScreenResId() {
52         return R.xml.battery_saver_settings;
53     }
54 
55     @Override
getLogTag()56     protected String getLogTag() {
57         return TAG;
58     }
59 
60     @Override
getHelpResource()61     public int getHelpResource() {
62         return R.string.help_url_battery_saver_settings;
63     }
64 
65     /**
66      * For Search.
67      */
68     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
69             new BaseSearchIndexProvider() {
70                 @Override
71                 public List<SearchIndexableResource> getXmlResourcesToIndex(
72                         Context context, boolean enabled) {
73                     final SearchIndexableResource sir = new SearchIndexableResource(context);
74                     sir.xmlResId = R.xml.battery_saver_settings;
75                     return Arrays.asList(sir);
76                 }
77             };
78 }
79