Loading src/java/com/android/internal/telephony/GsmCdmaPhone.java +13 −7 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDI import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOICE; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.content.BroadcastReceiver; import android.content.ContentValues; Loading Loading @@ -1507,15 +1508,20 @@ public class GsmCdmaPhone extends Phone { } @Override @Nullable public String getSubscriberId() { if (isPhoneTypeGsm()) { IccRecords r = mIccRecords.get(); return (r != null) ? r.getIMSI() : null; } else if (isPhoneTypeCdma()) { return mSST.getImsi(); } else { //isPhoneTypeCdmaLte() return (mSimRecords != null) ? mSimRecords.getIMSI() : ""; String subscriberId = null; if (isPhoneTypeCdma()) { subscriberId = mSST.getImsi(); } else { // Both Gsm and CdmaLte get the IMSI from Usim. IccRecords iccRecords = mUiccController.getIccRecords( mPhoneId, UiccController.APP_FAM_3GPP); if (iccRecords != null) { subscriberId = iccRecords.getIMSI(); } } return subscriberId; } @Override Loading tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +54 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; Loading Loading @@ -61,6 +62,7 @@ import com.android.internal.telephony.test.SimulatedCommands; import com.android.internal.telephony.uicc.IccCardApplicationStatus; import com.android.internal.telephony.uicc.IccException; import com.android.internal.telephony.uicc.IccRecords; import com.android.internal.telephony.uicc.UiccController; import com.android.internal.telephony.uicc.UiccProfile; import com.android.internal.telephony.uicc.UiccSlot; Loading @@ -70,6 +72,7 @@ import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; import java.util.List; Loading Loading @@ -177,6 +180,57 @@ public class GsmCdmaPhoneTest extends TelephonyTest { assertEquals(serviceState, mPhoneUT.getServiceState()); } @Test @SmallTest public void testGetSubscriberIdForGsmPhone() { final String subscriberId = "123456789"; IccRecords iccRecords = Mockito.mock(IccRecords.class); doReturn(subscriberId).when(iccRecords).getIMSI(); doReturn(iccRecords).when(mUiccController) .getIccRecords(anyInt() /* phoneId */, eq(UiccController.APP_FAM_3GPP)); // Ensure the phone type is GSM GsmCdmaPhone spyPhone = spy(mPhoneUT); doReturn(false).when(spyPhone).isPhoneTypeCdma(); doReturn(false).when(spyPhone).isPhoneTypeCdmaLte(); doReturn(true).when(spyPhone).isPhoneTypeGsm(); assertEquals(subscriberId, spyPhone.getSubscriberId()); } @Test @SmallTest public void testGetSubscriberIdForCdmaLtePhone() { final String subscriberId = "abcdefghijk"; IccRecords iccRecords = Mockito.mock(IccRecords.class); doReturn(subscriberId).when(iccRecords).getIMSI(); doReturn(iccRecords).when(mUiccController) .getIccRecords(anyInt() /* phoneId */, eq(UiccController.APP_FAM_3GPP)); // Ensure the phone type is CdmaLte GsmCdmaPhone spyPhone = spy(mPhoneUT); doReturn(false).when(spyPhone).isPhoneTypeCdma(); doReturn(true).when(spyPhone).isPhoneTypeCdmaLte(); doReturn(false).when(spyPhone).isPhoneTypeGsm(); assertEquals(subscriberId, spyPhone.getSubscriberId()); } @Test @SmallTest public void testGetSubscriberIdForCdmaPhone() { final String subscriberId = "987654321"; doReturn(subscriberId).when(mSST).getImsi(); // Ensure the phone type is GSM GsmCdmaPhone spyPhone = spy(mPhoneUT); doReturn(true).when(spyPhone).isPhoneTypeCdma(); doReturn(false).when(spyPhone).isPhoneTypeCdmaLte(); doReturn(false).when(spyPhone).isPhoneTypeGsm(); assertEquals(subscriberId, spyPhone.getSubscriberId()); } @Test @SmallTest public void testGetCellLocation() { Loading Loading
src/java/com/android/internal/telephony/GsmCdmaPhone.java +13 −7 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static com.android.internal.telephony.CommandsInterface.CF_REASON_UNCONDI import static com.android.internal.telephony.CommandsInterface.SERVICE_CLASS_VOICE; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.ActivityManager; import android.content.BroadcastReceiver; import android.content.ContentValues; Loading Loading @@ -1507,15 +1508,20 @@ public class GsmCdmaPhone extends Phone { } @Override @Nullable public String getSubscriberId() { if (isPhoneTypeGsm()) { IccRecords r = mIccRecords.get(); return (r != null) ? r.getIMSI() : null; } else if (isPhoneTypeCdma()) { return mSST.getImsi(); } else { //isPhoneTypeCdmaLte() return (mSimRecords != null) ? mSimRecords.getIMSI() : ""; String subscriberId = null; if (isPhoneTypeCdma()) { subscriberId = mSST.getImsi(); } else { // Both Gsm and CdmaLte get the IMSI from Usim. IccRecords iccRecords = mUiccController.getIccRecords( mPhoneId, UiccController.APP_FAM_3GPP); if (iccRecords != null) { subscriberId = iccRecords.getIMSI(); } } return subscriberId; } @Override Loading
tests/telephonytests/src/com/android/internal/telephony/GsmCdmaPhoneTest.java +54 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; Loading Loading @@ -61,6 +62,7 @@ import com.android.internal.telephony.test.SimulatedCommands; import com.android.internal.telephony.uicc.IccCardApplicationStatus; import com.android.internal.telephony.uicc.IccException; import com.android.internal.telephony.uicc.IccRecords; import com.android.internal.telephony.uicc.UiccController; import com.android.internal.telephony.uicc.UiccProfile; import com.android.internal.telephony.uicc.UiccSlot; Loading @@ -70,6 +72,7 @@ import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; import java.util.List; Loading Loading @@ -177,6 +180,57 @@ public class GsmCdmaPhoneTest extends TelephonyTest { assertEquals(serviceState, mPhoneUT.getServiceState()); } @Test @SmallTest public void testGetSubscriberIdForGsmPhone() { final String subscriberId = "123456789"; IccRecords iccRecords = Mockito.mock(IccRecords.class); doReturn(subscriberId).when(iccRecords).getIMSI(); doReturn(iccRecords).when(mUiccController) .getIccRecords(anyInt() /* phoneId */, eq(UiccController.APP_FAM_3GPP)); // Ensure the phone type is GSM GsmCdmaPhone spyPhone = spy(mPhoneUT); doReturn(false).when(spyPhone).isPhoneTypeCdma(); doReturn(false).when(spyPhone).isPhoneTypeCdmaLte(); doReturn(true).when(spyPhone).isPhoneTypeGsm(); assertEquals(subscriberId, spyPhone.getSubscriberId()); } @Test @SmallTest public void testGetSubscriberIdForCdmaLtePhone() { final String subscriberId = "abcdefghijk"; IccRecords iccRecords = Mockito.mock(IccRecords.class); doReturn(subscriberId).when(iccRecords).getIMSI(); doReturn(iccRecords).when(mUiccController) .getIccRecords(anyInt() /* phoneId */, eq(UiccController.APP_FAM_3GPP)); // Ensure the phone type is CdmaLte GsmCdmaPhone spyPhone = spy(mPhoneUT); doReturn(false).when(spyPhone).isPhoneTypeCdma(); doReturn(true).when(spyPhone).isPhoneTypeCdmaLte(); doReturn(false).when(spyPhone).isPhoneTypeGsm(); assertEquals(subscriberId, spyPhone.getSubscriberId()); } @Test @SmallTest public void testGetSubscriberIdForCdmaPhone() { final String subscriberId = "987654321"; doReturn(subscriberId).when(mSST).getImsi(); // Ensure the phone type is GSM GsmCdmaPhone spyPhone = spy(mPhoneUT); doReturn(true).when(spyPhone).isPhoneTypeCdma(); doReturn(false).when(spyPhone).isPhoneTypeCdmaLte(); doReturn(false).when(spyPhone).isPhoneTypeGsm(); assertEquals(subscriberId, spyPhone.getSubscriberId()); } @Test @SmallTest public void testGetCellLocation() { Loading