Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85141775 authored by chelseahao's avatar chelseahao
Browse files

Check nullability of WifiConfiguration.

Test: atest -c SystemUITests:InternetDialogControllerTest
Bug: 323475995
Flag: NA
Change-Id: I11f3f1fe9b308918e2d13f9530cbb6b9cca22167
parent 1ae8b771
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1450,7 +1450,8 @@ public class InternetDialogController implements AccessPointController.AccessPoi

    Intent getConfiguratorQrCodeGeneratorIntentOrNull(WifiEntry wifiEntry) {
        if (!mFeatureFlags.isEnabled(Flags.SHARE_WIFI_QS_BUTTON) || wifiEntry == null
                || mWifiManager == null || !wifiEntry.canShare()) {
                || mWifiManager == null || !wifiEntry.canShare()
                || wifiEntry.getWifiConfiguration() == null) {
            return null;
        }
        Intent intent = new Intent();
+13 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.telephony.ServiceState;
@@ -176,6 +177,8 @@ public class InternetDialogDelegateControllerTest extends SysuiTestCase {
    private WifiStateWorker mWifiStateWorker;
    @Mock
    private SignalStrength mSignalStrength;
    @Mock
    private WifiConfiguration mWifiConfiguration;

    private FakeFeatureFlags mFlags = new FakeFeatureFlags();

@@ -1036,10 +1039,20 @@ public class InternetDialogDelegateControllerTest extends SysuiTestCase {
                mConnectedEntry)).isNull();
    }

    @Test
    public void getConfiguratorQrCodeGeneratorIntentOrNull_configurationNull_returnNull() {
        mFlags.set(Flags.SHARE_WIFI_QS_BUTTON, true);
        when(mConnectedEntry.canShare()).thenReturn(true);
        when(mConnectedEntry.getWifiConfiguration()).thenReturn(null);
        assertThat(mInternetDialogController.getConfiguratorQrCodeGeneratorIntentOrNull(
                mConnectedEntry)).isNull();
    }

    @Test
    public void getConfiguratorQrCodeGeneratorIntentOrNull_wifiShareable() {
        mFlags.set(Flags.SHARE_WIFI_QS_BUTTON, true);
        when(mConnectedEntry.canShare()).thenReturn(true);
        when(mConnectedEntry.getWifiConfiguration()).thenReturn(mWifiConfiguration);
        assertThat(mInternetDialogController.getConfiguratorQrCodeGeneratorIntentOrNull(
                mConnectedEntry)).isNotNull();
    }