Loading src/java/com/android/internal/telephony/PhoneFactory.java +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater "); sSubInfoRecordUpdater = new SubscriptionInfoUpdater( BackgroundThread.get().getLooper(), context, sPhones, sCommandsInterfaces); BackgroundThread.get().getLooper(), context, sCommandsInterfaces); sc.updatePhonesAvailability(sPhones); // Only bring up IMS if the device supports having an IMS stack. Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +16 −23 Original line number Diff line number Diff line Loading @@ -103,8 +103,6 @@ public class SubscriptionInfoUpdater extends Handler { // Key used to read/write the current IMSI. Updated on SIM_STATE_CHANGED - LOADED. public static final String CURR_SUBID = "curr_subid"; @UnsupportedAppUsage private static Phone[] sPhones; @UnsupportedAppUsage private static Context sContext = null; @UnsupportedAppUsage Loading Loading @@ -140,22 +138,17 @@ public class SubscriptionInfoUpdater extends Handler { // TODO: The SubscriptionController instance should be passed in here from PhoneFactory // rather than invoking the static getter all over the place. public SubscriptionInfoUpdater( Looper looper, Context context, Phone[] phone, CommandsInterface[] ci) { this(looper, context, phone, ci, IPackageManager.Stub.asInterface(ServiceManager.getService("package")), AppGlobals.getPermissionManager()); public SubscriptionInfoUpdater(Looper looper, Context context, CommandsInterface[] ci) { this(looper, context, ci, IPackageManager.Stub.asInterface( ServiceManager.getService("package")), AppGlobals.getPermissionManager()); } @VisibleForTesting public SubscriptionInfoUpdater( Looper looper, Context context, Phone[] phone, CommandsInterface[] ci, IPackageManager packageMgr, IPermissionManager permissionMgr) { @VisibleForTesting public SubscriptionInfoUpdater(Looper looper, Context context, CommandsInterface[] ci, IPackageManager packageMgr, IPermissionManager permissionMgr) { logd("Constructor invoked"); mBackgroundHandler = new Handler(looper); sContext = context; sPhones = phone; mSubscriptionManager = SubscriptionManager.from(sContext); mEuiccManager = (EuiccManager) sContext.getSystemService(Context.EUICC_SERVICE); mPackageManager = packageMgr; Loading Loading @@ -260,7 +253,7 @@ public class SubscriptionInfoUpdater extends Handler { if (ar.exception == null && ar.result != null) { int[] modes = (int[])ar.result; if (modes[0] == 1) { // Manual mode. sPhones[slotId].setNetworkSelectionModeAutomatic(null); PhoneFactory.getPhone(slotId).setNetworkSelectionModeAutomatic(null); } } else { logd("EVENT_GET_NETWORK_SELECTION_MODE_DONE: error getting network mode."); Loading Loading @@ -371,7 +364,7 @@ public class SubscriptionInfoUpdater extends Handler { String iccId = sIccId[slotId]; if (iccId == null) { IccCard iccCard = sPhones[slotId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(slotId).getIccCard(); if (iccCard == null) { logd("handleSimLocked: IccCard null"); return; Loading Loading @@ -418,7 +411,7 @@ public class SubscriptionInfoUpdater extends Handler { private void handleSimNotReady(int slotId) { logd("handleSimNotReady: slotId: " + slotId); IccCard iccCard = sPhones[slotId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(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 Loading @@ -440,7 +433,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 = sPhones[slotId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(slotId).getIccCard(); if (iccCard == null) { // Possibly a race condition. logd("handleSimLoaded: IccCard null"); return; Loading Loading @@ -510,7 +503,7 @@ public class SubscriptionInfoUpdater extends Handler { if (storedSubId != subId) { int networkType = Settings.Global.getInt( sPhones[slotId].getContext().getContentResolver(), PhoneFactory.getPhone(slotId).getContext().getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE + subId, -1 /* invalid network mode */); Loading @@ -525,16 +518,16 @@ public class SubscriptionInfoUpdater extends Handler { + "Settings.Global.PREFERRED_NETWORK_MODE"); } Settings.Global.putInt( sPhones[slotId].getContext().getContentResolver(), PhoneFactory.getPhone(slotId).getContext().getContentResolver(), Global.PREFERRED_NETWORK_MODE + subId, networkType); } // Set the modem network mode sPhones[slotId].setPreferredNetworkType(networkType, null); PhoneFactory.getPhone(slotId).setPreferredNetworkType(networkType, null); // Only support automatic selection mode on SIM change. sPhones[slotId].getNetworkSelectionMode( PhoneFactory.getPhone(slotId).getNetworkSelectionMode( obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE, new Integer(slotId))); Loading Loading @@ -574,8 +567,8 @@ public class SubscriptionInfoUpdater extends Handler { } private void updateSubscriptionCarrierId(int slotId, String simState) { if (sPhones != null && sPhones[slotId] != null) { sPhones[slotId].resolveSubscriptionCarrierId(simState); if (PhoneFactory.getPhone(slotId) != null) { PhoneFactory.getPhone(slotId).resolveSubscriptionCarrierId(simState); } } Loading Loading @@ -1104,7 +1097,7 @@ public class SubscriptionInfoUpdater extends Handler { boolean isUnknownToNotReady = (sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN && state == TelephonyManager.SIM_STATE_NOT_READY); IccCard iccCard = sPhones[phoneId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard(); boolean emptyProfile = iccCard != null && iccCard.isEmptyProfile(); if (state != sSimApplicationState[phoneId] && (!isUnknownToNotReady || emptyProfile)) { sSimApplicationState[phoneId] = state; Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +3 −5 Original line number Diff line number Diff line Loading @@ -158,9 +158,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { .getActiveSubIdList(/*visibleOnly*/false); mIccRecord = mUiccProfile.getIccRecords(); mUpdater = new SubscriptionInfoUpdater(Looper.myLooper(), mContext, new Phone[]{mPhone}, new CommandsInterface[]{mSimulatedCommands}, mPackageManager, mPermissionManager); mUpdater = new SubscriptionInfoUpdater(Looper.myLooper(), mContext, new CommandsInterface[]{mSimulatedCommands}, mPackageManager, mPermissionManager); processAllMessages(); assertFalse(mUpdater.isSubInfoInitialized()); Loading Loading @@ -390,11 +389,10 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { @SmallTest public void testDualSimLoaded() throws Exception { // Mock there is two sim cards replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[]{mPhone, mPhone}); replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[]{null, null}); replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 2); replaceInstance(SubscriptionInfoUpdater.class, "sPhones", null, new Phone[]{mPhone, mPhone}); replaceInstance(SubscriptionInfoUpdater.class, "sSimCardState", null, new int[]{0, 0}); replaceInstance(SubscriptionInfoUpdater.class, "sSimApplicationState", null, Loading Loading
src/java/com/android/internal/telephony/PhoneFactory.java +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ public class PhoneFactory { Rlog.i(LOG_TAG, "Creating SubInfoRecordUpdater "); sSubInfoRecordUpdater = new SubscriptionInfoUpdater( BackgroundThread.get().getLooper(), context, sPhones, sCommandsInterfaces); BackgroundThread.get().getLooper(), context, sCommandsInterfaces); sc.updatePhonesAvailability(sPhones); // Only bring up IMS if the device supports having an IMS stack. Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +16 −23 Original line number Diff line number Diff line Loading @@ -103,8 +103,6 @@ public class SubscriptionInfoUpdater extends Handler { // Key used to read/write the current IMSI. Updated on SIM_STATE_CHANGED - LOADED. public static final String CURR_SUBID = "curr_subid"; @UnsupportedAppUsage private static Phone[] sPhones; @UnsupportedAppUsage private static Context sContext = null; @UnsupportedAppUsage Loading Loading @@ -140,22 +138,17 @@ public class SubscriptionInfoUpdater extends Handler { // TODO: The SubscriptionController instance should be passed in here from PhoneFactory // rather than invoking the static getter all over the place. public SubscriptionInfoUpdater( Looper looper, Context context, Phone[] phone, CommandsInterface[] ci) { this(looper, context, phone, ci, IPackageManager.Stub.asInterface(ServiceManager.getService("package")), AppGlobals.getPermissionManager()); public SubscriptionInfoUpdater(Looper looper, Context context, CommandsInterface[] ci) { this(looper, context, ci, IPackageManager.Stub.asInterface( ServiceManager.getService("package")), AppGlobals.getPermissionManager()); } @VisibleForTesting public SubscriptionInfoUpdater( Looper looper, Context context, Phone[] phone, CommandsInterface[] ci, IPackageManager packageMgr, IPermissionManager permissionMgr) { @VisibleForTesting public SubscriptionInfoUpdater(Looper looper, Context context, CommandsInterface[] ci, IPackageManager packageMgr, IPermissionManager permissionMgr) { logd("Constructor invoked"); mBackgroundHandler = new Handler(looper); sContext = context; sPhones = phone; mSubscriptionManager = SubscriptionManager.from(sContext); mEuiccManager = (EuiccManager) sContext.getSystemService(Context.EUICC_SERVICE); mPackageManager = packageMgr; Loading Loading @@ -260,7 +253,7 @@ public class SubscriptionInfoUpdater extends Handler { if (ar.exception == null && ar.result != null) { int[] modes = (int[])ar.result; if (modes[0] == 1) { // Manual mode. sPhones[slotId].setNetworkSelectionModeAutomatic(null); PhoneFactory.getPhone(slotId).setNetworkSelectionModeAutomatic(null); } } else { logd("EVENT_GET_NETWORK_SELECTION_MODE_DONE: error getting network mode."); Loading Loading @@ -371,7 +364,7 @@ public class SubscriptionInfoUpdater extends Handler { String iccId = sIccId[slotId]; if (iccId == null) { IccCard iccCard = sPhones[slotId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(slotId).getIccCard(); if (iccCard == null) { logd("handleSimLocked: IccCard null"); return; Loading Loading @@ -418,7 +411,7 @@ public class SubscriptionInfoUpdater extends Handler { private void handleSimNotReady(int slotId) { logd("handleSimNotReady: slotId: " + slotId); IccCard iccCard = sPhones[slotId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(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 Loading @@ -440,7 +433,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 = sPhones[slotId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(slotId).getIccCard(); if (iccCard == null) { // Possibly a race condition. logd("handleSimLoaded: IccCard null"); return; Loading Loading @@ -510,7 +503,7 @@ public class SubscriptionInfoUpdater extends Handler { if (storedSubId != subId) { int networkType = Settings.Global.getInt( sPhones[slotId].getContext().getContentResolver(), PhoneFactory.getPhone(slotId).getContext().getContentResolver(), Settings.Global.PREFERRED_NETWORK_MODE + subId, -1 /* invalid network mode */); Loading @@ -525,16 +518,16 @@ public class SubscriptionInfoUpdater extends Handler { + "Settings.Global.PREFERRED_NETWORK_MODE"); } Settings.Global.putInt( sPhones[slotId].getContext().getContentResolver(), PhoneFactory.getPhone(slotId).getContext().getContentResolver(), Global.PREFERRED_NETWORK_MODE + subId, networkType); } // Set the modem network mode sPhones[slotId].setPreferredNetworkType(networkType, null); PhoneFactory.getPhone(slotId).setPreferredNetworkType(networkType, null); // Only support automatic selection mode on SIM change. sPhones[slotId].getNetworkSelectionMode( PhoneFactory.getPhone(slotId).getNetworkSelectionMode( obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE, new Integer(slotId))); Loading Loading @@ -574,8 +567,8 @@ public class SubscriptionInfoUpdater extends Handler { } private void updateSubscriptionCarrierId(int slotId, String simState) { if (sPhones != null && sPhones[slotId] != null) { sPhones[slotId].resolveSubscriptionCarrierId(simState); if (PhoneFactory.getPhone(slotId) != null) { PhoneFactory.getPhone(slotId).resolveSubscriptionCarrierId(simState); } } Loading Loading @@ -1104,7 +1097,7 @@ public class SubscriptionInfoUpdater extends Handler { boolean isUnknownToNotReady = (sSimApplicationState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN && state == TelephonyManager.SIM_STATE_NOT_READY); IccCard iccCard = sPhones[phoneId].getIccCard(); IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard(); boolean emptyProfile = iccCard != null && iccCard.isEmptyProfile(); if (state != sSimApplicationState[phoneId] && (!isUnknownToNotReady || emptyProfile)) { sSimApplicationState[phoneId] = state; Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +3 −5 Original line number Diff line number Diff line Loading @@ -158,9 +158,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { .getActiveSubIdList(/*visibleOnly*/false); mIccRecord = mUiccProfile.getIccRecords(); mUpdater = new SubscriptionInfoUpdater(Looper.myLooper(), mContext, new Phone[]{mPhone}, new CommandsInterface[]{mSimulatedCommands}, mPackageManager, mPermissionManager); mUpdater = new SubscriptionInfoUpdater(Looper.myLooper(), mContext, new CommandsInterface[]{mSimulatedCommands}, mPackageManager, mPermissionManager); processAllMessages(); assertFalse(mUpdater.isSubInfoInitialized()); Loading Loading @@ -390,11 +389,10 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { @SmallTest public void testDualSimLoaded() throws Exception { // Mock there is two sim cards replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[]{mPhone, mPhone}); replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null, new String[]{null, null}); replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 2); replaceInstance(SubscriptionInfoUpdater.class, "sPhones", null, new Phone[]{mPhone, mPhone}); replaceInstance(SubscriptionInfoUpdater.class, "sSimCardState", null, new int[]{0, 0}); replaceInstance(SubscriptionInfoUpdater.class, "sSimApplicationState", null, Loading