Merge "Move filterMobileSubscriptionInSameGroup into KeyguardUpdateMonitor." into qt-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fab553bc7b
@@ -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_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
|
||||||
import static android.telephony.PhoneStateListener.LISTEN_NONE;
|
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.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.telephony.CarrierConfigManager;
|
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -37,20 +33,18 @@ import android.telephony.TelephonyManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import com.android.internal.telephony.IccCardConstants;
|
import com.android.internal.telephony.IccCardConstants;
|
||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
import com.android.internal.telephony.TelephonyProperties;
|
|
||||||
import com.android.settingslib.WirelessUtils;
|
import com.android.settingslib.WirelessUtils;
|
||||||
import com.android.systemui.Dependency;
|
import com.android.systemui.Dependency;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller that generates text including the carrier names and/or the status of all the SIM
|
* 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
|
* 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 Context mContext;
|
||||||
private CharSequence mSeparator;
|
private CharSequence mSeparator;
|
||||||
private WakefulnessLifecycle mWakefulnessLifecycle;
|
private WakefulnessLifecycle mWakefulnessLifecycle;
|
||||||
@VisibleForTesting
|
|
||||||
protected boolean mDisplayOpportunisticSubscriptionCarrierText;
|
|
||||||
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
|
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
|
||||||
new WakefulnessLifecycle.Observer() {
|
new WakefulnessLifecycle.Observer() {
|
||||||
@Override
|
@Override
|
||||||
@@ -175,9 +167,6 @@ public class CarrierTextController {
|
|||||||
mSimSlotsNumber = ((TelephonyManager) context.getSystemService(
|
mSimSlotsNumber = ((TelephonyManager) context.getSystemService(
|
||||||
Context.TELEPHONY_SERVICE)).getPhoneCount();
|
Context.TELEPHONY_SERVICE)).getPhoneCount();
|
||||||
mSimErrorState = new boolean[mSimSlotsNumber];
|
mSimErrorState = new boolean[mSimSlotsNumber];
|
||||||
updateDisplayOpportunisticSubscriptionCarrierText(SystemProperties.getBoolean(
|
|
||||||
TelephonyProperties.DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME,
|
|
||||||
false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,63 +243,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() {
|
protected List<SubscriptionInfo> getSubscriptionInfo() {
|
||||||
List<SubscriptionInfo> subs;
|
return mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateCarrierText() {
|
protected void updateCarrierText() {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import static android.os.BatteryManager.EXTRA_PLUGGED;
|
|||||||
import static android.os.BatteryManager.EXTRA_STATUS;
|
import static android.os.BatteryManager.EXTRA_STATUS;
|
||||||
import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
|
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_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_DPM_LOCK_NOW;
|
||||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
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.provider.Settings;
|
||||||
import android.service.dreams.DreamService;
|
import android.service.dreams.DreamService;
|
||||||
import android.service.dreams.IDreamManager;
|
import android.service.dreams.IDreamManager;
|
||||||
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
@@ -257,6 +259,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
private boolean mLogoutEnabled;
|
private boolean mLogoutEnabled;
|
||||||
// If the user long pressed the lock icon, disabling face auth for the current session.
|
// If the user long pressed the lock icon, disabling face auth for the current session.
|
||||||
private boolean mLockIconPressed;
|
private boolean mLockIconPressed;
|
||||||
|
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short delay before restarting biometric authentication after a successful try
|
* 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
|
@Override
|
||||||
public void onActiveDataSubscriptionIdChanged(int subId) {
|
public void onActiveDataSubscriptionIdChanged(int subId) {
|
||||||
|
mActiveMobileDataSubscription = subId;
|
||||||
mHandler.sendEmptyMessage(MSG_SIM_SUBSCRIPTION_INFO_CHANGED);
|
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) {
|
public List<SubscriptionInfo> getSubscriptionInfo(boolean forceReload) {
|
||||||
List<SubscriptionInfo> sil = mSubscriptionInfo;
|
List<SubscriptionInfo> sil = mSubscriptionInfo;
|
||||||
if (sil == null || forceReload) {
|
if (sil == null || forceReload) {
|
||||||
@@ -508,7 +515,42 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
} else {
|
} else {
|
||||||
mSubscriptionInfo = sil;
|
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
|
@Override
|
||||||
@@ -2637,6 +2679,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
pw.println(" " + mSubscriptionInfo.get(i));
|
pw.println(" " + mSubscriptionInfo.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pw.println(" Current active data subId=" + mActiveMobileDataSubscription);
|
||||||
pw.println(" Service states:");
|
pw.println(" Service states:");
|
||||||
for (int subId : mServiceStates.keySet()) {
|
for (int subId : mServiceStates.keySet()) {
|
||||||
pw.println(" " + subId + "=" + mServiceStates.get(subId));
|
pw.println(" " + subId + "=" + mServiceStates.get(subId));
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class OperatorNameView extends TextView implements DemoMode, DarkReceiver
|
|||||||
|
|
||||||
private void updateText() {
|
private void updateText() {
|
||||||
CharSequence displayText = null;
|
CharSequence displayText = null;
|
||||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||||
final int N = subs.size();
|
final int N = subs.size();
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int subId = subs.get(i).getSubscriptionId();
|
int subId = subs.get(i).getSubscriptionId();
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class EmergencyCryptkeeperText extends TextView {
|
|||||||
boolean allSimsMissing = true;
|
boolean allSimsMissing = true;
|
||||||
CharSequence displayText = null;
|
CharSequence displayText = null;
|
||||||
|
|
||||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||||
final int N = subs.size();
|
final int N = subs.size();
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int subId = subs.get(i).getSubscriptionId();
|
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 CharSequence AIRPLANE_MODE_TEXT = "Airplane mode";
|
||||||
private static final String TEST_CARRIER = "TEST_CARRIER";
|
private static final String TEST_CARRIER = "TEST_CARRIER";
|
||||||
private static final String TEST_CARRIER_2 = "TEST_CARRIER_2";
|
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 int TEST_CARRIER_ID = 1;
|
||||||
private static final SubscriptionInfo TEST_SUBSCRIPTION = new SubscriptionInfo(0, "", 0,
|
private static final SubscriptionInfo TEST_SUBSCRIPTION = new SubscriptionInfo(0, "", 0,
|
||||||
TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
|
TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
|
||||||
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID,
|
DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, null,
|
||||||
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,
|
|
||||||
TEST_CARRIER_ID, 0);
|
TEST_CARRIER_ID, 0);
|
||||||
private static final SubscriptionInfo TEST_SUBSCRIPTION_NULL = new SubscriptionInfo(0, "", 0,
|
private static final SubscriptionInfo TEST_SUBSCRIPTION_NULL = new SubscriptionInfo(0, "", 0,
|
||||||
TEST_CARRIER, null, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "", DATA_ROAMING_DISABLE,
|
TEST_CARRIER, null, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "", DATA_ROAMING_DISABLE,
|
||||||
@@ -135,7 +130,6 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
mKeyguardUpdateMonitor);
|
mKeyguardUpdateMonitor);
|
||||||
// This should not start listening on any of the real dependencies
|
// This should not start listening on any of the real dependencies
|
||||||
mCarrierTextController.setListening(mCarrierTextCallback);
|
mCarrierTextController.setListening(mCarrierTextCallback);
|
||||||
mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -144,7 +138,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
reset(mCarrierTextCallback);
|
reset(mCarrierTextCallback);
|
||||||
List<SubscriptionInfo> list = new ArrayList<>();
|
List<SubscriptionInfo> list = new ArrayList<>();
|
||||||
list.add(TEST_SUBSCRIPTION);
|
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(0)).thenReturn(IccCardConstants.State.READY);
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
@@ -164,7 +158,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
reset(mCarrierTextCallback);
|
reset(mCarrierTextCallback);
|
||||||
List<SubscriptionInfo> list = new ArrayList<>();
|
List<SubscriptionInfo> list = new ArrayList<>();
|
||||||
list.add(TEST_SUBSCRIPTION);
|
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(0)).thenReturn(IccCardConstants.State.READY);
|
||||||
when(mKeyguardUpdateMonitor.getSimState(1)).thenReturn(
|
when(mKeyguardUpdateMonitor.getSimState(1)).thenReturn(
|
||||||
IccCardConstants.State.CARD_IO_ERROR);
|
IccCardConstants.State.CARD_IO_ERROR);
|
||||||
@@ -188,7 +182,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testWrongSlots() {
|
public void testWrongSlots() {
|
||||||
reset(mCarrierTextCallback);
|
reset(mCarrierTextCallback);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
||||||
IccCardConstants.State.CARD_IO_ERROR);
|
IccCardConstants.State.CARD_IO_ERROR);
|
||||||
@@ -202,7 +196,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testMoreSlotsThanSubs() {
|
public void testMoreSlotsThanSubs() {
|
||||||
reset(mCarrierTextCallback);
|
reset(mCarrierTextCallback);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
|
|
||||||
// STOPSHIP(b/130246708) This line makes sure that SubscriptionManager provides the
|
// STOPSHIP(b/130246708) This line makes sure that SubscriptionManager provides the
|
||||||
@@ -252,7 +246,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
List<SubscriptionInfo> list = new ArrayList<>();
|
List<SubscriptionInfo> list = new ArrayList<>();
|
||||||
list.add(TEST_SUBSCRIPTION);
|
list.add(TEST_SUBSCRIPTION);
|
||||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||||
|
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
@@ -276,7 +270,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
List<SubscriptionInfo> list = new ArrayList<>();
|
List<SubscriptionInfo> list = new ArrayList<>();
|
||||||
list.add(TEST_SUBSCRIPTION_ROAMING);
|
list.add(TEST_SUBSCRIPTION_ROAMING);
|
||||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||||
|
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
@@ -356,7 +350,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testCreateInfo_noSubscriptions() {
|
public void testCreateInfo_noSubscriptions() {
|
||||||
reset(mCarrierTextCallback);
|
reset(mCarrierTextCallback);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
|
|
||||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||||
@@ -380,7 +374,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
list.add(TEST_SUBSCRIPTION);
|
list.add(TEST_SUBSCRIPTION);
|
||||||
list.add(TEST_SUBSCRIPTION);
|
list.add(TEST_SUBSCRIPTION);
|
||||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||||
|
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
@@ -405,7 +399,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
||||||
.thenReturn(IccCardConstants.State.READY)
|
.thenReturn(IccCardConstants.State.READY)
|
||||||
.thenReturn(IccCardConstants.State.NOT_READY);
|
.thenReturn(IccCardConstants.State.NOT_READY);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||||
|
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
@@ -430,7 +424,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
when(mKeyguardUpdateMonitor.getSimState(anyInt()))
|
||||||
.thenReturn(IccCardConstants.State.NOT_READY)
|
.thenReturn(IccCardConstants.State.NOT_READY)
|
||||||
.thenReturn(IccCardConstants.State.READY);
|
.thenReturn(IccCardConstants.State.READY);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||||
|
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
@@ -457,7 +451,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
.thenReturn(IccCardConstants.State.READY)
|
.thenReturn(IccCardConstants.State.READY)
|
||||||
.thenReturn(IccCardConstants.State.NOT_READY)
|
.thenReturn(IccCardConstants.State.NOT_READY)
|
||||||
.thenReturn(IccCardConstants.State.READY);
|
.thenReturn(IccCardConstants.State.READY);
|
||||||
when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
|
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||||
|
|
||||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||||
@@ -472,30 +466,6 @@ public class CarrierTextControllerTest extends SysuiTestCase {
|
|||||||
captor.getValue().carrierText);
|
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 {
|
public static class TestCarrierTextController extends CarrierTextController {
|
||||||
private KeyguardUpdateMonitor mKUM;
|
private KeyguardUpdateMonitor mKUM;
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,18 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
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 com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.clearInvocations;
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.reset;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -42,6 +45,7 @@ import android.hardware.fingerprint.FingerprintManager;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
@@ -62,6 +66,8 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -73,7 +79,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
// new tests.
|
// new tests.
|
||||||
@RunWithLooper(setAsMainLooper = true)
|
@RunWithLooper(setAsMainLooper = true)
|
||||||
public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
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
|
@Mock
|
||||||
private KeyguardUpdateMonitor.StrongAuthTracker mStrongAuthTracker;
|
private KeyguardUpdateMonitor.StrongAuthTracker mStrongAuthTracker;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -92,6 +109,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
private DevicePolicyManager mDevicePolicyManager;
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
@Mock
|
@Mock
|
||||||
private KeyguardBypassController mKeyguardBypassController;
|
private KeyguardBypassController mKeyguardBypassController;
|
||||||
|
@Mock
|
||||||
|
private SubscriptionManager mSubscriptionManager;
|
||||||
private TestableLooper mTestableLooper;
|
private TestableLooper mTestableLooper;
|
||||||
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
|
|
||||||
@@ -119,6 +138,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
context.addMockSystemService(FaceManager.class, mFaceManager);
|
context.addMockSystemService(FaceManager.class, mFaceManager);
|
||||||
context.addMockSystemService(UserManager.class, mUserManager);
|
context.addMockSystemService(UserManager.class, mUserManager);
|
||||||
context.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager);
|
context.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager);
|
||||||
|
context.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
|
||||||
|
|
||||||
mTestableLooper = TestableLooper.get(this);
|
mTestableLooper = TestableLooper.get(this);
|
||||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(context);
|
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(context);
|
||||||
@@ -441,6 +461,22 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
assertThat(mKeyguardUpdateMonitor.getUserCanSkipBouncer(user)).isTrue();
|
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) {
|
private Intent putPhoneInfo(Intent intent, Bundle data, Boolean simInited) {
|
||||||
int subscription = simInited
|
int subscription = simInited
|
||||||
? 1/* mock subid=1 */ : SubscriptionManager.DUMMY_SUBSCRIPTION_ID_BASE;
|
? 1/* mock subid=1 */ : SubscriptionManager.DUMMY_SUBSCRIPTION_ID_BASE;
|
||||||
|
|||||||
Reference in New Issue
Block a user