ConfigureWifiSettings.java revision a7b27b22b99e005cecd7b2deab74565683b3998a
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; 30import com.android.settings.wifi.p2p.WifiP2pPreferenceController; 31 32import java.util.ArrayList; 33import java.util.Arrays; 34import java.util.List; 35 36public class ConfigureWifiSettings extends DashboardFragment { 37 38 private static final String TAG = "ConfigureWifiSettings"; 39 40 private WifiManager mWifiManager; 41 42 @Override 43 public int getMetricsCategory() { 44 return MetricsEvent.CONFIGURE_WIFI; 45 } 46 47 @Override 48 protected String getLogTag() { 49 return TAG; 50 } 51 52 @Override 53 public void onAttach(Context context) { 54 super.onAttach(context); 55 mProgressiveDisclosureMixin.setTileLimit(5); 56 } 57 58 @Override 59 protected int getPreferenceScreenResId() { 60 return R.xml.wifi_configure_settings; 61 } 62 63 @Override 64 protected List<PreferenceController> getPreferenceControllers(Context context) { 65 mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); 66 final List<PreferenceController> controllers = new ArrayList<>(); 67 controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), mWifiManager)); 68 controllers.add(new CellularFallbackPreferenceController(context)); 69 controllers.add(new AllowRecommendationPreferenceController(context)); 70 controllers.add(new NotifyOpenNetworksPreferenceController(context, getLifecycle())); 71 controllers.add(new WifiWakeupPreferenceController(context, getLifecycle())); 72 controllers.add(new WifiSleepPolicyPreferenceController(context)); 73 controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), mWifiManager)); 74 controllers.add(new WpsPreferenceController( 75 context, getLifecycle(), mWifiManager, getFragmentManager())); 76 return controllers; 77 } 78 79 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 80 new BaseSearchIndexProvider() { 81 @Override 82 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 83 boolean enabled) { 84 final SearchIndexableResource sir = new SearchIndexableResource(context); 85 sir.xmlResId = R.xml.wifi_configure_settings; 86 return Arrays.asList(sir); 87 } 88 }; 89} 90