1 /* 2 * Copyright (C) 2017 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 package com.android.settings.wifi.details; 17 18 import android.content.Context; 19 import android.net.ConnectivityManager; 20 import android.net.wifi.WifiManager; 21 import android.os.Bundle; 22 import android.os.Handler; 23 import android.os.Looper; 24 25 import com.android.internal.logging.nano.MetricsProto; 26 import com.android.settings.R; 27 import com.android.settings.core.PreferenceController; 28 import com.android.settings.dashboard.DashboardFragment; 29 import com.android.settings.vpn2.ConnectivityManagerWrapperImpl; 30 import com.android.settingslib.wifi.AccessPoint; 31 32 import java.util.ArrayList; 33 import java.util.List; 34 35 /** 36 * Detail page for the currently connected wifi network. 37 * 38 * <p>The AccessPoint should be saved to the intent Extras when launching this class via 39 * {@link AccessPoint#saveWifiState(Bundle)} in order to properly render this page. 40 */ 41 public class WifiNetworkDetailsFragment extends DashboardFragment { 42 private static final String TAG = "WifiNetworkDetailsFrg"; 43 44 private AccessPoint mAccessPoint; 45 private WifiDetailPreferenceController mWifiDetailPreferenceController; 46 47 @Override 48 public void onAttach(Context context) { 49 mAccessPoint = new AccessPoint(context, getArguments()); 50 super.onAttach(context); 51 } 52 53 @Override 54 public int getMetricsCategory() { 55 return MetricsProto.MetricsEvent.WIFI_NETWORK_DETAILS; 56 } 57 58 @Override 59 protected String getLogTag() { 60 return TAG; 61 } 62 63 @Override 64 protected int getPreferenceScreenResId() { 65 return R.xml.wifi_network_details_fragment; 66 } 67 68 @Override 69 protected List<PreferenceController> getPreferenceControllers(Context context) { 70 ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); 71 mWifiDetailPreferenceController = new WifiDetailPreferenceController( 72 mAccessPoint, 73 new ConnectivityManagerWrapperImpl(cm), 74 context, 75 this, 76 new Handler(Looper.getMainLooper()), // UI thread. 77 getLifecycle(), 78 context.getSystemService(WifiManager.class), 79 mMetricsFeatureProvider); 80 81 ArrayList<PreferenceController> controllers = new ArrayList(1); 82 controllers.add(mWifiDetailPreferenceController); 83 return controllers; 84 } 85 } 86