Merge "Clean up unused deps"
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 27e1a98..d5ef9aa 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -24,6 +24,7 @@
 import android.icu.text.ListFormatter;
 import android.provider.SearchIndexableResource;
 import android.text.BidiFormatter;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.android.internal.logging.nano.MetricsProto;
@@ -153,21 +154,25 @@
 
         private final Context mContext;
         private final SummaryLoader mSummaryLoader;
+        private final WifiMasterSwitchPreferenceController mWifiPreferenceController;
         private final MobileNetworkPreferenceController mMobileNetworkPreferenceController;
         private final TetherPreferenceController mTetherPreferenceController;
 
         public SummaryProvider(Context context, SummaryLoader summaryLoader) {
             this(context, summaryLoader,
+                    new WifiMasterSwitchPreferenceController(context, null),
                     new MobileNetworkPreferenceController(context),
                     new TetherPreferenceController(context, null /* lifecycle */));
         }
 
         @VisibleForTesting(otherwise = VisibleForTesting.NONE)
         SummaryProvider(Context context, SummaryLoader summaryLoader,
+                WifiMasterSwitchPreferenceController wifiPreferenceController,
                 MobileNetworkPreferenceController mobileNetworkPreferenceController,
                 TetherPreferenceController tetherPreferenceController) {
             mContext = context;
             mSummaryLoader = summaryLoader;
+            mWifiPreferenceController = wifiPreferenceController;
             mMobileNetworkPreferenceController = mobileNetworkPreferenceController;
             mTetherPreferenceController = tetherPreferenceController;
         }
@@ -176,20 +181,27 @@
         @Override
         public void setListening(boolean listening) {
             if (listening) {
-                final List<String> summaries = new ArrayList<>();
+                final String wifiSummary = BidiFormatter.getInstance()
+                    .unicodeWrap(mContext.getString(R.string.wifi_settings_title));
+                final String mobileSummary = mContext.getString(
+                    R.string.network_dashboard_summary_mobile);
+                final String dataUsageSummary = mContext.getString(
+                    R.string.network_dashboard_summary_data_usage);
+                final String hotspotSummary = mContext.getString(
+                    R.string.network_dashboard_summary_hotspot);
 
-                summaries.add(BidiFormatter.getInstance()
-                        .unicodeWrap(mContext.getString(R.string.wifi_settings_title)));
-                if (mMobileNetworkPreferenceController.isAvailable()) {
-                    summaries.add(mContext.getString(
-                            R.string.network_dashboard_summary_mobile));
+                final List<String> summaries = new ArrayList<>();
+                if (mWifiPreferenceController.isAvailable() && !TextUtils.isEmpty(wifiSummary)) {
+                    summaries.add(wifiSummary);
                 }
-                final String dataUsageSettingSummary = mContext.getString(
-                        R.string.network_dashboard_summary_data_usage);
-                summaries.add(dataUsageSettingSummary);
-                if (mTetherPreferenceController.isAvailable()) {
-                    summaries.add(mContext.getString(
-                            R.string.network_dashboard_summary_hotspot));
+                if (mMobileNetworkPreferenceController.isAvailable() && !TextUtils.isEmpty(mobileSummary)) {
+                    summaries.add(mobileSummary);
+                }
+                if (!TextUtils.isEmpty(dataUsageSummary)) {
+                    summaries.add(dataUsageSummary);
+                }
+                if (mTetherPreferenceController.isAvailable() && !TextUtils.isEmpty(hotspotSummary)) {
+                    summaries.add(hotspotSummary);
                 }
                 mSummaryLoader.setSummary(this, ListFormatter.getInstance().format(summaries));
             }
diff --git a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
index 187f0dc..d6310ab 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
@@ -26,6 +26,7 @@
 
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.wifi.WifiMasterSwitchPreferenceController;
 import com.android.settingslib.drawer.CategoryKey;
 
 import org.junit.Before;
@@ -66,6 +67,8 @@
 
     @Test
     public void summaryProviderSetListening_hasMobileAndHotspot_shouldReturnMobileSummary() {
+        final WifiMasterSwitchPreferenceController wifiPreferenceController =
+                mock(WifiMasterSwitchPreferenceController.class);
         final MobileNetworkPreferenceController mobileNetworkPreferenceController =
                 mock(MobileNetworkPreferenceController.class);
         final TetherPreferenceController tetherPreferenceController =
@@ -74,12 +77,14 @@
         final SummaryLoader summaryLoader = mock(SummaryLoader.class);
         final SummaryLoader.SummaryProvider provider =
                 new NetworkDashboardFragment.SummaryProvider(mContext, summaryLoader,
-                        mobileNetworkPreferenceController, tetherPreferenceController);
+                        wifiPreferenceController, mobileNetworkPreferenceController,
+                        tetherPreferenceController);
 
         provider.setListening(false);
 
         verifyZeroInteractions(summaryLoader);
 
+        when(wifiPreferenceController.isAvailable()).thenReturn(true);
         when(mobileNetworkPreferenceController.isAvailable()).thenReturn(true);
         when(tetherPreferenceController.isAvailable()).thenReturn(true);
 
@@ -90,6 +95,8 @@
 
     @Test
     public void summaryProviderSetListening_noMobileOrHotspot_shouldReturnSimpleSummary() {
+        final WifiMasterSwitchPreferenceController wifiPreferenceController =
+                mock(WifiMasterSwitchPreferenceController.class);
         final MobileNetworkPreferenceController mobileNetworkPreferenceController =
                 mock(MobileNetworkPreferenceController.class);
         final TetherPreferenceController tetherPreferenceController =
@@ -98,12 +105,14 @@
         final SummaryLoader summaryLoader = mock(SummaryLoader.class);
         final SummaryLoader.SummaryProvider provider =
                 new NetworkDashboardFragment.SummaryProvider(mContext, summaryLoader,
-                        mobileNetworkPreferenceController, tetherPreferenceController);
+                        wifiPreferenceController, mobileNetworkPreferenceController,
+                        tetherPreferenceController);
 
         provider.setListening(false);
 
         verifyZeroInteractions(summaryLoader);
 
+        when(wifiPreferenceController.isAvailable()).thenReturn(true);
         when(mobileNetworkPreferenceController.isAvailable()).thenReturn(false);
         when(tetherPreferenceController.isAvailable()).thenReturn(false);