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

Commit b1bf7f55 authored by Quang Luong's avatar Quang Luong Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE on getTitle()" into rvc-dev

parents 5d7d2aa0 c006ad91
Loading
Loading
Loading
Loading
+6 −4
Original line number 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.
     */
    public String getTitle() {
        if (isPasspoint()) {
        if (isPasspoint() && !TextUtils.isEmpty(mConfig.providerFriendlyName)) {
            return mConfig.providerFriendlyName;
        } else if (isPasspointConfig()) {
        } else if (isPasspointConfig() && !TextUtils.isEmpty(mProviderFriendlyName)) {
            return mProviderFriendlyName;
        } else if (isOsuProvider()) {
        } else if (isOsuProvider() && !TextUtils.isEmpty(mOsuProvider.getFriendlyName())) {
            return mOsuProvider.getFriendlyName();
        } else {
        } else if (!TextUtils.isEmpty(getSsidStr())) {
            return getSsidStr();
        } else {
            return "";
        }
    }

+11 −0
Original line number Diff line number Diff line
@@ -147,6 +147,17 @@ public class AccessPointTest {
        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
    public void testCompareTo_GivesActiveBeforeInactive() {
        AccessPoint activeAp = new TestAccessPointBuilder(mContext).setActive(true).build();