Loading src/java/com/android/internal/telephony/PhoneSubInfoController.java +2 −3 Original line number Diff line number Diff line Loading @@ -125,9 +125,8 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } public String getSubscriberIdForSubscriber(int subId, String callingPackage) { Phone thePhone = getPhone(subId); String message = "getSubscriberId"; if (thePhone != null) { if (SubscriptionController.getInstance().isActiveSubId(subId, callingPackage)) { return callPhoneMethodForSubIdWithReadSubscriberIdentifiersCheck(subId, callingPackage, message, (phone) -> phone.getSubscriberId()); } else { Loading @@ -137,7 +136,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } final long identity = Binder.clearCallingIdentity(); try { return SubscriptionController.getInstance().getImsi(subId); return SubscriptionController.getInstance().getImsiPrivileged(subId); } finally { Binder.restoreCallingIdentity(identity); } Loading src/java/com/android/internal/telephony/SubscriptionController.java +15 −12 Original line number Diff line number Diff line Loading @@ -1893,29 +1893,32 @@ public class SubscriptionController extends ISub.Stub { /** * Get IMSI by subscription ID * For active subIds, this will always return the corresponding imsi * For inactive subIds, once they are activated once, even if they are deactivated at the time * of calling this function, the corresponding imsi will be returned * When calling this method, the permission check should have already been done to allow * only privileged read * * @return imsi */ public String getImsi(int subId) { Cursor cursor = mContext.getContentResolver().query( SubscriptionManager.getUriForSubscriptionId(subId), null, public String getImsiPrivileged(int subId) { try (Cursor cursor = mContext.getContentResolver().query( SubscriptionManager.CONTENT_URI, null, SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?", new String[]{String.valueOf(subId)}, null); new String[] {String.valueOf(subId)}, null)) { String imsi = null; try { if (cursor != null) { if (cursor.moveToNext()) { imsi = getOptionalStringFromCursor(cursor, SubscriptionManager.IMSI, /*defaultVal*/ null); } } else { logd("getImsiPrivileged: failed to retrieve imsi."); } } finally { if (cursor != null) { cursor.close(); } } return imsi; } } /** * Set ISO country code by subscription ID Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { doReturn(0).when(mSubscriptionController).getPhoneId(eq(0)); doReturn(1).when(mSubscriptionController).getPhoneId(eq(1)); doReturn(2).when(mTelephonyManager).getPhoneCount(); doReturn(true).when(mSubscriptionController).isActiveSubId(0, TAG); doReturn(true).when(mSubscriptionController).isActiveSubId(1, TAG); mServiceManagerMockedServices.put("isub", mSubscriptionController); doReturn(mSubscriptionController).when(mSubscriptionController) Loading Loading
src/java/com/android/internal/telephony/PhoneSubInfoController.java +2 −3 Original line number Diff line number Diff line Loading @@ -125,9 +125,8 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } public String getSubscriberIdForSubscriber(int subId, String callingPackage) { Phone thePhone = getPhone(subId); String message = "getSubscriberId"; if (thePhone != null) { if (SubscriptionController.getInstance().isActiveSubId(subId, callingPackage)) { return callPhoneMethodForSubIdWithReadSubscriberIdentifiersCheck(subId, callingPackage, message, (phone) -> phone.getSubscriberId()); } else { Loading @@ -137,7 +136,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } final long identity = Binder.clearCallingIdentity(); try { return SubscriptionController.getInstance().getImsi(subId); return SubscriptionController.getInstance().getImsiPrivileged(subId); } finally { Binder.restoreCallingIdentity(identity); } Loading
src/java/com/android/internal/telephony/SubscriptionController.java +15 −12 Original line number Diff line number Diff line Loading @@ -1893,29 +1893,32 @@ public class SubscriptionController extends ISub.Stub { /** * Get IMSI by subscription ID * For active subIds, this will always return the corresponding imsi * For inactive subIds, once they are activated once, even if they are deactivated at the time * of calling this function, the corresponding imsi will be returned * When calling this method, the permission check should have already been done to allow * only privileged read * * @return imsi */ public String getImsi(int subId) { Cursor cursor = mContext.getContentResolver().query( SubscriptionManager.getUriForSubscriptionId(subId), null, public String getImsiPrivileged(int subId) { try (Cursor cursor = mContext.getContentResolver().query( SubscriptionManager.CONTENT_URI, null, SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?", new String[]{String.valueOf(subId)}, null); new String[] {String.valueOf(subId)}, null)) { String imsi = null; try { if (cursor != null) { if (cursor.moveToNext()) { imsi = getOptionalStringFromCursor(cursor, SubscriptionManager.IMSI, /*defaultVal*/ null); } } else { logd("getImsiPrivileged: failed to retrieve imsi."); } } finally { if (cursor != null) { cursor.close(); } } return imsi; } } /** * Set ISO country code by subscription ID Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { doReturn(0).when(mSubscriptionController).getPhoneId(eq(0)); doReturn(1).when(mSubscriptionController).getPhoneId(eq(1)); doReturn(2).when(mTelephonyManager).getPhoneCount(); doReturn(true).when(mSubscriptionController).isActiveSubId(0, TAG); doReturn(true).when(mSubscriptionController).isActiveSubId(1, TAG); mServiceManagerMockedServices.put("isub", mSubscriptionController); doReturn(mSubscriptionController).when(mSubscriptionController) Loading