Snap for 8704887 from 6947d508e8 to tm-qpr1-release
Change-Id: I85ba788339df05b1f316c724c0e69a09fd628e13
This commit is contained in:
@@ -1126,6 +1126,8 @@
|
||||
<string name="security_settings_fingerprint_enroll_dialog_name_label">Name</string>
|
||||
<!-- Button text shown in fingerprint dialog that allows the user to rename a fingerprint template [CHAR LIMIT=22] -->
|
||||
<string name="security_settings_fingerprint_enroll_dialog_ok">OK</string>
|
||||
<!-- Button text shown in fingerprint dialog that allows the user to try and enroll again[CHAR LIMIT=22] -->
|
||||
<string name="security_settings_fingerprint_enroll_dialog_try_again">Try again</string>
|
||||
<!-- Button text shown in fingerprint dialog that allows the user to delete the fingerprint template [CHAR LIMIT=22] -->
|
||||
<string name="security_settings_fingerprint_enroll_dialog_delete">Delete</string>
|
||||
<!-- Title shown in fingerprint enrollment dialog to begin enrollment [CHAR LIMIT=29]-->
|
||||
@@ -1282,9 +1284,9 @@
|
||||
<!-- Dialog message for dialog which shows when user touches the icon on the screen, instead of the sensor at the back [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_fingerprint_enroll_touch_dialog_message">Touch the sensor on the back of your phone. Use your index finger.</string>
|
||||
<!-- Dialog message for dialog which shows when finger cannot be enrolled. [CHAR LIMIT=45] -->
|
||||
<string name="security_settings_fingerprint_enroll_error_dialog_title">Enrollment was not completed</string>
|
||||
<string name="security_settings_fingerprint_enroll_error_dialog_title">Fingerprint setup timed out</string>
|
||||
<!-- Dialog message for dialog which shows when finger cannot be enrolled due to being idle too long. -->
|
||||
<string name="security_settings_fingerprint_enroll_error_timeout_dialog_message">Fingerprint enrollment time limit reached. Try again.</string>
|
||||
<string name="security_settings_fingerprint_enroll_error_timeout_dialog_message">Try again now or set up your fingerprint later in Settings</string>
|
||||
<!-- Dialog message for dialog which shows when finger cannot be enrolled due to an internal error or fingerprint can't be read. -->
|
||||
<string name="security_settings_fingerprint_enroll_error_generic_dialog_message">Fingerprint enrollment didn\'t work. Try again or use a different finger.</string>
|
||||
<!-- Button text shown at the end of enrollment that allows the user to add another fingerprint -->
|
||||
|
||||
@@ -508,7 +508,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
public void onEnrollmentProgressChange(int steps, int remaining) {
|
||||
updateProgress(true /* animate */);
|
||||
updateTitleAndDescription();
|
||||
clearError();
|
||||
animateFlash();
|
||||
if (!mCanAssumeUdfps) {
|
||||
mErrorText.removeCallbacks(mTouchAgainRunnable);
|
||||
@@ -537,6 +536,11 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
|
||||
int progress = getProgress(
|
||||
mSidecar.getEnrollmentSteps(), mSidecar.getEnrollmentRemaining());
|
||||
// Only clear the error when progress has been made.
|
||||
// TODO (b/234772728) Add tests.
|
||||
if (mProgressBar != null && mProgressBar.getProgress() < progress) {
|
||||
clearError();
|
||||
}
|
||||
if (animate) {
|
||||
animateProgress(progress);
|
||||
} else {
|
||||
|
||||
@@ -16,20 +16,78 @@
|
||||
|
||||
package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_FINISHED;
|
||||
import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_TIMEOUT;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.DialogInterface;
|
||||
import android.hardware.biometrics.BiometricConstants;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.biometrics.BiometricEnrollBase;
|
||||
import com.android.settings.biometrics.BiometricErrorDialog;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
|
||||
/** Fingerprint error dialog, will be shown when an error occurs during fingerprint enrollment. */
|
||||
public class FingerprintErrorDialog extends InstrumentedDialogFragment {
|
||||
|
||||
public static final String KEY_ERROR_MSG = "error_msg";
|
||||
public static final String KEY_ERROR_ID = "error_id";
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
CharSequence errorString = getArguments().getCharSequence(KEY_ERROR_MSG);
|
||||
final int errMsgId = getArguments().getInt(KEY_ERROR_ID);
|
||||
boolean wasTimeout = errMsgId == BiometricConstants.BIOMETRIC_ERROR_TIMEOUT;
|
||||
|
||||
builder.setTitle(R.string.security_settings_fingerprint_enroll_error_dialog_title)
|
||||
.setMessage(errorString)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(
|
||||
R.string.security_settings_fingerprint_enroll_dialog_ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
Activity activity = getActivity();
|
||||
activity.setResult(RESULT_FINISHED);
|
||||
activity.finish();
|
||||
}
|
||||
});
|
||||
if (wasTimeout) {
|
||||
builder.setPositiveButton(
|
||||
R.string.security_settings_fingerprint_enroll_dialog_try_again,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
getActivity().recreate();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(
|
||||
R.string.security_settings_fingerprint_enroll_dialog_ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
Activity activity = getActivity();
|
||||
activity.setResult(RESULT_TIMEOUT);
|
||||
activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fingerprint error dialog, will be shown when an error occurs during fingerprint enrollment.
|
||||
*/
|
||||
public class FingerprintErrorDialog extends BiometricErrorDialog {
|
||||
public static void showErrorDialog(BiometricEnrollBase host, int errMsgId) {
|
||||
if (host.isFinishing()) {
|
||||
return;
|
||||
@@ -48,8 +106,8 @@ public class FingerprintErrorDialog extends BiometricErrorDialog {
|
||||
private static int getErrorMessage(int errMsgId) {
|
||||
switch (errMsgId) {
|
||||
case FingerprintManager.FINGERPRINT_ERROR_TIMEOUT:
|
||||
// This message happens when the underlying crypto layer decides to revoke the
|
||||
// enrollment auth token.
|
||||
// This message happens when the underlying crypto layer decides to revoke
|
||||
// the enrollment auth token.
|
||||
return R.string.security_settings_fingerprint_enroll_error_timeout_dialog_message;
|
||||
case FingerprintManager.FINGERPRINT_ERROR_BAD_CALIBRATION:
|
||||
return R.string.security_settings_fingerprint_bad_calibration;
|
||||
@@ -68,16 +126,6 @@ public class FingerprintErrorDialog extends BiometricErrorDialog {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleResId() {
|
||||
return R.string.security_settings_fingerprint_enroll_error_dialog_title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOkButtonTextResId() {
|
||||
return R.string.security_settings_fingerprint_enroll_dialog_ok;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.DIALOG_FINGERPINT_ERROR;
|
||||
|
||||
@@ -141,6 +141,7 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
|
||||
mContentResolver.registerContentObserver(BRIGHTNESS_ADJ_URI, false, mBrightnessObserver);
|
||||
mDisplayManager.registerDisplayListener(mDisplayListener, mHandler,
|
||||
DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS);
|
||||
updatedSummary(mPreference);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -479,7 +479,7 @@ public class SubscriptionUtil {
|
||||
.stream()
|
||||
.filter(subInfo -> subInfo.getSubscriptionId() == subId)
|
||||
.findFirst()
|
||||
.get();
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.app.PendingIntent;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.UiccCardInfo;
|
||||
import android.telephony.UiccPortInfo;
|
||||
import android.telephony.UiccSlotInfo;
|
||||
import android.telephony.UiccSlotMapping;
|
||||
import android.telephony.euicc.EuiccManager;
|
||||
import android.util.Log;
|
||||
@@ -28,6 +30,8 @@ import android.util.Log;
|
||||
import com.android.settings.SidecarFragment;
|
||||
import com.android.settings.network.telephony.EuiccOperationSidecar;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -44,6 +48,7 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
private int mPort;
|
||||
private SubscriptionInfo mRemovedSubInfo;
|
||||
private boolean mIsDuringSimSlotMapping;
|
||||
private List<SubscriptionInfo> mActiveSubInfos;
|
||||
|
||||
/** Returns a SwitchToEuiccSubscriptionSidecar sidecar instance. */
|
||||
public static SwitchToEuiccSubscriptionSidecar get(FragmentManager fm) {
|
||||
@@ -87,6 +92,10 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
setState(State.RUNNING, Substate.UNUSED);
|
||||
mCallbackIntent = createCallbackIntent();
|
||||
mSubId = subscriptionId;
|
||||
SubscriptionManager subscriptionManager = getContext().getSystemService(
|
||||
SubscriptionManager.class);
|
||||
mActiveSubInfos = SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
|
||||
|
||||
int targetSlot = getTargetSlot();
|
||||
if (targetSlot < 0) {
|
||||
Log.d(TAG, "There is no esim, the TargetSlot is " + targetSlot);
|
||||
@@ -99,15 +108,29 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
mPort = (port < 0) ? getTargetPortId(targetSlot, removedSubInfo) : port;
|
||||
mRemovedSubInfo = removedSubInfo;
|
||||
Log.d(TAG,
|
||||
String.format("set esim into the SubId%d Slot%d:Port%d",
|
||||
String.format("set esim into the SubId%d Physical Slot%d:Port%d",
|
||||
mSubId, targetSlot, mPort));
|
||||
|
||||
if (mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
|
||||
&& removedSubInfo.isEmbedded()) {
|
||||
// In DSDS mode+MEP, if the replaced esim is active, then it should be disabled esim
|
||||
// profile before changing SimSlotMapping process.
|
||||
// Use INVALID_SUBSCRIPTION_ID to disable the esim profile.
|
||||
// The SimSlotMapping is ready, then to execute activate/inactivate esim.
|
||||
if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
// If the subId is INVALID_SUBSCRIPTION_ID, disable the esim (the default esim slot
|
||||
// which is selected by the framework).
|
||||
switchToSubscription();
|
||||
} else if ((mTelephonyManager.isMultiSimEnabled() && removedSubInfo != null
|
||||
&& removedSubInfo.isEmbedded())
|
||||
|| isEsimEnabledAtTargetSlotPort(targetSlot, mPort)) {
|
||||
// Case1: In DSDS mode+MEP, if the replaced esim is active, then the replaced esim
|
||||
// should be disabled before changing SimSlotMapping process.
|
||||
//
|
||||
// Case2: If the user enables the esimA on the target slot:port and the target
|
||||
// slot:port is active and there is an active esimB on target slot:port, then the
|
||||
// settings disables the esimB before the settings enables the esimA on the
|
||||
// target slot:port.
|
||||
//
|
||||
// Step:
|
||||
// 1. disables the replaced esim.
|
||||
// 2. switches the SimSlotMapping if the target slot port is not active.
|
||||
// 3. enables the target esim.
|
||||
// Note: Use INVALID_SUBSCRIPTION_ID to disable the esim profile.
|
||||
Log.d(TAG, "disable the enabled esim before the settings enables the target esim");
|
||||
mIsDuringSimSlotMapping = true;
|
||||
mEuiccManager.switchToSubscription(SubscriptionManager.INVALID_SUBSCRIPTION_ID, mPort,
|
||||
mCallbackIntent);
|
||||
@@ -117,8 +140,8 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
}
|
||||
|
||||
private int getTargetPortId(int physicalEsimSlotIndex, SubscriptionInfo removedSubInfo) {
|
||||
if (!isMultipleEnabledProfilesSupported()) {
|
||||
Log.d(TAG, "The device is no MEP, port is 0");
|
||||
if (!isMultipleEnabledProfilesSupported(physicalEsimSlotIndex)) {
|
||||
Log.d(TAG, "The slotId" + physicalEsimSlotIndex + " is no MEP, port is 0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -150,11 +173,12 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
// port is 0.
|
||||
|
||||
int port = 0;
|
||||
SubscriptionManager subscriptionManager = getContext().getSystemService(
|
||||
SubscriptionManager.class);
|
||||
if(mActiveSubInfos == null){
|
||||
Log.d(TAG, "mActiveSubInfos is null.");
|
||||
return port;
|
||||
}
|
||||
List<SubscriptionInfo> activeEsimSubInfos =
|
||||
SubscriptionUtil.getActiveSubscriptions(subscriptionManager)
|
||||
.stream()
|
||||
mActiveSubInfos.stream()
|
||||
.filter(i -> i.isEmbedded())
|
||||
.sorted(Comparator.comparingInt(SubscriptionInfo::getPortIndex))
|
||||
.collect(Collectors.toList());
|
||||
@@ -167,7 +191,31 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
}
|
||||
|
||||
private int getTargetSlot() {
|
||||
return UiccSlotUtil.getEsimSlotId(getContext());
|
||||
return UiccSlotUtil.getEsimSlotId(getContext(), mSubId);
|
||||
}
|
||||
|
||||
private boolean isEsimEnabledAtTargetSlotPort(int physicalSlotIndex, int portIndex) {
|
||||
int logicalSlotId = getLogicalSlotIndex(physicalSlotIndex, portIndex);
|
||||
if (logicalSlotId == SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
|
||||
return false;
|
||||
}
|
||||
return mActiveSubInfos != null
|
||||
&& mActiveSubInfos.stream()
|
||||
.anyMatch(i -> i.isEmbedded() && i.getSimSlotIndex() == logicalSlotId);
|
||||
}
|
||||
|
||||
private int getLogicalSlotIndex(int physicalSlotIndex, int portIndex) {
|
||||
ImmutableList<UiccSlotInfo> slotInfos = UiccSlotUtil.getSlotInfos(mTelephonyManager);
|
||||
if (slotInfos != null && physicalSlotIndex >= 0 && physicalSlotIndex < slotInfos.size()
|
||||
&& slotInfos.get(physicalSlotIndex) != null) {
|
||||
for (UiccPortInfo portInfo : slotInfos.get(physicalSlotIndex).getPorts()) {
|
||||
if (portInfo.getPortIndex() == portIndex) {
|
||||
return portInfo.getLogicalSlotIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SubscriptionManager.INVALID_SIM_SLOT_INDEX;
|
||||
}
|
||||
|
||||
private void onSwitchSlotSidecarStateChange() {
|
||||
@@ -185,14 +233,15 @@ public class SwitchToEuiccSubscriptionSidecar extends EuiccOperationSidecar {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMultipleEnabledProfilesSupported() {
|
||||
private boolean isMultipleEnabledProfilesSupported(int physicalEsimSlotIndex) {
|
||||
List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
|
||||
if (cardInfos == null) {
|
||||
Log.w(TAG, "UICC cards info list is empty.");
|
||||
return false;
|
||||
}
|
||||
return cardInfos.stream().anyMatch(
|
||||
cardInfo -> cardInfo.isMultipleEnabledProfilesSupported());
|
||||
return cardInfos.stream()
|
||||
.anyMatch(cardInfo -> cardInfo.getPhysicalSlotIndex() == physicalEsimSlotIndex
|
||||
&& cardInfo.isMultipleEnabledProfilesSupported());
|
||||
}
|
||||
|
||||
private void switchToSubscription() {
|
||||
|
||||
@@ -22,11 +22,13 @@ import android.provider.Settings;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.UiccCardInfo;
|
||||
import android.telephony.UiccSlotInfo;
|
||||
import android.telephony.UiccSlotMapping;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.telephony.uicc.UiccController;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -36,6 +38,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -183,9 +186,27 @@ public class UiccSlotUtil {
|
||||
* @param context the application context.
|
||||
* @return the esim slot. If the value is -1, there is not the esim.
|
||||
*/
|
||||
public static int getEsimSlotId(Context context) {
|
||||
public static int getEsimSlotId(Context context, int subId) {
|
||||
TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
|
||||
List<UiccCardInfo> uiccCardInfos = telMgr.getUiccCardsInfo();
|
||||
ImmutableList<UiccSlotInfo> slotInfos = UiccSlotUtil.getSlotInfos(telMgr);
|
||||
SubscriptionManager subscriptionManager = context.getSystemService(
|
||||
SubscriptionManager.class);
|
||||
SubscriptionInfo subInfo = SubscriptionUtil.getSubById(subscriptionManager, subId);
|
||||
|
||||
// checking whether this is the removable esim. If it is, then return the removable slot id.
|
||||
if (subInfo != null && subInfo.isEmbedded()) {
|
||||
for (UiccCardInfo uiccCardInfo : uiccCardInfos) {
|
||||
if (uiccCardInfo.getCardId() == subInfo.getCardId()
|
||||
&& uiccCardInfo.getCardId() > TelephonyManager.UNSUPPORTED_CARD_ID
|
||||
&& uiccCardInfo.isEuicc()
|
||||
&& uiccCardInfo.isRemovable()) {
|
||||
Log.d(TAG, "getEsimSlotId: This subInfo is removable esim.");
|
||||
return uiccCardInfo.getPhysicalSlotIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int firstEsimSlot = IntStream.range(0, slotInfos.size())
|
||||
.filter(
|
||||
index -> {
|
||||
|
||||
@@ -88,6 +88,11 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements
|
||||
return;
|
||||
}
|
||||
|
||||
if (dialog == null) {
|
||||
Log.d(TAG, "Dialog is null.");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
final SubscriptionInfo info = getPreferredSubscription();
|
||||
if (info == null) {
|
||||
dismiss();
|
||||
|
||||
@@ -100,6 +100,11 @@ public class SelectSpecificDataSimDialogFragment extends SimDialogFragment imple
|
||||
return;
|
||||
}
|
||||
|
||||
if (dialog == null) {
|
||||
Log.d(TAG, "Dialog is null.");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
SubscriptionInfo currentDataSubInfo = getDefaultDataSubInfo();
|
||||
SubscriptionInfo newSubInfo = getNonDefaultDataSubscriptionInfo(currentDataSubInfo);
|
||||
|
||||
|
||||
@@ -135,6 +135,21 @@ public class BrightnessLevelPreferenceControllerTest {
|
||||
System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldSetSummary() {
|
||||
BrightnessLevelPreferenceController controller =
|
||||
new BrightnessLevelPreferenceController(mContext, null);
|
||||
controller.displayPreference(mScreen);
|
||||
|
||||
controller.onStop();
|
||||
when(mDisplay.getBrightnessInfo()).thenReturn(
|
||||
new BrightnessInfo(0.5f, 0.0f, 1.0f, BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF,
|
||||
0.5f, BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE));
|
||||
controller.onStart();
|
||||
|
||||
verify(mPreference).setSummary("87%");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_inVrMode_shouldSetSummaryToVrBrightness() {
|
||||
doReturn(true).when(mController).isInVrMode();
|
||||
|
||||
@@ -25,7 +25,9 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.UiccCardInfo;
|
||||
import android.telephony.UiccPortInfo;
|
||||
import android.telephony.UiccSlotInfo;
|
||||
import android.telephony.UiccSlotMapping;
|
||||
@@ -53,16 +55,24 @@ public class UiccSlotUtilTest {
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@Mock
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
|
||||
private static final int ESIM_PHYSICAL_SLOT = 0;
|
||||
private static final int PSIM_PHYSICAL_SLOT = 1;
|
||||
|
||||
private List<SubscriptionInfo> mSubscriptionInfoList = new ArrayList<>();
|
||||
private List<UiccCardInfo> mUiccCardInfo = new ArrayList<>();
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
|
||||
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(mUiccCardInfo);
|
||||
|
||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
|
||||
when(mSubscriptionManager.getAllSubscriptionInfoList()).thenReturn(mSubscriptionInfoList);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,15 +98,35 @@ public class UiccSlotUtilTest {
|
||||
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot0_returnTheCorrectEsimSlot() {
|
||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||
twoSimSlotsDeviceActiveEsimActivePsim());
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext,0);
|
||||
|
||||
assertThat(testSlot).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEsimSlotId_twoSimSlotsDeviceAndRemovableEsimIsSlot1_returnTheCorrectEsimSlot() {
|
||||
public void getEsimSlotId_simIsRemovableEsimAndRemovableEsimIsSlot1_returnRemovableEsimSlot1() {
|
||||
int subId = 0;
|
||||
int cardId = 0;
|
||||
mSubscriptionInfoList.add(createSubscriptionInfo(subId,-1, -1, true, cardId));
|
||||
mUiccCardInfo.add(createUiccCardInfo(true, 3, 0, false, -1, -1));
|
||||
mUiccCardInfo.add(createUiccCardInfo(true, cardId, 1, true, -1, -1));
|
||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||
twoSimSlotsDeviceActiveEsimActiveRemovableEsim());
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext, subId);
|
||||
|
||||
assertThat(testSlot).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEsimSlotId_simIsRemovableEsimAndTwoRemovableSlots_returnRemovableEsimSlot1() {
|
||||
int subId = 0;
|
||||
int cardId = 0;
|
||||
mSubscriptionInfoList.add(createSubscriptionInfo(subId,-1, -1, true, cardId));
|
||||
mUiccCardInfo.add(createUiccCardInfo(false, 4, 0, true, -1, -1));
|
||||
mUiccCardInfo.add(createUiccCardInfo(true, cardId, 1, true, -1, -1));
|
||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||
twoSimSlotsDeviceActivePsimActiveRemovableEsim());
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext, subId);
|
||||
|
||||
assertThat(testSlot).isEqualTo(1);
|
||||
}
|
||||
@@ -105,7 +135,7 @@ public class UiccSlotUtilTest {
|
||||
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
|
||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||
twoSimSlotsDeviceActivePsimActiveEsim());
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext,0);
|
||||
|
||||
assertThat(testSlot).isEqualTo(1);
|
||||
}
|
||||
@@ -114,7 +144,7 @@ public class UiccSlotUtilTest {
|
||||
public void getEsimSlotId_noEimSlotDevice_returnTheCorrectEsimSlot() {
|
||||
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
|
||||
oneSimSlotDeviceActivePsim());
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
|
||||
int testSlot = UiccSlotUtil.getEsimSlotId(mContext,0);
|
||||
|
||||
assertThat(testSlot).isEqualTo(-1);
|
||||
}
|
||||
@@ -620,13 +650,38 @@ public class UiccSlotUtilTest {
|
||||
}
|
||||
|
||||
private SubscriptionInfo createSubscriptionInfo(int logicalSlotIndex, int portIndex) {
|
||||
return createSubscriptionInfo(0, logicalSlotIndex, portIndex, true, 25);
|
||||
}
|
||||
|
||||
private SubscriptionInfo createSubscriptionInfo(int subId, int logicalSlotIndex, int portIndex,
|
||||
boolean isEmbedded, int cardId) {
|
||||
return new SubscriptionInfo(
|
||||
0, "", logicalSlotIndex, "", "", 0, 0, "", 0, null, "", "", "",
|
||||
true /* isEmbedded */,
|
||||
null, "", 25,
|
||||
subId, "",
|
||||
logicalSlotIndex, "", "", 0, 0, "", 0, null, "", "", "",
|
||||
isEmbedded /* isEmbedded */,
|
||||
null, "",
|
||||
cardId,
|
||||
false, null, false, 0, 0, 0, null, null, true, portIndex);
|
||||
}
|
||||
|
||||
private UiccCardInfo createUiccCardInfo(boolean isEuicc, int cardId, int physicalSlotIndex,
|
||||
boolean isRemovable, int logicalSlotIndex, int portIndex) {
|
||||
return new UiccCardInfo(
|
||||
isEuicc /* isEuicc */,
|
||||
cardId /* cardId */,
|
||||
null /* eid */,
|
||||
physicalSlotIndex /* physicalSlotIndex */,
|
||||
isRemovable /* isRemovable */,
|
||||
false /* isMultipleEnabledProfileSupported */,
|
||||
Collections.singletonList(
|
||||
new UiccPortInfo(
|
||||
"123451234567890" /* iccId */,
|
||||
portIndex /* portIdx */,
|
||||
logicalSlotIndex /* logicalSlotIdx */,
|
||||
true /* isActive */)
|
||||
));
|
||||
}
|
||||
|
||||
private List<SubscriptionInfo> createActiveSubscriptionInfoListOneSim(int logicalSlotIndex,
|
||||
int portIndex) {
|
||||
List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
|
||||
@@ -737,6 +792,12 @@ public class UiccSlotUtilTest {
|
||||
createUiccSlotInfo(true, false, 1, true)};
|
||||
}
|
||||
|
||||
private UiccSlotInfo[] twoSimSlotsDeviceActiveEsimActiveRemovableEsim() {
|
||||
return new UiccSlotInfo[]{
|
||||
createUiccSlotInfo(true, false, 0, true),
|
||||
createUiccSlotInfo(true, true, 1, true)};
|
||||
}
|
||||
|
||||
private UiccSlotInfo[] twoSimSlotsDeviceActivePsimActiveRemovableEsim() {
|
||||
return new UiccSlotInfo[]{
|
||||
createUiccSlotInfo(false, true, 0, true),
|
||||
|
||||
Reference in New Issue
Block a user