Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +30 −6 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ public class PhoneSwitcher extends Handler { private static final int EVENT_REMOVE_DEFAULT_NETWORK_CHANGE_CALLBACK = 111; private static final int EVENT_MODEM_COMMAND_DONE = 112; private static final int EVENT_MODEM_COMMAND_RETRY = 113; private static final int EVENT_DATA_ENABLED_CHANGED = 114; // Depending on version of IRadioConfig, we need to send either RIL_REQUEST_ALLOW_DATA if it's // 1.0, or RIL_REQUEST_SET_PREFERRED_DATA if it's 1.1 or later. So internally mHalCommandToUse Loading Loading @@ -264,6 +265,21 @@ public class PhoneSwitcher extends Handler { if (mPhoneIdInVoiceCall != oldPhoneIdInVoiceCall) { log("mPhoneIdInVoiceCall changed from" + oldPhoneIdInVoiceCall + " to " + mPhoneIdInVoiceCall); // Switches and listens to the updated voice phone. Phone dataPhone = findPhoneById(mPhoneIdInVoiceCall); if (dataPhone != null && dataPhone.getDataEnabledSettings() != null) { dataPhone.getDataEnabledSettings() .registerForDataEnabledChanged(getInstance(), EVENT_DATA_ENABLED_CHANGED, null); } Phone oldDataPhone = findPhoneById(oldPhoneIdInVoiceCall); if (oldDataPhone != null && oldDataPhone.getDataEnabledSettings() != null) { oldDataPhone.getDataEnabledSettings() .unregisterForDataEnabledChanged(getInstance()); } Message msg = PhoneSwitcher.this.obtainMessage(EVENT_PHONE_IN_CALL_CHANGED); msg.sendToTarget(); } Loading Loading @@ -397,7 +413,9 @@ public class PhoneSwitcher extends Handler { onEvaluate(REQUESTS_UNCHANGED, "EVENT_RADIO_AVAILABLE"); break; } case EVENT_PHONE_IN_CALL_CHANGED: { // fall through case EVENT_DATA_ENABLED_CHANGED: case EVENT_PHONE_IN_CALL_CHANGED: if (onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED")) { logDataSwitchEvent(mOpptDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, Loading @@ -405,7 +423,6 @@ public class PhoneSwitcher extends Handler { registerDefaultNetworkChangeCallback(); } break; } case EVENT_NETWORK_VALIDATION_DONE: { int subId = msg.arg1; boolean passed = (msg.arg2 == 1); Loading Loading @@ -770,15 +787,15 @@ public class PhoneSwitcher extends Handler { } } // This updates mPreferredDataPhoneId which decides which phone should // handle default network requests. // This updates mPreferredDataPhoneId which decides which phone should handle default network // requests. private void updatePreferredDataPhoneId() { if (SubscriptionManager.isValidPhoneId(mPhoneIdInVoiceCall)) { Phone voicePhone = findPhoneById(mPhoneIdInVoiceCall); if (voicePhone != null && voicePhone.isUserDataEnabled()) { // If a phone is in call and user enabled its mobile data, we // should switch internet connection to it. Because the other modem // will lose data connection anyway. // TODO: validate network first. mPreferredDataPhoneId = mPhoneIdInVoiceCall; } else { int subId = getSubIdForDefaultNetworkRequests(); Loading @@ -799,6 +816,13 @@ public class PhoneSwitcher extends Handler { mPreferredDataSubId = mSubscriptionController.getSubIdUsingPhoneId(mPreferredDataPhoneId); } private Phone findPhoneById(final int phoneId) { if (phoneId < 0 || phoneId >= mNumPhones) { return null; } return mPhones[phoneId]; } public boolean shouldApplyNetworkRequest(NetworkRequest networkRequest, int phoneId) { validatePhoneId(phoneId); Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -566,6 +566,7 @@ public class PhoneSwitcherTest extends TelephonyTest { mSlotIndexToSubId = new int[numPhones][]; doReturn(0).when(mPhone).getPhoneId(); doReturn(1).when(mPhone2).getPhoneId(); doReturn(true).when(mPhone2).isUserDataEnabled(); for (int i = 0; i < numPhones; i++) { mSlotIndexToSubId[i] = new int[1]; mSlotIndexToSubId[i][0] = SubscriptionManager.INVALID_SUBSCRIPTION_ID; Loading Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +30 −6 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ public class PhoneSwitcher extends Handler { private static final int EVENT_REMOVE_DEFAULT_NETWORK_CHANGE_CALLBACK = 111; private static final int EVENT_MODEM_COMMAND_DONE = 112; private static final int EVENT_MODEM_COMMAND_RETRY = 113; private static final int EVENT_DATA_ENABLED_CHANGED = 114; // Depending on version of IRadioConfig, we need to send either RIL_REQUEST_ALLOW_DATA if it's // 1.0, or RIL_REQUEST_SET_PREFERRED_DATA if it's 1.1 or later. So internally mHalCommandToUse Loading Loading @@ -264,6 +265,21 @@ public class PhoneSwitcher extends Handler { if (mPhoneIdInVoiceCall != oldPhoneIdInVoiceCall) { log("mPhoneIdInVoiceCall changed from" + oldPhoneIdInVoiceCall + " to " + mPhoneIdInVoiceCall); // Switches and listens to the updated voice phone. Phone dataPhone = findPhoneById(mPhoneIdInVoiceCall); if (dataPhone != null && dataPhone.getDataEnabledSettings() != null) { dataPhone.getDataEnabledSettings() .registerForDataEnabledChanged(getInstance(), EVENT_DATA_ENABLED_CHANGED, null); } Phone oldDataPhone = findPhoneById(oldPhoneIdInVoiceCall); if (oldDataPhone != null && oldDataPhone.getDataEnabledSettings() != null) { oldDataPhone.getDataEnabledSettings() .unregisterForDataEnabledChanged(getInstance()); } Message msg = PhoneSwitcher.this.obtainMessage(EVENT_PHONE_IN_CALL_CHANGED); msg.sendToTarget(); } Loading Loading @@ -397,7 +413,9 @@ public class PhoneSwitcher extends Handler { onEvaluate(REQUESTS_UNCHANGED, "EVENT_RADIO_AVAILABLE"); break; } case EVENT_PHONE_IN_CALL_CHANGED: { // fall through case EVENT_DATA_ENABLED_CHANGED: case EVENT_PHONE_IN_CALL_CHANGED: if (onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED")) { logDataSwitchEvent(mOpptDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, Loading @@ -405,7 +423,6 @@ public class PhoneSwitcher extends Handler { registerDefaultNetworkChangeCallback(); } break; } case EVENT_NETWORK_VALIDATION_DONE: { int subId = msg.arg1; boolean passed = (msg.arg2 == 1); Loading Loading @@ -770,15 +787,15 @@ public class PhoneSwitcher extends Handler { } } // This updates mPreferredDataPhoneId which decides which phone should // handle default network requests. // This updates mPreferredDataPhoneId which decides which phone should handle default network // requests. private void updatePreferredDataPhoneId() { if (SubscriptionManager.isValidPhoneId(mPhoneIdInVoiceCall)) { Phone voicePhone = findPhoneById(mPhoneIdInVoiceCall); if (voicePhone != null && voicePhone.isUserDataEnabled()) { // If a phone is in call and user enabled its mobile data, we // should switch internet connection to it. Because the other modem // will lose data connection anyway. // TODO: validate network first. mPreferredDataPhoneId = mPhoneIdInVoiceCall; } else { int subId = getSubIdForDefaultNetworkRequests(); Loading @@ -799,6 +816,13 @@ public class PhoneSwitcher extends Handler { mPreferredDataSubId = mSubscriptionController.getSubIdUsingPhoneId(mPreferredDataPhoneId); } private Phone findPhoneById(final int phoneId) { if (phoneId < 0 || phoneId >= mNumPhones) { return null; } return mPhones[phoneId]; } public boolean shouldApplyNetworkRequest(NetworkRequest networkRequest, int phoneId) { validatePhoneId(phoneId); Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -566,6 +566,7 @@ public class PhoneSwitcherTest extends TelephonyTest { mSlotIndexToSubId = new int[numPhones][]; doReturn(0).when(mPhone).getPhoneId(); doReturn(1).when(mPhone2).getPhoneId(); doReturn(true).when(mPhone2).isUserDataEnabled(); for (int i = 0; i < numPhones; i++) { mSlotIndexToSubId[i] = new int[1]; mSlotIndexToSubId[i][0] = SubscriptionManager.INVALID_SUBSCRIPTION_ID; Loading