aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Wang <huiwang@google.com>2024-01-16 19:56:32 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-16 19:56:32 +0000
commit807067d4078d74d51b631f0dfdde8a38bd1b3200 (patch)
tree040e0bede858183dcb9c4caf5f7eb29a6874bd71
parent2b16ae3a02dec7b0712a8680cb753245b7ad2f7e (diff)
parentb4a3c7d5195798f25ca2b4a9cb061fe91b8b2fc4 (diff)
downloadtelephony-807067d4078d74d51b631f0dfdde8a38bd1b3200.tar.gz
Merge "Always return success when set the opportunistic sub to default" into main am: b4a3c7d519
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2903116 Change-Id: I697ca6e80269d39fd0ed22313dcb27261f414033 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--src/java/com/android/internal/telephony/data/PhoneSwitcher.java11
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java13
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());