Helper function to return the unique name for subscription info
Many classes within Settings have access to the subscription info, rather than only having access to the subscription id. For these classes, it is more convenient to have a helper method where the whole subscription info can be passed in, rather than having to call the getSubscriptionId() helper method in so many locations within the telephony settings codebase. Bug: 150370656 Bug: 148303118 Test: atest -c SubscriptionUtilTest Change-Id: I181960933ab8610d5572b7a7d6671fab8c1dbd22
This commit is contained in:
@@ -360,6 +360,26 @@ public class SubscriptionUtilTest {
|
||||
assertTrue(TextUtils.isEmpty(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUniqueDisplayName_fullSubscriptionInfo_correctNameReturned() {
|
||||
// Each subscription's default display name is unique.
|
||||
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
|
||||
when(info1.getSubscriptionId()).thenReturn(SUBID_1);
|
||||
when(info1.getDisplayName()).thenReturn(CARRIER_1);
|
||||
when(mSubMgr.getActiveSubscriptionInfoList()).thenReturn(
|
||||
Arrays.asList(info1));
|
||||
|
||||
TelephonyManager sub1Telmgr = mock(TelephonyManager.class);
|
||||
when(sub1Telmgr.getLine1Number()).thenReturn("1112223333");
|
||||
when(mTelMgr.createForSubscriptionId(SUBID_1)).thenReturn(sub1Telmgr);
|
||||
|
||||
final CharSequence name =
|
||||
SubscriptionUtil.getUniqueSubscriptionDisplayName(info1, mContext);
|
||||
|
||||
assertThat(name).isNotNull();
|
||||
assertEquals(CARRIER_1, name);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isInactiveInsertedPSim_nullSubInfo_doesNotCrash() {
|
||||
assertThat(SubscriptionUtil.isInactiveInsertedPSim(null)).isFalse();
|
||||
|
Reference in New Issue
Block a user