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

Commit 72c56e2c authored by Quang Luong's avatar Quang Luong Committed by Automerger Merge Worker
Browse files

Merge "Fix NPE on getTitle()" into qt-dev am: afee5a72

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15888886

Change-Id: Ib57e720c6c28fe5d24406775ba8832650c8dbd12
parents 8ff47243 afee5a72
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1104,14 +1104,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
@@ -146,6 +146,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();