Migrate to getNetworkSelectionStatus()

isNetworkEnabled() & isNetworkPermanentlyDisabled()
should not be formal APIs. Instead,
getNetworkSelectionStatus() with a set of constants
is sufficient as an API surface, and will be more
maintainable in the future.

Bug: 146046526
Test: make RunCarSettingsRoboTests -j40
Change-Id: I1e944c1c78b7ebb39bc34fe9b62473ea2ae5a030
diff --git a/src/com/android/car/settings/wifi/WifiUtil.java b/src/com/android/car/settings/wifi/WifiUtil.java
index 79db041..94ff45f 100644
--- a/src/com/android/car/settings/wifi/WifiUtil.java
+++ b/src/com/android/car/settings/wifi/WifiUtil.java
@@ -15,6 +15,8 @@
  */
 package com.android.car.settings.wifi;
 
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
+
 import android.annotation.DrawableRes;
 import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
@@ -233,7 +235,8 @@
         }
         WifiConfiguration.NetworkSelectionStatus networkStatus =
                 config.getNetworkSelectionStatus();
-        if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+        if (networkStatus == null
+                || networkStatus.getNetworkSelectionStatus() == NETWORK_SELECTION_ENABLED) {
             return false;
         }
         return networkStatus.getNetworkSelectionDisableReason()
diff --git a/tests/robotests/src/com/android/car/settings/wifi/AccessPointListPreferenceControllerTest.java b/tests/robotests/src/com/android/car/settings/wifi/AccessPointListPreferenceControllerTest.java
index c2f8fea..8d4b05b 100644
--- a/tests/robotests/src/com/android/car/settings/wifi/AccessPointListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/car/settings/wifi/AccessPointListPreferenceControllerTest.java
@@ -16,6 +16,8 @@
 
 package com.android.car.settings.wifi;
 
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
@@ -203,7 +205,7 @@
         when(mMockAccessPoint1.isSaved()).thenReturn(true);
         when(mMockAccessPoint1.getConfig()).thenReturn(config);
         when(config.getNetworkSelectionStatus()).thenReturn(status);
-        when(status.isNetworkEnabled()).thenReturn(true);
+        when(status.getNetworkSelectionStatus()).thenReturn(NETWORK_SELECTION_ENABLED);
 
         List<AccessPoint> accessPointList = Arrays.asList(mMockAccessPoint1);
         when(mMockCarWifiManager.getAllAccessPoints()).thenReturn(accessPointList);
diff --git a/tests/robotests/src/com/android/car/settings/wifi/AccessPointPreferenceTest.java b/tests/robotests/src/com/android/car/settings/wifi/AccessPointPreferenceTest.java
index 18b63d3..1776472 100644
--- a/tests/robotests/src/com/android/car/settings/wifi/AccessPointPreferenceTest.java
+++ b/tests/robotests/src/com/android/car/settings/wifi/AccessPointPreferenceTest.java
@@ -16,6 +16,9 @@
 
 package com.android.car.settings.wifi;
 
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_PERMANENTLY_DISABLED;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.mock;
@@ -80,7 +83,7 @@
         when(mAccessPoint.isSaved()).thenReturn(true);
         when(mAccessPoint.getConfig()).thenReturn(config);
         when(config.getNetworkSelectionStatus()).thenReturn(status);
-        when(status.isNetworkEnabled()).thenReturn(true);
+        when(status.getNetworkSelectionStatus()).thenReturn(NETWORK_SELECTION_ENABLED);
         mPreference.onClick();
 
         AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
@@ -97,7 +100,7 @@
         when(mAccessPoint.isSaved()).thenReturn(true);
         when(mAccessPoint.getConfig()).thenReturn(config);
         when(config.getNetworkSelectionStatus()).thenReturn(status);
-        when(status.isNetworkEnabled()).thenReturn(false);
+        when(status.getNetworkSelectionStatus()).thenReturn(NETWORK_SELECTION_PERMANENTLY_DISABLED);
         when(status.getNetworkSelectionDisableReason()).thenReturn(
                 WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
         mPreference.onClick();