Fix NPE on getTitle()
Bug: 199922685
Test: make RunSettingsLibRoboTests -j40
Change-Id: I35bf6f5911dc0ee56e43af7faddaceb479362863
(cherry picked from commit f00f2203b5)
Merged-In: I35bf6f5911dc0ee56e43af7faddaceb479362863
This commit is contained in:
@@ -997,14 +997,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 "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,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();
|
||||
|
||||
Reference in New Issue
Block a user