Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +26 −22 Original line number Original line Diff line number Diff line Loading @@ -612,16 +612,7 @@ public class PhoneSwitcher extends Handler { } } case EVENT_MODEM_COMMAND_DONE: { case EVENT_MODEM_COMMAND_DONE: { AsyncResult ar = (AsyncResult) msg.obj; AsyncResult ar = (AsyncResult) msg.obj; boolean commandSuccess = ar != null && ar.exception == null; onDdsSwitchResponse(ar); 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); } break; break; } } case EVENT_MODEM_COMMAND_RETRY: { case EVENT_MODEM_COMMAND_RETRY: { Loading Loading @@ -914,6 +905,9 @@ public class PhoneSwitcher extends Handler { // Check if phoneId for preferred data is changed. // Check if phoneId for preferred data is changed. int oldPreferredDataPhoneId = mPreferredDataPhoneId; 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 // 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 // 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 // phone ID. Ideally there should be a single set of checks that evaluate the correct Loading @@ -925,6 +919,10 @@ public class PhoneSwitcher extends Handler { sb.append(" preferred phoneId ").append(oldPreferredDataPhoneId) sb.append(" preferred phoneId ").append(oldPreferredDataPhoneId) .append("->").append(mPreferredDataPhoneId); .append("->").append(mPreferredDataPhoneId); diffDetected = true; diffDetected = true; } else if (oldPreferredDataSubId != mPreferredDataSubId.get()) { log("SIM refresh, notify dds change"); // Inform connectivity about the active data phone notifyPreferredDataSubIdChanged(); } } if (diffDetected) { if (diffDetected) { Loading Loading @@ -1074,7 +1072,8 @@ public class PhoneSwitcher extends Handler { PhoneFactory.getPhone(phoneId).mCi.setDataAllowed(isPhoneActive(phoneId), message); PhoneFactory.getPhone(phoneId).mCi.setDataAllowed(isPhoneActive(phoneId), message); } } } else if (phoneId == mPreferredDataPhoneId) { } 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); mRadioConfig.setPreferredDataModem(mPreferredDataPhoneId, message); } } } } Loading Loading @@ -1506,8 +1505,15 @@ public class PhoneSwitcher extends Handler { return ret; return ret; } } private void onDdsSwitchResponse(AsyncResult ar, int phoneId) { private void onDdsSwitchResponse(AsyncResult ar) { if (ar.exception != null) { 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); log("onDdsSwitchResponse: DDS switch failed. with exception " + ar.exception); if (ar.exception instanceof CommandException) { if (ar.exception instanceof CommandException) { CommandException.Error error = ((CommandException) CommandException.Error error = ((CommandException) Loading @@ -1523,18 +1529,17 @@ public class PhoneSwitcher extends Handler { return; return; } } } } log("onDdsSwitchResponse: Scheduling DDS switch retry"); log("onDdsSwitchResponse: Scheduling DDS switch retry"); sendMessageDelayed(Message.obtain(this, EVENT_MODEM_COMMAND_RETRY, sendMessageDelayed(Message.obtain(this, EVENT_MODEM_COMMAND_RETRY, phoneId), MODEM_COMMAND_RETRY_PERIOD_MS); phoneId), MODEM_COMMAND_RETRY_PERIOD_MS); } else { return; log("onDdsSwitchResponse: DDS switch success on phoneId = " + phoneId); } if (commandSuccess) log("onDdsSwitchResponse: DDS switch success on phoneId = " + phoneId); mCurrentDdsSwitchFailure.get(phoneId).clear(); mCurrentDdsSwitchFailure.get(phoneId).clear(); // Notify all registrants // Notify all registrants mActivePhoneRegistrants.notifyRegistrants(); mActivePhoneRegistrants.notifyRegistrants(); notifyPreferredDataSubIdChanged(); notifyPreferredDataSubIdChanged(); } } } private boolean isPhoneIdValidForRetry(int phoneId) { private boolean isPhoneIdValidForRetry(int phoneId) { int phoneIdForRequest = INVALID_PHONE_INDEX; int phoneIdForRequest = INVALID_PHONE_INDEX; Loading @@ -1546,8 +1551,7 @@ public class PhoneSwitcher extends Handler { if (mPrioritizedDcRequests.size() == 0) { if (mPrioritizedDcRequests.size() == 0) { return false; return false; } } for (int i = 0; i < mMaxDataAttachModemCount; i++) { for (DcRequest dcRequest : mPrioritizedDcRequests) { DcRequest dcRequest = mPrioritizedDcRequests.get(i); if (dcRequest != null) { if (dcRequest != null) { phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest); phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest); if (phoneIdForRequest == phoneId) { if (phoneIdForRequest == phoneId) { Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -654,8 +654,8 @@ public class PhoneSwitcherTest extends TelephonyTest { processAllMessages(); processAllMessages(); verify(mFuturePhone).complete(true); verify(mFuturePhone).complete(true); // Emergency override result sent this, onDdsSwitchResponse won't be invoked // Make sure the correct broadcast is sent out for the overridden phone ID verify(mTelephonyRegistryManager, never()).notifyActiveDataSubIdChanged(eq(1)); verify(mTelephonyRegistryManager).notifyActiveDataSubIdChanged(eq(2)); } } @Test @Test Loading Loading @@ -748,9 +748,8 @@ public class PhoneSwitcherTest extends TelephonyTest { moveTimeForward(ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS + 2000); moveTimeForward(ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS + 2000); processAllMessages(); processAllMessages(); verify(mMockRadioConfig, never()).setPreferredDataModem(eq(0), any()); verify(mMockRadioConfig, never()).setPreferredDataModem(eq(0), any()); // Make sure the correct broadcast is sent out for the phone ID // Emergency override result sent this, onDdsSwitchResponse won't be invoked verify(mTelephonyRegistryManager).notifyActiveDataSubIdChanged(eq(2)); verify(mTelephonyRegistryManager, never()).notifyActiveDataSubIdChanged(eq(0)); // End ECBM // End ECBM clearInvocations(mTelephonyRegistryManager); clearInvocations(mTelephonyRegistryManager); Loading Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +26 −22 Original line number Original line Diff line number Diff line Loading @@ -612,16 +612,7 @@ public class PhoneSwitcher extends Handler { } } case EVENT_MODEM_COMMAND_DONE: { case EVENT_MODEM_COMMAND_DONE: { AsyncResult ar = (AsyncResult) msg.obj; AsyncResult ar = (AsyncResult) msg.obj; boolean commandSuccess = ar != null && ar.exception == null; onDdsSwitchResponse(ar); 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); } break; break; } } case EVENT_MODEM_COMMAND_RETRY: { case EVENT_MODEM_COMMAND_RETRY: { Loading Loading @@ -914,6 +905,9 @@ public class PhoneSwitcher extends Handler { // Check if phoneId for preferred data is changed. // Check if phoneId for preferred data is changed. int oldPreferredDataPhoneId = mPreferredDataPhoneId; 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 // 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 // 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 // phone ID. Ideally there should be a single set of checks that evaluate the correct Loading @@ -925,6 +919,10 @@ public class PhoneSwitcher extends Handler { sb.append(" preferred phoneId ").append(oldPreferredDataPhoneId) sb.append(" preferred phoneId ").append(oldPreferredDataPhoneId) .append("->").append(mPreferredDataPhoneId); .append("->").append(mPreferredDataPhoneId); diffDetected = true; diffDetected = true; } else if (oldPreferredDataSubId != mPreferredDataSubId.get()) { log("SIM refresh, notify dds change"); // Inform connectivity about the active data phone notifyPreferredDataSubIdChanged(); } } if (diffDetected) { if (diffDetected) { Loading Loading @@ -1074,7 +1072,8 @@ public class PhoneSwitcher extends Handler { PhoneFactory.getPhone(phoneId).mCi.setDataAllowed(isPhoneActive(phoneId), message); PhoneFactory.getPhone(phoneId).mCi.setDataAllowed(isPhoneActive(phoneId), message); } } } else if (phoneId == mPreferredDataPhoneId) { } 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); mRadioConfig.setPreferredDataModem(mPreferredDataPhoneId, message); } } } } Loading Loading @@ -1506,8 +1505,15 @@ public class PhoneSwitcher extends Handler { return ret; return ret; } } private void onDdsSwitchResponse(AsyncResult ar, int phoneId) { private void onDdsSwitchResponse(AsyncResult ar) { if (ar.exception != null) { 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); log("onDdsSwitchResponse: DDS switch failed. with exception " + ar.exception); if (ar.exception instanceof CommandException) { if (ar.exception instanceof CommandException) { CommandException.Error error = ((CommandException) CommandException.Error error = ((CommandException) Loading @@ -1523,18 +1529,17 @@ public class PhoneSwitcher extends Handler { return; return; } } } } log("onDdsSwitchResponse: Scheduling DDS switch retry"); log("onDdsSwitchResponse: Scheduling DDS switch retry"); sendMessageDelayed(Message.obtain(this, EVENT_MODEM_COMMAND_RETRY, sendMessageDelayed(Message.obtain(this, EVENT_MODEM_COMMAND_RETRY, phoneId), MODEM_COMMAND_RETRY_PERIOD_MS); phoneId), MODEM_COMMAND_RETRY_PERIOD_MS); } else { return; log("onDdsSwitchResponse: DDS switch success on phoneId = " + phoneId); } if (commandSuccess) log("onDdsSwitchResponse: DDS switch success on phoneId = " + phoneId); mCurrentDdsSwitchFailure.get(phoneId).clear(); mCurrentDdsSwitchFailure.get(phoneId).clear(); // Notify all registrants // Notify all registrants mActivePhoneRegistrants.notifyRegistrants(); mActivePhoneRegistrants.notifyRegistrants(); notifyPreferredDataSubIdChanged(); notifyPreferredDataSubIdChanged(); } } } private boolean isPhoneIdValidForRetry(int phoneId) { private boolean isPhoneIdValidForRetry(int phoneId) { int phoneIdForRequest = INVALID_PHONE_INDEX; int phoneIdForRequest = INVALID_PHONE_INDEX; Loading @@ -1546,8 +1551,7 @@ public class PhoneSwitcher extends Handler { if (mPrioritizedDcRequests.size() == 0) { if (mPrioritizedDcRequests.size() == 0) { return false; return false; } } for (int i = 0; i < mMaxDataAttachModemCount; i++) { for (DcRequest dcRequest : mPrioritizedDcRequests) { DcRequest dcRequest = mPrioritizedDcRequests.get(i); if (dcRequest != null) { if (dcRequest != null) { phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest); phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest); if (phoneIdForRequest == phoneId) { if (phoneIdForRequest == phoneId) { Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -654,8 +654,8 @@ public class PhoneSwitcherTest extends TelephonyTest { processAllMessages(); processAllMessages(); verify(mFuturePhone).complete(true); verify(mFuturePhone).complete(true); // Emergency override result sent this, onDdsSwitchResponse won't be invoked // Make sure the correct broadcast is sent out for the overridden phone ID verify(mTelephonyRegistryManager, never()).notifyActiveDataSubIdChanged(eq(1)); verify(mTelephonyRegistryManager).notifyActiveDataSubIdChanged(eq(2)); } } @Test @Test Loading Loading @@ -748,9 +748,8 @@ public class PhoneSwitcherTest extends TelephonyTest { moveTimeForward(ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS + 2000); moveTimeForward(ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS + 2000); processAllMessages(); processAllMessages(); verify(mMockRadioConfig, never()).setPreferredDataModem(eq(0), any()); verify(mMockRadioConfig, never()).setPreferredDataModem(eq(0), any()); // Make sure the correct broadcast is sent out for the phone ID // Emergency override result sent this, onDdsSwitchResponse won't be invoked verify(mTelephonyRegistryManager).notifyActiveDataSubIdChanged(eq(2)); verify(mTelephonyRegistryManager, never()).notifyActiveDataSubIdChanged(eq(0)); // End ECBM // End ECBM clearInvocations(mTelephonyRegistryManager); clearInvocations(mTelephonyRegistryManager); Loading