diff options
author | Hui Wang <huiwang@google.com> | 2024-01-16 19:13:26 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-01-16 19:13:26 +0000 |
commit | b4a3c7d5195798f25ca2b4a9cb061fe91b8b2fc4 (patch) | |
tree | 040e0bede858183dcb9c4caf5f7eb29a6874bd71 | |
parent | 7fdcb37d8514bfe1ba4eab5b715599456b4cb8ee (diff) | |
parent | f6de4cb2052566436b8992414b9f577deb6d8189 (diff) | |
download | telephony-b4a3c7d5195798f25ca2b4a9cb061fe91b8b2fc4.tar.gz |
Merge "Always return success when set the opportunistic sub to default" into main
-rw-r--r-- | src/java/com/android/internal/telephony/data/PhoneSwitcher.java | 11 | ||||
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java | 13 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/java/com/android/internal/telephony/data/PhoneSwitcher.java b/src/java/com/android/internal/telephony/data/PhoneSwitcher.java index cf1a47d3f6..13ccadcabe 100644 --- a/src/java/com/android/internal/telephony/data/PhoneSwitcher.java +++ b/src/java/com/android/internal/telephony/data/PhoneSwitcher.java @@ -28,6 +28,7 @@ import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATIO import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NONE; + import static java.util.Arrays.copyOf; import android.annotation.NonNull; @@ -1502,18 +1503,22 @@ public class PhoneSwitcher extends Handler { */ private void validate(int subId, boolean needValidation, int switchReason, @Nullable ISetOpportunisticDataCallback callback) { - logl("Validate subId " + subId + " due to " + switchReasonToString(switchReason) - + " needValidation=" + needValidation); int subIdToValidate = (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) ? mPrimaryDataSubId : subId; + logl("Validate subId " + subId + " due to " + switchReasonToString(switchReason) + + " needValidation=" + needValidation + " subIdToValidate=" + subIdToValidate + + " mAutoSelectedDataSubId=" + mAutoSelectedDataSubId + + " mPreferredDataSubId=" + mPreferredDataSubId.get()); if (!isActiveSubId(subIdToValidate)) { logl("Can't switch data to inactive subId " + subIdToValidate); if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { // the default data sub is not selected yet, store the intent of switching to // default subId once it becomes available. mAutoSelectedDataSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; + sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_SUCCESS); + } else { + sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION); } - sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION); return; } diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java index c215483b63..3fa5ba577f 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java @@ -26,8 +26,10 @@ import static android.telephony.TelephonyManager.SIM_STATE_LOADED; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN; import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE; + import static com.android.internal.telephony.data.AutoDataSwitchController.EVALUATION_REASON_VOICE_CALL_END; import static com.android.internal.telephony.data.PhoneSwitcher.ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -1390,13 +1392,22 @@ public class PhoneSwitcherTest extends TelephonyTest { // Switch to primary before a primary is selected/inactive. setDefaultDataSubId(SubscriptionManager.INVALID_SUBSCRIPTION_ID); mPhoneSwitcherUT.trySetOpportunisticDataSubscription( - SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, false, mSetOpptDataCallback1); + SubscriptionManager.INVALID_SUBSCRIPTION_ID, false, mSetOpptDataCallback1); processAllMessages(); assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mPhoneSwitcherUT.getAutoSelectedDataSubId()); verify(mSetOpptDataCallback1).onComplete(SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION); + // Verify that the switch to default sub is successful + mPhoneSwitcherUT.trySetOpportunisticDataSubscription( + SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, false, mSetOpptDataCallback1); + processAllMessages(); + + assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, + mPhoneSwitcherUT.getAutoSelectedDataSubId()); + verify(mSetOpptDataCallback1).onComplete(SET_OPPORTUNISTIC_SUB_SUCCESS); + // once the primary is selected, it becomes the active sub. setDefaultDataSubId(2); assertEquals(2, mPhoneSwitcherUT.getActiveDataSubId()); |