Loading src/java/com/android/internal/telephony/PhoneSubInfoController.java +18 −17 Original line number Diff line number Diff line Loading @@ -59,15 +59,15 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } public String getDeviceIdForPhone(int phoneId, String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getDeviceId")) { return null; } if (!SubscriptionManager.isValidPhoneId(phoneId)) { phoneId = 0; } final Phone phone = mPhone[phoneId]; if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, phone.getSubId(), callingPackage, "getDeviceId")) { return null; } return phone.getDeviceId(); } else { loge("getDeviceIdForPhone phone " + phoneId + " is null"); Loading @@ -79,7 +79,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getNai")) { mContext, subId, callingPackage, "getNai")) { return null; } return phone.getNai(); Loading @@ -93,7 +93,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getImei")) { mContext, subId, callingPackage, "getImei")) { return null; } return phone.getImei(); Loading @@ -108,7 +108,8 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getCarrierInfoForImsiEncryption")) { mContext, subId, callingPackage, "getCarrierInfoForImsiEncryption")) { return null; } return phone.getCarrierInfoForImsiEncryption(keyType); Loading @@ -123,7 +124,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "setCarrierInfoForImsiEncryption")) { mContext, subId, callingPackage, "setCarrierInfoForImsiEncryption")) { return; } phone.setCarrierInfoForImsiEncryption(imsiEncryptionInfo); Loading @@ -142,7 +143,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getDeviceSvn")) { mContext, subId, callingPackage, "getDeviceSvn")) { return null; } return phone.getDeviceSvn(); Loading @@ -160,7 +161,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getSubscriberId")) { mContext, subId, callingPackage, "getSubscriberId")) { return null; } return phone.getSubscriberId(); Loading @@ -181,7 +182,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getIccSerialNumber")) { mContext, subId, callingPackage, "getIccSerialNumber")) { return null; } return phone.getIccSerialNumber(); Loading @@ -200,7 +201,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { if (phone != null) { // This is open to apps with WRITE_SMS. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneNumber( mContext, callingPackage, "getLine1Number")) { mContext, subId, callingPackage, "getLine1Number")) { return null; } return phone.getLine1Number(); Loading @@ -218,7 +219,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getLine1AlphaTag")) { mContext, subId, callingPackage, "getLine1AlphaTag")) { return null; } return phone.getLine1AlphaTag(); Loading @@ -236,7 +237,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getMsisdn")) { mContext, subId, callingPackage, "getMsisdn")) { return null; } return phone.getMsisdn(); Loading @@ -254,7 +255,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getVoiceMailNumber")) { mContext, subId, callingPackage, "getVoiceMailNumber")) { return null; } String number = PhoneNumberUtils.extractNetworkPortion(phone.getVoiceMailNumber()); Loading Loading @@ -292,7 +293,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getVoiceMailAlphaTag")) { mContext, subId, callingPackage, "getVoiceMailAlphaTag")) { return null; } return phone.getVoiceMailAlphaTag(); Loading Loading @@ -473,7 +474,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getGroupIdLevel1")) { mContext, subId, callingPackage, "getGroupIdLevel1")) { return null; } return phone.getGroupIdLevel1(); Loading src/java/com/android/internal/telephony/SubscriptionController.java +110 −73 Original line number Diff line number Diff line Loading @@ -418,7 +418,7 @@ public class SubscriptionController extends ISub.Stub { @Override public SubscriptionInfo getActiveSubscriptionInfo(int subId, String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfo")) { mContext, subId, callingPackage, "getActiveSubscriptionInfo")) { return null; } Loading Loading @@ -457,12 +457,29 @@ public class SubscriptionController extends ISub.Stub { */ @Override public SubscriptionInfo getActiveSubscriptionInfoForIccId(String iccId, String callingPackage) { // Query the subscriptions unconditionally, and then check whether the caller has access to // the given subscription. final SubscriptionInfo si = getActiveSubscriptionInfoForIccIdInternal(iccId); final int subId = si != null ? si.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID; if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfoForIccId") || iccId == null) { mContext, subId, callingPackage, "getActiveSubscriptionInfoForIccId")) { return null; } return si; } /** * Get the active SubscriptionInfo associated with the given iccId. The caller *must* perform * permission checks when using this method. */ private SubscriptionInfo getActiveSubscriptionInfoForIccIdInternal(String iccId) { if (iccId == null) { return null; } // Now that all security checks passes, perform the operation as ourselves. final long identity = Binder.clearCallingIdentity(); try { List<SubscriptionInfo> subList = getActiveSubscriptionInfoList( Loading Loading @@ -496,8 +513,16 @@ public class SubscriptionController extends ISub.Stub { @Override public SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex, String callingPackage) { Phone phone = PhoneFactory.getPhone(slotIndex); if (phone == null) { if (DBG) { loge("[getActiveSubscriptionInfoForSimSlotIndex] no phone, slotIndex=" + slotIndex); } return null; } if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfoForSimSlotIndex")) { mContext, phone.getSubId(), callingPackage, "getActiveSubscriptionInfoForSimSlotIndex")) { return null; } Loading Loading @@ -542,8 +567,11 @@ public class SubscriptionController extends ISub.Stub { public List<SubscriptionInfo> getAllSubInfoList(String callingPackage) { if (DBG) logd("[getAllSubInfoList]+"); // This API isn't public, so no need to provide a valid subscription ID - we're not worried // about carrier-privileged callers not having access. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getAllSubInfoList")) { mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, "getAllSubInfoList")) { return null; } Loading @@ -570,13 +598,19 @@ public class SubscriptionController extends ISub.Stub { */ @Override public List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfoList")) { return null; boolean canReadAllPhoneState; try { canReadAllPhoneState = TelephonyPermissions.checkReadPhoneState(mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, "getActiveSubscriptionInfoList"); } catch (SecurityException e) { canReadAllPhoneState = false; } // Now that all security checks passes, perform the operation as ourselves. // Perform the operation as ourselves. If the caller cannot read phone state, they may still // have carrier privileges for that subscription, so we always need to make the query and // then filter the results. List<SubscriptionInfo> subList; final long identity = Binder.clearCallingIdentity(); try { if (!isSubInfoReady()) { Loading @@ -592,7 +626,7 @@ public class SubscriptionController extends ISub.Stub { logd("[getActiveSubscriptionInfoList] Getting Cached subInfo=" + si); } } return new ArrayList<SubscriptionInfo>(tmpCachedSubList); subList = tmpCachedSubList; } else { if (DBG_CACHE) { logd("[getActiveSubscriptionInfoList] Cached subInfo is null"); Loading @@ -602,6 +636,24 @@ public class SubscriptionController extends ISub.Stub { } finally { Binder.restoreCallingIdentity(identity); } // If the caller can read all phone state, just return the full list. if (canReadAllPhoneState) { return new ArrayList<>(subList); } // Filter the list to only include subscriptions which the (restored) caller can manage. return subList.stream() .filter(subscriptionInfo -> { try { return TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subscriptionInfo.getSubscriptionId(), callingPackage, "getActiveSubscriptionInfoList"); } catch (SecurityException e) { return false; } }) .collect(Collectors.toList()); } /** Loading Loading @@ -655,25 +707,14 @@ public class SubscriptionController extends ISub.Stub { */ @Override public int getActiveSubInfoCount(String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubInfoCount")) { return 0; } // Now that all security checks passes, perform the operation as ourselves. final long identity = Binder.clearCallingIdentity(); try { List<SubscriptionInfo> records = getActiveSubscriptionInfoList( mContext.getOpPackageName()); // Let getActiveSubscriptionInfoList perform permission checks / filtering. List<SubscriptionInfo> records = getActiveSubscriptionInfoList(callingPackage); if (records == null) { if (VDBG) logd("[getActiveSubInfoCount] records null"); return 0; } if (VDBG) logd("[getActiveSubInfoCount]- count: " + records.size()); return records.size(); } finally { Binder.restoreCallingIdentity(identity); } } /** Loading @@ -685,8 +726,11 @@ public class SubscriptionController extends ISub.Stub { public int getAllSubInfoCount(String callingPackage) { if (DBG) logd("[getAllSubInfoCount]+"); // This API isn't public, so no need to provide a valid subscription ID - we're not worried // about carrier-privileged callers not having access. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getAllSubInfoCount")) { mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, "getAllSubInfoCount")) { return 0; } Loading Loading @@ -725,8 +769,11 @@ public class SubscriptionController extends ISub.Stub { @Override public List<SubscriptionInfo> getAvailableSubscriptionInfoList(String callingPackage) { // This API isn't public, so no need to provide a valid subscription ID - we're not worried // about carrier-privileged callers not having access. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getAvailableSubscriptionInfoList")) { mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, "getAvailableSubscriptionInfoList")) { throw new SecurityException("Need READ_PHONE_STATE to call " + " getAvailableSubscriptionInfoList"); } Loading Loading @@ -1862,28 +1909,21 @@ public class SubscriptionController extends ISub.Stub { return subIds[0]; } public List<SubscriptionInfo> getSubInfoUsingSlotIndexWithCheck(int slotIndex, boolean needCheck, String callingPackage) { if (DBG) logd("[getSubInfoUsingSlotIndexWithCheck]+ slotIndex:" + slotIndex); if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getSubInfoUsingSlotIndexWithCheck")) { return null; } // Now that all security checks passes, perform the operation as ourselves. final long identity = Binder.clearCallingIdentity(); try { /** Must be public for access from instrumentation tests. */ @VisibleForTesting public List<SubscriptionInfo> getSubInfoUsingSlotIndexPrivileged(int slotIndex, boolean needCheck) { if (DBG) logd("[getSubInfoUsingSlotIndexPrivileged]+ slotIndex:" + slotIndex); if (slotIndex == SubscriptionManager.DEFAULT_SIM_SLOT_INDEX) { slotIndex = getSlotIndex(getDefaultSubId()); } if (!SubscriptionManager.isValidSlotIndex(slotIndex)) { if (DBG) logd("[getSubInfoUsingSlotIndexWithCheck]- invalid slotIndex"); if (DBG) logd("[getSubInfoUsingSlotIndexPrivileged]- invalid slotIndex"); return null; } if (needCheck && !isSubInfoReady()) { if (DBG) logd("[getSubInfoUsingSlotIndexWithCheck]- not ready"); if (DBG) logd("[getSubInfoUsingSlotIndexPrivileged]- not ready"); return null; } Loading Loading @@ -1911,9 +1951,6 @@ public class SubscriptionController extends ISub.Stub { if (DBG) logd("[getSubInfoUsingSlotIndex]- null info return"); return subList; } finally { Binder.restoreCallingIdentity(identity); } } private void validateSubId(int subId) { Loading Loading @@ -2059,7 +2096,7 @@ public class SubscriptionController extends ISub.Stub { @Override public String getSubscriptionProperty(int subId, String propKey, String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getSubInfoUsingSlotIndexWithCheck")) { mContext, subId, callingPackage, "getSubscriptionProperty")) { return null; } String resultValue = null; Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −3 Original line number Diff line number Diff line Loading @@ -603,9 +603,8 @@ public class SubscriptionInfoUpdater extends Handler { String[] decIccId = new String[PROJECT_SIM_NUM]; for (int i = 0; i < PROJECT_SIM_NUM; i++) { oldIccId[i] = null; List<SubscriptionInfo> oldSubInfo = SubscriptionController.getInstance().getSubInfoUsingSlotIndexWithCheck(i, false, mContext.getOpPackageName()); List<SubscriptionInfo> oldSubInfo = SubscriptionController.getInstance() .getSubInfoUsingSlotIndexPrivileged(i, false); decIccId[i] = IccUtils.getDecimalSubstring(mIccId[i]); if (oldSubInfo != null && oldSubInfo.size() > 0) { oldIccId[i] = oldSubInfo.get(0).getIccId(); Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +29 −29 Original line number Diff line number Diff line Loading @@ -15,15 +15,10 @@ */ package com.android.internal.telephony; import android.app.AppOpsManager; import android.content.Context; import org.junit.After; import org.junit.Assert; import org.junit.Before; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.Manifest.permission.READ_SMS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; Loading @@ -31,12 +26,17 @@ import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import org.junit.Test; import org.mockito.Mock; import android.app.AppOpsManager; import android.content.Context; import android.test.suitebuilder.annotation.SmallTest; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; public class PhoneSubInfoControllerTest extends TelephonyTest { private PhoneSubInfoController mPhoneSubInfoControllerUT; private AppOpsManager mAppOsMgr; Loading Loading @@ -92,7 +92,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceId", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceId")); } try { Loading @@ -100,7 +100,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceId", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceId")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -142,7 +142,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getNai", ex.getMessage()); assertTrue(ex.getMessage().contains("getNai")); } try { Loading @@ -150,7 +150,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getNai", ex.getMessage()); assertTrue(ex.getMessage().contains("getNai")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -192,7 +192,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getImei", ex.getMessage()); assertTrue(ex.getMessage().contains("getImei")); } try { Loading @@ -200,7 +200,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getImei", ex.getMessage()); assertTrue(ex.getMessage().contains("getImei")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -242,7 +242,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceSvn", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceSvn")); } try { Loading @@ -250,7 +250,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceSvn", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceSvn")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -295,7 +295,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getSubscriberId", ex.getMessage()); assertTrue(ex.getMessage().contains("getSubscriberId")); } try { Loading @@ -303,7 +303,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getSubscriberId", ex.getMessage()); assertTrue(ex.getMessage().contains("getSubscriberId")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -350,7 +350,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getIccSerialNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getIccSerialNumber")); } try { Loading @@ -358,7 +358,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getIccSerialNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getIccSerialNumber")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -483,7 +483,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getLine1AlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getLine1AlphaTag")); } try { Loading @@ -491,7 +491,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getLine1AlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getLine1AlphaTag")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -535,7 +535,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getMsisdn", ex.getMessage()); assertTrue(ex.getMessage().contains("getMsisdn")); } try { Loading @@ -543,7 +543,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getMsisdn", ex.getMessage()); assertTrue(ex.getMessage().contains("getMsisdn")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -587,7 +587,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailNumber")); } try { Loading @@ -595,7 +595,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailNumber")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -641,7 +641,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailAlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailAlphaTag")); } try { Loading @@ -649,7 +649,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailAlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailAlphaTag")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +6 −6 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/java/com/android/internal/telephony/PhoneSubInfoController.java +18 −17 Original line number Diff line number Diff line Loading @@ -59,15 +59,15 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { } public String getDeviceIdForPhone(int phoneId, String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getDeviceId")) { return null; } if (!SubscriptionManager.isValidPhoneId(phoneId)) { phoneId = 0; } final Phone phone = mPhone[phoneId]; if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, phone.getSubId(), callingPackage, "getDeviceId")) { return null; } return phone.getDeviceId(); } else { loge("getDeviceIdForPhone phone " + phoneId + " is null"); Loading @@ -79,7 +79,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getNai")) { mContext, subId, callingPackage, "getNai")) { return null; } return phone.getNai(); Loading @@ -93,7 +93,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getImei")) { mContext, subId, callingPackage, "getImei")) { return null; } return phone.getImei(); Loading @@ -108,7 +108,8 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getCarrierInfoForImsiEncryption")) { mContext, subId, callingPackage, "getCarrierInfoForImsiEncryption")) { return null; } return phone.getCarrierInfoForImsiEncryption(keyType); Loading @@ -123,7 +124,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "setCarrierInfoForImsiEncryption")) { mContext, subId, callingPackage, "setCarrierInfoForImsiEncryption")) { return; } phone.setCarrierInfoForImsiEncryption(imsiEncryptionInfo); Loading @@ -142,7 +143,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getDeviceSvn")) { mContext, subId, callingPackage, "getDeviceSvn")) { return null; } return phone.getDeviceSvn(); Loading @@ -160,7 +161,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getSubscriberId")) { mContext, subId, callingPackage, "getSubscriberId")) { return null; } return phone.getSubscriberId(); Loading @@ -181,7 +182,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getIccSerialNumber")) { mContext, subId, callingPackage, "getIccSerialNumber")) { return null; } return phone.getIccSerialNumber(); Loading @@ -200,7 +201,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { if (phone != null) { // This is open to apps with WRITE_SMS. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneNumber( mContext, callingPackage, "getLine1Number")) { mContext, subId, callingPackage, "getLine1Number")) { return null; } return phone.getLine1Number(); Loading @@ -218,7 +219,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getLine1AlphaTag")) { mContext, subId, callingPackage, "getLine1AlphaTag")) { return null; } return phone.getLine1AlphaTag(); Loading @@ -236,7 +237,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getMsisdn")) { mContext, subId, callingPackage, "getMsisdn")) { return null; } return phone.getMsisdn(); Loading @@ -254,7 +255,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getVoiceMailNumber")) { mContext, subId, callingPackage, "getVoiceMailNumber")) { return null; } String number = PhoneNumberUtils.extractNetworkPortion(phone.getVoiceMailNumber()); Loading Loading @@ -292,7 +293,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getVoiceMailAlphaTag")) { mContext, subId, callingPackage, "getVoiceMailAlphaTag")) { return null; } return phone.getVoiceMailAlphaTag(); Loading Loading @@ -473,7 +474,7 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub { Phone phone = getPhone(subId); if (phone != null) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getGroupIdLevel1")) { mContext, subId, callingPackage, "getGroupIdLevel1")) { return null; } return phone.getGroupIdLevel1(); Loading
src/java/com/android/internal/telephony/SubscriptionController.java +110 −73 Original line number Diff line number Diff line Loading @@ -418,7 +418,7 @@ public class SubscriptionController extends ISub.Stub { @Override public SubscriptionInfo getActiveSubscriptionInfo(int subId, String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfo")) { mContext, subId, callingPackage, "getActiveSubscriptionInfo")) { return null; } Loading Loading @@ -457,12 +457,29 @@ public class SubscriptionController extends ISub.Stub { */ @Override public SubscriptionInfo getActiveSubscriptionInfoForIccId(String iccId, String callingPackage) { // Query the subscriptions unconditionally, and then check whether the caller has access to // the given subscription. final SubscriptionInfo si = getActiveSubscriptionInfoForIccIdInternal(iccId); final int subId = si != null ? si.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID; if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfoForIccId") || iccId == null) { mContext, subId, callingPackage, "getActiveSubscriptionInfoForIccId")) { return null; } return si; } /** * Get the active SubscriptionInfo associated with the given iccId. The caller *must* perform * permission checks when using this method. */ private SubscriptionInfo getActiveSubscriptionInfoForIccIdInternal(String iccId) { if (iccId == null) { return null; } // Now that all security checks passes, perform the operation as ourselves. final long identity = Binder.clearCallingIdentity(); try { List<SubscriptionInfo> subList = getActiveSubscriptionInfoList( Loading Loading @@ -496,8 +513,16 @@ public class SubscriptionController extends ISub.Stub { @Override public SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex, String callingPackage) { Phone phone = PhoneFactory.getPhone(slotIndex); if (phone == null) { if (DBG) { loge("[getActiveSubscriptionInfoForSimSlotIndex] no phone, slotIndex=" + slotIndex); } return null; } if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfoForSimSlotIndex")) { mContext, phone.getSubId(), callingPackage, "getActiveSubscriptionInfoForSimSlotIndex")) { return null; } Loading Loading @@ -542,8 +567,11 @@ public class SubscriptionController extends ISub.Stub { public List<SubscriptionInfo> getAllSubInfoList(String callingPackage) { if (DBG) logd("[getAllSubInfoList]+"); // This API isn't public, so no need to provide a valid subscription ID - we're not worried // about carrier-privileged callers not having access. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getAllSubInfoList")) { mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, "getAllSubInfoList")) { return null; } Loading @@ -570,13 +598,19 @@ public class SubscriptionController extends ISub.Stub { */ @Override public List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubscriptionInfoList")) { return null; boolean canReadAllPhoneState; try { canReadAllPhoneState = TelephonyPermissions.checkReadPhoneState(mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, "getActiveSubscriptionInfoList"); } catch (SecurityException e) { canReadAllPhoneState = false; } // Now that all security checks passes, perform the operation as ourselves. // Perform the operation as ourselves. If the caller cannot read phone state, they may still // have carrier privileges for that subscription, so we always need to make the query and // then filter the results. List<SubscriptionInfo> subList; final long identity = Binder.clearCallingIdentity(); try { if (!isSubInfoReady()) { Loading @@ -592,7 +626,7 @@ public class SubscriptionController extends ISub.Stub { logd("[getActiveSubscriptionInfoList] Getting Cached subInfo=" + si); } } return new ArrayList<SubscriptionInfo>(tmpCachedSubList); subList = tmpCachedSubList; } else { if (DBG_CACHE) { logd("[getActiveSubscriptionInfoList] Cached subInfo is null"); Loading @@ -602,6 +636,24 @@ public class SubscriptionController extends ISub.Stub { } finally { Binder.restoreCallingIdentity(identity); } // If the caller can read all phone state, just return the full list. if (canReadAllPhoneState) { return new ArrayList<>(subList); } // Filter the list to only include subscriptions which the (restored) caller can manage. return subList.stream() .filter(subscriptionInfo -> { try { return TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subscriptionInfo.getSubscriptionId(), callingPackage, "getActiveSubscriptionInfoList"); } catch (SecurityException e) { return false; } }) .collect(Collectors.toList()); } /** Loading Loading @@ -655,25 +707,14 @@ public class SubscriptionController extends ISub.Stub { */ @Override public int getActiveSubInfoCount(String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getActiveSubInfoCount")) { return 0; } // Now that all security checks passes, perform the operation as ourselves. final long identity = Binder.clearCallingIdentity(); try { List<SubscriptionInfo> records = getActiveSubscriptionInfoList( mContext.getOpPackageName()); // Let getActiveSubscriptionInfoList perform permission checks / filtering. List<SubscriptionInfo> records = getActiveSubscriptionInfoList(callingPackage); if (records == null) { if (VDBG) logd("[getActiveSubInfoCount] records null"); return 0; } if (VDBG) logd("[getActiveSubInfoCount]- count: " + records.size()); return records.size(); } finally { Binder.restoreCallingIdentity(identity); } } /** Loading @@ -685,8 +726,11 @@ public class SubscriptionController extends ISub.Stub { public int getAllSubInfoCount(String callingPackage) { if (DBG) logd("[getAllSubInfoCount]+"); // This API isn't public, so no need to provide a valid subscription ID - we're not worried // about carrier-privileged callers not having access. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getAllSubInfoCount")) { mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, "getAllSubInfoCount")) { return 0; } Loading Loading @@ -725,8 +769,11 @@ public class SubscriptionController extends ISub.Stub { @Override public List<SubscriptionInfo> getAvailableSubscriptionInfoList(String callingPackage) { // This API isn't public, so no need to provide a valid subscription ID - we're not worried // about carrier-privileged callers not having access. if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getAvailableSubscriptionInfoList")) { mContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage, "getAvailableSubscriptionInfoList")) { throw new SecurityException("Need READ_PHONE_STATE to call " + " getAvailableSubscriptionInfoList"); } Loading Loading @@ -1862,28 +1909,21 @@ public class SubscriptionController extends ISub.Stub { return subIds[0]; } public List<SubscriptionInfo> getSubInfoUsingSlotIndexWithCheck(int slotIndex, boolean needCheck, String callingPackage) { if (DBG) logd("[getSubInfoUsingSlotIndexWithCheck]+ slotIndex:" + slotIndex); if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getSubInfoUsingSlotIndexWithCheck")) { return null; } // Now that all security checks passes, perform the operation as ourselves. final long identity = Binder.clearCallingIdentity(); try { /** Must be public for access from instrumentation tests. */ @VisibleForTesting public List<SubscriptionInfo> getSubInfoUsingSlotIndexPrivileged(int slotIndex, boolean needCheck) { if (DBG) logd("[getSubInfoUsingSlotIndexPrivileged]+ slotIndex:" + slotIndex); if (slotIndex == SubscriptionManager.DEFAULT_SIM_SLOT_INDEX) { slotIndex = getSlotIndex(getDefaultSubId()); } if (!SubscriptionManager.isValidSlotIndex(slotIndex)) { if (DBG) logd("[getSubInfoUsingSlotIndexWithCheck]- invalid slotIndex"); if (DBG) logd("[getSubInfoUsingSlotIndexPrivileged]- invalid slotIndex"); return null; } if (needCheck && !isSubInfoReady()) { if (DBG) logd("[getSubInfoUsingSlotIndexWithCheck]- not ready"); if (DBG) logd("[getSubInfoUsingSlotIndexPrivileged]- not ready"); return null; } Loading Loading @@ -1911,9 +1951,6 @@ public class SubscriptionController extends ISub.Stub { if (DBG) logd("[getSubInfoUsingSlotIndex]- null info return"); return subList; } finally { Binder.restoreCallingIdentity(identity); } } private void validateSubId(int subId) { Loading Loading @@ -2059,7 +2096,7 @@ public class SubscriptionController extends ISub.Stub { @Override public String getSubscriptionProperty(int subId, String propKey, String callingPackage) { if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( mContext, callingPackage, "getSubInfoUsingSlotIndexWithCheck")) { mContext, subId, callingPackage, "getSubscriptionProperty")) { return null; } String resultValue = null; Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −3 Original line number Diff line number Diff line Loading @@ -603,9 +603,8 @@ public class SubscriptionInfoUpdater extends Handler { String[] decIccId = new String[PROJECT_SIM_NUM]; for (int i = 0; i < PROJECT_SIM_NUM; i++) { oldIccId[i] = null; List<SubscriptionInfo> oldSubInfo = SubscriptionController.getInstance().getSubInfoUsingSlotIndexWithCheck(i, false, mContext.getOpPackageName()); List<SubscriptionInfo> oldSubInfo = SubscriptionController.getInstance() .getSubInfoUsingSlotIndexPrivileged(i, false); decIccId[i] = IccUtils.getDecimalSubstring(mIccId[i]); if (oldSubInfo != null && oldSubInfo.size() > 0) { oldIccId[i] = oldSubInfo.get(0).getIccId(); Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +29 −29 Original line number Diff line number Diff line Loading @@ -15,15 +15,10 @@ */ package com.android.internal.telephony; import android.app.AppOpsManager; import android.content.Context; import org.junit.After; import org.junit.Assert; import org.junit.Before; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static android.Manifest.permission.READ_SMS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; Loading @@ -31,12 +26,17 @@ import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import org.junit.Test; import org.mockito.Mock; import android.app.AppOpsManager; import android.content.Context; import android.test.suitebuilder.annotation.SmallTest; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; public class PhoneSubInfoControllerTest extends TelephonyTest { private PhoneSubInfoController mPhoneSubInfoControllerUT; private AppOpsManager mAppOsMgr; Loading Loading @@ -92,7 +92,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceId", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceId")); } try { Loading @@ -100,7 +100,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceId", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceId")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -142,7 +142,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getNai", ex.getMessage()); assertTrue(ex.getMessage().contains("getNai")); } try { Loading @@ -150,7 +150,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getNai", ex.getMessage()); assertTrue(ex.getMessage().contains("getNai")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -192,7 +192,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getImei", ex.getMessage()); assertTrue(ex.getMessage().contains("getImei")); } try { Loading @@ -200,7 +200,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getImei", ex.getMessage()); assertTrue(ex.getMessage().contains("getImei")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -242,7 +242,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceSvn", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceSvn")); } try { Loading @@ -250,7 +250,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getDeviceSvn", ex.getMessage()); assertTrue(ex.getMessage().contains("getDeviceSvn")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -295,7 +295,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getSubscriberId", ex.getMessage()); assertTrue(ex.getMessage().contains("getSubscriberId")); } try { Loading @@ -303,7 +303,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getSubscriberId", ex.getMessage()); assertTrue(ex.getMessage().contains("getSubscriberId")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -350,7 +350,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getIccSerialNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getIccSerialNumber")); } try { Loading @@ -358,7 +358,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getIccSerialNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getIccSerialNumber")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -483,7 +483,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getLine1AlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getLine1AlphaTag")); } try { Loading @@ -491,7 +491,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getLine1AlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getLine1AlphaTag")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -535,7 +535,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getMsisdn", ex.getMessage()); assertTrue(ex.getMessage().contains("getMsisdn")); } try { Loading @@ -543,7 +543,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getMsisdn", ex.getMessage()); assertTrue(ex.getMessage().contains("getMsisdn")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -587,7 +587,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailNumber")); } try { Loading @@ -595,7 +595,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailNumber", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailNumber")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading Loading @@ -641,7 +641,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailAlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailAlphaTag")); } try { Loading @@ -649,7 +649,7 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { Assert.fail("expected Security Exception Thrown"); } catch (Exception ex) { assertTrue(ex instanceof SecurityException); assertEquals(READ_PHONE_STATE + " denied: getVoiceMailAlphaTag", ex.getMessage()); assertTrue(ex.getMessage().contains("getVoiceMailAlphaTag")); } //case 2: no READ_PRIVILEGED_PHONE_STATE & appOsMgr READ_PHONE_PERMISSION Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +6 −6 File changed.Preview size limit exceeded, changes collapsed. Show changes