Loading src/java/com/android/internal/telephony/PhoneSubInfoController.java +24 −16 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.app.AppOpsManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.RemoteException; Loading Loading @@ -624,27 +625,34 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } /** * Returns SIP URI or tel URI of the Public Service Identity of the SM-SC that fetched from * EFPSISMSC elementary field that are loaded based on the ISIM/USIM appType. * Returns SIP URI or tel URI of the Public Service Identity of the SM-SC fetched from * EF_PSISMSC elementary field as defined in Section 4.5.9 (3GPP TS 31.102). * @throws IllegalStateException in case if phone or UiccApplication is not available. */ public String getSmscIdentity(int subId, int appType) throws RemoteException { return callPhoneMethodForSubIdWithPrivilegedCheck(subId, "getSmscIdentity", public Uri getSmscIdentity(int subId, int appType) throws RemoteException { Uri smscIdentityUri = callPhoneMethodForSubIdWithPrivilegedCheck(subId, "getSmscIdentity", (phone) -> { try { String smscIdentity = null; UiccPort uiccPort = phone.getUiccPort(); if (uiccPort == null || uiccPort.getUiccProfile() == null) { loge("getSmscIdentity(): uiccPort or uiccProfile is null"); return null; } UiccCardApplication uiccApp = uiccPort.getUiccProfile().getApplicationByType( UiccCardApplication uiccApp = uiccPort.getUiccProfile().getApplicationByType( appType); if (uiccApp == null) { loge("getSmscIdentity(): no app with specified type = " + appType); smscIdentity = (uiccApp != null) ? uiccApp.getIccRecords().getSmscIdentity() : null; if (TextUtils.isEmpty(smscIdentity)) { return Uri.EMPTY; } return Uri.parse(smscIdentity); } catch (NullPointerException ex) { Rlog.e(TAG, "getSmscIdentity(): Exception = " + ex); return null; } return uiccApp.getIccRecords().getSmscIdentity(); }); if (smscIdentityUri == null) { throw new IllegalStateException("Telephony service error"); } return smscIdentityUri; } private void log(String s) { Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +20 −18 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.internal.telephony; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.telephony.TelephonyManager.APPTYPE_ISIM; import static android.telephony.TelephonyManager.APPTYPE_USIM; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; Loading Loading @@ -52,9 +54,9 @@ import org.mockito.Mockito; public class PhoneSubInfoControllerTest extends TelephonyTest { private static final String FEATURE_ID = "myfeatureId"; private static final String PSI_SMSC_TEL1 = "tel:+91123456789"; private static final String PSI_SMSC_SIP1 = "sip:+1234567890@msg.pc.t-mobile.com;user=phone"; private static final String PSI_SMSC_SIP1 = "sip:+1234567890@abc.pc.operetor1.com;user=phone"; private static final String PSI_SMSC_TEL2 = "tel:+91987654321"; private static final String PSI_SMSC_SIP2 = "sip:+19876543210@msg.pc.t-mobile.com;user=phone"; private static final String PSI_SMSC_SIP2 = "sip:+19876543210@dcf.pc.operetor2.com;user=phone"; private PhoneSubInfoController mPhoneSubInfoControllerUT; private AppOpsManager mAppOsMgr; Loading Loading @@ -965,13 +967,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { try { setUpInitials(); assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 5)); .getSmscIdentity(0, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 3)); .getSmscIdentity(0, APPTYPE_USIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_USIM).toString()); } catch (RemoteException e) { e.printStackTrace(); } Loading Loading @@ -1003,13 +1005,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { doReturn(PSI_SMSC_SIP2).when(mIsimUiccRecords).getSmscIdentity(); assertEquals(PSI_SMSC_SIP1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 5)); .getSmscIdentity(0, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_SIP1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 3)); .getSmscIdentity(0, APPTYPE_USIM).toString()); assertEquals(PSI_SMSC_SIP2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_SIP2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_USIM).toString()); } catch (RemoteException e) { e.printStackTrace(); } Loading @@ -1022,7 +1024,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { //case 1: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); try { mPhoneSubInfoControllerUT.getSmscIdentity(0, 5); mPhoneSubInfoControllerUT.getSmscIdentity(0, APPTYPE_ISIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1030,7 +1032,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { } try { mPhoneSubInfoControllerUT.getSmscIdentity(1, 5); mPhoneSubInfoControllerUT.getSmscIdentity(1, APPTYPE_ISIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1038,7 +1040,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { } try { mPhoneSubInfoControllerUT.getSmscIdentity(0, 3); mPhoneSubInfoControllerUT.getSmscIdentity(0, APPTYPE_USIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1046,7 +1048,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { } try { mPhoneSubInfoControllerUT.getSmscIdentity(1, 3); mPhoneSubInfoControllerUT.getSmscIdentity(1, APPTYPE_USIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1061,13 +1063,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { try { assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 5)); .getSmscIdentity(0, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 3)); .getSmscIdentity(0, APPTYPE_USIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_USIM).toString()); } catch (RemoteException e) { e.printStackTrace(); } Loading Loading
src/java/com/android/internal/telephony/PhoneSubInfoController.java +24 −16 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.app.AppOpsManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.RemoteException; Loading Loading @@ -624,27 +625,34 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } /** * Returns SIP URI or tel URI of the Public Service Identity of the SM-SC that fetched from * EFPSISMSC elementary field that are loaded based on the ISIM/USIM appType. * Returns SIP URI or tel URI of the Public Service Identity of the SM-SC fetched from * EF_PSISMSC elementary field as defined in Section 4.5.9 (3GPP TS 31.102). * @throws IllegalStateException in case if phone or UiccApplication is not available. */ public String getSmscIdentity(int subId, int appType) throws RemoteException { return callPhoneMethodForSubIdWithPrivilegedCheck(subId, "getSmscIdentity", public Uri getSmscIdentity(int subId, int appType) throws RemoteException { Uri smscIdentityUri = callPhoneMethodForSubIdWithPrivilegedCheck(subId, "getSmscIdentity", (phone) -> { try { String smscIdentity = null; UiccPort uiccPort = phone.getUiccPort(); if (uiccPort == null || uiccPort.getUiccProfile() == null) { loge("getSmscIdentity(): uiccPort or uiccProfile is null"); return null; } UiccCardApplication uiccApp = uiccPort.getUiccProfile().getApplicationByType( UiccCardApplication uiccApp = uiccPort.getUiccProfile().getApplicationByType( appType); if (uiccApp == null) { loge("getSmscIdentity(): no app with specified type = " + appType); smscIdentity = (uiccApp != null) ? uiccApp.getIccRecords().getSmscIdentity() : null; if (TextUtils.isEmpty(smscIdentity)) { return Uri.EMPTY; } return Uri.parse(smscIdentity); } catch (NullPointerException ex) { Rlog.e(TAG, "getSmscIdentity(): Exception = " + ex); return null; } return uiccApp.getIccRecords().getSmscIdentity(); }); if (smscIdentityUri == null) { throw new IllegalStateException("Telephony service error"); } return smscIdentityUri; } private void log(String s) { Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +20 −18 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.internal.telephony; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.telephony.TelephonyManager.APPTYPE_ISIM; import static android.telephony.TelephonyManager.APPTYPE_USIM; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; Loading Loading @@ -52,9 +54,9 @@ import org.mockito.Mockito; public class PhoneSubInfoControllerTest extends TelephonyTest { private static final String FEATURE_ID = "myfeatureId"; private static final String PSI_SMSC_TEL1 = "tel:+91123456789"; private static final String PSI_SMSC_SIP1 = "sip:+1234567890@msg.pc.t-mobile.com;user=phone"; private static final String PSI_SMSC_SIP1 = "sip:+1234567890@abc.pc.operetor1.com;user=phone"; private static final String PSI_SMSC_TEL2 = "tel:+91987654321"; private static final String PSI_SMSC_SIP2 = "sip:+19876543210@msg.pc.t-mobile.com;user=phone"; private static final String PSI_SMSC_SIP2 = "sip:+19876543210@dcf.pc.operetor2.com;user=phone"; private PhoneSubInfoController mPhoneSubInfoControllerUT; private AppOpsManager mAppOsMgr; Loading Loading @@ -965,13 +967,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { try { setUpInitials(); assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 5)); .getSmscIdentity(0, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 3)); .getSmscIdentity(0, APPTYPE_USIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_USIM).toString()); } catch (RemoteException e) { e.printStackTrace(); } Loading Loading @@ -1003,13 +1005,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { doReturn(PSI_SMSC_SIP2).when(mIsimUiccRecords).getSmscIdentity(); assertEquals(PSI_SMSC_SIP1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 5)); .getSmscIdentity(0, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_SIP1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 3)); .getSmscIdentity(0, APPTYPE_USIM).toString()); assertEquals(PSI_SMSC_SIP2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_SIP2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_USIM).toString()); } catch (RemoteException e) { e.printStackTrace(); } Loading @@ -1022,7 +1024,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { //case 1: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); try { mPhoneSubInfoControllerUT.getSmscIdentity(0, 5); mPhoneSubInfoControllerUT.getSmscIdentity(0, APPTYPE_ISIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1030,7 +1032,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { } try { mPhoneSubInfoControllerUT.getSmscIdentity(1, 5); mPhoneSubInfoControllerUT.getSmscIdentity(1, APPTYPE_ISIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1038,7 +1040,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { } try { mPhoneSubInfoControllerUT.getSmscIdentity(0, 3); mPhoneSubInfoControllerUT.getSmscIdentity(0, APPTYPE_USIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1046,7 +1048,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { } try { mPhoneSubInfoControllerUT.getSmscIdentity(1, 3); mPhoneSubInfoControllerUT.getSmscIdentity(1, APPTYPE_USIM); Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); Loading @@ -1061,13 +1063,13 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { try { assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 5)); .getSmscIdentity(0, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL1, mPhoneSubInfoControllerUT .getSmscIdentity(0, 3)); .getSmscIdentity(0, APPTYPE_USIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_ISIM).toString()); assertEquals(PSI_SMSC_TEL2, mPhoneSubInfoControllerUT .getSmscIdentity(1, 5)); .getSmscIdentity(1, APPTYPE_USIM).toString()); } catch (RemoteException e) { e.printStackTrace(); } Loading