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

Commit 69b31596 authored by Johnson Lu's avatar Johnson Lu
Browse files

Fix crash issue when click 'Share' button

Hide 'Share' button if access point return null wifi config.

Change-Id: I554ce8c3214c94892d57c213d0588c70aad97439
Fixes: 123172888
Test: robotests
parent 61447c7b
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -442,9 +442,9 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController

    private void updateIpLayerInfo() {
        mButtonsPref.setButton2Visible(canSignIntoNetwork());
        mButtonsPref.setButton3Visible(isSharingNetworkEnabled());
        mButtonsPref.setButton3Visible(canShareNetwork());
        mButtonsPref.setVisible(
                canSignIntoNetwork() || canForgetNetwork() || isSharingNetworkEnabled());
                canSignIntoNetwork() || canForgetNetwork() || canShareNetwork());

        if (mNetwork == null || mLinkProperties == null) {
            mIpAddressPref.setVisible(false);
@@ -532,8 +532,9 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
    /**
     * Returns whether the user can share the network represented by this preference with QR code.
     */
    private boolean isSharingNetworkEnabled() {
        return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.WIFI_SHARING);
    private boolean canShareNetwork() {
        return mAccessPoint.getConfig() != null && FeatureFlagUtils.isEnabled(mContext,
                FeatureFlags.WIFI_SHARING);
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -685,6 +685,15 @@ public class WifiDetailPreferenceControllerTest {
        verify(mockButtonsPref).setButton1Visible(false);
    }

    @Test
    public void canShareNetwork_noNetwork() {
        when(mockAccessPoint.getConfig()).thenReturn(null);

        displayAndResume();

        verify(mockButtonsPref).setButton3Visible(false);
    }

    @Test
    public void canModifyNetwork_saved() {
        assertThat(mController.canModifyNetwork()).isTrue();