Merge "Fix NPE on getTitle()" into qt-dev
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.
|
* 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 "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,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();
|
||||||
|
|||||||
Reference in New Issue
Block a user