Loading src/java/com/android/internal/telephony/data/AutoDataSwitchController.java +14 −4 Original line number Diff line number Diff line Loading @@ -639,7 +639,12 @@ public class AutoDataSwitchController extends Handler { int currentScore = mPhonesSignalStatus[preferredPhoneId].getRatSignalScore(); for (int phoneId = 0; phoneId < mPhonesSignalStatus.length; phoneId++) { if (phoneId == preferredPhoneId) continue; int candidateScore = mPhonesSignalStatus[phoneId].getRatSignalScore(); PhoneSignalStatus candidateStatus = mPhonesSignalStatus[phoneId]; // Ignore non-home phone. if (candidateStatus.getUsableState() != PhoneSignalStatus.UsableState.HOME) { continue; } int candidateScore = candidateStatus.getRatSignalScore(); if ((candidateScore - currentScore) > mScoreTolerance // Also reevaluate if DDS has the same score as the current phone. || (candidateScore >= currentScore && phoneId == ddsPhoneId)) { Loading Loading @@ -715,6 +720,7 @@ public class AutoDataSwitchController extends Handler { mSelectedTargetPhoneId = INVALID_PHONE_INDEX; mPhoneSwitcherCallback.onRequireImmediatelySwitchToPhone(DEFAULT_PHONE_INDEX, EVALUATION_REASON_DATA_SETTINGS_CHANGED); cancelAnyPendingSwitch(); log(debugMessage.append( ", immediately back to default as user turns off default").toString()); return; Loading @@ -723,6 +729,7 @@ public class AutoDataSwitchController extends Handler { mSelectedTargetPhoneId = INVALID_PHONE_INDEX; mPhoneSwitcherCallback.onRequireImmediatelySwitchToPhone( DEFAULT_PHONE_INDEX, EVALUATION_REASON_DATA_SETTINGS_CHANGED); cancelAnyPendingSwitch(); log(debugMessage.append( ", immediately back to default because backup ") .append(internetEvaluation).toString()); Loading Loading @@ -762,7 +769,9 @@ public class AutoDataSwitchController extends Handler { if (isCurrentUsable) { // Both phones are usable. if (isRatSignalStrengthBasedSwitchEnabled()) { if (isRatSignalStrengthBasedSwitchEnabled() && currentUsableState == PhoneSignalStatus.UsableState.HOME && defaultUsableState == PhoneSignalStatus.UsableState.HOME) { int defaultScore = mPhonesSignalStatus[defaultDataPhoneId] .getRatSignalScore(); int currentScore = mPhonesSignalStatus[preferredPhoneId] Loading Loading @@ -854,8 +863,9 @@ public class AutoDataSwitchController extends Handler { if (candidateUsableState.mScore > currentUsableState.mScore) { secondaryDataPhone = PhoneFactory.getPhone(phoneId); } else if (isRatSignalStrengthBasedSwitchEnabled() && currentUsableState.mScore == candidateUsableState.mScore) { // Both phones are home or both roaming enabled, so compare RAT/signal score. && currentUsableState == PhoneSignalStatus.UsableState.HOME && candidateUsableState == PhoneSignalStatus.UsableState.HOME) { // Both phones are home, so compare RAT/signal score. int defaultScore = defaultPhoneStatus.getRatSignalScore(); int candidateScore = candidatePhoneStatus.getRatSignalScore(); Loading tests/telephonytests/src/com/android/internal/telephony/data/AutoDataSwitchControllerTest.java +5 −7 Original line number Diff line number Diff line Loading @@ -383,21 +383,19 @@ public class AutoDataSwitchControllerTest extends TelephonyTest { @Test public void testRoaming_same_roaming_condition_uses_rat_signalStrength() { // On primary phone // 1. Both roaming, user allow roaming on both phone, uses RAT score to decide switch. // 1. Both roaming, user allow roaming on both phone, do NOT use RAT score to decide switch. prepareIdealUsesNonDdsCondition(); serviceStateChanged(PHONE_1, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); serviceStateChanged(PHONE_2, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); processAllFutureMessages(); verify(mMockedPhoneSwitcherCallback).onRequireValidation(PHONE_2, true/*needValidation*/); verify(mMockedPhoneSwitcherCallback, never()).onRequireValidation(PHONE_2, true/*needValidation*/); // On backup phone doReturn(PHONE_2).when(mPhoneSwitcher).getPreferredDataPhoneId(); // 2. Both roaming, user allow roaming on both phone, uses RAT score to decide switch. signalStrengthChanged(PHONE_1, SignalStrength.SIGNAL_STRENGTH_GREAT); signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_POOR); displayInfoChanged(PHONE_1, mGoodTelephonyDisplayInfo); displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo); // 2. Both roaming, do NOT uses RAT score to decide switch, so switch back to primary. mAutoDataSwitchControllerUT.evaluateAutoDataSwitch(EVALUATION_REASON_DATA_SETTINGS_CHANGED); processAllFutureMessages(); verify(mMockedPhoneSwitcherCallback).onRequireValidation(DEFAULT_PHONE_INDEX, Loading Loading
src/java/com/android/internal/telephony/data/AutoDataSwitchController.java +14 −4 Original line number Diff line number Diff line Loading @@ -639,7 +639,12 @@ public class AutoDataSwitchController extends Handler { int currentScore = mPhonesSignalStatus[preferredPhoneId].getRatSignalScore(); for (int phoneId = 0; phoneId < mPhonesSignalStatus.length; phoneId++) { if (phoneId == preferredPhoneId) continue; int candidateScore = mPhonesSignalStatus[phoneId].getRatSignalScore(); PhoneSignalStatus candidateStatus = mPhonesSignalStatus[phoneId]; // Ignore non-home phone. if (candidateStatus.getUsableState() != PhoneSignalStatus.UsableState.HOME) { continue; } int candidateScore = candidateStatus.getRatSignalScore(); if ((candidateScore - currentScore) > mScoreTolerance // Also reevaluate if DDS has the same score as the current phone. || (candidateScore >= currentScore && phoneId == ddsPhoneId)) { Loading Loading @@ -715,6 +720,7 @@ public class AutoDataSwitchController extends Handler { mSelectedTargetPhoneId = INVALID_PHONE_INDEX; mPhoneSwitcherCallback.onRequireImmediatelySwitchToPhone(DEFAULT_PHONE_INDEX, EVALUATION_REASON_DATA_SETTINGS_CHANGED); cancelAnyPendingSwitch(); log(debugMessage.append( ", immediately back to default as user turns off default").toString()); return; Loading @@ -723,6 +729,7 @@ public class AutoDataSwitchController extends Handler { mSelectedTargetPhoneId = INVALID_PHONE_INDEX; mPhoneSwitcherCallback.onRequireImmediatelySwitchToPhone( DEFAULT_PHONE_INDEX, EVALUATION_REASON_DATA_SETTINGS_CHANGED); cancelAnyPendingSwitch(); log(debugMessage.append( ", immediately back to default because backup ") .append(internetEvaluation).toString()); Loading Loading @@ -762,7 +769,9 @@ public class AutoDataSwitchController extends Handler { if (isCurrentUsable) { // Both phones are usable. if (isRatSignalStrengthBasedSwitchEnabled()) { if (isRatSignalStrengthBasedSwitchEnabled() && currentUsableState == PhoneSignalStatus.UsableState.HOME && defaultUsableState == PhoneSignalStatus.UsableState.HOME) { int defaultScore = mPhonesSignalStatus[defaultDataPhoneId] .getRatSignalScore(); int currentScore = mPhonesSignalStatus[preferredPhoneId] Loading Loading @@ -854,8 +863,9 @@ public class AutoDataSwitchController extends Handler { if (candidateUsableState.mScore > currentUsableState.mScore) { secondaryDataPhone = PhoneFactory.getPhone(phoneId); } else if (isRatSignalStrengthBasedSwitchEnabled() && currentUsableState.mScore == candidateUsableState.mScore) { // Both phones are home or both roaming enabled, so compare RAT/signal score. && currentUsableState == PhoneSignalStatus.UsableState.HOME && candidateUsableState == PhoneSignalStatus.UsableState.HOME) { // Both phones are home, so compare RAT/signal score. int defaultScore = defaultPhoneStatus.getRatSignalScore(); int candidateScore = candidatePhoneStatus.getRatSignalScore(); Loading
tests/telephonytests/src/com/android/internal/telephony/data/AutoDataSwitchControllerTest.java +5 −7 Original line number Diff line number Diff line Loading @@ -383,21 +383,19 @@ public class AutoDataSwitchControllerTest extends TelephonyTest { @Test public void testRoaming_same_roaming_condition_uses_rat_signalStrength() { // On primary phone // 1. Both roaming, user allow roaming on both phone, uses RAT score to decide switch. // 1. Both roaming, user allow roaming on both phone, do NOT use RAT score to decide switch. prepareIdealUsesNonDdsCondition(); serviceStateChanged(PHONE_1, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); serviceStateChanged(PHONE_2, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING); processAllFutureMessages(); verify(mMockedPhoneSwitcherCallback).onRequireValidation(PHONE_2, true/*needValidation*/); verify(mMockedPhoneSwitcherCallback, never()).onRequireValidation(PHONE_2, true/*needValidation*/); // On backup phone doReturn(PHONE_2).when(mPhoneSwitcher).getPreferredDataPhoneId(); // 2. Both roaming, user allow roaming on both phone, uses RAT score to decide switch. signalStrengthChanged(PHONE_1, SignalStrength.SIGNAL_STRENGTH_GREAT); signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_POOR); displayInfoChanged(PHONE_1, mGoodTelephonyDisplayInfo); displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo); // 2. Both roaming, do NOT uses RAT score to decide switch, so switch back to primary. mAutoDataSwitchControllerUT.evaluateAutoDataSwitch(EVALUATION_REASON_DATA_SETTINGS_CHANGED); processAllFutureMessages(); verify(mMockedPhoneSwitcherCallback).onRequireValidation(DEFAULT_PHONE_INDEX, Loading