ConfigureWifiSettings.java revision 3aa547b50d09ea901ac4e649e7029345af97f32e
1/* 2 * Copyright (C) 2015 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 */ 16package com.android.settings.wifi; 17 18import static android.content.Context.WIFI_SERVICE; 19 20import android.content.Context; 21import android.net.wifi.WifiManager; 22import android.provider.SearchIndexableResource; 23 24import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 25import com.android.settings.R; 26import com.android.settings.core.PreferenceController; 27import com.android.settings.dashboard.DashboardFragment; 28import com.android.settings.search.BaseSearchIndexProvider; 29import com.android.settings.search.Indexable; 30 31import java.util.ArrayList; 32import java.util.Arrays; 33import java.util.List; 34 35public class ConfigureWifiSettings extends DashboardFragment { 36 37 private static final String TAG = "ConfigureWifiSettings"; 38 39 private WifiManager mWifiManager; 40 41 @Override 42 public int getMetricsCategory() { 43 return MetricsEvent.CONFIGURE_WIFI; 44 } 45 46 @Override 47 protected String getCategoryKey() { 48 // We don't want to inject any external settings into this screen. 49 return null; 50 } 51 52 @Override 53 protected String getLogTag() { 54 return TAG; 55 } 56 57 @Override 58 protected int getPreferenceScreenResId() { 59 return R.xml.wifi_configure_settings; 60 } 61 62 @Override 63 protected List<PreferenceController> getPreferenceControllers(Context context) { 64 mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); 65 final List<PreferenceController> controllers = new ArrayList<>(); 66 controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), mWifiManager)); 67 controllers.add(new SavedNetworkPreferenceController(context, mWifiManager)); 68 controllers.add(new NotifyOpenNetworksPreferenceController(context, mWifiManager)); 69 controllers.add(new CellularFallbackPreferenceController(context)); 70 controllers.add(new AllowRecommendationPreferenceController(context)); 71 controllers.add(new WifiSleepPolicyPreferenceController(context)); 72 return controllers; 73 } 74 75 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 76 new BaseSearchIndexProvider() { 77 @Override 78 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 79 boolean enabled) { 80 final SearchIndexableResource sir = new SearchIndexableResource(context); 81 sir.xmlResId = R.xml.wifi_configure_settings; 82 return Arrays.asList(sir); 83 } 84 }; 85} 86