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

Commit 8475931b authored by Susheel Nyamala's avatar Susheel Nyamala
Browse files

Fix DDS sub notify issue for SIM refresh

Update preferred subid to clients in case of SIM refresh
where there is no change in phoneid

Modify UT cases in PhoneSwitcherTest

Bug: 175103069
Change-Id: I592a1dcc8f3f8e8e27152bfa5726cb5bf71636c7
parent a8efa11c
Loading
Loading
Loading
Loading
+26 −22
Original line number Diff line number Diff line
@@ -612,16 +612,7 @@ public class PhoneSwitcher extends Handler {
            }
            case EVENT_MODEM_COMMAND_DONE: {
                AsyncResult ar = (AsyncResult) msg.obj;
                boolean commandSuccess = ar != null && ar.exception == null;
                if (mEmergencyOverride != null) {
                    log("Emergency override result sent = " + commandSuccess);
                    mEmergencyOverride.sendOverrideCompleteCallbackResultAndClear(commandSuccess);
                    // Do not retry , as we do not allow changes in onEvaluate during an emergency
                    // call. When the call ends, we will start the countdown to remove the override.
                } else {
                    int phoneId = (int) ar.userObj;
                    onDdsSwitchResponse(ar, phoneId);
                }
                onDdsSwitchResponse(ar);
                break;
            }
            case EVENT_MODEM_COMMAND_RETRY: {
@@ -914,6 +905,9 @@ public class PhoneSwitcher extends Handler {
        // Check if phoneId for preferred data is changed.
        int oldPreferredDataPhoneId = mPreferredDataPhoneId;

        // Check if subId for preferred data is changed.
        int oldPreferredDataSubId = mPreferredDataSubId.get();

        // When there are no subscriptions, the preferred data phone ID is invalid, but we want
        // to keep a valid phoneId for Emergency, so skip logic that updates for preferred data
        // phone ID. Ideally there should be a single set of checks that evaluate the correct
@@ -925,6 +919,10 @@ public class PhoneSwitcher extends Handler {
            sb.append(" preferred phoneId ").append(oldPreferredDataPhoneId)
                    .append("->").append(mPreferredDataPhoneId);
            diffDetected = true;
        } else if (oldPreferredDataSubId != mPreferredDataSubId.get()) {
            log("SIM refresh, notify dds change");
            // Inform connectivity about the active data phone
            notifyPreferredDataSubIdChanged();
        }

        if (diffDetected) {
@@ -1074,7 +1072,8 @@ public class PhoneSwitcher extends Handler {
                PhoneFactory.getPhone(phoneId).mCi.setDataAllowed(isPhoneActive(phoneId), message);
            }
        } else if (phoneId == mPreferredDataPhoneId) {
            // Only setPreferredDataModem if the phoneId equals to current mPreferredDataPhoneId.
            // Only setPreferredDataModem if the phoneId equals to current mPreferredDataPhoneId
            log("sendRilCommands: setPreferredDataModem - phoneId: " + phoneId);
            mRadioConfig.setPreferredDataModem(mPreferredDataPhoneId, message);
        }
    }
@@ -1506,8 +1505,15 @@ public class PhoneSwitcher extends Handler {
        return ret;
    }

    private void onDdsSwitchResponse(AsyncResult ar, int phoneId) {
        if (ar.exception != null) {
    private void onDdsSwitchResponse(AsyncResult ar) {
        boolean commandSuccess = ar != null && ar.exception == null;
        int phoneId = (int) ar.userObj;
        if (mEmergencyOverride != null) {
            log("Emergency override result sent = " + commandSuccess);
            mEmergencyOverride.sendOverrideCompleteCallbackResultAndClear(commandSuccess);
            // Do not retry , as we do not allow changes in onEvaluate during an emergency
            // call. When the call ends, we will start the countdown to remove the override.
        } else if (!commandSuccess) {
            log("onDdsSwitchResponse: DDS switch failed. with exception " + ar.exception);
            if (ar.exception instanceof CommandException) {
                CommandException.Error error = ((CommandException)
@@ -1523,18 +1529,17 @@ public class PhoneSwitcher extends Handler {
                    return;
                }
            }

            log("onDdsSwitchResponse: Scheduling DDS switch retry");
            sendMessageDelayed(Message.obtain(this, EVENT_MODEM_COMMAND_RETRY,
                        phoneId), MODEM_COMMAND_RETRY_PERIOD_MS);
        } else {
            log("onDdsSwitchResponse: DDS switch success on phoneId = " + phoneId);
            return;
        }
        if (commandSuccess) log("onDdsSwitchResponse: DDS switch success on phoneId = " + phoneId);
        mCurrentDdsSwitchFailure.get(phoneId).clear();
        // Notify all registrants
        mActivePhoneRegistrants.notifyRegistrants();
        notifyPreferredDataSubIdChanged();
    }
    }

    private boolean isPhoneIdValidForRetry(int phoneId) {
        int phoneIdForRequest = INVALID_PHONE_INDEX;
@@ -1546,8 +1551,7 @@ public class PhoneSwitcher extends Handler {
            if (mPrioritizedDcRequests.size() == 0) {
                return false;
            }
            for (int i = 0; i < mMaxDataAttachModemCount; i++) {
                DcRequest dcRequest = mPrioritizedDcRequests.get(i);
            for (DcRequest dcRequest : mPrioritizedDcRequests) {
                if (dcRequest != null) {
                    phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest);
                    if (phoneIdForRequest == phoneId) {
+4 −5
Original line number Diff line number Diff line
@@ -654,8 +654,8 @@ public class PhoneSwitcherTest extends TelephonyTest {
        processAllMessages();
        verify(mFuturePhone).complete(true);

        // Emergency override result sent this, onDdsSwitchResponse won't be invoked
        verify(mTelephonyRegistryManager, never()).notifyActiveDataSubIdChanged(eq(1));
        // Make sure the correct broadcast is sent out for the overridden phone ID
        verify(mTelephonyRegistryManager).notifyActiveDataSubIdChanged(eq(2));
    }

    @Test
@@ -748,9 +748,8 @@ public class PhoneSwitcherTest extends TelephonyTest {
        moveTimeForward(ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS + 2000);
        processAllMessages();
        verify(mMockRadioConfig, never()).setPreferredDataModem(eq(0), any());

        // Emergency override result sent this, onDdsSwitchResponse won't be invoked
        verify(mTelephonyRegistryManager, never()).notifyActiveDataSubIdChanged(eq(0));
        // Make sure the correct broadcast is sent out for the phone ID
        verify(mTelephonyRegistryManager).notifyActiveDataSubIdChanged(eq(2));

        // End ECBM
        clearInvocations(mTelephonyRegistryManager);