switch SIM refactor to support MEP

1. Using new telephony API and doing the code refactor
2. To support multi esim profiles case

Bug: 199902896
Test: local build pass.
Change-Id: I8580022793e5c3fc14159f14b406f864353477f8
This commit is contained in:
SongFerngWang
2021-12-03 16:03:45 +08:00
parent fd9287b7da
commit 1e0e9021ac
11 changed files with 526 additions and 106 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings.network;
import android.annotation.IntDef;
import android.app.FragmentManager;
import android.os.Bundle;
import android.telephony.SubscriptionInfo;
import android.util.Log;
import com.android.settings.AsyncTaskSidecar;
@@ -41,11 +42,14 @@ public class SwitchSlotSidecar
})
private @interface Command {
int SWITCH_TO_REMOVABLE_SIM = 0;
int SWITCH_TO_EUICC_SIM = 1;
}
static class Param {
@Command int command;
int slotId;
int port;
SubscriptionInfo removedSubInfo;
}
static class Result {
@@ -65,13 +69,24 @@ public class SwitchSlotSidecar
}
/** Starts switching to the removable slot. */
public void runSwitchToRemovableSlot(int id) {
public void runSwitchToRemovableSlot(int id, SubscriptionInfo removedSubInfo) {
Param param = new Param();
param.command = Command.SWITCH_TO_REMOVABLE_SIM;
param.slotId = id;
param.removedSubInfo = removedSubInfo;
param.port = 0;
super.run(param);
}
/** Starts switching to the removable slot. */
public void runSwitchToEuiccSlot(int id, int port, SubscriptionInfo removedSubInfo) {
Param param = new Param();
param.command = Command.SWITCH_TO_EUICC_SIM;
param.slotId = id;
param.removedSubInfo = removedSubInfo;
param.port = port;
super.run(param);
}
/**
* Returns the exception thrown during the execution of a command. Will be null in any state
* other than {@link State#SUCCESS}, and may be null in that state if there was not an error.
@@ -91,7 +106,14 @@ public class SwitchSlotSidecar
try {
switch (param.command) {
case Command.SWITCH_TO_REMOVABLE_SIM:
UiccSlotUtil.switchToRemovableSlot(param.slotId, getContext());
Log.i(TAG, "Start to switch to removable slot.");
UiccSlotUtil.switchToRemovableSlot(getContext(), param.slotId,
param.removedSubInfo);
break;
case Command.SWITCH_TO_EUICC_SIM:
Log.i(TAG, "Start to switch to euicc slot.");
UiccSlotUtil.switchToEuiccSlot(getContext(), param.slotId, param.port,
param.removedSubInfo);
break;
default:
Log.e(TAG, "Wrong command.");