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

Commit b28e95e6 authored by Cn Chen's avatar Cn Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE on getTitle()"

parents a1f3fd5b f00f2203
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -1117,14 +1117,16 @@ public class AccessPoint implements Comparable<AccessPoint> {
     * Returns the display title for the AccessPoint, such as for an AccessPointPreference's title.
     * Returns the display title for the AccessPoint, such as for an AccessPointPreference's title.
     */
     */
    public String getTitle() {
    public String getTitle() {
        if (isPasspoint()) {
        if (isPasspoint() && !TextUtils.isEmpty(mConfig.providerFriendlyName)) {
            return mConfig.providerFriendlyName;
            return mConfig.providerFriendlyName;
        } else if (isPasspointConfig()) {
        } else if (isPasspointConfig() && !TextUtils.isEmpty(mProviderFriendlyName)) {
            return mProviderFriendlyName;
            return mProviderFriendlyName;
        } else if (isOsuProvider()) {
        } else if (isOsuProvider() && !TextUtils.isEmpty(mOsuProvider.getFriendlyName())) {
            return mOsuProvider.getFriendlyName();
            return mOsuProvider.getFriendlyName();
        } else {
        } else if (!TextUtils.isEmpty(getSsidStr())) {
            return getSsidStr();
            return getSsidStr();
        } else {
            return "";
        }
        }
    }
    }


+11 −0
Original line number Original line Diff line number Diff line
@@ -147,6 +147,17 @@ public class AccessPointTest {
        assertThat(ssid instanceof SpannableString).isFalse();
        assertThat(ssid instanceof SpannableString).isFalse();
    }
    }


    @Test
    public void testCompareTo_GivesNull() {
        WifiConfiguration spyConfig = spy(new WifiConfiguration());

        when(spyConfig.isPasspoint()).thenReturn(true);
        spyConfig.providerFriendlyName = null;
        AccessPoint passpointAp = new AccessPoint(mContext, spyConfig);

        assertThat(passpointAp.getTitle()).isEqualTo("");
    }

    @Test
    @Test
    public void testCompareTo_GivesActiveBeforeInactive() {
    public void testCompareTo_GivesActiveBeforeInactive() {
        AccessPoint activeAp = new TestAccessPointBuilder(mContext).setActive(true).build();
        AccessPoint activeAp = new TestAccessPointBuilder(mContext).setActive(true).build();