Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7de1eecc authored by Muralidhar Reddy's avatar Muralidhar Reddy
Browse files

[MEP] Refactor port index related changes in SubscriptionInfoUpdater and UiccController

Test: build
Bug: 199559346
Change-Id: Ib563e0476c4ca2a8fdceb041a3acfcbe64a303ed
parent e23e90cb
Loading
Loading
Loading
Loading
+21 −20
Original line number Diff line number Diff line
@@ -215,12 +215,12 @@ public class SubscriptionInfoUpdater extends Handler {
    }

    /**
     * Update subscriptions if needed when there's a change in inactive slot.
     * @param prevActivePhoneId is the corresponding phoneId of the slot if slot was previously
     * Update subscriptions if needed when there's a change in inactive port.
     * @param prevActivePhoneId is the corresponding phoneId of the port if port was previously
     *                          active. It could be INVALID if it was already inactive.
     * @param iccId iccId in that slot, if any.
     * @param iccId iccId in that port, if any.
     */
    public void updateInternalIccStateForInactiveSlot(int prevActivePhoneId, String iccId) {
    public void updateInternalIccStateForInactivePort(int prevActivePhoneId, String iccId) {
        sendMessage(obtainMessage(EVENT_INACTIVE_SLOT_ICC_STATE_CHANGED, prevActivePhoneId,
                0, iccId));
    }
@@ -247,12 +247,13 @@ public class SubscriptionInfoUpdater extends Handler {
        for (int i = 0; i < TelephonyManager.getDefault().getActiveModemCount(); i++) {
            UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(i);
            int slotId = UiccController.getInstance().getSlotIdFromPhoneId(i);
            if  (sIccId[i] == null || slot == null || !slot.isActive()) {
            if  (sIccId[i] == null || UiccController.getInstance().getUiccPort(i) == null) {
                if (sIccId[i] == null) {
                    logd("Wait for SIM " + i + " Iccid");
                } else {
                    logd(String.format("Wait for slot corresponding to phone %d to be active, "
                            + "slotId is %d", i, slotId));
                    logd(String.format("Wait for port corresponding to phone %d to be active, "
                        + "slotId is %d" + " , portIndex is %d", i, slotId,
                            slot.getPortIndexFromPhoneId(i)));
                }
                return false;
            }
@@ -289,7 +290,7 @@ public class SubscriptionInfoUpdater extends Handler {
                break;

            case EVENT_INACTIVE_SLOT_ICC_STATE_CHANGED:
                handleInactiveSlotIccStateChange(msg.arg1, (String) msg.obj);
                handleInactivePortIccStateChange(msg.arg1, (String) msg.obj);
                break;

            case EVENT_SIM_LOCKED:
@@ -649,10 +650,10 @@ public class SubscriptionInfoUpdater extends Handler {
    }

    /**
     * PhoneId is the corresponding phoneId of the slot if slot was previously active.
     * PhoneId is the corresponding phoneId of the port if port was previously active.
     * It could be INVALID if it was already inactive.
     */
    private void handleInactiveSlotIccStateChange(int phoneId, String iccId) {
    private void handleInactivePortIccStateChange(int phoneId, String iccId) {
        if (SubscriptionManager.isValidPhoneId(phoneId)) {
            // If phoneId is valid, it means the physical slot was previously active in that
            // phoneId. In this case, found the subId and set its phoneId to invalid.
@@ -1190,15 +1191,15 @@ public class SubscriptionInfoUpdater extends Handler {
            SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId);
            // TODO(b/130664115) we manually populate this intent with the slotId. In the future we
            // should do a review of whether to make this public
            UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(phoneId);
            int slotId = UiccController.getInstance().getSlotIdFromPhoneId(phoneId);
            i.putExtra(PhoneConstants.SLOT_KEY, slotId);
            UiccPort portInfo = UiccController.getInstance().getUiccPortForPhone(phoneId);
            if (portInfo != null) {
                int portId = portInfo.getPortIdx();
                i.putExtra(PhoneConstants.PORT_KEY, portId);
            if (slot != null) {
                i.putExtra(PhoneConstants.PORT_KEY, slot.getPortIndexFromPhoneId(phoneId));
            }
            logd("Broadcasting intent ACTION_SIM_CARD_STATE_CHANGED " + simStateString(state)
                    + " for phone: " + phoneId + " slot: " + slotId);
                    + " for phone: " + phoneId + " slot: " + slotId + " port: "
                    + slot.getPortIndexFromPhoneId(phoneId));
            sContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
            TelephonyMetrics.getInstance().updateSimState(phoneId, state);
        }
@@ -1222,15 +1223,15 @@ public class SubscriptionInfoUpdater extends Handler {
            SubscriptionManager.putPhoneIdAndSubIdExtra(i, phoneId);
            // TODO(b/130664115) we populate this intent with the actual slotId. In the future we
            // should do a review of whether to make this public
            UiccSlot slot = UiccController.getInstance().getUiccSlotForPhone(phoneId);
            int slotId = UiccController.getInstance().getSlotIdFromPhoneId(phoneId);
            i.putExtra(PhoneConstants.SLOT_KEY, slotId);
            UiccPort portInfo = UiccController.getInstance().getUiccPortForPhone(phoneId);
            if (portInfo != null) {
                int portId = portInfo.getPortIdx();
                i.putExtra(PhoneConstants.PORT_KEY, portId);
            if (slot != null) {
                i.putExtra(PhoneConstants.PORT_KEY, slot.getPortIndexFromPhoneId(phoneId));
            }
            logd("Broadcasting intent ACTION_SIM_APPLICATION_STATE_CHANGED " + simStateString(state)
                    + " for phone: " + phoneId + " slot: " + slotId);
                    + " for phone: " + phoneId + " slot: " + slotId + "port: "
                    + slot.getPortIndexFromPhoneId(phoneId));
            sContext.sendBroadcast(i, Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
            TelephonyMetrics.getInstance().updateSimState(phoneId, state);
        }
+1 −2
Original line number Diff line number Diff line
@@ -723,8 +723,7 @@ public class UiccController extends Handler {

        SubscriptionInfoUpdater subInfoUpdator = PhoneFactory.getSubscriptionInfoUpdater();
        if (subInfoUpdator != null) {
            // TODO: Rename API from InactiveSlot -> InactivePort
            subInfoUpdator.updateInternalIccStateForInactiveSlot(prevActivePhoneId, iccId);
            subInfoUpdator.updateInternalIccStateForInactivePort(prevActivePhoneId, iccId);
        } else {
            Rlog.e(LOG_TAG, "subInfoUpdate is null.");
        }
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                .getSubInfoUsingSlotIndexPrivileged(eq(FAKE_SUB_ID_1));
        doReturn(new int[]{FAKE_SUB_ID_1}).when(mSubscriptionController)
                .getActiveSubIdList(/*visibleOnly*/false);
        mUpdater.updateInternalIccStateForInactiveSlot(FAKE_SUB_ID_1, null);
        mUpdater.updateInternalIccStateForInactivePort(FAKE_SUB_ID_1, null);

        processAllMessages();
        assertTrue(mUpdater.isSubInfoInitialized());
+1 −1
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ public class UiccSlotTest extends TelephonyTest {
        assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState());

        // assert that we tried to update subscriptions
        verify(mSubInfoRecordUpdater).updateInternalIccStateForInactiveSlot(
        verify(mSubInfoRecordUpdater).updateInternalIccStateForInactivePort(
                activeIss.mSimPortInfos[0].mLogicalSlotIndex, inactiveIss.mSimPortInfos[0].mIccId);
    }