Move filterMobileSubscriptionInSameGroup into KeyguardUpdateMonitor.
This avoids race condition that, KeyguardUpdateMonitor refreshes active sub list however CarrierTextController filtered it based on stale active data subId. By move filterMobileSubscriptionInSameGroup into KeyguardUpdateMonitor, it becomes the single source of truth about which carrier name should be shown. Bug: 138456731 Test: manual and unittest Merged-In: Ida3a90c5408b056cad7a79fbba84fe880ce1e5be Change-Id: Ida3a90c5408b056cad7a79fbba84fe880ce1e5be
This commit is contained in:
committed by
Brad Ebinger
parent
0ed49867e2
commit
43ed6f45ed
@@ -19,16 +19,12 @@ package com.android.keyguard;
|
||||
import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
|
||||
import static android.telephony.PhoneStateListener.LISTEN_NONE;
|
||||
|
||||
import static com.android.internal.telephony.PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemProperties;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
@@ -37,20 +33,18 @@ import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.telephony.IccCardConstants;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.internal.telephony.TelephonyProperties;
|
||||
import com.android.settingslib.WirelessUtils;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Controller that generates text including the carrier names and/or the status of all the SIM
|
||||
* interfaces in the device. Through a callback, the updates can be retrieved either as a list or
|
||||
@@ -73,8 +67,6 @@ public class CarrierTextController {
|
||||
private Context mContext;
|
||||
private CharSequence mSeparator;
|
||||
private WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
@VisibleForTesting
|
||||
protected boolean mDisplayOpportunisticSubscriptionCarrierText;
|
||||
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
|
||||
new WakefulnessLifecycle.Observer() {
|
||||
@Override
|
||||
@@ -173,9 +165,6 @@ public class CarrierTextController {
|
||||
mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
|
||||
mSimSlotsNumber = getTelephonyManager().getSupportedModemCount();
|
||||
mSimErrorState = new boolean[mSimSlotsNumber];
|
||||
updateDisplayOpportunisticSubscriptionCarrierText(SystemProperties.getBoolean(
|
||||
TelephonyProperties.DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME,
|
||||
false));
|
||||
}
|
||||
|
||||
private TelephonyManager getTelephonyManager() {
|
||||
@@ -255,63 +244,8 @@ public class CarrierTextController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subscriptions
|
||||
*/
|
||||
private void filterMobileSubscriptionInSameGroup(List<SubscriptionInfo> subscriptions) {
|
||||
if (subscriptions.size() == MAX_PHONE_COUNT_DUAL_SIM) {
|
||||
SubscriptionInfo info1 = subscriptions.get(0);
|
||||
SubscriptionInfo info2 = subscriptions.get(1);
|
||||
if (info1.getGroupUuid() != null && info1.getGroupUuid().equals(info2.getGroupUuid())) {
|
||||
// If both subscriptions are primary, show both.
|
||||
if (!info1.isOpportunistic() && !info2.isOpportunistic()) return;
|
||||
|
||||
// If carrier required, always show signal bar of primary subscription.
|
||||
// Otherwise, show whichever subscription is currently active for Internet.
|
||||
boolean alwaysShowPrimary = CarrierConfigManager.getDefaultConfig()
|
||||
.getBoolean(CarrierConfigManager
|
||||
.KEY_ALWAYS_SHOW_PRIMARY_SIGNAL_BAR_IN_OPPORTUNISTIC_NETWORK_BOOLEAN);
|
||||
if (alwaysShowPrimary) {
|
||||
subscriptions.remove(info1.isOpportunistic() ? info1 : info2);
|
||||
} else {
|
||||
subscriptions.remove(info1.getSubscriptionId() == mActiveMobileDataSubscription
|
||||
? info2 : info1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updates if opportunistic sub carrier text should be displayed or not
|
||||
*
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void updateDisplayOpportunisticSubscriptionCarrierText(boolean isEnable) {
|
||||
mDisplayOpportunisticSubscriptionCarrierText = isEnable;
|
||||
}
|
||||
|
||||
protected List<SubscriptionInfo> getSubscriptionInfo() {
|
||||
List<SubscriptionInfo> subs;
|
||||
if (mDisplayOpportunisticSubscriptionCarrierText) {
|
||||
SubscriptionManager subscriptionManager = ((SubscriptionManager) mContext
|
||||
.getSystemService(
|
||||
Context.TELEPHONY_SUBSCRIPTION_SERVICE));
|
||||
subs = subscriptionManager.getActiveSubscriptionInfoList(false);
|
||||
if (subs == null) {
|
||||
subs = new ArrayList<>();
|
||||
} else {
|
||||
filterMobileSubscriptionInSameGroup(subs);
|
||||
}
|
||||
} else {
|
||||
subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
||||
if (subs == null) {
|
||||
subs = new ArrayList<>();
|
||||
} else {
|
||||
filterMobileSubscriptionInSameGroup(subs);
|
||||
}
|
||||
}
|
||||
return subs;
|
||||
return mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||
}
|
||||
|
||||
protected void updateCarrierText() {
|
||||
|
||||
@@ -30,6 +30,7 @@ import static android.os.BatteryManager.EXTRA_PLUGGED;
|
||||
import static android.os.BatteryManager.EXTRA_STATUS;
|
||||
import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
|
||||
|
||||
import static com.android.internal.telephony.PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
||||
@@ -77,6 +78,7 @@ import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.service.dreams.DreamService;
|
||||
import android.service.dreams.IDreamManager;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
@@ -257,6 +259,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
private boolean mLogoutEnabled;
|
||||
// If the user long pressed the lock icon, disabling face auth for the current session.
|
||||
private boolean mLockIconPressed;
|
||||
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
/**
|
||||
* Short delay before restarting biometric authentication after a successful try
|
||||
@@ -392,9 +395,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
};
|
||||
|
||||
private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
||||
@VisibleForTesting
|
||||
public PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
||||
@Override
|
||||
public void onActiveDataSubscriptionIdChanged(int subId) {
|
||||
mActiveMobileDataSubscription = subId;
|
||||
mHandler.sendEmptyMessage(MSG_SIM_SUBSCRIPTION_INFO_CHANGED);
|
||||
}
|
||||
};
|
||||
@@ -496,7 +501,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
}
|
||||
|
||||
/** @return List of SubscriptionInfo records, maybe empty but never null */
|
||||
/**
|
||||
* @return List of SubscriptionInfo records, maybe empty but never null.
|
||||
*/
|
||||
public List<SubscriptionInfo> getSubscriptionInfo(boolean forceReload) {
|
||||
List<SubscriptionInfo> sil = mSubscriptionInfo;
|
||||
if (sil == null || forceReload) {
|
||||
@@ -508,7 +515,42 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
} else {
|
||||
mSubscriptionInfo = sil;
|
||||
}
|
||||
return mSubscriptionInfo;
|
||||
return new ArrayList<>(mSubscriptionInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns filtered list of SubscriptionInfo from {@link #getSubscriptionInfo}.
|
||||
* above. Maybe empty but never null.
|
||||
*
|
||||
* In DSDS mode if both subscriptions are grouped and one is opportunistic, we filter out one
|
||||
* of them based on carrier config. e.g. In this case we should only show one carrier name
|
||||
* on the status bar and quick settings.
|
||||
*/
|
||||
public List<SubscriptionInfo> getFilteredSubscriptionInfo(boolean forceReload) {
|
||||
List<SubscriptionInfo> subscriptions = getSubscriptionInfo(false);
|
||||
if (subscriptions.size() == MAX_PHONE_COUNT_DUAL_SIM) {
|
||||
SubscriptionInfo info1 = subscriptions.get(0);
|
||||
SubscriptionInfo info2 = subscriptions.get(1);
|
||||
if (info1.getGroupUuid() != null && info1.getGroupUuid().equals(info2.getGroupUuid())) {
|
||||
// If both subscriptions are primary, show both.
|
||||
if (!info1.isOpportunistic() && !info2.isOpportunistic()) return subscriptions;
|
||||
|
||||
// If carrier required, always show signal bar of primary subscription.
|
||||
// Otherwise, show whichever subscription is currently active for Internet.
|
||||
boolean alwaysShowPrimary = CarrierConfigManager.getDefaultConfig()
|
||||
.getBoolean(CarrierConfigManager
|
||||
.KEY_ALWAYS_SHOW_PRIMARY_SIGNAL_BAR_IN_OPPORTUNISTIC_NETWORK_BOOLEAN);
|
||||
if (alwaysShowPrimary) {
|
||||
subscriptions.remove(info1.isOpportunistic() ? info1 : info2);
|
||||
} else {
|
||||
subscriptions.remove(info1.getSubscriptionId() == mActiveMobileDataSubscription
|
||||
? info2 : info1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2637,6 +2679,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
pw.println(" " + mSubscriptionInfo.get(i));
|
||||
}
|
||||
}
|
||||
pw.println(" Current active data subId=" + mActiveMobileDataSubscription);
|
||||
pw.println(" Service states:");
|
||||
for (int subId : mServiceStates.keySet()) {
|
||||
pw.println(" " + subId + "=" + mServiceStates.get(subId));
|
||||
|
||||
@@ -134,7 +134,7 @@ public class OperatorNameView extends TextView implements DemoMode, DarkReceiver
|
||||
|
||||
private void updateText() {
|
||||
CharSequence displayText = null;
|
||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||
final int N = subs.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
int subId = subs.get(i).getSubscriptionId();
|
||||
|
||||
@@ -97,7 +97,7 @@ public class EmergencyCryptkeeperText extends TextView {
|
||||
boolean allSimsMissing = true;
|
||||
CharSequence displayText = null;
|
||||
|
||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||
final int N = subs.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
int subId = subs.get(i).getSubscriptionId();
|
||||
|
||||
@@ -77,15 +77,10 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
private static final CharSequence AIRPLANE_MODE_TEXT = "Airplane mode";
|
||||
private static final String TEST_CARRIER = "TEST_CARRIER";
|
||||
private static final String TEST_CARRIER_2 = "TEST_CARRIER_2";
|
||||
private static final String TEST_GROUP_UUID = "59b5c870-fc4c-47a4-a99e-9db826b48b24";
|
||||
private static final int TEST_CARRIER_ID = 1;
|
||||
private static final SubscriptionInfo TEST_SUBSCRIPTION = new SubscriptionInfo(0, "", 0,
|
||||
TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
|
||||
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID,
|
||||
TEST_CARRIER_ID, 0);
|
||||
private static final SubscriptionInfo TEST_SUBSCRIPTION_2 = new SubscriptionInfo(0, "", 0,
|
||||
TEST_CARRIER, TEST_CARRIER_2, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
|
||||
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", true, TEST_GROUP_UUID,
|
||||
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, null,
|
||||
TEST_CARRIER_ID, 0);
|
||||
private static final SubscriptionInfo TEST_SUBSCRIPTION_NULL = new SubscriptionInfo(0, "", 0,
|
||||
TEST_CARRIER, null, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "", DATA_ROAMING_DISABLE,
|
||||
@@ -136,7 +131,6 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
mKeyguardUpdateMonitor);
|
||||
// This should not start listening on any of the real dependencies
|
||||
mCarrierTextController.setListening(mCarrierTextCallback);
|
||||
mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +139,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
reset(mCarrierTextCallback);
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY);
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
@@ -165,7 +159,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
reset(mCarrierTextCallback);
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY);
|
||||
when(mKeyguardUpdateMonitor.getSimState(1)).thenReturn(
|
||||
IccCardConstants.State.CARD_IO_ERROR);
|
||||
@@ -198,7 +192,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testWrongSlots() {
|
||||
reset(mCarrierTextCallback);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
new ArrayList<>());
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
||||
IccCardConstants.State.CARD_IO_ERROR);
|
||||
@@ -212,7 +206,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testMoreSlotsThanSubs() {
|
||||
reset(mCarrierTextCallback);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
new ArrayList<>());
|
||||
|
||||
// STOPSHIP(b/130246708) This line makes sure that SubscriptionManager provides the
|
||||
@@ -262,7 +256,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
@@ -286,7 +280,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION_ROAMING);
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
@@ -366,7 +360,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testCreateInfo_noSubscriptions() {
|
||||
reset(mCarrierTextCallback);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
new ArrayList<>());
|
||||
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
@@ -390,7 +384,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
@@ -415,7 +409,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
||||
.thenReturn(IccCardConstants.State.READY)
|
||||
.thenReturn(IccCardConstants.State.NOT_READY);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
@@ -440,7 +434,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
||||
.thenReturn(IccCardConstants.State.NOT_READY)
|
||||
.thenReturn(IccCardConstants.State.READY);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
@@ -467,7 +461,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
.thenReturn(IccCardConstants.State.READY)
|
||||
.thenReturn(IccCardConstants.State.NOT_READY)
|
||||
.thenReturn(IccCardConstants.State.READY);
|
||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
@@ -482,30 +476,6 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
captor.getValue().carrierText);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCarrierText_GroupedSubWithOpportunisticCarrierText() {
|
||||
reset(mCarrierTextCallback);
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
list.add(TEST_SUBSCRIPTION_2);
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
||||
.thenReturn(IccCardConstants.State.READY);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(true);
|
||||
when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(list);
|
||||
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
assertEquals(TEST_CARRIER_2, captor.getValue().carrierText);
|
||||
}
|
||||
|
||||
public static class TestCarrierTextController extends CarrierTextController {
|
||||
private KeyguardUpdateMonitor mKUM;
|
||||
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static android.telephony.SubscriptionManager.DATA_ROAMING_DISABLE;
|
||||
import static android.telephony.SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -42,6 +45,7 @@ import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
@@ -62,6 +66,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@SmallTest
|
||||
@@ -73,7 +79,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
// new tests.
|
||||
@RunWithLooper(setAsMainLooper = true)
|
||||
public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
|
||||
private static final String TEST_CARRIER = "TEST_CARRIER";
|
||||
private static final String TEST_CARRIER_2 = "TEST_CARRIER_2";
|
||||
private static final int TEST_CARRIER_ID = 1;
|
||||
private static final String TEST_GROUP_UUID = "59b5c870-fc4c-47a4-a99e-9db826b48b24";
|
||||
private static final SubscriptionInfo TEST_SUBSCRIPTION = new SubscriptionInfo(1, "", 0,
|
||||
TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
|
||||
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID,
|
||||
TEST_CARRIER_ID, 0);
|
||||
private static final SubscriptionInfo TEST_SUBSCRIPTION_2 = new SubscriptionInfo(2, "", 0,
|
||||
TEST_CARRIER, TEST_CARRIER_2, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
|
||||
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", true, TEST_GROUP_UUID,
|
||||
TEST_CARRIER_ID, 0);
|
||||
@Mock
|
||||
private KeyguardUpdateMonitor.StrongAuthTracker mStrongAuthTracker;
|
||||
@Mock
|
||||
@@ -92,6 +109,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
@Mock
|
||||
private KeyguardBypassController mKeyguardBypassController;
|
||||
@Mock
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private TestableLooper mTestableLooper;
|
||||
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
|
||||
@@ -119,6 +138,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
context.addMockSystemService(FaceManager.class, mFaceManager);
|
||||
context.addMockSystemService(UserManager.class, mUserManager);
|
||||
context.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager);
|
||||
context.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
|
||||
|
||||
mTestableLooper = TestableLooper.get(this);
|
||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(context);
|
||||
@@ -441,6 +461,22 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
assertThat(mKeyguardUpdateMonitor.getUserCanSkipBouncer(user)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubscriptionInfo_whenInGroupedSubWithOpportunistic() {
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
list.add(TEST_SUBSCRIPTION_2);
|
||||
when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(list);
|
||||
mKeyguardUpdateMonitor.mPhoneStateListener.onActiveDataSubscriptionIdChanged(
|
||||
TEST_SUBSCRIPTION_2.getSubscriptionId());
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
List<SubscriptionInfo> listToVerify = mKeyguardUpdateMonitor
|
||||
.getFilteredSubscriptionInfo(false);
|
||||
assertThat(listToVerify.size()).isEqualTo(1);
|
||||
assertThat(listToVerify.get(0)).isEqualTo(TEST_SUBSCRIPTION_2);
|
||||
}
|
||||
|
||||
private Intent putPhoneInfo(Intent intent, Bundle data, Boolean simInited) {
|
||||
int subscription = simInited
|
||||
? 1/* mock subid=1 */ : SubscriptionManager.DUMMY_SUBSCRIPTION_ID_BASE;
|
||||
|
||||
Reference in New Issue
Block a user