Revert "Add ViewController to CarrierText."
Revert submission 13536242-b179775696-depenency-get-keyguard Reason for revert: Candidate reversion for broken tests: b/180440298 Reverted Changes: I6d0271692:Add ViewController to CarrierText. I4d9a4a21f:Add Controller for Emergency Button. I4c76d99f9:Remove Dependency.get from KeyguardSliceTextView. I730593fcf:Add injection to ClockProvider. Ifbb93e624:Remove Dependency.get from KeyguardStatusView. I237215456:Remove final calls to Dependency.get from keyguard... Change-Id: I3022b0e18b4a40a407de7177be6c94c602f9fcb1
This commit is contained in:
@@ -24,14 +24,41 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class CarrierText extends TextView {
|
||||
private final boolean mShowMissingSim;
|
||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||
private static final String TAG = "CarrierText";
|
||||
|
||||
private final boolean mShowAirplaneMode;
|
||||
private static CharSequence mSeparator;
|
||||
|
||||
private boolean mShowMissingSim;
|
||||
|
||||
private boolean mShowAirplaneMode;
|
||||
private boolean mShouldMarquee;
|
||||
|
||||
private CarrierTextController mCarrierTextController;
|
||||
|
||||
private CarrierTextController.CarrierTextCallback mCarrierTextCallback =
|
||||
new CarrierTextController.CarrierTextCallback() {
|
||||
@Override
|
||||
public void updateCarrierInfo(CarrierTextController.CarrierTextCallbackInfo info) {
|
||||
setText(info.carrierText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startedGoingToSleep() {
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishedWakingUp() {
|
||||
setSelected(true);
|
||||
}
|
||||
};
|
||||
|
||||
public CarrierText(Context context) {
|
||||
this(context, null);
|
||||
@@ -51,6 +78,30 @@ public class CarrierText extends TextView {
|
||||
}
|
||||
setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mSeparator = getResources().getString(
|
||||
com.android.internal.R.string.kg_text_message_separator);
|
||||
mCarrierTextController = new CarrierTextController(mContext, mSeparator, mShowAirplaneMode,
|
||||
mShowMissingSim);
|
||||
mShouldMarquee = Dependency.get(KeyguardUpdateMonitor.class).isDeviceInteractive();
|
||||
setSelected(mShouldMarquee); // Allow marquee to work.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mCarrierTextController.setListening(mCarrierTextCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mCarrierTextController.setListening(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||
super.onVisibilityChanged(changedView, visibility);
|
||||
@@ -62,15 +113,7 @@ public class CarrierText extends TextView {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowAirplaneMode() {
|
||||
return mShowAirplaneMode;
|
||||
}
|
||||
|
||||
public boolean getShowMissingSim() {
|
||||
return mShowMissingSim;
|
||||
}
|
||||
|
||||
private static class CarrierTextTransformationMethod extends SingleLineTransformationMethod {
|
||||
private class CarrierTextTransformationMethod extends SingleLineTransformationMethod {
|
||||
private final Locale mLocale;
|
||||
private final boolean mAllCaps;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,61 +16,680 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import com.android.systemui.util.ViewController;
|
||||
import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
|
||||
import static android.telephony.PhoneStateListener.LISTEN_NONE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settingslib.WirelessUtils;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Controller for {@link CarrierText}.
|
||||
* 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
|
||||
* separated by a given separator {@link CharSequence}.
|
||||
*/
|
||||
public class CarrierTextController extends ViewController<CarrierText> {
|
||||
private final CarrierTextManager mCarrierTextManager;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
public class CarrierTextController {
|
||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||
private static final String TAG = "CarrierTextController";
|
||||
|
||||
private final CarrierTextManager.CarrierTextCallback mCarrierTextCallback =
|
||||
new CarrierTextManager.CarrierTextCallback() {
|
||||
private final boolean mIsEmergencyCallCapable;
|
||||
private final Handler mMainHandler;
|
||||
private final Handler mBgHandler;
|
||||
private boolean mTelephonyCapable;
|
||||
private boolean mShowMissingSim;
|
||||
private boolean mShowAirplaneMode;
|
||||
private final AtomicBoolean mNetworkSupported = new AtomicBoolean();
|
||||
@VisibleForTesting
|
||||
protected KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private WifiManager mWifiManager;
|
||||
private boolean[] mSimErrorState;
|
||||
private final int mSimSlotsNumber;
|
||||
@Nullable // Check for nullability before dispatching
|
||||
private CarrierTextCallback mCarrierTextCallback;
|
||||
private Context mContext;
|
||||
private CharSequence mSeparator;
|
||||
private WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
|
||||
new WakefulnessLifecycle.Observer() {
|
||||
@Override
|
||||
public void updateCarrierInfo(CarrierTextManager.CarrierTextCallbackInfo info) {
|
||||
mView.setText(info.carrierText);
|
||||
public void onFinishedWakingUp() {
|
||||
final CarrierTextCallback callback = mCarrierTextCallback;
|
||||
if (callback != null) callback.finishedWakingUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startedGoingToSleep() {
|
||||
mView.setSelected(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishedWakingUp() {
|
||||
mView.setSelected(true);
|
||||
public void onStartedGoingToSleep() {
|
||||
final CarrierTextCallback callback = mCarrierTextCallback;
|
||||
if (callback != null) callback.startedGoingToSleep();
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
public CarrierTextController(CarrierText view,
|
||||
CarrierTextManager.Builder carrierTextManagerBuilder,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor) {
|
||||
super(view);
|
||||
@VisibleForTesting
|
||||
protected final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
||||
@Override
|
||||
public void onRefreshCarrierInfo() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onRefreshCarrierInfo(), mTelephonyCapable: "
|
||||
+ Boolean.toString(mTelephonyCapable));
|
||||
}
|
||||
updateCarrierText();
|
||||
}
|
||||
|
||||
mCarrierTextManager = carrierTextManagerBuilder
|
||||
.setShowAirplaneMode(mView.getShowAirplaneMode())
|
||||
.setShowMissingSim(mView.getShowMissingSim())
|
||||
.build();
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
@Override
|
||||
public void onTelephonyCapable(boolean capable) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onTelephonyCapable() mTelephonyCapable: "
|
||||
+ Boolean.toString(capable));
|
||||
}
|
||||
mTelephonyCapable = capable;
|
||||
updateCarrierText();
|
||||
}
|
||||
|
||||
public void onSimStateChanged(int subId, int slotId, int simState) {
|
||||
if (slotId < 0 || slotId >= mSimSlotsNumber) {
|
||||
Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId
|
||||
+ " mTelephonyCapable: " + Boolean.toString(mTelephonyCapable));
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) Log.d(TAG, "onSimStateChanged: " + getStatusForIccState(simState));
|
||||
if (getStatusForIccState(simState) == CarrierTextController.StatusMode.SimIoError) {
|
||||
mSimErrorState[slotId] = true;
|
||||
updateCarrierText();
|
||||
} else if (mSimErrorState[slotId]) {
|
||||
mSimErrorState[slotId] = false;
|
||||
updateCarrierText();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
||||
@Override
|
||||
public void onActiveDataSubscriptionIdChanged(int subId) {
|
||||
mActiveMobileDataSubscription = subId;
|
||||
if (mNetworkSupported.get() && mCarrierTextCallback != null) {
|
||||
updateCarrierText();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The status of this lock screen. Primarily used for widgets on LockScreen.
|
||||
*/
|
||||
private enum StatusMode {
|
||||
Normal, // Normal case (sim card present, it's not locked)
|
||||
NetworkLocked, // SIM card is 'network locked'.
|
||||
SimMissing, // SIM card is missing.
|
||||
SimMissingLocked, // SIM card is missing, and device isn't provisioned; don't allow access
|
||||
SimPukLocked, // SIM card is PUK locked because SIM entered wrong too many times
|
||||
SimLocked, // SIM card is currently locked
|
||||
SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure
|
||||
SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM.
|
||||
SimIoError, // SIM card is faulty
|
||||
SimUnknown // SIM card is unknown
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
super.onInit();
|
||||
mView.setSelected(mKeyguardUpdateMonitor.isDeviceInteractive());
|
||||
/**
|
||||
* Controller that provides updates on text with carriers names or SIM status.
|
||||
* Used by {@link CarrierText}.
|
||||
*
|
||||
* @param separator Separator between different parts of the text
|
||||
*/
|
||||
public CarrierTextController(Context context, CharSequence separator, boolean showAirplaneMode,
|
||||
boolean showMissingSim) {
|
||||
mContext = context;
|
||||
mIsEmergencyCallCapable = getTelephonyManager().isVoiceCapable();
|
||||
|
||||
mShowAirplaneMode = showAirplaneMode;
|
||||
mShowMissingSim = showMissingSim;
|
||||
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mSeparator = separator;
|
||||
mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
|
||||
mSimSlotsNumber = getTelephonyManager().getSupportedModemCount();
|
||||
mSimErrorState = new boolean[mSimSlotsNumber];
|
||||
mMainHandler = Dependency.get(Dependency.MAIN_HANDLER);
|
||||
mBgHandler = new Handler(Dependency.get(Dependency.BG_LOOPER));
|
||||
mKeyguardUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
|
||||
mBgHandler.post(() -> {
|
||||
boolean supported = ConnectivityManager.from(mContext).isNetworkSupported(
|
||||
ConnectivityManager.TYPE_MOBILE);
|
||||
if (supported && mNetworkSupported.compareAndSet(false, supported)) {
|
||||
// This will set/remove the listeners appropriately. Note that it will never double
|
||||
// add the listeners.
|
||||
handleSetListening(mCarrierTextCallback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mCarrierTextManager.setListening(mCarrierTextCallback);
|
||||
private TelephonyManager getTelephonyManager() {
|
||||
return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewDetached() {
|
||||
mCarrierTextManager.setListening(null);
|
||||
/**
|
||||
* Checks if there are faulty cards. Adds the text depending on the slot of the card
|
||||
*
|
||||
* @param text: current carrier text based on the sim state
|
||||
* @param carrierNames names order by subscription order
|
||||
* @param subOrderBySlot array containing the sub index for each slot ID
|
||||
* @param noSims: whether a valid sim card is inserted
|
||||
* @return text
|
||||
*/
|
||||
private CharSequence updateCarrierTextWithSimIoError(CharSequence text,
|
||||
CharSequence[] carrierNames, int[] subOrderBySlot, boolean noSims) {
|
||||
final CharSequence carrier = "";
|
||||
CharSequence carrierTextForSimIOError = getCarrierTextForSimState(
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR, carrier);
|
||||
// mSimErrorState has the state of each sim indexed by slotID.
|
||||
for (int index = 0; index < getTelephonyManager().getActiveModemCount(); index++) {
|
||||
if (!mSimErrorState[index]) {
|
||||
continue;
|
||||
}
|
||||
// In the case when no sim cards are detected but a faulty card is inserted
|
||||
// overwrite the text and only show "Invalid card"
|
||||
if (noSims) {
|
||||
return concatenate(carrierTextForSimIOError,
|
||||
getContext().getText(
|
||||
com.android.internal.R.string.emergency_calls_only),
|
||||
mSeparator);
|
||||
} else if (subOrderBySlot[index] != -1) {
|
||||
int subIndex = subOrderBySlot[index];
|
||||
// prepend "Invalid card" when faulty card is inserted in slot 0 or 1
|
||||
carrierNames[subIndex] = concatenate(carrierTextForSimIOError,
|
||||
carrierNames[subIndex],
|
||||
mSeparator);
|
||||
} else {
|
||||
// concatenate "Invalid card" when faulty card is inserted in other slot
|
||||
text = concatenate(text, carrierTextForSimIOError, mSeparator);
|
||||
}
|
||||
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* This may be called internally after retrieving the correct value of {@code mNetworkSupported}
|
||||
* (assumed false to start). In that case, the following happens:
|
||||
* <ul>
|
||||
* <li> If there was a registered callback, and the network is supported, it will register
|
||||
* listeners.
|
||||
* <li> If there was not a registered callback, it will try to remove unregistered listeners
|
||||
* which is a no-op
|
||||
* </ul>
|
||||
*
|
||||
* This call will always be processed in a background thread.
|
||||
*/
|
||||
private void handleSetListening(CarrierTextCallback callback) {
|
||||
TelephonyManager telephonyManager = getTelephonyManager();
|
||||
if (callback != null) {
|
||||
mCarrierTextCallback = callback;
|
||||
if (mNetworkSupported.get()) {
|
||||
// Keyguard update monitor expects callbacks from main thread
|
||||
mMainHandler.post(() -> mKeyguardUpdateMonitor.registerCallback(mCallback));
|
||||
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
||||
telephonyManager.listen(mPhoneStateListener,
|
||||
LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
|
||||
} else {
|
||||
// Don't listen and clear out the text when the device isn't a phone.
|
||||
mMainHandler.post(() -> callback.updateCarrierInfo(
|
||||
new CarrierTextCallbackInfo("", null, false, null)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
mCarrierTextCallback = null;
|
||||
mMainHandler.post(() -> mKeyguardUpdateMonitor.removeCallback(mCallback));
|
||||
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
|
||||
telephonyManager.listen(mPhoneStateListener, LISTEN_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the listening status of this controller. If the callback is null, it is set to
|
||||
* not listening.
|
||||
*
|
||||
* @param callback Callback to provide text updates
|
||||
*/
|
||||
public void setListening(CarrierTextCallback callback) {
|
||||
mBgHandler.post(() -> handleSetListening(callback));
|
||||
}
|
||||
|
||||
protected List<SubscriptionInfo> getSubscriptionInfo() {
|
||||
return mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||
}
|
||||
|
||||
protected void updateCarrierText() {
|
||||
boolean allSimsMissing = true;
|
||||
boolean anySimReadyAndInService = false;
|
||||
CharSequence displayText = null;
|
||||
List<SubscriptionInfo> subs = getSubscriptionInfo();
|
||||
|
||||
final int numSubs = subs.size();
|
||||
final int[] subsIds = new int[numSubs];
|
||||
// This array will contain in position i, the index of subscription in slot ID i.
|
||||
// -1 if no subscription in that slot
|
||||
final int[] subOrderBySlot = new int[mSimSlotsNumber];
|
||||
for (int i = 0; i < mSimSlotsNumber; i++) {
|
||||
subOrderBySlot[i] = -1;
|
||||
}
|
||||
final CharSequence[] carrierNames = new CharSequence[numSubs];
|
||||
if (DEBUG) Log.d(TAG, "updateCarrierText(): " + numSubs);
|
||||
|
||||
for (int i = 0; i < numSubs; i++) {
|
||||
int subId = subs.get(i).getSubscriptionId();
|
||||
carrierNames[i] = "";
|
||||
subsIds[i] = subId;
|
||||
subOrderBySlot[subs.get(i).getSimSlotIndex()] = i;
|
||||
int simState = mKeyguardUpdateMonitor.getSimState(subId);
|
||||
CharSequence carrierName = subs.get(i).getCarrierName();
|
||||
CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName);
|
||||
}
|
||||
if (carrierTextForSimState != null) {
|
||||
allSimsMissing = false;
|
||||
carrierNames[i] = carrierTextForSimState;
|
||||
}
|
||||
if (simState == TelephonyManager.SIM_STATE_READY) {
|
||||
ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId);
|
||||
if (ss != null && ss.getDataRegistrationState() == ServiceState.STATE_IN_SERVICE) {
|
||||
// hack for WFC (IWLAN) not turning off immediately once
|
||||
// Wi-Fi is disassociated or disabled
|
||||
if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
|
||||
|| (mWifiManager.isWifiEnabled()
|
||||
&& mWifiManager.getConnectionInfo() != null
|
||||
&& mWifiManager.getConnectionInfo().getBSSID() != null)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss);
|
||||
}
|
||||
anySimReadyAndInService = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only create "No SIM card" if no cards with CarrierName && no wifi when some sim is READY
|
||||
// This condition will also be true always when numSubs == 0
|
||||
if (allSimsMissing && !anySimReadyAndInService) {
|
||||
if (numSubs != 0) {
|
||||
// Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
|
||||
// This depends on mPlmn containing the text "Emergency calls only" when the radio
|
||||
// has some connectivity. Otherwise, it should be null or empty and just show
|
||||
// "No SIM card"
|
||||
// Grab the first subscripton, because they all should contain the emergency text,
|
||||
// described above.
|
||||
displayText = makeCarrierStringOnEmergencyCapable(
|
||||
getMissingSimMessage(), subs.get(0).getCarrierName());
|
||||
} else {
|
||||
// We don't have a SubscriptionInfo to get the emergency calls only from.
|
||||
// Grab it from the old sticky broadcast if possible instead. We can use it
|
||||
// here because no subscriptions are active, so we don't have
|
||||
// to worry about MSIM clashing.
|
||||
CharSequence text =
|
||||
getContext().getText(com.android.internal.R.string.emergency_calls_only);
|
||||
Intent i = getContext().registerReceiver(null,
|
||||
new IntentFilter(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED));
|
||||
if (i != null) {
|
||||
String spn = "";
|
||||
String plmn = "";
|
||||
if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_SPN, false)) {
|
||||
spn = i.getStringExtra(TelephonyManager.EXTRA_SPN);
|
||||
}
|
||||
if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false)) {
|
||||
plmn = i.getStringExtra(TelephonyManager.EXTRA_PLMN);
|
||||
}
|
||||
if (DEBUG) Log.d(TAG, "Getting plmn/spn sticky brdcst " + plmn + "/" + spn);
|
||||
if (Objects.equals(plmn, spn)) {
|
||||
text = plmn;
|
||||
} else {
|
||||
text = concatenate(plmn, spn, mSeparator);
|
||||
}
|
||||
}
|
||||
displayText = makeCarrierStringOnEmergencyCapable(getMissingSimMessage(), text);
|
||||
}
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(displayText)) displayText = joinNotEmpty(mSeparator, carrierNames);
|
||||
|
||||
displayText = updateCarrierTextWithSimIoError(displayText, carrierNames, subOrderBySlot,
|
||||
allSimsMissing);
|
||||
|
||||
boolean airplaneMode = false;
|
||||
// APM (airplane mode) != no carrier state. There are carrier services
|
||||
// (e.g. WFC = Wi-Fi calling) which may operate in APM.
|
||||
if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) {
|
||||
displayText = getAirplaneModeMessage();
|
||||
airplaneMode = true;
|
||||
}
|
||||
|
||||
final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo(
|
||||
displayText,
|
||||
carrierNames,
|
||||
!allSimsMissing,
|
||||
subsIds,
|
||||
airplaneMode);
|
||||
postToCallback(info);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void postToCallback(CarrierTextCallbackInfo info) {
|
||||
final CarrierTextCallback callback = mCarrierTextCallback;
|
||||
if (callback != null) {
|
||||
mMainHandler.post(() -> callback.updateCarrierInfo(info));
|
||||
}
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
private String getMissingSimMessage() {
|
||||
return mShowMissingSim && mTelephonyCapable
|
||||
? getContext().getString(R.string.keyguard_missing_sim_message_short) : "";
|
||||
}
|
||||
|
||||
private String getAirplaneModeMessage() {
|
||||
return mShowAirplaneMode
|
||||
? getContext().getString(R.string.airplane_mode) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Top-level function for creating carrier text. Makes text based on simState, PLMN
|
||||
* and SPN as well as device capabilities, such as being emergency call capable.
|
||||
*
|
||||
* @return Carrier text if not in missing state, null otherwise.
|
||||
*/
|
||||
private CharSequence getCarrierTextForSimState(int simState, CharSequence text) {
|
||||
CharSequence carrierText = null;
|
||||
CarrierTextController.StatusMode status = getStatusForIccState(simState);
|
||||
switch (status) {
|
||||
case Normal:
|
||||
carrierText = text;
|
||||
break;
|
||||
|
||||
case SimNotReady:
|
||||
// Null is reserved for denoting missing, in this case we have nothing to display.
|
||||
carrierText = ""; // nothing to display yet.
|
||||
break;
|
||||
|
||||
case NetworkLocked:
|
||||
carrierText = makeCarrierStringOnEmergencyCapable(
|
||||
mContext.getText(R.string.keyguard_network_locked_message), text);
|
||||
break;
|
||||
|
||||
case SimMissing:
|
||||
carrierText = null;
|
||||
break;
|
||||
|
||||
case SimPermDisabled:
|
||||
carrierText = makeCarrierStringOnEmergencyCapable(
|
||||
getContext().getText(
|
||||
R.string.keyguard_permanent_disabled_sim_message_short),
|
||||
text);
|
||||
break;
|
||||
|
||||
case SimMissingLocked:
|
||||
carrierText = null;
|
||||
break;
|
||||
|
||||
case SimLocked:
|
||||
carrierText = makeCarrierStringOnLocked(
|
||||
getContext().getText(R.string.keyguard_sim_locked_message),
|
||||
text);
|
||||
break;
|
||||
|
||||
case SimPukLocked:
|
||||
carrierText = makeCarrierStringOnLocked(
|
||||
getContext().getText(R.string.keyguard_sim_puk_locked_message),
|
||||
text);
|
||||
break;
|
||||
case SimIoError:
|
||||
carrierText = makeCarrierStringOnEmergencyCapable(
|
||||
getContext().getText(R.string.keyguard_sim_error_message_short),
|
||||
text);
|
||||
break;
|
||||
case SimUnknown:
|
||||
carrierText = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return carrierText;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add emergencyCallMessage to carrier string only if phone supports emergency calls.
|
||||
*/
|
||||
private CharSequence makeCarrierStringOnEmergencyCapable(
|
||||
CharSequence simMessage, CharSequence emergencyCallMessage) {
|
||||
if (mIsEmergencyCallCapable) {
|
||||
return concatenate(simMessage, emergencyCallMessage, mSeparator);
|
||||
}
|
||||
return simMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add "SIM card is locked" in parenthesis after carrier name, so it is easily associated in
|
||||
* DSDS
|
||||
*/
|
||||
private CharSequence makeCarrierStringOnLocked(CharSequence simMessage,
|
||||
CharSequence carrierName) {
|
||||
final boolean simMessageValid = !TextUtils.isEmpty(simMessage);
|
||||
final boolean carrierNameValid = !TextUtils.isEmpty(carrierName);
|
||||
if (simMessageValid && carrierNameValid) {
|
||||
return mContext.getString(R.string.keyguard_carrier_name_with_sim_locked_template,
|
||||
carrierName, simMessage);
|
||||
} else if (simMessageValid) {
|
||||
return simMessage;
|
||||
} else if (carrierNameValid) {
|
||||
return carrierName;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the current status of the lock screen given the SIM state and other stuff.
|
||||
*/
|
||||
private CarrierTextController.StatusMode getStatusForIccState(int simState) {
|
||||
final boolean missingAndNotProvisioned =
|
||||
!mKeyguardUpdateMonitor.isDeviceProvisioned()
|
||||
&& (simState == TelephonyManager.SIM_STATE_ABSENT
|
||||
|| simState == TelephonyManager.SIM_STATE_PERM_DISABLED);
|
||||
|
||||
// Assume we're NETWORK_LOCKED if not provisioned
|
||||
simState = missingAndNotProvisioned ? TelephonyManager.SIM_STATE_NETWORK_LOCKED : simState;
|
||||
switch (simState) {
|
||||
case TelephonyManager.SIM_STATE_ABSENT:
|
||||
return CarrierTextController.StatusMode.SimMissing;
|
||||
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
|
||||
return CarrierTextController.StatusMode.SimMissingLocked;
|
||||
case TelephonyManager.SIM_STATE_NOT_READY:
|
||||
return CarrierTextController.StatusMode.SimNotReady;
|
||||
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
|
||||
return CarrierTextController.StatusMode.SimLocked;
|
||||
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
|
||||
return CarrierTextController.StatusMode.SimPukLocked;
|
||||
case TelephonyManager.SIM_STATE_READY:
|
||||
return CarrierTextController.StatusMode.Normal;
|
||||
case TelephonyManager.SIM_STATE_PERM_DISABLED:
|
||||
return CarrierTextController.StatusMode.SimPermDisabled;
|
||||
case TelephonyManager.SIM_STATE_UNKNOWN:
|
||||
return CarrierTextController.StatusMode.SimUnknown;
|
||||
case TelephonyManager.SIM_STATE_CARD_IO_ERROR:
|
||||
return CarrierTextController.StatusMode.SimIoError;
|
||||
}
|
||||
return CarrierTextController.StatusMode.SimUnknown;
|
||||
}
|
||||
|
||||
private static CharSequence concatenate(CharSequence plmn, CharSequence spn,
|
||||
CharSequence separator) {
|
||||
final boolean plmnValid = !TextUtils.isEmpty(plmn);
|
||||
final boolean spnValid = !TextUtils.isEmpty(spn);
|
||||
if (plmnValid && spnValid) {
|
||||
return new StringBuilder().append(plmn).append(separator).append(spn).toString();
|
||||
} else if (plmnValid) {
|
||||
return plmn;
|
||||
} else if (spnValid) {
|
||||
return spn;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins the strings in a sequence using a separator. Empty strings are discarded with no extra
|
||||
* separator added so there are no extra separators that are not needed.
|
||||
*/
|
||||
private static CharSequence joinNotEmpty(CharSequence separator, CharSequence[] sequences) {
|
||||
int length = sequences.length;
|
||||
if (length == 0) return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!TextUtils.isEmpty(sequences[i])) {
|
||||
if (!TextUtils.isEmpty(sb)) {
|
||||
sb.append(separator);
|
||||
}
|
||||
sb.append(sequences[i]);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static List<CharSequence> append(List<CharSequence> list, CharSequence string) {
|
||||
if (!TextUtils.isEmpty(string)) {
|
||||
list.add(string);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private CharSequence getCarrierHelpTextForSimState(int simState,
|
||||
String plmn, String spn) {
|
||||
int carrierHelpTextId = 0;
|
||||
CarrierTextController.StatusMode status = getStatusForIccState(simState);
|
||||
switch (status) {
|
||||
case NetworkLocked:
|
||||
carrierHelpTextId = R.string.keyguard_instructions_when_pattern_disabled;
|
||||
break;
|
||||
|
||||
case SimMissing:
|
||||
carrierHelpTextId = R.string.keyguard_missing_sim_instructions_long;
|
||||
break;
|
||||
|
||||
case SimPermDisabled:
|
||||
carrierHelpTextId = R.string.keyguard_permanent_disabled_sim_instructions;
|
||||
break;
|
||||
|
||||
case SimMissingLocked:
|
||||
carrierHelpTextId = R.string.keyguard_missing_sim_instructions;
|
||||
break;
|
||||
|
||||
case Normal:
|
||||
case SimLocked:
|
||||
case SimPukLocked:
|
||||
break;
|
||||
}
|
||||
|
||||
return mContext.getText(carrierHelpTextId);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final Context mContext;
|
||||
private final String mSeparator;
|
||||
private boolean mShowAirplaneMode;
|
||||
private boolean mShowMissingSim;
|
||||
|
||||
@Inject
|
||||
public Builder(Context context, @Main Resources resources) {
|
||||
mContext = context;
|
||||
mSeparator = resources.getString(
|
||||
com.android.internal.R.string.kg_text_message_separator);
|
||||
}
|
||||
|
||||
|
||||
public Builder setShowAirplaneMode(boolean showAirplaneMode) {
|
||||
mShowAirplaneMode = showAirplaneMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setShowMissingSim(boolean showMissingSim) {
|
||||
mShowMissingSim = showMissingSim;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CarrierTextController build() {
|
||||
return new CarrierTextController(
|
||||
mContext, mSeparator, mShowAirplaneMode, mShowMissingSim);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Data structure for passing information to CarrierTextController subscribers
|
||||
*/
|
||||
public static final class CarrierTextCallbackInfo {
|
||||
public final CharSequence carrierText;
|
||||
public final CharSequence[] listOfCarriers;
|
||||
public final boolean anySimReady;
|
||||
public final int[] subscriptionIds;
|
||||
public boolean airplaneMode;
|
||||
|
||||
@VisibleForTesting
|
||||
public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers,
|
||||
boolean anySimReady, int[] subscriptionIds) {
|
||||
this(carrierText, listOfCarriers, anySimReady, subscriptionIds, false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers,
|
||||
boolean anySimReady, int[] subscriptionIds, boolean airplaneMode) {
|
||||
this.carrierText = carrierText;
|
||||
this.listOfCarriers = listOfCarriers;
|
||||
this.anySimReady = anySimReady;
|
||||
this.subscriptionIds = subscriptionIds;
|
||||
this.airplaneMode = airplaneMode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to communicate to Views
|
||||
*/
|
||||
public interface CarrierTextCallback {
|
||||
/**
|
||||
* Provides updated carrier information.
|
||||
*/
|
||||
default void updateCarrierInfo(CarrierTextCallbackInfo info) {};
|
||||
|
||||
/**
|
||||
* Notifies the View that the device is going to sleep
|
||||
*/
|
||||
default void startedGoingToSleep() {};
|
||||
|
||||
/**
|
||||
* Notifies the View that the device finished waking up
|
||||
*/
|
||||
default void finishedWakingUp() {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,720 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE;
|
||||
import static android.telephony.PhoneStateListener.LISTEN_NONE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.ServiceState;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settingslib.WirelessUtils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* separated by a given separator {@link CharSequence}.
|
||||
*/
|
||||
public class CarrierTextManager {
|
||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||
private static final String TAG = "CarrierTextController";
|
||||
|
||||
private final boolean mIsEmergencyCallCapable;
|
||||
private final Handler mMainHandler;
|
||||
private final Handler mBgHandler;
|
||||
private boolean mTelephonyCapable;
|
||||
private final boolean mShowMissingSim;
|
||||
private final boolean mShowAirplaneMode;
|
||||
private final AtomicBoolean mNetworkSupported = new AtomicBoolean();
|
||||
@VisibleForTesting
|
||||
protected KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final WifiManager mWifiManager;
|
||||
private final boolean[] mSimErrorState;
|
||||
private final int mSimSlotsNumber;
|
||||
@Nullable // Check for nullability before dispatching
|
||||
private CarrierTextCallback mCarrierTextCallback;
|
||||
private final Context mContext;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
private final CharSequence mSeparator;
|
||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
|
||||
new WakefulnessLifecycle.Observer() {
|
||||
@Override
|
||||
public void onFinishedWakingUp() {
|
||||
final CarrierTextCallback callback = mCarrierTextCallback;
|
||||
if (callback != null) callback.finishedWakingUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartedGoingToSleep() {
|
||||
final CarrierTextCallback callback = mCarrierTextCallback;
|
||||
if (callback != null) callback.startedGoingToSleep();
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
protected final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
||||
@Override
|
||||
public void onRefreshCarrierInfo() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onRefreshCarrierInfo(), mTelephonyCapable: "
|
||||
+ Boolean.toString(mTelephonyCapable));
|
||||
}
|
||||
updateCarrierText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTelephonyCapable(boolean capable) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onTelephonyCapable() mTelephonyCapable: "
|
||||
+ Boolean.toString(capable));
|
||||
}
|
||||
mTelephonyCapable = capable;
|
||||
updateCarrierText();
|
||||
}
|
||||
|
||||
public void onSimStateChanged(int subId, int slotId, int simState) {
|
||||
if (slotId < 0 || slotId >= mSimSlotsNumber) {
|
||||
Log.d(TAG, "onSimStateChanged() - slotId invalid: " + slotId
|
||||
+ " mTelephonyCapable: " + Boolean.toString(mTelephonyCapable));
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) Log.d(TAG, "onSimStateChanged: " + getStatusForIccState(simState));
|
||||
if (getStatusForIccState(simState) == CarrierTextManager.StatusMode.SimIoError) {
|
||||
mSimErrorState[slotId] = true;
|
||||
updateCarrierText();
|
||||
} else if (mSimErrorState[slotId]) {
|
||||
mSimErrorState[slotId] = false;
|
||||
updateCarrierText();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
|
||||
@Override
|
||||
public void onActiveDataSubscriptionIdChanged(int subId) {
|
||||
if (mNetworkSupported.get() && mCarrierTextCallback != null) {
|
||||
updateCarrierText();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The status of this lock screen. Primarily used for widgets on LockScreen.
|
||||
*/
|
||||
private enum StatusMode {
|
||||
Normal, // Normal case (sim card present, it's not locked)
|
||||
NetworkLocked, // SIM card is 'network locked'.
|
||||
SimMissing, // SIM card is missing.
|
||||
SimMissingLocked, // SIM card is missing, and device isn't provisioned; don't allow access
|
||||
SimPukLocked, // SIM card is PUK locked because SIM entered wrong too many times
|
||||
SimLocked, // SIM card is currently locked
|
||||
SimPermDisabled, // SIM card is permanently disabled due to PUK unlock failure
|
||||
SimNotReady, // SIM is not ready yet. May never be on devices w/o a SIM.
|
||||
SimIoError, // SIM card is faulty
|
||||
SimUnknown // SIM card is unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller that provides updates on text with carriers names or SIM status.
|
||||
* Used by {@link CarrierText}.
|
||||
*
|
||||
* @param separator Separator between different parts of the text
|
||||
*/
|
||||
private CarrierTextManager(Context context, CharSequence separator, boolean showAirplaneMode,
|
||||
boolean showMissingSim, @Nullable WifiManager wifiManager,
|
||||
ConnectivityManager connectivityManager, TelephonyManager telephonyManager,
|
||||
WakefulnessLifecycle wakefulnessLifecycle, @Main Handler mainHandler,
|
||||
@Background Handler bgHandler, KeyguardUpdateMonitor keyguardUpdateMonitor) {
|
||||
mContext = context;
|
||||
mIsEmergencyCallCapable = telephonyManager.isVoiceCapable();
|
||||
|
||||
mShowAirplaneMode = showAirplaneMode;
|
||||
mShowMissingSim = showMissingSim;
|
||||
|
||||
mWifiManager = wifiManager;
|
||||
mTelephonyManager = telephonyManager;
|
||||
mSeparator = separator;
|
||||
mWakefulnessLifecycle = wakefulnessLifecycle;
|
||||
mSimSlotsNumber = getTelephonyManager().getSupportedModemCount();
|
||||
mSimErrorState = new boolean[mSimSlotsNumber];
|
||||
mMainHandler = mainHandler;
|
||||
mBgHandler = bgHandler;
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
mBgHandler.post(() -> {
|
||||
boolean supported = connectivityManager.isNetworkSupported(
|
||||
ConnectivityManager.TYPE_MOBILE);
|
||||
if (supported && mNetworkSupported.compareAndSet(false, supported)) {
|
||||
// This will set/remove the listeners appropriately. Note that it will never double
|
||||
// add the listeners.
|
||||
handleSetListening(mCarrierTextCallback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private TelephonyManager getTelephonyManager() {
|
||||
return mTelephonyManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are faulty cards. Adds the text depending on the slot of the card
|
||||
*
|
||||
* @param text: current carrier text based on the sim state
|
||||
* @param carrierNames names order by subscription order
|
||||
* @param subOrderBySlot array containing the sub index for each slot ID
|
||||
* @param noSims: whether a valid sim card is inserted
|
||||
* @return text
|
||||
*/
|
||||
private CharSequence updateCarrierTextWithSimIoError(CharSequence text,
|
||||
CharSequence[] carrierNames, int[] subOrderBySlot, boolean noSims) {
|
||||
final CharSequence carrier = "";
|
||||
CharSequence carrierTextForSimIOError = getCarrierTextForSimState(
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR, carrier);
|
||||
// mSimErrorState has the state of each sim indexed by slotID.
|
||||
for (int index = 0; index < getTelephonyManager().getActiveModemCount(); index++) {
|
||||
if (!mSimErrorState[index]) {
|
||||
continue;
|
||||
}
|
||||
// In the case when no sim cards are detected but a faulty card is inserted
|
||||
// overwrite the text and only show "Invalid card"
|
||||
if (noSims) {
|
||||
return concatenate(carrierTextForSimIOError,
|
||||
getContext().getText(
|
||||
com.android.internal.R.string.emergency_calls_only),
|
||||
mSeparator);
|
||||
} else if (subOrderBySlot[index] != -1) {
|
||||
int subIndex = subOrderBySlot[index];
|
||||
// prepend "Invalid card" when faulty card is inserted in slot 0 or 1
|
||||
carrierNames[subIndex] = concatenate(carrierTextForSimIOError,
|
||||
carrierNames[subIndex],
|
||||
mSeparator);
|
||||
} else {
|
||||
// concatenate "Invalid card" when faulty card is inserted in other slot
|
||||
text = concatenate(text, carrierTextForSimIOError, mSeparator);
|
||||
}
|
||||
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* This may be called internally after retrieving the correct value of {@code mNetworkSupported}
|
||||
* (assumed false to start). In that case, the following happens:
|
||||
* <ul>
|
||||
* <li> If there was a registered callback, and the network is supported, it will register
|
||||
* listeners.
|
||||
* <li> If there was not a registered callback, it will try to remove unregistered listeners
|
||||
* which is a no-op
|
||||
* </ul>
|
||||
*
|
||||
* This call will always be processed in a background thread.
|
||||
*/
|
||||
private void handleSetListening(CarrierTextCallback callback) {
|
||||
TelephonyManager telephonyManager = getTelephonyManager();
|
||||
if (callback != null) {
|
||||
mCarrierTextCallback = callback;
|
||||
if (mNetworkSupported.get()) {
|
||||
// Keyguard update monitor expects callbacks from main thread
|
||||
mMainHandler.post(() -> mKeyguardUpdateMonitor.registerCallback(mCallback));
|
||||
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
||||
telephonyManager.listen(mPhoneStateListener,
|
||||
LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
|
||||
} else {
|
||||
// Don't listen and clear out the text when the device isn't a phone.
|
||||
mMainHandler.post(() -> callback.updateCarrierInfo(
|
||||
new CarrierTextCallbackInfo("", null, false, null)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
mCarrierTextCallback = null;
|
||||
mMainHandler.post(() -> mKeyguardUpdateMonitor.removeCallback(mCallback));
|
||||
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
|
||||
telephonyManager.listen(mPhoneStateListener, LISTEN_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the listening status of this controller. If the callback is null, it is set to
|
||||
* not listening.
|
||||
*
|
||||
* @param callback Callback to provide text updates
|
||||
*/
|
||||
public void setListening(CarrierTextCallback callback) {
|
||||
mBgHandler.post(() -> handleSetListening(callback));
|
||||
}
|
||||
|
||||
protected List<SubscriptionInfo> getSubscriptionInfo() {
|
||||
return mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(false);
|
||||
}
|
||||
|
||||
protected void updateCarrierText() {
|
||||
boolean allSimsMissing = true;
|
||||
boolean anySimReadyAndInService = false;
|
||||
CharSequence displayText = null;
|
||||
List<SubscriptionInfo> subs = getSubscriptionInfo();
|
||||
|
||||
final int numSubs = subs.size();
|
||||
final int[] subsIds = new int[numSubs];
|
||||
// This array will contain in position i, the index of subscription in slot ID i.
|
||||
// -1 if no subscription in that slot
|
||||
final int[] subOrderBySlot = new int[mSimSlotsNumber];
|
||||
for (int i = 0; i < mSimSlotsNumber; i++) {
|
||||
subOrderBySlot[i] = -1;
|
||||
}
|
||||
final CharSequence[] carrierNames = new CharSequence[numSubs];
|
||||
if (DEBUG) Log.d(TAG, "updateCarrierText(): " + numSubs);
|
||||
|
||||
for (int i = 0; i < numSubs; i++) {
|
||||
int subId = subs.get(i).getSubscriptionId();
|
||||
carrierNames[i] = "";
|
||||
subsIds[i] = subId;
|
||||
subOrderBySlot[subs.get(i).getSimSlotIndex()] = i;
|
||||
int simState = mKeyguardUpdateMonitor.getSimState(subId);
|
||||
CharSequence carrierName = subs.get(i).getCarrierName();
|
||||
CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName);
|
||||
}
|
||||
if (carrierTextForSimState != null) {
|
||||
allSimsMissing = false;
|
||||
carrierNames[i] = carrierTextForSimState;
|
||||
}
|
||||
if (simState == TelephonyManager.SIM_STATE_READY) {
|
||||
ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId);
|
||||
if (ss != null && ss.getDataRegistrationState() == ServiceState.STATE_IN_SERVICE) {
|
||||
// hack for WFC (IWLAN) not turning off immediately once
|
||||
// Wi-Fi is disassociated or disabled
|
||||
if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
|
||||
|| (mWifiManager != null && mWifiManager.isWifiEnabled()
|
||||
&& mWifiManager.getConnectionInfo() != null
|
||||
&& mWifiManager.getConnectionInfo().getBSSID() != null)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss);
|
||||
}
|
||||
anySimReadyAndInService = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only create "No SIM card" if no cards with CarrierName && no wifi when some sim is READY
|
||||
// This condition will also be true always when numSubs == 0
|
||||
if (allSimsMissing && !anySimReadyAndInService) {
|
||||
if (numSubs != 0) {
|
||||
// Shows "No SIM card | Emergency calls only" on devices that are voice-capable.
|
||||
// This depends on mPlmn containing the text "Emergency calls only" when the radio
|
||||
// has some connectivity. Otherwise, it should be null or empty and just show
|
||||
// "No SIM card"
|
||||
// Grab the first subscripton, because they all should contain the emergency text,
|
||||
// described above.
|
||||
displayText = makeCarrierStringOnEmergencyCapable(
|
||||
getMissingSimMessage(), subs.get(0).getCarrierName());
|
||||
} else {
|
||||
// We don't have a SubscriptionInfo to get the emergency calls only from.
|
||||
// Grab it from the old sticky broadcast if possible instead. We can use it
|
||||
// here because no subscriptions are active, so we don't have
|
||||
// to worry about MSIM clashing.
|
||||
CharSequence text =
|
||||
getContext().getText(com.android.internal.R.string.emergency_calls_only);
|
||||
Intent i = getContext().registerReceiver(null,
|
||||
new IntentFilter(TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED));
|
||||
if (i != null) {
|
||||
String spn = "";
|
||||
String plmn = "";
|
||||
if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_SPN, false)) {
|
||||
spn = i.getStringExtra(TelephonyManager.EXTRA_SPN);
|
||||
}
|
||||
if (i.getBooleanExtra(TelephonyManager.EXTRA_SHOW_PLMN, false)) {
|
||||
plmn = i.getStringExtra(TelephonyManager.EXTRA_PLMN);
|
||||
}
|
||||
if (DEBUG) Log.d(TAG, "Getting plmn/spn sticky brdcst " + plmn + "/" + spn);
|
||||
if (Objects.equals(plmn, spn)) {
|
||||
text = plmn;
|
||||
} else {
|
||||
text = concatenate(plmn, spn, mSeparator);
|
||||
}
|
||||
}
|
||||
displayText = makeCarrierStringOnEmergencyCapable(getMissingSimMessage(), text);
|
||||
}
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(displayText)) displayText = joinNotEmpty(mSeparator, carrierNames);
|
||||
|
||||
displayText = updateCarrierTextWithSimIoError(displayText, carrierNames, subOrderBySlot,
|
||||
allSimsMissing);
|
||||
|
||||
boolean airplaneMode = false;
|
||||
// APM (airplane mode) != no carrier state. There are carrier services
|
||||
// (e.g. WFC = Wi-Fi calling) which may operate in APM.
|
||||
if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) {
|
||||
displayText = getAirplaneModeMessage();
|
||||
airplaneMode = true;
|
||||
}
|
||||
|
||||
final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo(
|
||||
displayText,
|
||||
carrierNames,
|
||||
!allSimsMissing,
|
||||
subsIds,
|
||||
airplaneMode);
|
||||
postToCallback(info);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void postToCallback(CarrierTextCallbackInfo info) {
|
||||
final CarrierTextCallback callback = mCarrierTextCallback;
|
||||
if (callback != null) {
|
||||
mMainHandler.post(() -> callback.updateCarrierInfo(info));
|
||||
}
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
private String getMissingSimMessage() {
|
||||
return mShowMissingSim && mTelephonyCapable
|
||||
? getContext().getString(R.string.keyguard_missing_sim_message_short) : "";
|
||||
}
|
||||
|
||||
private String getAirplaneModeMessage() {
|
||||
return mShowAirplaneMode
|
||||
? getContext().getString(R.string.airplane_mode) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Top-level function for creating carrier text. Makes text based on simState, PLMN
|
||||
* and SPN as well as device capabilities, such as being emergency call capable.
|
||||
*
|
||||
* @return Carrier text if not in missing state, null otherwise.
|
||||
*/
|
||||
private CharSequence getCarrierTextForSimState(int simState, CharSequence text) {
|
||||
CharSequence carrierText = null;
|
||||
CarrierTextManager.StatusMode status = getStatusForIccState(simState);
|
||||
switch (status) {
|
||||
case Normal:
|
||||
carrierText = text;
|
||||
break;
|
||||
|
||||
case SimNotReady:
|
||||
// Null is reserved for denoting missing, in this case we have nothing to display.
|
||||
carrierText = ""; // nothing to display yet.
|
||||
break;
|
||||
|
||||
case NetworkLocked:
|
||||
carrierText = makeCarrierStringOnEmergencyCapable(
|
||||
mContext.getText(R.string.keyguard_network_locked_message), text);
|
||||
break;
|
||||
|
||||
case SimMissing:
|
||||
carrierText = null;
|
||||
break;
|
||||
|
||||
case SimPermDisabled:
|
||||
carrierText = makeCarrierStringOnEmergencyCapable(
|
||||
getContext().getText(
|
||||
R.string.keyguard_permanent_disabled_sim_message_short),
|
||||
text);
|
||||
break;
|
||||
|
||||
case SimMissingLocked:
|
||||
carrierText = null;
|
||||
break;
|
||||
|
||||
case SimLocked:
|
||||
carrierText = makeCarrierStringOnLocked(
|
||||
getContext().getText(R.string.keyguard_sim_locked_message),
|
||||
text);
|
||||
break;
|
||||
|
||||
case SimPukLocked:
|
||||
carrierText = makeCarrierStringOnLocked(
|
||||
getContext().getText(R.string.keyguard_sim_puk_locked_message),
|
||||
text);
|
||||
break;
|
||||
case SimIoError:
|
||||
carrierText = makeCarrierStringOnEmergencyCapable(
|
||||
getContext().getText(R.string.keyguard_sim_error_message_short),
|
||||
text);
|
||||
break;
|
||||
case SimUnknown:
|
||||
carrierText = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return carrierText;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add emergencyCallMessage to carrier string only if phone supports emergency calls.
|
||||
*/
|
||||
private CharSequence makeCarrierStringOnEmergencyCapable(
|
||||
CharSequence simMessage, CharSequence emergencyCallMessage) {
|
||||
if (mIsEmergencyCallCapable) {
|
||||
return concatenate(simMessage, emergencyCallMessage, mSeparator);
|
||||
}
|
||||
return simMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add "SIM card is locked" in parenthesis after carrier name, so it is easily associated in
|
||||
* DSDS
|
||||
*/
|
||||
private CharSequence makeCarrierStringOnLocked(CharSequence simMessage,
|
||||
CharSequence carrierName) {
|
||||
final boolean simMessageValid = !TextUtils.isEmpty(simMessage);
|
||||
final boolean carrierNameValid = !TextUtils.isEmpty(carrierName);
|
||||
if (simMessageValid && carrierNameValid) {
|
||||
return mContext.getString(R.string.keyguard_carrier_name_with_sim_locked_template,
|
||||
carrierName, simMessage);
|
||||
} else if (simMessageValid) {
|
||||
return simMessage;
|
||||
} else if (carrierNameValid) {
|
||||
return carrierName;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the current status of the lock screen given the SIM state and other stuff.
|
||||
*/
|
||||
private CarrierTextManager.StatusMode getStatusForIccState(int simState) {
|
||||
final boolean missingAndNotProvisioned =
|
||||
!mKeyguardUpdateMonitor.isDeviceProvisioned()
|
||||
&& (simState == TelephonyManager.SIM_STATE_ABSENT
|
||||
|| simState == TelephonyManager.SIM_STATE_PERM_DISABLED);
|
||||
|
||||
// Assume we're NETWORK_LOCKED if not provisioned
|
||||
simState = missingAndNotProvisioned ? TelephonyManager.SIM_STATE_NETWORK_LOCKED : simState;
|
||||
switch (simState) {
|
||||
case TelephonyManager.SIM_STATE_ABSENT:
|
||||
return CarrierTextManager.StatusMode.SimMissing;
|
||||
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
|
||||
return CarrierTextManager.StatusMode.SimMissingLocked;
|
||||
case TelephonyManager.SIM_STATE_NOT_READY:
|
||||
return CarrierTextManager.StatusMode.SimNotReady;
|
||||
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
|
||||
return CarrierTextManager.StatusMode.SimLocked;
|
||||
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
|
||||
return CarrierTextManager.StatusMode.SimPukLocked;
|
||||
case TelephonyManager.SIM_STATE_READY:
|
||||
return CarrierTextManager.StatusMode.Normal;
|
||||
case TelephonyManager.SIM_STATE_PERM_DISABLED:
|
||||
return CarrierTextManager.StatusMode.SimPermDisabled;
|
||||
case TelephonyManager.SIM_STATE_UNKNOWN:
|
||||
return CarrierTextManager.StatusMode.SimUnknown;
|
||||
case TelephonyManager.SIM_STATE_CARD_IO_ERROR:
|
||||
return CarrierTextManager.StatusMode.SimIoError;
|
||||
}
|
||||
return CarrierTextManager.StatusMode.SimUnknown;
|
||||
}
|
||||
|
||||
private static CharSequence concatenate(CharSequence plmn, CharSequence spn,
|
||||
CharSequence separator) {
|
||||
final boolean plmnValid = !TextUtils.isEmpty(plmn);
|
||||
final boolean spnValid = !TextUtils.isEmpty(spn);
|
||||
if (plmnValid && spnValid) {
|
||||
return new StringBuilder().append(plmn).append(separator).append(spn).toString();
|
||||
} else if (plmnValid) {
|
||||
return plmn;
|
||||
} else if (spnValid) {
|
||||
return spn;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins the strings in a sequence using a separator. Empty strings are discarded with no extra
|
||||
* separator added so there are no extra separators that are not needed.
|
||||
*/
|
||||
private static CharSequence joinNotEmpty(CharSequence separator, CharSequence[] sequences) {
|
||||
int length = sequences.length;
|
||||
if (length == 0) return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!TextUtils.isEmpty(sequences[i])) {
|
||||
if (!TextUtils.isEmpty(sb)) {
|
||||
sb.append(separator);
|
||||
}
|
||||
sb.append(sequences[i]);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static List<CharSequence> append(List<CharSequence> list, CharSequence string) {
|
||||
if (!TextUtils.isEmpty(string)) {
|
||||
list.add(string);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private CharSequence getCarrierHelpTextForSimState(int simState,
|
||||
String plmn, String spn) {
|
||||
int carrierHelpTextId = 0;
|
||||
CarrierTextManager.StatusMode status = getStatusForIccState(simState);
|
||||
switch (status) {
|
||||
case NetworkLocked:
|
||||
carrierHelpTextId = R.string.keyguard_instructions_when_pattern_disabled;
|
||||
break;
|
||||
|
||||
case SimMissing:
|
||||
carrierHelpTextId = R.string.keyguard_missing_sim_instructions_long;
|
||||
break;
|
||||
|
||||
case SimPermDisabled:
|
||||
carrierHelpTextId = R.string.keyguard_permanent_disabled_sim_instructions;
|
||||
break;
|
||||
|
||||
case SimMissingLocked:
|
||||
carrierHelpTextId = R.string.keyguard_missing_sim_instructions;
|
||||
break;
|
||||
|
||||
case Normal:
|
||||
case SimLocked:
|
||||
case SimPukLocked:
|
||||
break;
|
||||
}
|
||||
|
||||
return mContext.getText(carrierHelpTextId);
|
||||
}
|
||||
|
||||
/** Injectable Buildeer for {@#link CarrierTextManager}. */
|
||||
public static class Builder {
|
||||
private final Context mContext;
|
||||
private final String mSeparator;
|
||||
private final WifiManager mWifiManager;
|
||||
private final ConnectivityManager mConnectivityManager;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
private final Handler mMainHandler;
|
||||
private final Handler mBgHandler;
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private boolean mShowAirplaneMode;
|
||||
private boolean mShowMissingSim;
|
||||
|
||||
@Inject
|
||||
public Builder(Context context, @Main Resources resources,
|
||||
@Nullable WifiManager wifiManager, ConnectivityManager connectivityManager,
|
||||
TelephonyManager telephonyManager, WakefulnessLifecycle wakefulnessLifecycle,
|
||||
@Main Handler mainHandler, @Background Handler bgHandler,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor) {
|
||||
mContext = context;
|
||||
mSeparator = resources.getString(
|
||||
com.android.internal.R.string.kg_text_message_separator);
|
||||
mWifiManager = wifiManager;
|
||||
mConnectivityManager = connectivityManager;
|
||||
mTelephonyManager = telephonyManager;
|
||||
mWakefulnessLifecycle = wakefulnessLifecycle;
|
||||
mMainHandler = mainHandler;
|
||||
mBgHandler = bgHandler;
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
}
|
||||
|
||||
/** */
|
||||
public Builder setShowAirplaneMode(boolean showAirplaneMode) {
|
||||
mShowAirplaneMode = showAirplaneMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** */
|
||||
public Builder setShowMissingSim(boolean showMissingSim) {
|
||||
mShowMissingSim = showMissingSim;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Create a CarrierTextManager. */
|
||||
public CarrierTextManager build() {
|
||||
return new CarrierTextManager(
|
||||
mContext, mSeparator, mShowAirplaneMode, mShowMissingSim, mWifiManager,
|
||||
mConnectivityManager, mTelephonyManager, mWakefulnessLifecycle, mMainHandler,
|
||||
mBgHandler, mKeyguardUpdateMonitor);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Data structure for passing information to CarrierTextController subscribers
|
||||
*/
|
||||
public static final class CarrierTextCallbackInfo {
|
||||
public final CharSequence carrierText;
|
||||
public final CharSequence[] listOfCarriers;
|
||||
public final boolean anySimReady;
|
||||
public final int[] subscriptionIds;
|
||||
public boolean airplaneMode;
|
||||
|
||||
@VisibleForTesting
|
||||
public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers,
|
||||
boolean anySimReady, int[] subscriptionIds) {
|
||||
this(carrierText, listOfCarriers, anySimReady, subscriptionIds, false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers,
|
||||
boolean anySimReady, int[] subscriptionIds, boolean airplaneMode) {
|
||||
this.carrierText = carrierText;
|
||||
this.listOfCarriers = listOfCarriers;
|
||||
this.anySimReady = anySimReady;
|
||||
this.subscriptionIds = subscriptionIds;
|
||||
this.airplaneMode = airplaneMode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to communicate to Views
|
||||
*/
|
||||
public interface CarrierTextCallback {
|
||||
/**
|
||||
* Provides updated carrier information.
|
||||
*/
|
||||
default void updateCarrierInfo(CarrierTextCallbackInfo info) {};
|
||||
|
||||
/**
|
||||
* Notifies the View that the device is going to sleep
|
||||
*/
|
||||
default void startedGoingToSleep() {};
|
||||
|
||||
/**
|
||||
* Notifies the View that the device finished waking up
|
||||
*/
|
||||
default void finishedWakingUp() {};
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.keyguard.dagger;
|
||||
|
||||
import com.android.keyguard.KeyguardStatusViewController;
|
||||
import com.android.systemui.statusbar.phone.KeyguardStatusBarView;
|
||||
import com.android.systemui.statusbar.phone.KeyguardStatusBarViewController;
|
||||
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Subcomponent;
|
||||
|
||||
/**
|
||||
* Subcomponent for helping work with KeyguardStatusView and its children.
|
||||
*
|
||||
* TODO: unify this with {@link KeyguardStatusViewComponent}
|
||||
*/
|
||||
@Subcomponent(modules = {KeyguardStatusBarViewModule.class})
|
||||
@KeyguardStatusBarViewScope
|
||||
public interface KeyguardStatusBarViewComponent {
|
||||
/** Simple factory for {@link KeyguardStatusBarViewComponent}. */
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
KeyguardStatusBarViewComponent build(@BindsInstance KeyguardStatusBarView view);
|
||||
}
|
||||
|
||||
/** Builds a {@link KeyguardStatusViewController}. */
|
||||
KeyguardStatusBarViewController getKeyguardStatusBarViewController();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.keyguard.dagger;
|
||||
|
||||
import com.android.keyguard.CarrierText;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.phone.KeyguardStatusBarView;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/** Dagger module for {@link KeyguardStatusBarViewComponent}. */
|
||||
@Module
|
||||
public abstract class KeyguardStatusBarViewModule {
|
||||
@Provides
|
||||
@KeyguardStatusBarViewScope
|
||||
static CarrierText getCarrierText(KeyguardStatusBarView view) {
|
||||
return view.findViewById(R.id.keyguard_carrier_text);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.keyguard.dagger;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Scope;
|
||||
|
||||
/**
|
||||
* Scope annotation for singleton items within the StatusBarComponent.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Scope
|
||||
public @interface KeyguardStatusBarViewScope {}
|
||||
@@ -25,8 +25,6 @@ import dagger.Subcomponent;
|
||||
|
||||
/**
|
||||
* Subcomponent for helping work with KeyguardStatusView and its children.
|
||||
*
|
||||
* TODO: unify this with {@link KeyguardStatusBarViewComponent}
|
||||
*/
|
||||
@Subcomponent(modules = {KeyguardStatusViewModule.class})
|
||||
@KeyguardStatusViewScope
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.android.keyguard.KeyguardDisplayManager;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardViewController;
|
||||
import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
|
||||
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
|
||||
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
|
||||
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
@@ -64,11 +63,8 @@ import dagger.Provides;
|
||||
/**
|
||||
* Dagger Module providing {@link StatusBar}.
|
||||
*/
|
||||
@Module(subcomponents = {
|
||||
KeyguardQsUserSwitchComponent.class,
|
||||
KeyguardStatusBarViewComponent.class,
|
||||
KeyguardStatusViewComponent.class,
|
||||
KeyguardUserSwitcherComponent.class},
|
||||
@Module(subcomponents = {KeyguardStatusViewComponent.class,
|
||||
KeyguardQsUserSwitchComponent.class, KeyguardUserSwitcherComponent.class},
|
||||
includes = {FalsingModule.class})
|
||||
public class KeyguardModule {
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.keyguard.CarrierTextManager;
|
||||
import com.android.keyguard.CarrierTextController;
|
||||
import com.android.settingslib.AccessibilityContentDescriptions;
|
||||
import com.android.settingslib.mobile.TelephonyIcons;
|
||||
import com.android.systemui.R;
|
||||
@@ -58,7 +58,7 @@ public class QSCarrierGroupController {
|
||||
private final ActivityStarter mActivityStarter;
|
||||
private final Handler mBgHandler;
|
||||
private final NetworkController mNetworkController;
|
||||
private final CarrierTextManager mCarrierTextManager;
|
||||
private final CarrierTextController mCarrierTextController;
|
||||
private final TextView mNoSimTextView;
|
||||
private final H mMainHandler;
|
||||
private final Callback mCallback;
|
||||
@@ -153,7 +153,7 @@ public class QSCarrierGroupController {
|
||||
}
|
||||
};
|
||||
|
||||
private static class Callback implements CarrierTextManager.CarrierTextCallback {
|
||||
private static class Callback implements CarrierTextController.CarrierTextCallback {
|
||||
private H mHandler;
|
||||
|
||||
Callback(H handler) {
|
||||
@@ -161,7 +161,7 @@ public class QSCarrierGroupController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCarrierInfo(CarrierTextManager.CarrierTextCallbackInfo info) {
|
||||
public void updateCarrierInfo(CarrierTextController.CarrierTextCallbackInfo info) {
|
||||
mHandler.obtainMessage(H.MSG_UPDATE_CARRIER_INFO, info).sendToTarget();
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class QSCarrierGroupController {
|
||||
private QSCarrierGroupController(QSCarrierGroup view, ActivityStarter activityStarter,
|
||||
@Background Handler bgHandler, @Main Looper mainLooper,
|
||||
NetworkController networkController,
|
||||
CarrierTextManager.Builder carrierTextManagerBuilder, Context context) {
|
||||
CarrierTextController.Builder carrierTextControllerBuilder, Context context) {
|
||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
|
||||
mProviderModel = true;
|
||||
} else {
|
||||
@@ -178,7 +178,7 @@ public class QSCarrierGroupController {
|
||||
mActivityStarter = activityStarter;
|
||||
mBgHandler = bgHandler;
|
||||
mNetworkController = networkController;
|
||||
mCarrierTextManager = carrierTextManagerBuilder
|
||||
mCarrierTextController = carrierTextControllerBuilder
|
||||
.setShowAirplaneMode(false)
|
||||
.setShowMissingSim(false)
|
||||
.build();
|
||||
@@ -196,6 +196,7 @@ public class QSCarrierGroupController {
|
||||
mMainHandler = new H(mainLooper, this::handleUpdateCarrierInfo, this::handleUpdateState);
|
||||
mCallback = new Callback(mMainHandler);
|
||||
|
||||
|
||||
mCarrierGroups[0] = view.getCarrier1View();
|
||||
mCarrierGroups[1] = view.getCarrier2View();
|
||||
mCarrierGroups[2] = view.getCarrier3View();
|
||||
@@ -246,10 +247,10 @@ public class QSCarrierGroupController {
|
||||
if (mNetworkController.hasVoiceCallingFeature()) {
|
||||
mNetworkController.addCallback(mSignalCallback);
|
||||
}
|
||||
mCarrierTextManager.setListening(mCallback);
|
||||
mCarrierTextController.setListening(mCallback);
|
||||
} else {
|
||||
mNetworkController.removeCallback(mSignalCallback);
|
||||
mCarrierTextManager.setListening(null);
|
||||
mCarrierTextController.setListening(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +277,7 @@ public class QSCarrierGroupController {
|
||||
}
|
||||
|
||||
@MainThread
|
||||
private void handleUpdateCarrierInfo(CarrierTextManager.CarrierTextCallbackInfo info) {
|
||||
private void handleUpdateCarrierInfo(CarrierTextController.CarrierTextCallbackInfo info) {
|
||||
if (!mMainHandler.getLooper().isCurrentThread()) {
|
||||
mMainHandler.obtainMessage(H.MSG_UPDATE_CARRIER_INFO, info).sendToTarget();
|
||||
return;
|
||||
@@ -330,13 +331,13 @@ public class QSCarrierGroupController {
|
||||
}
|
||||
|
||||
private static class H extends Handler {
|
||||
private Consumer<CarrierTextManager.CarrierTextCallbackInfo> mUpdateCarrierInfo;
|
||||
private Consumer<CarrierTextController.CarrierTextCallbackInfo> mUpdateCarrierInfo;
|
||||
private Runnable mUpdateState;
|
||||
static final int MSG_UPDATE_CARRIER_INFO = 0;
|
||||
static final int MSG_UPDATE_STATE = 1;
|
||||
|
||||
H(Looper looper,
|
||||
Consumer<CarrierTextManager.CarrierTextCallbackInfo> updateCarrierInfo,
|
||||
Consumer<CarrierTextController.CarrierTextCallbackInfo> updateCarrierInfo,
|
||||
Runnable updateState) {
|
||||
super(looper);
|
||||
mUpdateCarrierInfo = updateCarrierInfo;
|
||||
@@ -348,7 +349,7 @@ public class QSCarrierGroupController {
|
||||
switch (msg.what) {
|
||||
case MSG_UPDATE_CARRIER_INFO:
|
||||
mUpdateCarrierInfo.accept(
|
||||
(CarrierTextManager.CarrierTextCallbackInfo) msg.obj);
|
||||
(CarrierTextController.CarrierTextCallbackInfo) msg.obj);
|
||||
break;
|
||||
case MSG_UPDATE_STATE:
|
||||
mUpdateState.run();
|
||||
@@ -365,13 +366,13 @@ public class QSCarrierGroupController {
|
||||
private final Handler mHandler;
|
||||
private final Looper mLooper;
|
||||
private final NetworkController mNetworkController;
|
||||
private final CarrierTextManager.Builder mCarrierTextControllerBuilder;
|
||||
private final CarrierTextController.Builder mCarrierTextControllerBuilder;
|
||||
private final Context mContext;
|
||||
|
||||
@Inject
|
||||
public Builder(ActivityStarter activityStarter, @Background Handler handler,
|
||||
@Main Looper looper, NetworkController networkController,
|
||||
CarrierTextManager.Builder carrierTextControllerBuilder, Context context) {
|
||||
CarrierTextController.Builder carrierTextControllerBuilder, Context context) {
|
||||
mActivityStarter = activityStarter;
|
||||
mHandler = handler;
|
||||
mLooper = looper;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import com.android.keyguard.CarrierTextController;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */
|
||||
public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> {
|
||||
private final CarrierTextController mCarrierTextController;
|
||||
|
||||
@Inject
|
||||
public KeyguardStatusBarViewController(
|
||||
KeyguardStatusBarView view, CarrierTextController carrierTextController) {
|
||||
super(view);
|
||||
mCarrierTextController = carrierTextController;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
super.onInit();
|
||||
mCarrierTextController.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewDetached() {
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,6 @@ import com.android.keyguard.KeyguardStatusViewController;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
|
||||
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
|
||||
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
|
||||
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
|
||||
import com.android.systemui.DejankUtils;
|
||||
@@ -326,7 +325,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory;
|
||||
private final KeyguardQsUserSwitchComponent.Factory mKeyguardQsUserSwitchComponentFactory;
|
||||
private final KeyguardUserSwitcherComponent.Factory mKeyguardUserSwitcherComponentFactory;
|
||||
private final KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory;
|
||||
private final QSDetailDisplayer mQSDetailDisplayer;
|
||||
private final FeatureFlags mFeatureFlags;
|
||||
private final ScrimController mScrimController;
|
||||
@@ -343,7 +341,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
private boolean mKeyguardUserSwitcherIsShowing;
|
||||
private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
|
||||
private KeyguardStatusBarView mKeyguardStatusBar;
|
||||
private KeyguardStatusBarViewController mKeyguarStatusBarViewController;
|
||||
private ViewGroup mBigClockContainer;
|
||||
private QS mQs;
|
||||
private FrameLayout mQsFrame;
|
||||
@@ -597,7 +594,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory,
|
||||
KeyguardQsUserSwitchComponent.Factory keyguardQsUserSwitchComponentFactory,
|
||||
KeyguardUserSwitcherComponent.Factory keyguardUserSwitcherComponentFactory,
|
||||
KeyguardStatusBarViewComponent.Factory keyguardStatusBarViewComponentFactory,
|
||||
QSDetailDisplayer qsDetailDisplayer,
|
||||
NotificationGroupManagerLegacy groupManager,
|
||||
NotificationIconAreaController notificationIconAreaController,
|
||||
@@ -624,7 +620,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mGroupManager = groupManager;
|
||||
mNotificationIconAreaController = notificationIconAreaController;
|
||||
mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
|
||||
mKeyguardStatusBarViewComponentFactory = keyguardStatusBarViewComponentFactory;
|
||||
mFeatureFlags = featureFlags;
|
||||
mKeyguardQsUserSwitchComponentFactory = keyguardQsUserSwitchComponentFactory;
|
||||
mKeyguardUserSwitcherComponentFactory = keyguardUserSwitcherComponentFactory;
|
||||
@@ -728,9 +723,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
}
|
||||
|
||||
updateViewControllers(mView.findViewById(R.id.keyguard_status_view),
|
||||
userAvatarView,
|
||||
mKeyguardStatusBar,
|
||||
keyguardUserSwitcherView);
|
||||
userAvatarView, keyguardUserSwitcherView);
|
||||
mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
|
||||
NotificationStackScrollLayout stackScrollLayout = mView.findViewById(
|
||||
R.id.notification_stack_scroller);
|
||||
@@ -808,21 +801,13 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
}
|
||||
|
||||
private void updateViewControllers(KeyguardStatusView keyguardStatusView,
|
||||
UserAvatarView userAvatarView,
|
||||
KeyguardStatusBarView keyguardStatusBarView,
|
||||
KeyguardUserSwitcherView keyguardUserSwitcherView) {
|
||||
UserAvatarView userAvatarView, KeyguardUserSwitcherView keyguardUserSwitcherView) {
|
||||
// Re-associate the KeyguardStatusViewController
|
||||
KeyguardStatusViewComponent statusViewComponent =
|
||||
mKeyguardStatusViewComponentFactory.build(keyguardStatusView);
|
||||
mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController();
|
||||
mKeyguardStatusViewController.init();
|
||||
|
||||
KeyguardStatusBarViewComponent statusBarViewComponent =
|
||||
mKeyguardStatusBarViewComponentFactory.build(keyguardStatusBarView);
|
||||
mKeyguarStatusBarViewController =
|
||||
statusBarViewComponent.getKeyguardStatusBarViewController();
|
||||
mKeyguarStatusBarViewController.init();
|
||||
|
||||
// Re-associate the clock container with the keyguard clock switch.
|
||||
KeyguardClockSwitchController keyguardClockSwitchController =
|
||||
statusViewComponent.getKeyguardClockSwitchController();
|
||||
@@ -970,8 +955,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
showKeyguardUserSwitcher /* enabled */);
|
||||
|
||||
mBigClockContainer.removeAllViews();
|
||||
updateViewControllers(
|
||||
keyguardStatusView, userAvatarView, mKeyguardStatusBar, keyguardUserSwitcherView);
|
||||
updateViewControllers(keyguardStatusView, userAvatarView, keyguardUserSwitcherView);
|
||||
|
||||
// Update keyguard bottom area
|
||||
index = mView.indexOfChild(mKeyguardBottomArea);
|
||||
|
||||
@@ -54,6 +54,7 @@ import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||
@@ -73,7 +74,7 @@ import java.util.List;
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
public class CarrierTextControllerTest extends SysuiTestCase {
|
||||
|
||||
private static final CharSequence SEPARATOR = " \u2014 ";
|
||||
private static final CharSequence INVALID_CARD_TEXT = "Invalid card";
|
||||
@@ -94,9 +95,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
private WakefulnessLifecycle mWakefulnessLifecycle;
|
||||
@Mock
|
||||
private CarrierTextManager.CarrierTextCallback mCarrierTextCallback;
|
||||
private CarrierTextController.CarrierTextCallback mCarrierTextCallback;
|
||||
@Mock
|
||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
@Mock
|
||||
@@ -105,14 +104,13 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@Mock
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
private CarrierTextManager.CarrierTextCallbackInfo mCarrierTextCallbackInfo;
|
||||
private CarrierTextController.CarrierTextCallbackInfo mCarrierTextCallbackInfo;
|
||||
|
||||
private CarrierTextManager mCarrierTextManager;
|
||||
private CarrierTextController mCarrierTextController;
|
||||
private TestableLooper mTestableLooper;
|
||||
private Handler mMainHandler;
|
||||
|
||||
private Void checkMainThread(InvocationOnMock inv) {
|
||||
Looper mainLooper = mMainHandler.getLooper();
|
||||
Looper mainLooper = Dependency.get(Dependency.MAIN_HANDLER).getLooper();
|
||||
if (!mainLooper.isCurrentThread()) {
|
||||
fail("This call should be done from the main thread");
|
||||
}
|
||||
@@ -124,33 +122,35 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mTestableLooper = TestableLooper.get(this);
|
||||
|
||||
mMainHandler = new Handler(mTestableLooper.getLooper());
|
||||
mContext.addMockSystemService(WifiManager.class, mWifiManager);
|
||||
mContext.addMockSystemService(ConnectivityManager.class, mConnectivityManager);
|
||||
when(mConnectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
|
||||
mContext.addMockSystemService(TelephonyManager.class, mTelephonyManager);
|
||||
mContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
R.string.keyguard_sim_error_message_short, INVALID_CARD_TEXT);
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
R.string.airplane_mode, AIRPLANE_MODE_TEXT);
|
||||
mDependency.injectMockDependency(WakefulnessLifecycle.class);
|
||||
mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
|
||||
new Handler(mTestableLooper.getLooper()));
|
||||
mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper());
|
||||
mDependency.injectTestDependency(KeyguardUpdateMonitor.class, mKeyguardUpdateMonitor);
|
||||
|
||||
doAnswer(this::checkMainThread).when(mKeyguardUpdateMonitor)
|
||||
.registerCallback(any(KeyguardUpdateMonitorCallback.class));
|
||||
doAnswer(this::checkMainThread).when(mKeyguardUpdateMonitor)
|
||||
.removeCallback(any(KeyguardUpdateMonitorCallback.class));
|
||||
|
||||
mCarrierTextCallbackInfo = new CarrierTextManager.CarrierTextCallbackInfo("",
|
||||
mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("",
|
||||
new CharSequence[]{}, false, new int[]{});
|
||||
when(mTelephonyManager.getSupportedModemCount()).thenReturn(3);
|
||||
when(mTelephonyManager.getActiveModemCount()).thenReturn(3);
|
||||
|
||||
mCarrierTextManager = new CarrierTextManager.Builder(
|
||||
mContext, mContext.getResources(), mWifiManager, mConnectivityManager,
|
||||
mTelephonyManager, mWakefulnessLifecycle, new Handler(mTestableLooper.getLooper()),
|
||||
mMainHandler, mKeyguardUpdateMonitor)
|
||||
.setShowAirplaneMode(true)
|
||||
.setShowMissingSim(true)
|
||||
.build();
|
||||
mCarrierTextController = new CarrierTextController(mContext, SEPARATOR, true, true);
|
||||
// This should not start listening on any of the real dependencies but will test that
|
||||
// callbacks in mKeyguardUpdateMonitor are done in the mTestableLooper thread
|
||||
mCarrierTextManager.setListening(mCarrierTextCallback);
|
||||
mCarrierTextController.setListening(mCarrierTextCallback);
|
||||
mTestableLooper.processAllMessages();
|
||||
}
|
||||
|
||||
@@ -165,8 +165,8 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
TestableLooper testableLooper = new TestableLooper(thread.getLooper());
|
||||
Handler h = new Handler(testableLooper.getLooper());
|
||||
h.post(() -> {
|
||||
mCarrierTextManager.setListening(null);
|
||||
mCarrierTextManager.setListening(mCarrierTextCallback);
|
||||
mCarrierTextController.setListening(null);
|
||||
mCarrierTextController.setListening(mCarrierTextCallback);
|
||||
});
|
||||
testableLooper.processAllMessages();
|
||||
mTestableLooper.processAllMessages();
|
||||
@@ -183,11 +183,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(TelephonyManager.SIM_STATE_READY);
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
@@ -205,12 +205,12 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR);
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
mCarrierTextManager.mCallback.onSimStateChanged(3, 1,
|
||||
mCarrierTextController.mCallback.onSimStateChanged(3, 1,
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR);
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
@@ -223,7 +223,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
reset(mCarrierTextCallback);
|
||||
when(mTelephonyManager.getActiveModemCount()).thenReturn(1);
|
||||
// Update carrier text. It should ignore error state of subId 3 in inactive slotId.
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
assertEquals("TEST_CARRIER", captor.getValue().carrierText);
|
||||
@@ -237,9 +237,9 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR);
|
||||
// This should not produce an out of bounds error, even though there are no subscriptions
|
||||
mCarrierTextManager.mCallback.onSimStateChanged(0, -3,
|
||||
mCarrierTextController.mCallback.onSimStateChanged(0, -3,
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR);
|
||||
mCarrierTextManager.mCallback.onSimStateChanged(0, 3, TelephonyManager.SIM_STATE_READY);
|
||||
mCarrierTextController.mCallback.onSimStateChanged(0, 3, TelephonyManager.SIM_STATE_READY);
|
||||
verify(mCarrierTextCallback, never()).updateCarrierInfo(any());
|
||||
}
|
||||
|
||||
@@ -257,23 +257,23 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR);
|
||||
// This should not produce an out of bounds error, even though there are no subscriptions
|
||||
mCarrierTextManager.mCallback.onSimStateChanged(0, 1,
|
||||
mCarrierTextController.mCallback.onSimStateChanged(0, 1,
|
||||
TelephonyManager.SIM_STATE_CARD_IO_ERROR);
|
||||
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(
|
||||
any(CarrierTextManager.CarrierTextCallbackInfo.class));
|
||||
any(CarrierTextController.CarrierTextCallbackInfo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallback() {
|
||||
reset(mCarrierTextCallback);
|
||||
mCarrierTextManager.postToCallback(mCarrierTextCallbackInfo);
|
||||
mCarrierTextController.postToCallback(mCarrierTextCallbackInfo);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
assertEquals(mCarrierTextCallbackInfo, captor.getValue());
|
||||
}
|
||||
@@ -282,8 +282,8 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
public void testNullingCallback() {
|
||||
reset(mCarrierTextCallback);
|
||||
|
||||
mCarrierTextManager.postToCallback(mCarrierTextCallbackInfo);
|
||||
mCarrierTextManager.setListening(null);
|
||||
mCarrierTextController.postToCallback(mCarrierTextCallbackInfo);
|
||||
mCarrierTextController.setListening(null);
|
||||
|
||||
// This shouldn't produce NPE
|
||||
mTestableLooper.processAllMessages();
|
||||
@@ -301,15 +301,15 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
CarrierTextManager.CarrierTextCallbackInfo info = captor.getValue();
|
||||
CarrierTextController.CarrierTextCallbackInfo info = captor.getValue();
|
||||
assertEquals(1, info.listOfCarriers.length);
|
||||
assertEquals(TEST_CARRIER, info.listOfCarriers[0]);
|
||||
assertEquals(1, info.subscriptionIds.length);
|
||||
@@ -326,15 +326,15 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
CarrierTextManager.CarrierTextCallbackInfo info = captor.getValue();
|
||||
CarrierTextController.CarrierTextCallbackInfo info = captor.getValue();
|
||||
assertEquals(1, info.listOfCarriers.length);
|
||||
assertTrue(info.listOfCarriers[0].toString().contains(TEST_CARRIER));
|
||||
assertEquals(1, info.subscriptionIds.length);
|
||||
@@ -346,16 +346,16 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
List<SubscriptionInfo> list = new ArrayList<>();
|
||||
list.add(TEST_SUBSCRIPTION_NULL);
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
||||
TelephonyManager.SIM_STATE_READY);
|
||||
TelephonyManager.SIM_STATE_READY);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
@@ -380,11 +380,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
when(ss.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
|
||||
mKeyguardUpdateMonitor.mServiceStates.put(TEST_SUBSCRIPTION_NULL.getSubscriptionId(), ss);
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
@@ -407,15 +407,15 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(
|
||||
new ArrayList<>());
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
CarrierTextManager.CarrierTextCallbackInfo info = captor.getValue();
|
||||
CarrierTextController.CarrierTextCallbackInfo info = captor.getValue();
|
||||
assertEquals(0, info.listOfCarriers.length);
|
||||
assertEquals(0, info.subscriptionIds.length);
|
||||
|
||||
@@ -428,16 +428,16 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
list.add(TEST_SUBSCRIPTION);
|
||||
when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
|
||||
TelephonyManager.SIM_STATE_READY);
|
||||
TelephonyManager.SIM_STATE_READY);
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
@@ -458,11 +458,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
@@ -483,11 +483,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
@@ -509,11 +509,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
|
||||
when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo(anyBoolean())).thenReturn(list);
|
||||
mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
|
||||
|
||||
ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
|
||||
ArgumentCaptor.forClass(
|
||||
CarrierTextManager.CarrierTextCallbackInfo.class);
|
||||
CarrierTextController.CarrierTextCallbackInfo.class);
|
||||
|
||||
mCarrierTextManager.updateCarrierText();
|
||||
mCarrierTextController.updateCarrierText();
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
|
||||
|
||||
@@ -33,7 +33,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.keyguard.CarrierTextManager;
|
||||
import com.android.keyguard.CarrierTextController;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.statusbar.policy.NetworkController;
|
||||
import com.android.systemui.utils.leaks.LeakCheckedTest;
|
||||
@@ -54,7 +54,7 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
|
||||
private QSCarrierGroupController mQSCarrierGroupController;
|
||||
private NetworkController.SignalCallback mSignalCallback;
|
||||
private CarrierTextManager.CarrierTextCallback mCallback;
|
||||
private CarrierTextController.CarrierTextCallback mCallback;
|
||||
@Mock
|
||||
private QSCarrierGroup mQSCarrierGroup;
|
||||
@Mock
|
||||
@@ -62,9 +62,9 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
@Mock
|
||||
private NetworkController mNetworkController;
|
||||
@Mock
|
||||
private CarrierTextManager.Builder mCarrierTextControllerBuilder;
|
||||
private CarrierTextController.Builder mCarrierTextControllerBuilder;
|
||||
@Mock
|
||||
private CarrierTextManager mCarrierTextManager;
|
||||
private CarrierTextController mCarrierTextController;
|
||||
private TestableLooper mTestableLooper;
|
||||
|
||||
@Before
|
||||
@@ -83,11 +83,11 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
.thenReturn(mCarrierTextControllerBuilder);
|
||||
when(mCarrierTextControllerBuilder.setShowMissingSim(anyBoolean()))
|
||||
.thenReturn(mCarrierTextControllerBuilder);
|
||||
when(mCarrierTextControllerBuilder.build()).thenReturn(mCarrierTextManager);
|
||||
when(mCarrierTextControllerBuilder.build()).thenReturn(mCarrierTextController);
|
||||
|
||||
doAnswer(invocation -> mCallback = invocation.getArgument(0))
|
||||
.when(mCarrierTextManager)
|
||||
.setListening(any(CarrierTextManager.CarrierTextCallback.class));
|
||||
.when(mCarrierTextController)
|
||||
.setListening(any(CarrierTextController.CarrierTextCallback.class));
|
||||
|
||||
when(mQSCarrierGroup.getNoSimTextView()).thenReturn(new TextView(mContext));
|
||||
when(mQSCarrierGroup.getCarrier1View()).thenReturn(mock(QSCarrier.class));
|
||||
@@ -113,8 +113,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
(Answer<Integer>) invocationOnMock -> invocationOnMock.getArgument(0));
|
||||
|
||||
// listOfCarriers length 1, subscriptionIds length 1, anySims false
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c1 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c1 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{""},
|
||||
false,
|
||||
@@ -122,8 +122,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
mCallback.updateCarrierInfo(c1);
|
||||
|
||||
// listOfCarriers length 1, subscriptionIds length 1, anySims true
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c2 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c2 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{""},
|
||||
true,
|
||||
@@ -131,8 +131,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
mCallback.updateCarrierInfo(c2);
|
||||
|
||||
// listOfCarriers length 2, subscriptionIds length 2, anySims false
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c3 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c3 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{"", ""},
|
||||
false,
|
||||
@@ -140,8 +140,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
mCallback.updateCarrierInfo(c3);
|
||||
|
||||
// listOfCarriers length 2, subscriptionIds length 2, anySims true
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c4 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c4 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{"", ""},
|
||||
true,
|
||||
@@ -159,8 +159,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
(Answer<Integer>) invocationOnMock -> invocationOnMock.getArgument(0));
|
||||
|
||||
// listOfCarriers length 2, subscriptionIds length 1, anySims false
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c1 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c1 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{"", ""},
|
||||
false,
|
||||
@@ -168,8 +168,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
mCallback.updateCarrierInfo(c1);
|
||||
|
||||
// listOfCarriers length 2, subscriptionIds length 1, anySims true
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c2 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c2 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{"", ""},
|
||||
true,
|
||||
@@ -177,8 +177,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
mCallback.updateCarrierInfo(c2);
|
||||
|
||||
// listOfCarriers length 1, subscriptionIds length 2, anySims false
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c3 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c3 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{""},
|
||||
false,
|
||||
@@ -186,8 +186,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
mCallback.updateCarrierInfo(c3);
|
||||
|
||||
// listOfCarriers length 1, subscriptionIds length 2, anySims true
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c4 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c4 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{""},
|
||||
true,
|
||||
@@ -203,8 +203,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
when(spiedCarrierGroupController.getSlotIndex(anyInt())).thenReturn(
|
||||
SubscriptionManager.INVALID_SIM_SLOT_INDEX);
|
||||
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
c4 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
c4 = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{"", ""},
|
||||
true,
|
||||
@@ -223,8 +223,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
||||
|
||||
@Test
|
||||
public void testNoEmptyVisibleView_airplaneMode() {
|
||||
CarrierTextManager.CarrierTextCallbackInfo
|
||||
info = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||
CarrierTextController.CarrierTextCallbackInfo
|
||||
info = new CarrierTextController.CarrierTextCallbackInfo(
|
||||
"",
|
||||
new CharSequence[]{""},
|
||||
true,
|
||||
|
||||
@@ -61,7 +61,6 @@ import com.android.keyguard.KeyguardStatusView;
|
||||
import com.android.keyguard.KeyguardStatusViewController;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent;
|
||||
import com.android.keyguard.dagger.KeyguardStatusBarViewComponent;
|
||||
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
|
||||
import com.android.keyguard.dagger.KeyguardUserSwitcherComponent;
|
||||
import com.android.systemui.R;
|
||||
@@ -207,16 +206,10 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private KeyguardStatusViewComponent mKeyguardStatusViewComponent;
|
||||
@Mock
|
||||
private KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory;
|
||||
@Mock
|
||||
private KeyguardStatusBarViewComponent mKeyguardStatusBarViewComponent;
|
||||
@Mock
|
||||
private KeyguardClockSwitchController mKeyguardClockSwitchController;
|
||||
@Mock
|
||||
private KeyguardStatusViewController mKeyguardStatusViewController;
|
||||
@Mock
|
||||
private KeyguardStatusBarViewController mKeyguardStatusBarViewController;
|
||||
@Mock
|
||||
private NotificationStackScrollLayoutController mNotificationStackScrollLayoutController;
|
||||
@Mock
|
||||
private AuthController mAuthController;
|
||||
@@ -304,10 +297,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
||||
new ViewGroup.LayoutParams(600, 400));
|
||||
when(mNotificationStackScrollLayoutController.getLayoutParams()).thenReturn(
|
||||
new ViewGroup.LayoutParams(600, 400));
|
||||
when(mKeyguardStatusBarViewComponentFactory.build(any()))
|
||||
.thenReturn(mKeyguardStatusBarViewComponent);
|
||||
when(mKeyguardStatusBarViewComponent.getKeyguardStatusBarViewController())
|
||||
.thenReturn(mKeyguardStatusBarViewController);
|
||||
|
||||
mNotificationPanelViewController = new NotificationPanelViewController(mView,
|
||||
mResources,
|
||||
@@ -326,7 +315,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
||||
mKeyguardStatusViewComponentFactory,
|
||||
mKeyguardQsUserSwitchComponentFactory,
|
||||
mKeyguardUserSwitcherComponentFactory,
|
||||
mKeyguardStatusBarViewComponentFactory,
|
||||
mQSDetailDisplayer,
|
||||
mGroupManager,
|
||||
mNotificationAreaController,
|
||||
|
||||
Reference in New Issue
Block a user