To fix waiting too long issue when psim -> esim

if the user swithes slot from psim to esim, then the settings
need to wait the simSlotMapping completed and it has a timer to avoid
UI stay here too long.

Since the framework did not sned the carrier config changed with vaild
subId in MEP + psim->esim case, it cause the settings does not know the
simSlotMapping completed and it stay here until timeout.

For MEP case, changing this condition as SimSlotStatusChanged

Bug: 273813956
Test: atest UiccSlotUtilTest
Change-Id: Ic09dbcb3629fe13770f3ad301c0a396d6745969f
This commit is contained in:
SongFerngWang
2023-07-06 19:55:33 +08:00
committed by SongFerng Wang
parent 7c53d299a2
commit d94ac12190
2 changed files with 70 additions and 4 deletions

View File

@@ -20,10 +20,13 @@ import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -49,6 +52,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@RunWith(AndroidJUnit4.class)
public class UiccSlotUtilTest {
@@ -738,6 +742,25 @@ public class UiccSlotUtilTest {
assertThat(testSlot).isFalse();
}
@Test
public void performSwitchToSlot_setSimSlotMapping() throws UiccSlotsException {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsBNoOrding();
UiccSlotUtil.performSwitchToSlot(mTelephonyManager, uiccSlotMappings, mContext);
verify(mTelephonyManager).setSimSlotMapping(any());
}
@Test
public void onReceiveSimSlotChangeReceiver_receiveAction_timerCountDown() {
CountDownLatch latch = spy(new CountDownLatch(1));
UiccSlotUtil.SimSlotChangeReceiver receive = new UiccSlotUtil.SimSlotChangeReceiver(latch);
receive.onReceive(mContext, new Intent(TelephonyManager.ACTION_SIM_SLOT_STATUS_CHANGED));
verify(latch).countDown();
}
private void compareTwoUiccSlotMappings(Collection<UiccSlotMapping> testUiccSlotMappings,
Collection<UiccSlotMapping> verifyUiccSlotMappings) {
assertThat(testUiccSlotMappings.size()).isEqualTo(verifyUiccSlotMappings.size());