[Wi-Fi] Hide Connect button when passpoint is expired
If the passpoint is connected and expired, we still show
Disconnect button.
Bug: 148317997
Test: manual
Observe a connected passpoint and see Disconnect button.
Observe a disconnect passpoint and see no Connect button.
Should add test case in WifiDetailPreferenceController2Test
at later CL.
Change-Id: I07f22804eccce80c44ac709412cb594faaf6ccb0
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index 350c0ad..b9e39bc 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -596,7 +596,17 @@
mButtonsPref.setButton1Visible(canForgetNetwork);
mButtonsPref.setButton2Visible(canSignIntoNetwork);
- mButtonsPref.setButton3Visible(mWifiEntry.getLevel() != WifiEntry.WIFI_LEVEL_UNREACHABLE);
+ // If it's expired and connected, shows Disconnect button for users to disconnect it.
+ // If it's expired and not connected, hides the button and users are not able to connect it.
+ //
+ // expired connected visibility
+ // false false true show (Connect) button
+ // false true true show (Disconnect) button
+ // true false false hide button
+ // true true true show (Disconnect) button
+ mButtonsPref.setButton3Visible(mWifiEntry.getLevel() != WifiEntry.WIFI_LEVEL_UNREACHABLE
+ && (!mWifiEntry.isExpired()
+ || mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED));
mButtonsPref.setButton3Enabled(canConnectDisconnectNetwork);
mButtonsPref.setButton3Text(getConnectDisconnectButtonTextResource());
mButtonsPref.setButton3Icon(getConnectDisconnectButtonIconResource());