Snap for 8270536 from 768a07fb9e to tm-release

Change-Id: I24171713ce239c9e376b7d830f04a070901bb2b1
This commit is contained in:
Android Build Coastguard Worker
2022-03-08 02:08:17 +00:00
8 changed files with 494 additions and 131 deletions

View File

@@ -18,7 +18,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/preference_no_icon_padding_start" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingBottom="5dip" android:paddingBottom="5dip"
android:orientation="vertical"> android:orientation="vertical">

View File

@@ -648,7 +648,7 @@
android:title="@string/reset_shortcut_manager_throttling" /> android:title="@string/reset_shortcut_manager_throttling" />
</PreferenceCategory> </PreferenceCategory>
<com.android.settings.development.autofill.AutofillPreferenceCategory <PreferenceCategory
android:key="debug_autofill_category" android:key="debug_autofill_category"
android:title="@string/debug_autofill_category" android:title="@string/debug_autofill_category"
settings:searchable="false" settings:searchable="false"
@@ -672,7 +672,7 @@
android:key="autofill_reset_developer_options" android:key="autofill_reset_developer_options"
android:title="@string/autofill_reset_developer_options" /> android:title="@string/autofill_reset_developer_options" />
</com.android.settings.development.autofill.AutofillPreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="storage_category" android:key="storage_category"

View File

@@ -47,6 +47,7 @@ import com.android.settings.SettingsActivity;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.RestrictedDashboardFragment; import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.development.autofill.AutofillCategoryController;
import com.android.settings.development.autofill.AutofillLoggingLevelPreferenceController; import com.android.settings.development.autofill.AutofillLoggingLevelPreferenceController;
import com.android.settings.development.autofill.AutofillResetOptionsPreferenceController; import com.android.settings.development.autofill.AutofillResetOptionsPreferenceController;
import com.android.settings.development.bluetooth.AbstractBluetoothDialogPreferenceController; import com.android.settings.development.bluetooth.AbstractBluetoothDialogPreferenceController;
@@ -566,6 +567,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new DefaultLaunchPreferenceController(context, "density")); controllers.add(new DefaultLaunchPreferenceController(context, "density"));
controllers.add(new DefaultLaunchPreferenceController(context, "background_check")); controllers.add(new DefaultLaunchPreferenceController(context, "background_check"));
controllers.add(new DefaultLaunchPreferenceController(context, "inactive_apps")); controllers.add(new DefaultLaunchPreferenceController(context, "inactive_apps"));
controllers.add(new AutofillCategoryController(context, lifecycle));
controllers.add(new AutofillLoggingLevelPreferenceController(context, lifecycle)); controllers.add(new AutofillLoggingLevelPreferenceController(context, lifecycle));
controllers.add(new AutofillResetOptionsPreferenceController(context)); controllers.add(new AutofillResetOptionsPreferenceController(context));
controllers.add(new BluetoothCodecDialogPreferenceController(context, lifecycle, controllers.add(new BluetoothCodecDialogPreferenceController(context, lifecycle,

View File

@@ -1,15 +1,17 @@
/* /*
* Copyright (C) 2018 The Android Open Source Project * Copyright (C) 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * Licensed under the Apache License, Version 2.0 (the "License");
* except in compliance with the License. You may obtain a copy of the License at * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the * Unless required by applicable law or agreed to in writing, software
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * distributed under the License is distributed on an "AS IS" BASIS,
* KIND, either express or implied. See the License for the specific language governing * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* permissions and limitations under the License. * See the License for the specific language governing permissions and
* limitations under the License.
*/ */
package com.android.settings.development.autofill; package com.android.settings.development.autofill;
@@ -21,23 +23,36 @@ import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.provider.Settings; import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.autofill.AutofillManager; import android.view.autofill.AutofillManager;
import androidx.preference.PreferenceCategory; import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public final class AutofillPreferenceCategory extends PreferenceCategory { /**
* Controller class for observing the state of AutofillManager.
*/
public class AutofillCategoryController extends DeveloperOptionsPreferenceController implements
LifecycleObserver, OnStart, OnStop {
private static final String TAG = "AutofillPreferenceCategory"; private static final String TAG = "AutofillCategoryController";
private static final String CATEGORY_KEY = "debug_autofill_category";
private static final long DELAYED_MESSAGE_TIME_MS = 2000; private static final long DELAYED_MESSAGE_TIME_MS = 2000;
private final ContentResolver mContentResolver; private ContentResolver mContentResolver;
private final ContentObserver mSettingsObserver; private ContentObserver mSettingsObserver;
private final Handler mHandler = new Handler(Looper.getMainLooper()); private final Handler mHandler = new Handler(Looper.getMainLooper());
public AutofillPreferenceCategory(Context context, AttributeSet attrs) { public AutofillCategoryController(Context context, Lifecycle lifecycle) {
super(context, attrs); super(context);
if (lifecycle != null) {
lifecycle.addObserver(this);
}
mSettingsObserver = new ContentObserver(mHandler) { mSettingsObserver = new ContentObserver(mHandler) {
@Override @Override
@@ -45,7 +60,8 @@ public final class AutofillPreferenceCategory extends PreferenceCategory {
// We cannot apply the change yet because AutofillManager.isEnabled() state is // We cannot apply the change yet because AutofillManager.isEnabled() state is
// updated by a ContentObserver as well and there's no guarantee of which observer // updated by a ContentObserver as well and there's no guarantee of which observer
// is called first - hence, it's possible that the state didn't change here yet. // is called first - hence, it's possible that the state didn't change here yet.
mHandler.postDelayed(() -> notifyDependencyChange(shouldDisableDependents()), mHandler.postDelayed(
() -> mPreference.notifyDependencyChange(shouldDisableDependents()),
DELAYED_MESSAGE_TIME_MS); DELAYED_MESSAGE_TIME_MS);
} }
}; };
@@ -53,32 +69,33 @@ public final class AutofillPreferenceCategory extends PreferenceCategory {
} }
@Override @Override
public void onAttached() { public String getPreferenceKey() {
super.onAttached(); return CATEGORY_KEY;
mContentResolver.registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE), false,
mSettingsObserver);
} }
@Override @Override
public void onDetached() { public void onStart() {
mContentResolver.unregisterContentObserver(mSettingsObserver); mContentResolver.registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE), false,
mSettingsObserver);
super.onDetached(); }
@Override
public void onStop() {
mContentResolver.unregisterContentObserver(mSettingsObserver);
} }
// PreferenceCategory.isEnabled() always return false, so we rather not change that logic // PreferenceCategory.isEnabled() always return false, so we rather not change that logic
// decide whether the children should be shown using isAutofillEnabled() instead. // decide whether the children should be shown using isAutofillEnabled() instead.
private boolean isAutofillEnabled() { private boolean isAutofillEnabled() {
final AutofillManager afm = getContext().getSystemService(AutofillManager.class); final AutofillManager afm = mContext.getSystemService(AutofillManager.class);
final boolean enabled = afm != null && afm.isEnabled(); final boolean enabled = afm != null && afm.isEnabled();
Log.v(TAG, "isAutofillEnabled(): " + enabled); Log.v(TAG, "isAutofillEnabled(): " + enabled);
return enabled; return enabled;
} }
@Override private boolean shouldDisableDependents() {
public boolean shouldDisableDependents() {
final boolean shouldIt = !isAutofillEnabled(); final boolean shouldIt = !isAutofillEnabled();
Log.v(TAG, "shouldDisableDependents(): " + shouldIt); Log.v(TAG, "shouldDisableDependents(): " + shouldIt);
return shouldIt; return shouldIt;

View File

@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.content.Context; import android.content.Context;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.telephony.UiccSlotInfo; import android.telephony.UiccSlotInfo;
import android.telephony.UiccSlotMapping; import android.telephony.UiccSlotMapping;
@@ -47,6 +48,7 @@ public class UiccSlotUtil {
private static final long DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS = 25 * 1000L; private static final long DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS = 25 * 1000L;
public static final int INVALID_LOGICAL_SLOT_ID = -1;
public static final int INVALID_PHYSICAL_SLOT_ID = -1; public static final int INVALID_PHYSICAL_SLOT_ID = -1;
public static final int INVALID_PORT_ID = -1; public static final int INVALID_PORT_ID = -1;
@@ -115,24 +117,27 @@ public class UiccSlotUtil {
} }
TelephonyManager telMgr = context.getSystemService(TelephonyManager.class); TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
int inactiveRemovableSlot = getInactiveRemovableSlot(telMgr.getUiccSlotsInfo(), slotId); int inactiveRemovableSlot = getInactiveRemovableSlot(telMgr.getUiccSlotsInfo(), slotId);
Log.i(TAG, "The InactiveRemovableSlot: " + inactiveRemovableSlot); Log.d(TAG, "The InactiveRemovableSlot: " + inactiveRemovableSlot);
Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping();
Log.i(TAG, "The SimSlotMapping: " + uiccSlotMappings);
if (inactiveRemovableSlot == INVALID_PHYSICAL_SLOT_ID) { if (inactiveRemovableSlot == INVALID_PHYSICAL_SLOT_ID) {
// The slot is invalid slot id, then to skip this. // The slot is invalid slot id, then to skip this.
// The slot is active, then the sim can enable directly. // The slot is active, then the sim can enable directly.
return; return;
} }
Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping();
Log.d(TAG, "The SimSlotMapping: " + uiccSlotMappings);
SubscriptionManager subscriptionManager = context.getSystemService(
SubscriptionManager.class);
int excludedLogicalSlotIndex = getExcludedLogicalSlotIndex(uiccSlotMappings,
SubscriptionUtil.getActiveSubscriptions(subscriptionManager), removedSubInfo,
telMgr.isMultiSimEnabled());
performSwitchToSlot(telMgr, performSwitchToSlot(telMgr,
prepareUiccSlotMappings(uiccSlotMappings, prepareUiccSlotMappings(uiccSlotMappings,
/*slot is psim*/ true, /*slot is psim*/ true,
inactiveRemovableSlot, inactiveRemovableSlot,
/*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX, /*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX,
removedSubInfo, excludedLogicalSlotIndex),
telMgr.isMultiSimEnabled()),
context); context);
} }
@@ -156,16 +161,21 @@ public class UiccSlotUtil {
} }
TelephonyManager telMgr = context.getSystemService(TelephonyManager.class); TelephonyManager telMgr = context.getSystemService(TelephonyManager.class);
Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping(); Collection<UiccSlotMapping> uiccSlotMappings = telMgr.getSimSlotMapping();
Log.i(TAG, "The SimSlotMapping: " + uiccSlotMappings); Log.d(TAG, "The SimSlotMapping: " + uiccSlotMappings);
if (isTargetSlotActive(uiccSlotMappings, physicalSlotId, port)) { if (isTargetSlotActive(uiccSlotMappings, physicalSlotId, port)) {
Log.i(TAG, "The slot is active, then the sim can enable directly."); Log.d(TAG, "The slot is active, then the sim can enable directly.");
return; return;
} }
SubscriptionManager subscriptionManager = context.getSystemService(
SubscriptionManager.class);
int excludedLogicalSlotIndex = getExcludedLogicalSlotIndex(uiccSlotMappings,
SubscriptionUtil.getActiveSubscriptions(subscriptionManager), removedSubInfo,
telMgr.isMultiSimEnabled());
performSwitchToSlot(telMgr, performSwitchToSlot(telMgr,
prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false, prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false,
physicalSlotId, port, removedSubInfo, telMgr.isMultiSimEnabled()), physicalSlotId, port, excludedLogicalSlotIndex),
context); context);
} }
@@ -276,74 +286,91 @@ public class UiccSlotUtil {
@VisibleForTesting @VisibleForTesting
static Collection<UiccSlotMapping> prepareUiccSlotMappings( static Collection<UiccSlotMapping> prepareUiccSlotMappings(
Collection<UiccSlotMapping> uiccSlotMappings, boolean isPsim, int physicalSlotId, Collection<UiccSlotMapping> uiccSlotMappings, boolean isPsim, int physicalSlotId,
int port, SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) { int port, int removedLogicalSlotId) {
if (removedLogicalSlotId == INVALID_LOGICAL_SLOT_ID) {
Log.d(TAG, "There is no removedLogicalSlotId. Do nothing.");
return uiccSlotMappings;
}
Log.d(TAG,
String.format(
"Create new SimSlotMapping. Remove the UiccSlotMapping of logicalSlot%d"
+ ", and insert PhysicalSlotId%d-Port%d",
removedLogicalSlotId, physicalSlotId, port));
Collection<UiccSlotMapping> newUiccSlotMappings = new ArrayList<>(); Collection<UiccSlotMapping> newUiccSlotMappings = new ArrayList<>();
if (!isMultiSimEnabled) { int logicalSlotIndex = 0;
// In the 'SS mode', the port is 0. if (isPsim) {
newUiccSlotMappings.add(new UiccSlotMapping(port, physicalSlotId, 0)); // The target slot is psim. The psim is always the first index at LogicalSlot.
} else if (removedSubInfo != null) { newUiccSlotMappings.add(
// DSDS+MEP new UiccSlotMapping(port, physicalSlotId, logicalSlotIndex++));
// The target slot+port is not active, but the all of logical slots are full. It }
// needs to replace one of logical slots. Collection<UiccSlotMapping> tempUiccSlotMappings =
Log.i(TAG, uiccSlotMappings.stream()
String.format( .sorted(Comparator.comparingInt(UiccSlotMapping::getLogicalSlotIndex))
"Start to set SimSlotMapping from subId%d(LogicalSlot%d-Port%d) to " .collect(Collectors.toList());
+ "PhysicalSlotId%d-Port%d", for (UiccSlotMapping uiccSlotMapping : tempUiccSlotMappings) {
removedSubInfo.getSubscriptionId(), removedSubInfo.getSimSlotIndex(), if (uiccSlotMapping.getLogicalSlotIndex() == removedLogicalSlotId) {
removedSubInfo.getPortIndex(), physicalSlotId, port)); if (!isPsim) {
// Replace this uiccSlotMapping
int logicalSlotIndex = 0; newUiccSlotMappings.add(new UiccSlotMapping(port, physicalSlotId,
if (isPsim) { uiccSlotMapping.getLogicalSlotIndex()));
// The target slot is psim
newUiccSlotMappings.add(
new UiccSlotMapping(port, physicalSlotId, logicalSlotIndex++));
}
Collection<UiccSlotMapping> tempUiccSlotMappings =
uiccSlotMappings.stream()
.sorted(Comparator.comparingInt(UiccSlotMapping::getLogicalSlotIndex))
.collect(Collectors.toList());
for (UiccSlotMapping uiccSlotMapping : tempUiccSlotMappings) {
if (isSubInfoMappingIntoUiccSlotMapping(uiccSlotMapping, removedSubInfo)) {
if (!isPsim) {
// Replace this uiccSlotMapping
newUiccSlotMappings.add(new UiccSlotMapping(port, physicalSlotId,
uiccSlotMapping.getLogicalSlotIndex()));
}
continue;
} }
continue;
// If the psim is inserted, then change the
// logicalSlotIndex for another uiccSlotMappings.
newUiccSlotMappings.add(isPsim
? new UiccSlotMapping(
uiccSlotMapping.getPortIndex(),
uiccSlotMapping.getPhysicalSlotIndex(),
logicalSlotIndex++
) : uiccSlotMapping);
} }
} else {
// For no inserted psim case in DSDS+MEP, there is only one esim in device and // If the psim is inserted, then change the logicalSlotIndex for another
// then user inserts another esim in DSDS+MEP. // uiccSlotMappings.
// If the target is esim, then replace the psim. newUiccSlotMappings.add(isPsim
Log.i(TAG, "The removedSubInfo is null"); ? new UiccSlotMapping(uiccSlotMapping.getPortIndex(),
newUiccSlotMappings = uiccSlotMapping.getPhysicalSlotIndex(), logicalSlotIndex++)
uiccSlotMappings.stream().map(uiccSlotMapping -> { : uiccSlotMapping);
if (!isPsim && uiccSlotMapping.getPhysicalSlotIndex() != physicalSlotId) {
return new UiccSlotMapping(port, physicalSlotId,
uiccSlotMapping.getLogicalSlotIndex());
}
return uiccSlotMapping;
}).collect(Collectors.toList());
} }
Log.i(TAG, "The SimSlotMapping: " + newUiccSlotMappings); Log.d(TAG, "The new SimSlotMapping: " + newUiccSlotMappings);
return newUiccSlotMappings; return newUiccSlotMappings;
} }
private static boolean isSubInfoMappingIntoUiccSlotMapping(UiccSlotMapping uiccSlotMapping, /**
SubscriptionInfo subscriptionInfo) { * To get the excluded logical slot index from uiccSlotMapping list. If the sim which is
return uiccSlotMapping != null * enabled by user does not have the corresponding slot, then it needs to do the
&& uiccSlotMapping.getLogicalSlotIndex() == subscriptionInfo.getSimSlotIndex() * SimSlotMapping changed. This method can find the logical slot index of the corresponding slot
&& uiccSlotMapping.getPortIndex() == subscriptionInfo.getPortIndex(); * before the Frameworks do the SimSlotMapping changed.
*
* @param uiccSlotMappings The uiccSlotMapping list from the Telephony Frameworks.
* @param activeSubInfos The active subscriptionInfo list.
* @param removedSubInfo The removed sim card which is selected by the user. If the user
* don't select removed sim , then the value is null.
* @param isMultiSimEnabled whether the device is in the DSDS mode or not.
* @return The logical slot index of removed slot. If it can't find the removed slot, it
* returns {@link #INVALID_LOGICAL_SLOT_ID}.
*/
@VisibleForTesting
static int getExcludedLogicalSlotIndex(Collection<UiccSlotMapping> uiccSlotMappings,
Collection<SubscriptionInfo> activeSubInfos, SubscriptionInfo removedSubInfo,
boolean isMultiSimEnabled) {
if (!isMultiSimEnabled) {
Log.i(TAG, "In the ss mode.");
return 0;
}
if (removedSubInfo != null) {
// Use removedSubInfo's logicalSlotIndex
Log.i(TAG, "The removedSubInfo is not null");
return removedSubInfo.getSimSlotIndex();
}
// If it needs to do simSlotMapping when user enables sim and there is an empty slot which
// there is no enabled sim in this slot, then the empty slot can be removed.
Log.i(TAG, "The removedSubInfo is null");
return uiccSlotMappings.stream()
.filter(uiccSlotMapping -> {
// find the empty slots.
for (SubscriptionInfo subInfo : activeSubInfos) {
if (subInfo.getSimSlotIndex() == uiccSlotMapping.getLogicalSlotIndex()) {
return false;
}
}
return true;
})
.mapToInt(uiccSlotMapping -> uiccSlotMapping.getLogicalSlotIndex())
.findFirst()
.orElse(INVALID_LOGICAL_SLOT_ID);
} }
} }

View File

@@ -375,13 +375,20 @@ public class WifiP2pSettings extends DashboardFragment
super.onPause(); super.onPause();
if (mWifiP2pManager != null && mChannel != null) { if (mWifiP2pManager != null && mChannel != null) {
mWifiP2pManager.stopPeerDiscovery(mChannel, null); mWifiP2pManager.stopPeerDiscovery(mChannel, null);
}
getActivity().unregisterReceiver(mReceiver);
}
@Override
public void onStop() {
super.onStop();
if (mWifiP2pManager != null && mChannel != null) {
if (!mLastGroupFormed) { if (!mLastGroupFormed) {
// Close the channel when p2p doesn't connected. // Close the channel when p2p doesn't connected.
mChannel.close(); mChannel.close();
mChannel = null; mChannel = null;
} }
} }
getActivity().unregisterReceiver(mReceiver);
} }
@Override @Override

View File

@@ -319,12 +319,18 @@ public class WifiP2pSettingsTest {
assertThat(mFragment.onCreateDialog(-1 /* id */)).isNull(); assertThat(mFragment.onCreateDialog(-1 /* id */)).isNull();
} }
@Test
public void onStop_notLastGroupFormed_shouldCloseChannel() {
mFragment.onStop();
assertThat(mFragment.mChannel).isNull();
}
@Test @Test
public void peerDiscovery_whenOnPause_shouldStop() { public void peerDiscovery_whenOnPause_shouldStop() {
mFragment.onPause(); mFragment.onPause();
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any()); verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
assertThat(mFragment.mChannel).isNull();
} }
@Test @Test
@@ -332,7 +338,6 @@ public class WifiP2pSettingsTest {
mFragment.onPause(); mFragment.onPause();
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any()); verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
assertThat(mFragment.mChannel).isNull();
mFragment.onResume(); mFragment.onResume();
assertThat(mFragment.mChannel).isNotNull(); assertThat(mFragment.mChannel).isNotNull();

View File

@@ -116,9 +116,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingSsModePsimActive(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingSsModePsimActive();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingSsModeEsimPort0Active(); createUiccSlotMappingSsModeEsimPort0Active();
int removedLogicalSlotIndex = 0;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, null, false); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -129,9 +130,10 @@ public class UiccSlotUtilTest {
createUiccSlotMappingSsModeEsimPort0Active(); createUiccSlotMappingSsModeEsimPort0Active();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingSsModePsimActive(); createUiccSlotMappingSsModePsimActive();
int removedLogicalSlotIndex = 0;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, null, false); uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -141,9 +143,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort1(); createUiccSlotMappingPsimAndPort1();
SubscriptionInfo subInfo = createSubscriptionInfo(1, 0); int removedLogicalSlotIndex = 1;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, subInfo, true); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -153,10 +156,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort0(); createUiccSlotMappingPsimAndPort0();
int removedLogicalSlotIndex = 1;
SubscriptionInfo subInfo = createSubscriptionInfo(1, 1);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, subInfo, true); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -166,10 +169,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingDualPortsB(); createUiccSlotMappingDualPortsB();
int removedLogicalSlotIndex = 0;
SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, subInfo, true); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -179,10 +182,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingDualPortsA(); createUiccSlotMappingDualPortsA();
int removedLogicalSlotIndex = 0;
SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, subInfo, true); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -192,9 +195,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingDualPortsB(); createUiccSlotMappingDualPortsB();
int removedLogicalSlotIndex = 0;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, null, true); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -204,9 +208,66 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingDualPortsA(); createUiccSlotMappingDualPortsA();
int removedLogicalSlotIndex = 0;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, null, true); uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
}
@Test
public void prepareUiccSlotMappings_oneEsimAndFromDualPortsAToPsimAndPort1_psimAndPort1() {
// There is only one enabled esimPort1 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort1();
int removedLogicalSlotIndex = 0;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
}
@Test
public void prepareUiccSlotMappings_oneEsimAndFromDualPortsAToPsimAndPort0_psimAndPort0() {
// There is only one enabled esimPort0 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort0();
int removedLogicalSlotIndex = 1;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
}
@Test
public void prepareUiccSlotMappings_oneEsimAndFromDualPortsBToPsimAndPort1_psimAndPort1() {
// There is only one enabled esimPort1 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort1();
int removedLogicalSlotIndex = 1;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
}
@Test
public void prepareUiccSlotMappings_oneEsimAndFromDualPortsBToPsimAndPort0_psimAndPort0() {
// There is only one enabled esimPort0 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort0();
int removedLogicalSlotIndex = 0;
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -216,10 +277,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort1(); createUiccSlotMappingPsimAndPort1();
int removedLogicalSlotIndex = 0;
SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true); uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -229,10 +290,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort0(); createUiccSlotMappingPsimAndPort0();
int removedLogicalSlotIndex = 1;
SubscriptionInfo subInfo = createSubscriptionInfo(1, 1);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true); uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -242,10 +303,10 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort1(); createUiccSlotMappingPsimAndPort1();
int removedLogicalSlotIndex = 1;
SubscriptionInfo subInfo = createSubscriptionInfo(1, 0);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true); uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
@@ -255,20 +316,240 @@ public class UiccSlotUtilTest {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB(); Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
Collection<UiccSlotMapping> verifyUiccSlotMappings = Collection<UiccSlotMapping> verifyUiccSlotMappings =
createUiccSlotMappingPsimAndPort0(); createUiccSlotMappingPsimAndPort0();
int removedLogicalSlotIndex = 0;
SubscriptionInfo subInfo = createSubscriptionInfo(0, 1);
Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings( Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true); uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, removedLogicalSlotIndex);
compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings); compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
} }
private SubscriptionInfo createSubscriptionInfo(int logicalSlotIndex, int portIndex) { @Test
return new SubscriptionInfo( public void getExcludedLogicalSlotIndex_fromPsimActiveToEsimPort0Active_logicalSlot0() {
0, "", logicalSlotIndex, "", "", 0, 0, "", 0, null, "", "", "", Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingSsModePsimActive();
true /* isEmbedded */, Collection<SubscriptionInfo> activeSubscriptionInfoList =
null, "", 25, createActiveSubscriptionInfoListOneSim(0, 0);
false, null, false, 0, 0, 0, null, null, true, portIndex); SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, false);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromEsimPort0ActiveToPsimActive_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingSsModeEsimPort0Active();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(0, 0);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, false);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromPsimAndPort0ToPsimAndPort1_logicalSlot1() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 0, 1, 0);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(1, 0);
int verifyExcludedLogicalSlotIndex = 1;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromPsimAndPort1ToPsimAndPort0_logicalSlot1() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 0, 1, 1);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(1, 1);
int verifyExcludedLogicalSlotIndex = 1;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromPsimAndPort0ToDualPortsB_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 0, 1, 0);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(0, 0);
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromPsimAndPort1ToDualPortsA_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 0, 1, 1);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(0, 0);
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_noPsimAndFromPsimAndPort0ToDualPortsB_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(1, 0);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_noPsimAndFromPsimAndPort1ToDualPortsA_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(1, 1);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_oneEsimAndFromDualPortsAToPsimAndPort1_logicalSlot0() {
// There is only one enabled esimPort1 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(1, 1);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_oneEsimAndFromDualPortsAToPsimAndPort0_logicalSlot1() {
// There is only one enabled esimPort0 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(0, 0);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 1;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_oneEsimAndFromDualPortsBToPsimAndPort1_logicalSlot1() {
// There is only one enabled esimPort1 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(0, 1);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 1;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_oneEsimAndFromDualPortsBToPsimAndPort0_logicalSlot0() {
// There is only one enabled esimPort0 before user enables the psim.
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListOneSim(1, 0);
SubscriptionInfo removedSubInfo = null;
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromDualPortsAToPsimAndPort1_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 0, 1, 1);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(0, 0);
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromDualPortsAToPsimAndPort0_logicalSlot1() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 0, 1, 1);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(1, 1);
int verifyExcludedLogicalSlotIndex = 1;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromDualPortsBToPsimAndPort1_logicalSlot1() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 1, 1, 0);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(1, 0);
int verifyExcludedLogicalSlotIndex = 1;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
}
@Test
public void getExcludedLogicalSlotIndex_fromDualPortsBToPsimAndPort0_logicalSlot0() {
Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
Collection<SubscriptionInfo> activeSubscriptionInfoList =
createActiveSubscriptionInfoListTwoSims(0, 1, 1, 0);
SubscriptionInfo removedSubInfo = createSubscriptionInfo(0, 1);
int verifyExcludedLogicalSlotIndex = 0;
int testExcludedLogicalSlotIndex = UiccSlotUtil.getExcludedLogicalSlotIndex(
uiccSlotMappings, activeSubscriptionInfoList, removedSubInfo, true);
assertThat(testExcludedLogicalSlotIndex).isEqualTo(verifyExcludedLogicalSlotIndex);
} }
private void compareTwoUiccSlotMappings(Collection<UiccSlotMapping> testUiccSlotMappings, private void compareTwoUiccSlotMappings(Collection<UiccSlotMapping> testUiccSlotMappings,
@@ -288,6 +569,30 @@ public class UiccSlotUtilTest {
} }
} }
private SubscriptionInfo createSubscriptionInfo(int logicalSlotIndex, int portIndex) {
return new SubscriptionInfo(
0, "", logicalSlotIndex, "", "", 0, 0, "", 0, null, "", "", "",
true /* isEmbedded */,
null, "", 25,
false, null, false, 0, 0, 0, null, null, true, portIndex);
}
private List<SubscriptionInfo> createActiveSubscriptionInfoListOneSim(int logicalSlotIndex,
int portIndex) {
List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
subscriptionInfoList.add(createSubscriptionInfo(logicalSlotIndex, portIndex));
return subscriptionInfoList;
}
private List<SubscriptionInfo> createActiveSubscriptionInfoListTwoSims(int logicalSlotIndex1,
int portIndex1, int logicalSlotIndex2, int portIndex2) {
List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
subscriptionInfoList.add(createSubscriptionInfo(logicalSlotIndex1, portIndex1));
subscriptionInfoList.add(createSubscriptionInfo(logicalSlotIndex2, portIndex2));
return subscriptionInfoList;
}
// Device | |Slot | // Device | |Slot |
// Working| |Mapping| // Working| |Mapping|
// State |Type |Mode |Friendly name // State |Type |Mode |Friendly name