Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +57 −56 Original line number Diff line number Diff line Loading @@ -104,11 +104,12 @@ public class SubscriptionInfoUpdater extends Handler { public static final String CURR_SUBID = "curr_subid"; @UnsupportedAppUsage private static Phone[] mPhone; private static Phone[] sPhones; @UnsupportedAppUsage private static Context mContext = null; private static Context sContext = null; @UnsupportedAppUsage private static String mIccId[] = new String[PROJECT_SIM_NUM]; private static String[] sIccId = new String[PROJECT_SIM_NUM]; private static int[] sSimCardState = new int[PROJECT_SIM_NUM]; private static int[] sSimApplicationState = new int[PROJECT_SIM_NUM]; private static boolean sIsSubInfoInitialized = false; Loading Loading @@ -150,13 +151,13 @@ public class SubscriptionInfoUpdater extends Handler { logd("Constructor invoked"); mBackgroundHandler = new Handler(looper); mContext = context; mPhone = phone; mSubscriptionManager = SubscriptionManager.from(mContext); mEuiccManager = (EuiccManager) mContext.getSystemService(Context.EUICC_SERVICE); sContext = context; sPhones = phone; mSubscriptionManager = SubscriptionManager.from(sContext); mEuiccManager = (EuiccManager) sContext.getSystemService(Context.EUICC_SERVICE); mPackageManager = packageMgr; mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext); mCarrierServiceBindHelper = new CarrierServiceBindHelper(sContext); initializeCarrierApps(); } Loading @@ -172,9 +173,9 @@ public class SubscriptionInfoUpdater extends Handler { public void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { mCurrentlyActiveUserId = newUserId; CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), CarrierAppUtils.disableCarrierAppsUntilPrivileged(sContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), mContext.getContentResolver(), mCurrentlyActiveUserId); sContext.getContentResolver(), mCurrentlyActiveUserId); if (reply != null) { try { Loading @@ -184,14 +185,14 @@ public class SubscriptionInfoUpdater extends Handler { } } }, LOG_TAG); ActivityManager am = (ActivityManager) mContext.getSystemService( ActivityManager am = (ActivityManager) sContext.getSystemService( Context.ACTIVITY_SERVICE); mCurrentlyActiveUserId = am.getCurrentUser(); } catch (RemoteException e) { logd("Couldn't get current user ID; guessing it's 0: " + e.getMessage()); } CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), mContext.getContentResolver(), CarrierAppUtils.disableCarrierAppsUntilPrivileged(sContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), sContext.getContentResolver(), mCurrentlyActiveUserId); } Loading Loading @@ -230,8 +231,8 @@ public class SubscriptionInfoUpdater extends Handler { for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i); int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i); if (mIccId[i] == null || slot == null || !slot.isActive()) { if (mIccId[i] == null) { if (sIccId[i] == null || slot == null || !slot.isActive()) { if (sIccId[i] == null) { logd("Wait for SIM " + i + " Iccid"); } else { logd(String.format("Wait for slot corresponding to phone %d to be active, " Loading @@ -255,7 +256,7 @@ public class SubscriptionInfoUpdater extends Handler { if (ar.exception == null && ar.result != null) { int[] modes = (int[])ar.result; if (modes[0] == 1) { // Manual mode. mPhone[slotId].setNetworkSelectionModeAutomatic(null); sPhones[slotId].setNetworkSelectionModeAutomatic(null); } } else { logd("EVENT_GET_NETWORK_SELECTION_MODE_DONE: error getting network mode."); Loading Loading @@ -359,14 +360,14 @@ public class SubscriptionInfoUpdater extends Handler { } private void handleSimLocked(int slotId, String reason) { if (mIccId[slotId] != null && mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { if (sIccId[slotId] != null && sIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " hot plug in"); mIccId[slotId] = null; sIccId[slotId] = null; } String iccId = mIccId[slotId]; String iccId = sIccId[slotId]; if (iccId == null) { IccCard iccCard = mPhone[slotId].getIccCard(); IccCard iccCard = sPhones[slotId].getIccCard(); if (iccCard == null) { logd("handleSimLocked: IccCard null"); return; Loading @@ -380,7 +381,7 @@ public class SubscriptionInfoUpdater extends Handler { logd("handleSimLocked: IccID null"); return; } mIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); sIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); } else { logd("NOT Querying IccId its already set sIccid[" + slotId + "]=" + iccId); } Loading Loading @@ -413,12 +414,12 @@ public class SubscriptionInfoUpdater extends Handler { private void handleSimNotReady(int slotId) { logd("handleSimNotReady: slotId: " + slotId); IccCard iccCard = mPhone[slotId].getIccCard(); IccCard iccCard = sPhones[slotId].getIccCard(); if (iccCard.isEmptyProfile()) { // ICC_NOT_READY is a terminal state for an eSIM on the boot profile. At this // phase, the subscription list is accessible. Treating NOT_READY // as equivalent to ABSENT, once the rest of the system can handle it. mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; sIccId[slotId] = ICCID_STRING_FOR_NO_SIM; updateSubscriptionInfoByIccId(slotId, false /* updateEmbeddedSubs */); } Loading @@ -435,7 +436,7 @@ public class SubscriptionInfoUpdater extends Handler { // removed or a refresh RESET that the IccRecords could be null. The right behavior is to // not broadcast the SIM loaded. int loadedSlotId = slotId; IccCard iccCard = mPhone[slotId].getIccCard(); IccCard iccCard = sPhones[slotId].getIccCard(); if (iccCard == null) { // Possibly a race condition. logd("handleSimLoaded: IccCard null"); return; Loading @@ -449,7 +450,7 @@ public class SubscriptionInfoUpdater extends Handler { logd("handleSimLoaded: IccID null"); return; } mIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); sIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); updateSubscriptionInfoByIccId(slotId, true /* updateEmbeddedSubs */); List<SubscriptionInfo> subscriptionInfos = SubscriptionController.getInstance() Loading @@ -460,12 +461,12 @@ public class SubscriptionInfoUpdater extends Handler { for (SubscriptionInfo sub : subscriptionInfos) { int subId = sub.getSubscriptionId(); TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); sContext.getSystemService(Context.TELEPHONY_SERVICE); String operator = tm.getSimOperatorNumeric(subId); if (!TextUtils.isEmpty(operator)) { if (subId == SubscriptionController.getInstance().getDefaultSubId()) { MccTable.updateMccMncConfiguration(mContext, operator); MccTable.updateMccMncConfiguration(sContext, operator); } SubscriptionController.getInstance().setMccMnc(operator, subId); } else { Loading Loading @@ -500,12 +501,12 @@ public class SubscriptionInfoUpdater extends Handler { * Storing last subId in SharedPreference for now to detect SIM change. */ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); PreferenceManager.getDefaultSharedPreferences(sContext); int storedSubId = sp.getInt(CURR_SUBID + slotId, -1); if (storedSubId != subId) { int networkType = Settings.Global.getInt( mPhone[slotId].getContext().getContentResolver(), sPhones[slotId].getContext().getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE + subId, -1 /* invalid network mode */); Loading @@ -513,23 +514,23 @@ public class SubscriptionInfoUpdater extends Handler { networkType = RILConstants.PREFERRED_NETWORK_MODE; try { networkType = TelephonyManager.getIntAtIndex( mContext.getContentResolver(), sContext.getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE, slotId); } catch (SettingNotFoundException retrySnfe) { Rlog.e(LOG_TAG, "Settings Exception Reading Value At Index for " + "Settings.Global.PREFERRED_NETWORK_MODE"); } Settings.Global.putInt( mPhone[slotId].getContext().getContentResolver(), sPhones[slotId].getContext().getContentResolver(), Global.PREFERRED_NETWORK_MODE + subId, networkType); } // Set the modem network mode mPhone[slotId].setPreferredNetworkType(networkType, null); sPhones[slotId].setPreferredNetworkType(networkType, null); // Only support automatic selection mode on SIM change. mPhone[slotId].getNetworkSelectionMode( sPhones[slotId].getNetworkSelectionMode( obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE, new Integer(slotId))); Loading @@ -542,9 +543,9 @@ public class SubscriptionInfoUpdater extends Handler { } // Update set of enabled carrier apps now that the privilege rules may have changed. CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), CarrierAppUtils.disableCarrierAppsUntilPrivileged(sContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), mContext.getContentResolver(), mCurrentlyActiveUserId); sContext.getContentResolver(), mCurrentlyActiveUserId); /** * The sim loading sequence will be Loading @@ -563,22 +564,22 @@ public class SubscriptionInfoUpdater extends Handler { private void updateCarrierServices(int slotId, String simState) { CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); (CarrierConfigManager) sContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); configManager.updateConfigForPhoneId(slotId, simState); mCarrierServiceBindHelper.updateForPhoneId(slotId, simState); } private void updateSubscriptionCarrierId(int slotId, String simState) { if (mPhone != null && mPhone[slotId] != null) { mPhone[slotId].resolveSubscriptionCarrierId(simState); if (sPhones != null && sPhones[slotId] != null) { sPhones[slotId].resolveSubscriptionCarrierId(simState); } } private void handleSimAbsent(int slotId, int absentAndInactive) { if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { if (sIccId[slotId] != null && !sIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " hot plug out, absentAndInactive=" + absentAndInactive); } mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; sIccId[slotId] = ICCID_STRING_FOR_NO_SIM; updateSubscriptionInfoByIccId(slotId, true /* updateEmbeddedSubs */); // Do not broadcast if the SIM is absent and inactive, because the logical slotId here is // no longer correct Loading @@ -592,10 +593,10 @@ public class SubscriptionInfoUpdater extends Handler { } private void handleSimError(int slotId) { if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { if (sIccId[slotId] != null && !sIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " Error "); } mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; sIccId[slotId] = ICCID_STRING_FOR_NO_SIM; updateSubscriptionInfoByIccId(slotId, true /* updateEmbeddedSubs */); broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR); Loading @@ -620,10 +621,10 @@ public class SubscriptionInfoUpdater extends Handler { SubscriptionController.getInstance().clearSubInfoRecord(slotIndex); // If SIM is not absent, insert new record or update existing record. if (!ICCID_STRING_FOR_NO_SIM.equals(mIccId[slotIndex])) { if (!ICCID_STRING_FOR_NO_SIM.equals(sIccId[slotIndex])) { logd("updateSubscriptionInfoByIccId: adding subscription info record: iccid: " + mIccId[slotIndex] + "slot: " + slotIndex); mSubscriptionManager.addSubscriptionInfoRecord(mIccId[slotIndex], slotIndex); + sIccId[slotIndex] + "slot: " + slotIndex); mSubscriptionManager.addSubscriptionInfoRecord(sIccId[slotIndex], slotIndex); } List<SubscriptionInfo> subInfos = SubscriptionController.getInstance() Loading @@ -639,8 +640,8 @@ public class SubscriptionInfoUpdater extends Handler { if (!TextUtils.equals(msisdn, temp.getNumber())) { value.put(SubscriptionManager.NUMBER, msisdn); mContext.getContentResolver().update(SubscriptionManager.getUriForSubscriptionId( temp.getSubscriptionId()), value, null, null); sContext.getContentResolver().update(SubscriptionManager .getUriForSubscriptionId(temp.getSubscriptionId()), value, null, null); changed = true; } } Loading Loading @@ -803,7 +804,7 @@ public class SubscriptionInfoUpdater extends Handler { // returned by the eUICC controller). List<SubscriptionInfo> existingSubscriptions = SubscriptionController.getInstance() .getSubscriptionInfoListForEmbeddedSubscriptionUpdate(embeddedIccids, isRemovable); ContentResolver contentResolver = mContext.getContentResolver(); ContentResolver contentResolver = sContext.getContentResolver(); for (EuiccProfileInfo embeddedProfile : embeddedProfiles) { int index = findSubscriptionInfoForIccid(existingSubscriptions, embeddedProfile.getIccid()); Loading Loading @@ -851,7 +852,7 @@ public class SubscriptionInfoUpdater extends Handler { // is no valid carrier id present. if (prevCarrierId == TelephonyManager.UNKNOWN_CARRIER_ID) { values.put(SubscriptionManager.CARRIER_ID, CarrierResolver.getCarrierIdFromIdentifier(mContext, cid)); CarrierResolver.getCarrierIdFromIdentifier(sContext, cid)); } String mcc = cid.getMcc(); String mnc = cid.getMnc(); Loading Loading @@ -921,14 +922,14 @@ public class SubscriptionInfoUpdater extends Handler { private String getDefaultCarrierServicePackageName() { CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); (CarrierConfigManager) sContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); return configManager.getDefaultCarrierServicePackageName(); } private boolean isCarrierServicePackage(int phoneId, String pkgName) { if (pkgName.equals(getDefaultCarrierServicePackageName())) return false; List<String> carrierPackageNames = TelephonyManager.from(mContext) List<String> carrierPackageNames = TelephonyManager.from(sContext) .getCarrierPackageNamesForIntentAndPhone( new Intent(CarrierService.CARRIER_SERVICE_INTERFACE), phoneId); if (DBG) logd("Carrier Packages For Subscription = " + carrierPackageNames); Loading Loading @@ -1024,7 +1025,7 @@ public class SubscriptionInfoUpdater extends Handler { loge("Invalid Group UUID=" + groupUuidString); } } if (cv.size() > 0 && mContext.getContentResolver().update(SubscriptionManager if (cv.size() > 0 && sContext.getContentResolver().update(SubscriptionManager .getUriForSubscriptionId(currentSubId), cv, null, null) > 0) { sc.refreshCachedActiveSubscriptionInfoList(); sc.notifySubscriptionInfoChanged(); Loading Loading @@ -1089,7 +1090,7 @@ public class SubscriptionInfoUpdater extends Handler { i.putExtra(PhoneConstants.SLOT_KEY, slotId); logd("Broadcasting intent ACTION_SIM_CARD_STATE_CHANGED " + simStateString(state) + " for phone: " + phoneId + " slot: " + slotId); mContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); sContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); TelephonyMetrics.getInstance().updateSimState(phoneId, state); } } Loading @@ -1102,7 +1103,7 @@ public class SubscriptionInfoUpdater extends Handler { boolean isUnknownToNotReady = (sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN && state == TelephonyManager.SIM_STATE_NOT_READY); IccCard iccCard = mPhone[phoneId].getIccCard(); IccCard iccCard = sPhones[phoneId].getIccCard(); boolean emptyProfile = iccCard != null && iccCard.isEmptyProfile(); if (state != sSimApplicationState[phoneId] && (!isUnknownToNotReady || emptyProfile)) { sSimApplicationState[phoneId] = state; Loading @@ -1117,7 +1118,7 @@ public class SubscriptionInfoUpdater extends Handler { i.putExtra(PhoneConstants.SLOT_KEY, slotId); logd("Broadcasting intent ACTION_SIM_APPLICATION_STATE_CHANGED " + simStateString(state) + " for phone: " + phoneId + " slot: " + slotId); mContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); sContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); TelephonyMetrics.getInstance().updateSimState(phoneId, state); } } Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -119,8 +119,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { public void setUp() throws Exception { super.setUp(this.getClass().getSimpleName()); replaceInstance(SubscriptionInfoUpdater.class, "mIccId", null, new String[1]); replaceInstance(SubscriptionInfoUpdater.class, "mContext", null, null); replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[1]); replaceInstance(SubscriptionInfoUpdater.class, "sContext", null, null); replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 1); replaceInstance(SubscriptionInfoUpdater.class, "sSimCardState", null, new int[1]); replaceInstance(SubscriptionInfoUpdater.class, "sSimApplicationState", null, new int[1]); Loading Loading @@ -387,10 +387,10 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { @SmallTest public void testDualSimLoaded() throws Exception { // Mock there is two sim cards replaceInstance(SubscriptionInfoUpdater.class, "mIccId", null, replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[]{null, null}); replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 2); replaceInstance(SubscriptionInfoUpdater.class, "mPhone", null, replaceInstance(SubscriptionInfoUpdater.class, "sPhones", null, new Phone[]{mPhone, mPhone}); replaceInstance(SubscriptionInfoUpdater.class, "sSimCardState", null, new int[]{0, 0}); Loading Loading @@ -448,7 +448,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { public void testSimLockWithIccId() throws Exception { /* no need for IccId query */ replaceInstance(SubscriptionInfoUpdater.class, "mIccId", null, replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[]{"89012604200000000000"}); mUpdater.updateInternalIccState( Loading Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +57 −56 Original line number Diff line number Diff line Loading @@ -104,11 +104,12 @@ public class SubscriptionInfoUpdater extends Handler { public static final String CURR_SUBID = "curr_subid"; @UnsupportedAppUsage private static Phone[] mPhone; private static Phone[] sPhones; @UnsupportedAppUsage private static Context mContext = null; private static Context sContext = null; @UnsupportedAppUsage private static String mIccId[] = new String[PROJECT_SIM_NUM]; private static String[] sIccId = new String[PROJECT_SIM_NUM]; private static int[] sSimCardState = new int[PROJECT_SIM_NUM]; private static int[] sSimApplicationState = new int[PROJECT_SIM_NUM]; private static boolean sIsSubInfoInitialized = false; Loading Loading @@ -150,13 +151,13 @@ public class SubscriptionInfoUpdater extends Handler { logd("Constructor invoked"); mBackgroundHandler = new Handler(looper); mContext = context; mPhone = phone; mSubscriptionManager = SubscriptionManager.from(mContext); mEuiccManager = (EuiccManager) mContext.getSystemService(Context.EUICC_SERVICE); sContext = context; sPhones = phone; mSubscriptionManager = SubscriptionManager.from(sContext); mEuiccManager = (EuiccManager) sContext.getSystemService(Context.EUICC_SERVICE); mPackageManager = packageMgr; mCarrierServiceBindHelper = new CarrierServiceBindHelper(mContext); mCarrierServiceBindHelper = new CarrierServiceBindHelper(sContext); initializeCarrierApps(); } Loading @@ -172,9 +173,9 @@ public class SubscriptionInfoUpdater extends Handler { public void onUserSwitching(int newUserId, IRemoteCallback reply) throws RemoteException { mCurrentlyActiveUserId = newUserId; CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), CarrierAppUtils.disableCarrierAppsUntilPrivileged(sContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), mContext.getContentResolver(), mCurrentlyActiveUserId); sContext.getContentResolver(), mCurrentlyActiveUserId); if (reply != null) { try { Loading @@ -184,14 +185,14 @@ public class SubscriptionInfoUpdater extends Handler { } } }, LOG_TAG); ActivityManager am = (ActivityManager) mContext.getSystemService( ActivityManager am = (ActivityManager) sContext.getSystemService( Context.ACTIVITY_SERVICE); mCurrentlyActiveUserId = am.getCurrentUser(); } catch (RemoteException e) { logd("Couldn't get current user ID; guessing it's 0: " + e.getMessage()); } CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), mContext.getContentResolver(), CarrierAppUtils.disableCarrierAppsUntilPrivileged(sContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), sContext.getContentResolver(), mCurrentlyActiveUserId); } Loading Loading @@ -230,8 +231,8 @@ public class SubscriptionInfoUpdater extends Handler { for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i); int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i); if (mIccId[i] == null || slot == null || !slot.isActive()) { if (mIccId[i] == null) { if (sIccId[i] == null || slot == null || !slot.isActive()) { if (sIccId[i] == null) { logd("Wait for SIM " + i + " Iccid"); } else { logd(String.format("Wait for slot corresponding to phone %d to be active, " Loading @@ -255,7 +256,7 @@ public class SubscriptionInfoUpdater extends Handler { if (ar.exception == null && ar.result != null) { int[] modes = (int[])ar.result; if (modes[0] == 1) { // Manual mode. mPhone[slotId].setNetworkSelectionModeAutomatic(null); sPhones[slotId].setNetworkSelectionModeAutomatic(null); } } else { logd("EVENT_GET_NETWORK_SELECTION_MODE_DONE: error getting network mode."); Loading Loading @@ -359,14 +360,14 @@ public class SubscriptionInfoUpdater extends Handler { } private void handleSimLocked(int slotId, String reason) { if (mIccId[slotId] != null && mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { if (sIccId[slotId] != null && sIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " hot plug in"); mIccId[slotId] = null; sIccId[slotId] = null; } String iccId = mIccId[slotId]; String iccId = sIccId[slotId]; if (iccId == null) { IccCard iccCard = mPhone[slotId].getIccCard(); IccCard iccCard = sPhones[slotId].getIccCard(); if (iccCard == null) { logd("handleSimLocked: IccCard null"); return; Loading @@ -380,7 +381,7 @@ public class SubscriptionInfoUpdater extends Handler { logd("handleSimLocked: IccID null"); return; } mIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); sIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); } else { logd("NOT Querying IccId its already set sIccid[" + slotId + "]=" + iccId); } Loading Loading @@ -413,12 +414,12 @@ public class SubscriptionInfoUpdater extends Handler { private void handleSimNotReady(int slotId) { logd("handleSimNotReady: slotId: " + slotId); IccCard iccCard = mPhone[slotId].getIccCard(); IccCard iccCard = sPhones[slotId].getIccCard(); if (iccCard.isEmptyProfile()) { // ICC_NOT_READY is a terminal state for an eSIM on the boot profile. At this // phase, the subscription list is accessible. Treating NOT_READY // as equivalent to ABSENT, once the rest of the system can handle it. mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; sIccId[slotId] = ICCID_STRING_FOR_NO_SIM; updateSubscriptionInfoByIccId(slotId, false /* updateEmbeddedSubs */); } Loading @@ -435,7 +436,7 @@ public class SubscriptionInfoUpdater extends Handler { // removed or a refresh RESET that the IccRecords could be null. The right behavior is to // not broadcast the SIM loaded. int loadedSlotId = slotId; IccCard iccCard = mPhone[slotId].getIccCard(); IccCard iccCard = sPhones[slotId].getIccCard(); if (iccCard == null) { // Possibly a race condition. logd("handleSimLoaded: IccCard null"); return; Loading @@ -449,7 +450,7 @@ public class SubscriptionInfoUpdater extends Handler { logd("handleSimLoaded: IccID null"); return; } mIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); sIccId[slotId] = IccUtils.stripTrailingFs(records.getFullIccId()); updateSubscriptionInfoByIccId(slotId, true /* updateEmbeddedSubs */); List<SubscriptionInfo> subscriptionInfos = SubscriptionController.getInstance() Loading @@ -460,12 +461,12 @@ public class SubscriptionInfoUpdater extends Handler { for (SubscriptionInfo sub : subscriptionInfos) { int subId = sub.getSubscriptionId(); TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); sContext.getSystemService(Context.TELEPHONY_SERVICE); String operator = tm.getSimOperatorNumeric(subId); if (!TextUtils.isEmpty(operator)) { if (subId == SubscriptionController.getInstance().getDefaultSubId()) { MccTable.updateMccMncConfiguration(mContext, operator); MccTable.updateMccMncConfiguration(sContext, operator); } SubscriptionController.getInstance().setMccMnc(operator, subId); } else { Loading Loading @@ -500,12 +501,12 @@ public class SubscriptionInfoUpdater extends Handler { * Storing last subId in SharedPreference for now to detect SIM change. */ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); PreferenceManager.getDefaultSharedPreferences(sContext); int storedSubId = sp.getInt(CURR_SUBID + slotId, -1); if (storedSubId != subId) { int networkType = Settings.Global.getInt( mPhone[slotId].getContext().getContentResolver(), sPhones[slotId].getContext().getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE + subId, -1 /* invalid network mode */); Loading @@ -513,23 +514,23 @@ public class SubscriptionInfoUpdater extends Handler { networkType = RILConstants.PREFERRED_NETWORK_MODE; try { networkType = TelephonyManager.getIntAtIndex( mContext.getContentResolver(), sContext.getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE, slotId); } catch (SettingNotFoundException retrySnfe) { Rlog.e(LOG_TAG, "Settings Exception Reading Value At Index for " + "Settings.Global.PREFERRED_NETWORK_MODE"); } Settings.Global.putInt( mPhone[slotId].getContext().getContentResolver(), sPhones[slotId].getContext().getContentResolver(), Global.PREFERRED_NETWORK_MODE + subId, networkType); } // Set the modem network mode mPhone[slotId].setPreferredNetworkType(networkType, null); sPhones[slotId].setPreferredNetworkType(networkType, null); // Only support automatic selection mode on SIM change. mPhone[slotId].getNetworkSelectionMode( sPhones[slotId].getNetworkSelectionMode( obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE, new Integer(slotId))); Loading @@ -542,9 +543,9 @@ public class SubscriptionInfoUpdater extends Handler { } // Update set of enabled carrier apps now that the privilege rules may have changed. CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), CarrierAppUtils.disableCarrierAppsUntilPrivileged(sContext.getOpPackageName(), mPackageManager, TelephonyManager.getDefault(), mContext.getContentResolver(), mCurrentlyActiveUserId); sContext.getContentResolver(), mCurrentlyActiveUserId); /** * The sim loading sequence will be Loading @@ -563,22 +564,22 @@ public class SubscriptionInfoUpdater extends Handler { private void updateCarrierServices(int slotId, String simState) { CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); (CarrierConfigManager) sContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); configManager.updateConfigForPhoneId(slotId, simState); mCarrierServiceBindHelper.updateForPhoneId(slotId, simState); } private void updateSubscriptionCarrierId(int slotId, String simState) { if (mPhone != null && mPhone[slotId] != null) { mPhone[slotId].resolveSubscriptionCarrierId(simState); if (sPhones != null && sPhones[slotId] != null) { sPhones[slotId].resolveSubscriptionCarrierId(simState); } } private void handleSimAbsent(int slotId, int absentAndInactive) { if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { if (sIccId[slotId] != null && !sIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " hot plug out, absentAndInactive=" + absentAndInactive); } mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; sIccId[slotId] = ICCID_STRING_FOR_NO_SIM; updateSubscriptionInfoByIccId(slotId, true /* updateEmbeddedSubs */); // Do not broadcast if the SIM is absent and inactive, because the logical slotId here is // no longer correct Loading @@ -592,10 +593,10 @@ public class SubscriptionInfoUpdater extends Handler { } private void handleSimError(int slotId) { if (mIccId[slotId] != null && !mIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { if (sIccId[slotId] != null && !sIccId[slotId].equals(ICCID_STRING_FOR_NO_SIM)) { logd("SIM" + (slotId + 1) + " Error "); } mIccId[slotId] = ICCID_STRING_FOR_NO_SIM; sIccId[slotId] = ICCID_STRING_FOR_NO_SIM; updateSubscriptionInfoByIccId(slotId, true /* updateEmbeddedSubs */); broadcastSimStateChanged(slotId, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR, IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR); Loading @@ -620,10 +621,10 @@ public class SubscriptionInfoUpdater extends Handler { SubscriptionController.getInstance().clearSubInfoRecord(slotIndex); // If SIM is not absent, insert new record or update existing record. if (!ICCID_STRING_FOR_NO_SIM.equals(mIccId[slotIndex])) { if (!ICCID_STRING_FOR_NO_SIM.equals(sIccId[slotIndex])) { logd("updateSubscriptionInfoByIccId: adding subscription info record: iccid: " + mIccId[slotIndex] + "slot: " + slotIndex); mSubscriptionManager.addSubscriptionInfoRecord(mIccId[slotIndex], slotIndex); + sIccId[slotIndex] + "slot: " + slotIndex); mSubscriptionManager.addSubscriptionInfoRecord(sIccId[slotIndex], slotIndex); } List<SubscriptionInfo> subInfos = SubscriptionController.getInstance() Loading @@ -639,8 +640,8 @@ public class SubscriptionInfoUpdater extends Handler { if (!TextUtils.equals(msisdn, temp.getNumber())) { value.put(SubscriptionManager.NUMBER, msisdn); mContext.getContentResolver().update(SubscriptionManager.getUriForSubscriptionId( temp.getSubscriptionId()), value, null, null); sContext.getContentResolver().update(SubscriptionManager .getUriForSubscriptionId(temp.getSubscriptionId()), value, null, null); changed = true; } } Loading Loading @@ -803,7 +804,7 @@ public class SubscriptionInfoUpdater extends Handler { // returned by the eUICC controller). List<SubscriptionInfo> existingSubscriptions = SubscriptionController.getInstance() .getSubscriptionInfoListForEmbeddedSubscriptionUpdate(embeddedIccids, isRemovable); ContentResolver contentResolver = mContext.getContentResolver(); ContentResolver contentResolver = sContext.getContentResolver(); for (EuiccProfileInfo embeddedProfile : embeddedProfiles) { int index = findSubscriptionInfoForIccid(existingSubscriptions, embeddedProfile.getIccid()); Loading Loading @@ -851,7 +852,7 @@ public class SubscriptionInfoUpdater extends Handler { // is no valid carrier id present. if (prevCarrierId == TelephonyManager.UNKNOWN_CARRIER_ID) { values.put(SubscriptionManager.CARRIER_ID, CarrierResolver.getCarrierIdFromIdentifier(mContext, cid)); CarrierResolver.getCarrierIdFromIdentifier(sContext, cid)); } String mcc = cid.getMcc(); String mnc = cid.getMnc(); Loading Loading @@ -921,14 +922,14 @@ public class SubscriptionInfoUpdater extends Handler { private String getDefaultCarrierServicePackageName() { CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); (CarrierConfigManager) sContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); return configManager.getDefaultCarrierServicePackageName(); } private boolean isCarrierServicePackage(int phoneId, String pkgName) { if (pkgName.equals(getDefaultCarrierServicePackageName())) return false; List<String> carrierPackageNames = TelephonyManager.from(mContext) List<String> carrierPackageNames = TelephonyManager.from(sContext) .getCarrierPackageNamesForIntentAndPhone( new Intent(CarrierService.CARRIER_SERVICE_INTERFACE), phoneId); if (DBG) logd("Carrier Packages For Subscription = " + carrierPackageNames); Loading Loading @@ -1024,7 +1025,7 @@ public class SubscriptionInfoUpdater extends Handler { loge("Invalid Group UUID=" + groupUuidString); } } if (cv.size() > 0 && mContext.getContentResolver().update(SubscriptionManager if (cv.size() > 0 && sContext.getContentResolver().update(SubscriptionManager .getUriForSubscriptionId(currentSubId), cv, null, null) > 0) { sc.refreshCachedActiveSubscriptionInfoList(); sc.notifySubscriptionInfoChanged(); Loading Loading @@ -1089,7 +1090,7 @@ public class SubscriptionInfoUpdater extends Handler { i.putExtra(PhoneConstants.SLOT_KEY, slotId); logd("Broadcasting intent ACTION_SIM_CARD_STATE_CHANGED " + simStateString(state) + " for phone: " + phoneId + " slot: " + slotId); mContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); sContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); TelephonyMetrics.getInstance().updateSimState(phoneId, state); } } Loading @@ -1102,7 +1103,7 @@ public class SubscriptionInfoUpdater extends Handler { boolean isUnknownToNotReady = (sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN && state == TelephonyManager.SIM_STATE_NOT_READY); IccCard iccCard = mPhone[phoneId].getIccCard(); IccCard iccCard = sPhones[phoneId].getIccCard(); boolean emptyProfile = iccCard != null && iccCard.isEmptyProfile(); if (state != sSimApplicationState[phoneId] && (!isUnknownToNotReady || emptyProfile)) { sSimApplicationState[phoneId] = state; Loading @@ -1117,7 +1118,7 @@ public class SubscriptionInfoUpdater extends Handler { i.putExtra(PhoneConstants.SLOT_KEY, slotId); logd("Broadcasting intent ACTION_SIM_APPLICATION_STATE_CHANGED " + simStateString(state) + " for phone: " + phoneId + " slot: " + slotId); mContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); sContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE); TelephonyMetrics.getInstance().updateSimState(phoneId, state); } } Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -119,8 +119,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { public void setUp() throws Exception { super.setUp(this.getClass().getSimpleName()); replaceInstance(SubscriptionInfoUpdater.class, "mIccId", null, new String[1]); replaceInstance(SubscriptionInfoUpdater.class, "mContext", null, null); replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[1]); replaceInstance(SubscriptionInfoUpdater.class, "sContext", null, null); replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 1); replaceInstance(SubscriptionInfoUpdater.class, "sSimCardState", null, new int[1]); replaceInstance(SubscriptionInfoUpdater.class, "sSimApplicationState", null, new int[1]); Loading Loading @@ -387,10 +387,10 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { @SmallTest public void testDualSimLoaded() throws Exception { // Mock there is two sim cards replaceInstance(SubscriptionInfoUpdater.class, "mIccId", null, replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[]{null, null}); replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 2); replaceInstance(SubscriptionInfoUpdater.class, "mPhone", null, replaceInstance(SubscriptionInfoUpdater.class, "sPhones", null, new Phone[]{mPhone, mPhone}); replaceInstance(SubscriptionInfoUpdater.class, "sSimCardState", null, new int[]{0, 0}); Loading Loading @@ -448,7 +448,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { public void testSimLockWithIccId() throws Exception { /* no need for IccId query */ replaceInstance(SubscriptionInfoUpdater.class, "mIccId", null, replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[]{"89012604200000000000"}); mUpdater.updateInternalIccState( Loading