Merge "Hide RSSI next to single carrier name" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ef8407ab7d
@@ -39,6 +39,13 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:maxEms="7"/>
|
android:maxEms="7"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/spacer"
|
||||||
|
android:layout_width="@dimen/qs_carrier_margin_width"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/mobile_signal_group"
|
layout="@layout/mobile_signal_group"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import android.widget.FrameLayout;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Space;
|
import android.widget.Space;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.systemui.BatteryMeterView;
|
import com.android.systemui.BatteryMeterView;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -41,6 +43,8 @@ import com.android.systemui.statusbar.phone.StatusBarWindowView;
|
|||||||
import com.android.systemui.statusbar.phone.StatusIconContainer;
|
import com.android.systemui.statusbar.phone.StatusIconContainer;
|
||||||
import com.android.systemui.statusbar.policy.Clock;
|
import com.android.systemui.statusbar.policy.Clock;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View that contains the top-most bits of the QS panel (primarily the status bar with date, time,
|
* View that contains the top-most bits of the QS panel (primarily the status bar with date, time,
|
||||||
* battery, carrier info and privacy icons) and also contains the {@link QuickQSPanel}.
|
* battery, carrier info and privacy icons) and also contains the {@link QuickQSPanel}.
|
||||||
@@ -86,18 +90,13 @@ public class QuickStatusBarHeader extends FrameLayout {
|
|||||||
private float mKeyguardExpansionFraction;
|
private float mKeyguardExpansionFraction;
|
||||||
private int mTextColorPrimary = Color.TRANSPARENT;
|
private int mTextColorPrimary = Color.TRANSPARENT;
|
||||||
private int mTopViewMeasureHeight;
|
private int mTopViewMeasureHeight;
|
||||||
private boolean mProviderModel;
|
|
||||||
|
|
||||||
private final String mMobileSlotName;
|
@NonNull
|
||||||
private final String mNoCallingSlotName;
|
private List<String> mRssiIgnoredSlots;
|
||||||
private final String mCallStrengthSlotName;
|
private boolean mIsSingleCarrier;
|
||||||
|
|
||||||
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
|
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mMobileSlotName = context.getString(com.android.internal.R.string.status_bar_mobile);
|
|
||||||
mNoCallingSlotName = context.getString(com.android.internal.R.string.status_bar_no_calling);
|
|
||||||
mCallStrengthSlotName =
|
|
||||||
context.getString(com.android.internal.R.string.status_bar_call_strength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,9 +147,9 @@ public class QuickStatusBarHeader extends FrameLayout {
|
|||||||
|
|
||||||
void onAttach(TintedIconManager iconManager,
|
void onAttach(TintedIconManager iconManager,
|
||||||
QSExpansionPathInterpolator qsExpansionPathInterpolator,
|
QSExpansionPathInterpolator qsExpansionPathInterpolator,
|
||||||
boolean providerModel) {
|
List<String> rssiIgnoredSlots) {
|
||||||
mProviderModel = providerModel;
|
|
||||||
mTintedIconManager = iconManager;
|
mTintedIconManager = iconManager;
|
||||||
|
mRssiIgnoredSlots = rssiIgnoredSlots;
|
||||||
int fillColor = Utils.getColorAttrDefaultColor(getContext(),
|
int fillColor = Utils.getColorAttrDefaultColor(getContext(),
|
||||||
android.R.attr.textColorPrimary);
|
android.R.attr.textColorPrimary);
|
||||||
|
|
||||||
@@ -161,6 +160,11 @@ public class QuickStatusBarHeader extends FrameLayout {
|
|||||||
updateAnimators();
|
updateAnimators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIsSingleCarrier(boolean isSingleCarrier) {
|
||||||
|
mIsSingleCarrier = isSingleCarrier;
|
||||||
|
updateAlphaAnimator();
|
||||||
|
}
|
||||||
|
|
||||||
public QuickQSPanel getHeaderQsPanel() {
|
public QuickQSPanel getHeaderQsPanel() {
|
||||||
return mHeaderQsPanel;
|
return mHeaderQsPanel;
|
||||||
}
|
}
|
||||||
@@ -267,39 +271,26 @@ public class QuickStatusBarHeader extends FrameLayout {
|
|||||||
.setListener(new TouchAnimator.ListenerAdapter() {
|
.setListener(new TouchAnimator.ListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationAtEnd() {
|
public void onAnimationAtEnd() {
|
||||||
// TODO(b/185580157): Remove the mProviderModel if the mobile slot can be
|
super.onAnimationAtEnd();
|
||||||
// hidden in Provider model.
|
if (!mIsSingleCarrier) {
|
||||||
if (mProviderModel) {
|
mIconContainer.addIgnoredSlots(mRssiIgnoredSlots);
|
||||||
mIconContainer.addIgnoredSlot(mNoCallingSlotName);
|
|
||||||
mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
|
|
||||||
} else {
|
|
||||||
mIconContainer.addIgnoredSlot(mMobileSlotName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStarted() {
|
public void onAnimationStarted() {
|
||||||
if (mProviderModel) {
|
|
||||||
mIconContainer.addIgnoredSlot(mNoCallingSlotName);
|
|
||||||
mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
|
|
||||||
} else {
|
|
||||||
mIconContainer.addIgnoredSlot(mMobileSlotName);
|
|
||||||
}
|
|
||||||
|
|
||||||
setSeparatorVisibility(false);
|
setSeparatorVisibility(false);
|
||||||
|
if (!mIsSingleCarrier) {
|
||||||
|
mIconContainer.addIgnoredSlots(mRssiIgnoredSlots);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationAtStart() {
|
public void onAnimationAtStart() {
|
||||||
super.onAnimationAtStart();
|
super.onAnimationAtStart();
|
||||||
if (mProviderModel) {
|
|
||||||
mIconContainer.removeIgnoredSlot(mNoCallingSlotName);
|
|
||||||
mIconContainer.removeIgnoredSlot(mCallStrengthSlotName);
|
|
||||||
} else {
|
|
||||||
mIconContainer.removeIgnoredSlot(mMobileSlotName);
|
|
||||||
}
|
|
||||||
|
|
||||||
setSeparatorVisibility(mShowClockIconsSeparator);
|
setSeparatorVisibility(mShowClockIconsSeparator);
|
||||||
|
// In QQS we never ignore RSSI.
|
||||||
|
mIconContainer.removeIgnoredSlots(mRssiIgnoredSlots);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mAlphaAnimator = builder.build();
|
mAlphaAnimator = builder.build();
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import com.android.systemui.statusbar.phone.StatusIconContainer;
|
|||||||
import com.android.systemui.statusbar.policy.Clock;
|
import com.android.systemui.statusbar.policy.Clock;
|
||||||
import com.android.systemui.util.ViewController;
|
import com.android.systemui.util.ViewController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -76,6 +75,9 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
private boolean mMicCameraIndicatorsEnabled;
|
private boolean mMicCameraIndicatorsEnabled;
|
||||||
private boolean mLocationIndicatorsEnabled;
|
private boolean mLocationIndicatorsEnabled;
|
||||||
private boolean mPrivacyChipLogged;
|
private boolean mPrivacyChipLogged;
|
||||||
|
private final String mCameraSlot;
|
||||||
|
private final String mMicSlot;
|
||||||
|
private final String mLocationSlot;
|
||||||
|
|
||||||
private SysuiColorExtractor mColorExtractor;
|
private SysuiColorExtractor mColorExtractor;
|
||||||
private ColorExtractor.OnColorsChangedListener mOnColorsChangedListener;
|
private ColorExtractor.OnColorsChangedListener mOnColorsChangedListener;
|
||||||
@@ -104,8 +106,7 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
StatusIconContainer iconContainer = mView.requireViewById(R.id.statusIcons);
|
updatePrivacyIconSlots();
|
||||||
iconContainer.setIgnoredSlots(getIgnoredIconSlots());
|
|
||||||
setChipVisibility(!mPrivacyChip.getPrivacyList().isEmpty());
|
setChipVisibility(!mPrivacyChip.getPrivacyList().isEmpty());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -154,7 +155,7 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
mClockView = mView.findViewById(R.id.clock);
|
mClockView = mView.findViewById(R.id.clock);
|
||||||
mIconContainer = mView.findViewById(R.id.statusIcons);
|
mIconContainer = mView.findViewById(R.id.statusIcons);
|
||||||
|
|
||||||
mIconManager = new StatusBarIconController.TintedIconManager(mIconContainer, mFeatureFlags);
|
mIconManager = new StatusBarIconController.TintedIconManager(mIconContainer, featureFlags);
|
||||||
mDemoModeReceiver = new ClockDemoModeReceiver(mClockView);
|
mDemoModeReceiver = new ClockDemoModeReceiver(mClockView);
|
||||||
mColorExtractor = colorExtractor;
|
mColorExtractor = colorExtractor;
|
||||||
mOnColorsChangedListener = (extractor, which) -> {
|
mOnColorsChangedListener = (extractor, which) -> {
|
||||||
@@ -162,6 +163,10 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
mClockView.onColorsChanged(lightTheme);
|
mClockView.onColorsChanged(lightTheme);
|
||||||
};
|
};
|
||||||
mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener);
|
mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener);
|
||||||
|
|
||||||
|
mCameraSlot = getResources().getString(com.android.internal.R.string.status_bar_camera);
|
||||||
|
mMicSlot = getResources().getString(com.android.internal.R.string.status_bar_microphone);
|
||||||
|
mLocationSlot = getResources().getString(com.android.internal.R.string.status_bar_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -172,14 +177,30 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
mLocationIndicatorsEnabled = mPrivacyItemController.getLocationAvailable();
|
mLocationIndicatorsEnabled = mPrivacyItemController.getLocationAvailable();
|
||||||
|
|
||||||
// Ignore privacy icons because they show in the space above QQS
|
// Ignore privacy icons because they show in the space above QQS
|
||||||
mIconContainer.setIgnoredSlots(getIgnoredIconSlots());
|
updatePrivacyIconSlots();
|
||||||
mIconContainer.setShouldRestrictIcons(false);
|
mIconContainer.setShouldRestrictIcons(false);
|
||||||
mStatusBarIconController.addIconGroup(mIconManager);
|
mStatusBarIconController.addIconGroup(mIconManager);
|
||||||
|
|
||||||
setChipVisibility(mPrivacyChip.getVisibility() == View.VISIBLE);
|
setChipVisibility(mPrivacyChip.getVisibility() == View.VISIBLE);
|
||||||
|
|
||||||
mView.onAttach(mIconManager, mQSExpansionPathInterpolator,
|
mView.setIsSingleCarrier(mQSCarrierGroupController.isSingleCarrier());
|
||||||
mFeatureFlags.isCombinedStatusBarSignalIconsEnabled());
|
mQSCarrierGroupController
|
||||||
|
.setOnSingleCarrierChangedListener(mView::setIsSingleCarrier);
|
||||||
|
|
||||||
|
List<String> rssiIgnoredSlots;
|
||||||
|
|
||||||
|
if (mFeatureFlags.isCombinedStatusBarSignalIconsEnabled()) {
|
||||||
|
rssiIgnoredSlots = List.of(
|
||||||
|
getResources().getString(com.android.internal.R.string.status_bar_no_calling),
|
||||||
|
getResources().getString(com.android.internal.R.string.status_bar_call_strength)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
rssiIgnoredSlots = List.of(
|
||||||
|
getResources().getString(com.android.internal.R.string.status_bar_mobile)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
mView.onAttach(mIconManager, mQSExpansionPathInterpolator, rssiIgnoredSlots);
|
||||||
|
|
||||||
mDemoModeController.addCallback(mDemoModeReceiver);
|
mDemoModeController.addCallback(mDemoModeReceiver);
|
||||||
}
|
}
|
||||||
@@ -189,6 +210,7 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
mColorExtractor.removeOnColorsChangedListener(mOnColorsChangedListener);
|
mColorExtractor.removeOnColorsChangedListener(mOnColorsChangedListener);
|
||||||
mPrivacyChip.setOnClickListener(null);
|
mPrivacyChip.setOnClickListener(null);
|
||||||
mStatusBarIconController.removeIconGroup(mIconManager);
|
mStatusBarIconController.removeIconGroup(mIconManager);
|
||||||
|
mQSCarrierGroupController.setOnSingleCarrierChangedListener(null);
|
||||||
mDemoModeController.removeCallback(mDemoModeReceiver);
|
mDemoModeController.removeCallback(mDemoModeReceiver);
|
||||||
setListening(false);
|
setListening(false);
|
||||||
}
|
}
|
||||||
@@ -236,21 +258,25 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
|||||||
mView.setChipVisibility(chipVisible);
|
mView.setChipVisibility(chipVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getIgnoredIconSlots() {
|
private void updatePrivacyIconSlots() {
|
||||||
ArrayList<String> ignored = new ArrayList<>();
|
|
||||||
if (getChipEnabled()) {
|
if (getChipEnabled()) {
|
||||||
if (mMicCameraIndicatorsEnabled) {
|
if (mMicCameraIndicatorsEnabled) {
|
||||||
ignored.add(mView.getResources().getString(
|
mIconContainer.addIgnoredSlot(mCameraSlot);
|
||||||
com.android.internal.R.string.status_bar_camera));
|
mIconContainer.addIgnoredSlot(mMicSlot);
|
||||||
ignored.add(mView.getResources().getString(
|
} else {
|
||||||
com.android.internal.R.string.status_bar_microphone));
|
mIconContainer.removeIgnoredSlot(mCameraSlot);
|
||||||
|
mIconContainer.removeIgnoredSlot(mMicSlot);
|
||||||
}
|
}
|
||||||
if (mLocationIndicatorsEnabled) {
|
if (mLocationIndicatorsEnabled) {
|
||||||
ignored.add(mView.getResources().getString(
|
mIconContainer.addIgnoredSlot(mLocationSlot);
|
||||||
com.android.internal.R.string.status_bar_location));
|
} else {
|
||||||
|
mIconContainer.removeIgnoredSlot(mLocationSlot);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mIconContainer.removeIgnoredSlot(mCameraSlot);
|
||||||
|
mIconContainer.removeIgnoredSlot(mMicSlot);
|
||||||
|
mIconContainer.removeIgnoredSlot(mLocationSlot);
|
||||||
}
|
}
|
||||||
return ignored;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getChipEnabled() {
|
private boolean getChipEnabled() {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.settingslib.graph.SignalDrawable;
|
import com.android.settingslib.graph.SignalDrawable;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -37,8 +39,10 @@ public class QSCarrier extends LinearLayout {
|
|||||||
private TextView mCarrierText;
|
private TextView mCarrierText;
|
||||||
private ImageView mMobileSignal;
|
private ImageView mMobileSignal;
|
||||||
private ImageView mMobileRoaming;
|
private ImageView mMobileRoaming;
|
||||||
|
private View mSpacer;
|
||||||
private CellSignalState mLastSignalState;
|
private CellSignalState mLastSignalState;
|
||||||
private boolean mProviderModelInitialized = false;
|
private boolean mProviderModelInitialized = false;
|
||||||
|
private boolean mIsSingleCarrier;
|
||||||
|
|
||||||
public QSCarrier(Context context) {
|
public QSCarrier(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -63,18 +67,25 @@ public class QSCarrier extends LinearLayout {
|
|||||||
mMobileRoaming = findViewById(R.id.mobile_roaming);
|
mMobileRoaming = findViewById(R.id.mobile_roaming);
|
||||||
mMobileSignal = findViewById(R.id.mobile_signal);
|
mMobileSignal = findViewById(R.id.mobile_signal);
|
||||||
mCarrierText = findViewById(R.id.qs_carrier_text);
|
mCarrierText = findViewById(R.id.qs_carrier_text);
|
||||||
|
mSpacer = findViewById(R.id.spacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the state of this view
|
* Update the state of this view
|
||||||
* @param state the current state of the signal for this view
|
* @param state the current state of the signal for this view
|
||||||
|
* @param isSingleCarrier whether there is a single carrier being shown in the container
|
||||||
* @return true if the state was actually changed
|
* @return true if the state was actually changed
|
||||||
*/
|
*/
|
||||||
public boolean updateState(CellSignalState state) {
|
public boolean updateState(CellSignalState state, boolean isSingleCarrier) {
|
||||||
if (Objects.equals(state, mLastSignalState)) return false;
|
if (Objects.equals(state, mLastSignalState) && isSingleCarrier == mIsSingleCarrier) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mLastSignalState = state;
|
mLastSignalState = state;
|
||||||
mMobileGroup.setVisibility(state.visible ? View.VISIBLE : View.GONE);
|
mIsSingleCarrier = isSingleCarrier;
|
||||||
if (state.visible) {
|
final boolean visible = state.visible && !isSingleCarrier;
|
||||||
|
mMobileGroup.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||||
|
mSpacer.setVisibility(isSingleCarrier ? View.VISIBLE : View.GONE);
|
||||||
|
if (visible) {
|
||||||
mMobileRoaming.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
|
mMobileRoaming.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
|
||||||
ColorStateList colorStateList = Utils.getColorAttr(mContext,
|
ColorStateList colorStateList = Utils.getColorAttr(mContext,
|
||||||
android.R.attr.textColorPrimary);
|
android.R.attr.textColorPrimary);
|
||||||
@@ -125,6 +136,11 @@ public class QSCarrier extends LinearLayout {
|
|||||||
com.android.settingslib.R.string.not_default_data_content_description));
|
com.android.settingslib.R.string.not_default_data_content_description));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
View getRSSIView() {
|
||||||
|
return mMobileGroup;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCarrierText(CharSequence text) {
|
public void setCarrierText(CharSequence text) {
|
||||||
mCarrierText.setText(text);
|
mCarrierText.setText(text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.android.keyguard.CarrierTextManager;
|
|||||||
import com.android.settingslib.AccessibilityContentDescriptions;
|
import com.android.settingslib.AccessibilityContentDescriptions;
|
||||||
import com.android.settingslib.mobile.TelephonyIcons;
|
import com.android.settingslib.mobile.TelephonyIcons;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.qualifiers.Background;
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.plugins.ActivityStarter;
|
import com.android.systemui.plugins.ActivityStarter;
|
||||||
@@ -62,7 +63,8 @@ public class QSCarrierGroupController {
|
|||||||
private final NetworkController mNetworkController;
|
private final NetworkController mNetworkController;
|
||||||
private final CarrierTextManager mCarrierTextManager;
|
private final CarrierTextManager mCarrierTextManager;
|
||||||
private final TextView mNoSimTextView;
|
private final TextView mNoSimTextView;
|
||||||
private final H mMainHandler;
|
// Non final for testing
|
||||||
|
private H mMainHandler;
|
||||||
private final Callback mCallback;
|
private final Callback mCallback;
|
||||||
private boolean mListening;
|
private boolean mListening;
|
||||||
private final CellSignalState[] mInfos =
|
private final CellSignalState[] mInfos =
|
||||||
@@ -74,6 +76,11 @@ public class QSCarrierGroupController {
|
|||||||
private final boolean mProviderModel;
|
private final boolean mProviderModel;
|
||||||
private final CarrierConfigTracker mCarrierConfigTracker;
|
private final CarrierConfigTracker mCarrierConfigTracker;
|
||||||
|
|
||||||
|
private boolean mIsSingleCarrier;
|
||||||
|
private OnSingleCarrierChangedListener mOnSingleCarrierChangedListener;
|
||||||
|
|
||||||
|
private final SlotIndexResolver mSlotIndexResolver;
|
||||||
|
|
||||||
private final NetworkController.SignalCallback mSignalCallback =
|
private final NetworkController.SignalCallback mSignalCallback =
|
||||||
new NetworkController.SignalCallback() {
|
new NetworkController.SignalCallback() {
|
||||||
@Override
|
@Override
|
||||||
@@ -207,7 +214,8 @@ public class QSCarrierGroupController {
|
|||||||
@Background Handler bgHandler, @Main Looper mainLooper,
|
@Background Handler bgHandler, @Main Looper mainLooper,
|
||||||
NetworkController networkController,
|
NetworkController networkController,
|
||||||
CarrierTextManager.Builder carrierTextManagerBuilder, Context context,
|
CarrierTextManager.Builder carrierTextManagerBuilder, Context context,
|
||||||
CarrierConfigTracker carrierConfigTracker, FeatureFlags featureFlags) {
|
CarrierConfigTracker carrierConfigTracker, FeatureFlags featureFlags,
|
||||||
|
SlotIndexResolver slotIndexResolver) {
|
||||||
|
|
||||||
if (featureFlags.isCombinedStatusBarSignalIconsEnabled()) {
|
if (featureFlags.isCombinedStatusBarSignalIconsEnabled()) {
|
||||||
mProviderModel = true;
|
mProviderModel = true;
|
||||||
@@ -222,6 +230,7 @@ public class QSCarrierGroupController {
|
|||||||
.setShowMissingSim(false)
|
.setShowMissingSim(false)
|
||||||
.build();
|
.build();
|
||||||
mCarrierConfigTracker = carrierConfigTracker;
|
mCarrierConfigTracker = carrierConfigTracker;
|
||||||
|
mSlotIndexResolver = slotIndexResolver;
|
||||||
View.OnClickListener onClickListener = v -> {
|
View.OnClickListener onClickListener = v -> {
|
||||||
if (!v.isVisibleToUser()) {
|
if (!v.isVisibleToUser()) {
|
||||||
return;
|
return;
|
||||||
@@ -256,6 +265,7 @@ public class QSCarrierGroupController {
|
|||||||
.toString();
|
.toString();
|
||||||
mCarrierGroups[i].setOnClickListener(onClickListener);
|
mCarrierGroups[i].setOnClickListener(onClickListener);
|
||||||
}
|
}
|
||||||
|
mIsSingleCarrier = computeIsSingleCarrier();
|
||||||
view.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
|
view.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||||
|
|
||||||
view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||||
@@ -272,10 +282,24 @@ public class QSCarrierGroupController {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected int getSlotIndex(int subscriptionId) {
|
protected int getSlotIndex(int subscriptionId) {
|
||||||
return SubscriptionManager.getSlotIndex(subscriptionId);
|
return mSlotIndexResolver.getSlotIndex(subscriptionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSingleCarrier() {
|
/**
|
||||||
|
* Sets a {@link OnSingleCarrierChangedListener}.
|
||||||
|
*
|
||||||
|
* This will get notified when the number of carriers changes between 1 and "not one".
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
public void setOnSingleCarrierChangedListener(OnSingleCarrierChangedListener listener) {
|
||||||
|
mOnSingleCarrierChangedListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingleCarrier() {
|
||||||
|
return mIsSingleCarrier;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean computeIsSingleCarrier() {
|
||||||
int carrierCount = 0;
|
int carrierCount = 0;
|
||||||
for (int i = 0; i < SIM_SLOTS; i++) {
|
for (int i = 0; i < SIM_SLOTS; i++) {
|
||||||
|
|
||||||
@@ -315,7 +339,9 @@ public class QSCarrierGroupController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSingleCarrier()) {
|
boolean singleCarrier = computeIsSingleCarrier();
|
||||||
|
|
||||||
|
if (singleCarrier) {
|
||||||
for (int i = 0; i < SIM_SLOTS; i++) {
|
for (int i = 0; i < SIM_SLOTS; i++) {
|
||||||
if (mInfos[i].visible
|
if (mInfos[i].visible
|
||||||
&& mInfos[i].mobileSignalIconId == R.drawable.ic_qs_sim_card) {
|
&& mInfos[i].mobileSignalIconId == R.drawable.ic_qs_sim_card) {
|
||||||
@@ -326,7 +352,7 @@ public class QSCarrierGroupController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < SIM_SLOTS; i++) {
|
for (int i = 0; i < SIM_SLOTS; i++) {
|
||||||
mCarrierGroups[i].updateState(mInfos[i]);
|
mCarrierGroups[i].updateState(mInfos[i], singleCarrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
mCarrierDividers[0].setVisibility(
|
mCarrierDividers[0].setVisibility(
|
||||||
@@ -337,6 +363,12 @@ public class QSCarrierGroupController {
|
|||||||
mCarrierDividers[1].setVisibility(
|
mCarrierDividers[1].setVisibility(
|
||||||
(mInfos[1].visible && mInfos[2].visible)
|
(mInfos[1].visible && mInfos[2].visible)
|
||||||
|| (mInfos[0].visible && mInfos[2].visible) ? View.VISIBLE : View.GONE);
|
|| (mInfos[0].visible && mInfos[2].visible) ? View.VISIBLE : View.GONE);
|
||||||
|
if (mIsSingleCarrier != singleCarrier) {
|
||||||
|
mIsSingleCarrier = singleCarrier;
|
||||||
|
if (mOnSingleCarrierChangedListener != null) {
|
||||||
|
mOnSingleCarrierChangedListener.onSingleCarrierChanged(singleCarrier);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
@@ -433,12 +465,14 @@ public class QSCarrierGroupController {
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final CarrierConfigTracker mCarrierConfigTracker;
|
private final CarrierConfigTracker mCarrierConfigTracker;
|
||||||
private final FeatureFlags mFeatureFlags;
|
private final FeatureFlags mFeatureFlags;
|
||||||
|
private final SlotIndexResolver mSlotIndexResolver;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Builder(ActivityStarter activityStarter, @Background Handler handler,
|
public Builder(ActivityStarter activityStarter, @Background Handler handler,
|
||||||
@Main Looper looper, NetworkController networkController,
|
@Main Looper looper, NetworkController networkController,
|
||||||
CarrierTextManager.Builder carrierTextControllerBuilder, Context context,
|
CarrierTextManager.Builder carrierTextControllerBuilder, Context context,
|
||||||
CarrierConfigTracker carrierConfigTracker, FeatureFlags featureFlags) {
|
CarrierConfigTracker carrierConfigTracker, FeatureFlags featureFlags,
|
||||||
|
SlotIndexResolver slotIndexResolver) {
|
||||||
mActivityStarter = activityStarter;
|
mActivityStarter = activityStarter;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mLooper = looper;
|
mLooper = looper;
|
||||||
@@ -447,6 +481,7 @@ public class QSCarrierGroupController {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mCarrierConfigTracker = carrierConfigTracker;
|
mCarrierConfigTracker = carrierConfigTracker;
|
||||||
mFeatureFlags = featureFlags;
|
mFeatureFlags = featureFlags;
|
||||||
|
mSlotIndexResolver = slotIndexResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setQSCarrierGroup(QSCarrierGroup view) {
|
public Builder setQSCarrierGroup(QSCarrierGroup view) {
|
||||||
@@ -457,7 +492,43 @@ public class QSCarrierGroupController {
|
|||||||
public QSCarrierGroupController build() {
|
public QSCarrierGroupController build() {
|
||||||
return new QSCarrierGroupController(mView, mActivityStarter, mHandler, mLooper,
|
return new QSCarrierGroupController(mView, mActivityStarter, mHandler, mLooper,
|
||||||
mNetworkController, mCarrierTextControllerBuilder, mContext,
|
mNetworkController, mCarrierTextControllerBuilder, mContext,
|
||||||
mCarrierConfigTracker, mFeatureFlags);
|
mCarrierConfigTracker, mFeatureFlags, mSlotIndexResolver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify when the state changes from 1 carrier to "not one" and viceversa
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface OnSingleCarrierChangedListener {
|
||||||
|
void onSingleCarrierChanged(boolean isSingleCarrier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for resolving slot index from subscription ID.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface SlotIndexResolver {
|
||||||
|
/**
|
||||||
|
* Get slot index for given sub id.
|
||||||
|
*/
|
||||||
|
int getSlotIndex(int subscriptionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation for {@link SlotIndexResolver}.
|
||||||
|
*
|
||||||
|
* It retrieves the slot index using {@link SubscriptionManager#getSlotIndex}.
|
||||||
|
*/
|
||||||
|
@SysUISingleton
|
||||||
|
public static class SubscriptionManagerSlotIndexResolver implements SlotIndexResolver {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SubscriptionManagerSlotIndexResolver() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotIndex(int subscriptionId) {
|
||||||
|
return SubscriptionManager.getSlotIndex(subscriptionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.android.systemui.qs.QSFragment;
|
|||||||
import com.android.systemui.qs.QSPanel;
|
import com.android.systemui.qs.QSPanel;
|
||||||
import com.android.systemui.qs.QuickQSPanel;
|
import com.android.systemui.qs.QuickQSPanel;
|
||||||
import com.android.systemui.qs.QuickStatusBarHeader;
|
import com.android.systemui.qs.QuickStatusBarHeader;
|
||||||
|
import com.android.systemui.qs.carrier.QSCarrierGroupController;
|
||||||
import com.android.systemui.qs.customize.QSCustomizer;
|
import com.android.systemui.qs.customize.QSCustomizer;
|
||||||
import com.android.systemui.statusbar.phone.MultiUserSwitch;
|
import com.android.systemui.statusbar.phone.MultiUserSwitch;
|
||||||
|
|
||||||
@@ -146,4 +147,8 @@ public interface QSFragmentModule {
|
|||||||
return useQsMediaPlayer(context);
|
return useQsMediaPlayer(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
@Binds
|
||||||
|
QSCarrierGroupController.SlotIndexResolver provideSlotIndexResolver(
|
||||||
|
QSCarrierGroupController.SubscriptionManagerSlotIndexResolver impl);
|
||||||
}
|
}
|
||||||
@@ -89,5 +89,4 @@ public interface QSModule {
|
|||||||
/** */
|
/** */
|
||||||
@Binds
|
@Binds
|
||||||
QSHost provideQsHost(QSTileHost controllerImpl);
|
QSHost provideQsHost(QSTileHost controllerImpl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,8 +245,19 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
|
|||||||
* @param slotName name of the icon slot to remove from the ignored list
|
* @param slotName name of the icon slot to remove from the ignored list
|
||||||
*/
|
*/
|
||||||
public void removeIgnoredSlot(String slotName) {
|
public void removeIgnoredSlot(String slotName) {
|
||||||
if (mIgnoredSlots.contains(slotName)) {
|
mIgnoredSlots.remove(slotName);
|
||||||
mIgnoredSlots.remove(slotName);
|
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a list of slots from the list of ignored icon slots.
|
||||||
|
* It will then be shown when set to visible by the {@link StatusBarIconController}.
|
||||||
|
* @param slots name of the icon slots to remove from the ignored list
|
||||||
|
*/
|
||||||
|
public void removeIgnoredSlots(List<String> slots) {
|
||||||
|
for (String slot : slots) {
|
||||||
|
mIgnoredSlots.remove(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLayout();
|
requestLayout();
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import org.mockito.Answers
|
|||||||
import org.mockito.ArgumentMatchers.anyInt
|
import org.mockito.ArgumentMatchers.anyInt
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.mockito.Mockito.reset
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
@@ -98,6 +99,10 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
private lateinit var controller: QuickStatusBarHeaderController
|
private lateinit var controller: QuickStatusBarHeaderController
|
||||||
|
|
||||||
|
private lateinit var cameraSlotName: String
|
||||||
|
private lateinit var microphoneSlotName: String
|
||||||
|
private lateinit var locationSlotName: String
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
@@ -108,6 +113,13 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
`when`(view.isAttachedToWindow).thenReturn(true)
|
`when`(view.isAttachedToWindow).thenReturn(true)
|
||||||
`when`(view.context).thenReturn(context)
|
`when`(view.context).thenReturn(context)
|
||||||
|
|
||||||
|
cameraSlotName = mContext.resources.getString(
|
||||||
|
com.android.internal.R.string.status_bar_camera)
|
||||||
|
microphoneSlotName = mContext.resources.getString(
|
||||||
|
com.android.internal.R.string.status_bar_microphone)
|
||||||
|
locationSlotName = mContext.resources.getString(
|
||||||
|
com.android.internal.R.string.status_bar_location)
|
||||||
|
|
||||||
controller = QuickStatusBarHeaderController(
|
controller = QuickStatusBarHeaderController(
|
||||||
view,
|
view,
|
||||||
privacyItemController,
|
privacyItemController,
|
||||||
@@ -141,10 +153,9 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
val captor = argumentCaptor<List<String>>()
|
verify(iconContainer).removeIgnoredSlot(cameraSlotName)
|
||||||
verify(iconContainer).setIgnoredSlots(capture(captor))
|
verify(iconContainer).removeIgnoredSlot(microphoneSlotName)
|
||||||
|
verify(iconContainer).removeIgnoredSlot(locationSlotName)
|
||||||
assertThat(captor.value).isEmpty()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -153,15 +164,9 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
val captor = argumentCaptor<List<String>>()
|
verify(iconContainer).addIgnoredSlot(cameraSlotName)
|
||||||
verify(iconContainer).setIgnoredSlots(capture(captor))
|
verify(iconContainer).addIgnoredSlot(microphoneSlotName)
|
||||||
|
verify(iconContainer).removeIgnoredSlot(locationSlotName)
|
||||||
val cameraString = mContext.resources.getString(
|
|
||||||
com.android.internal.R.string.status_bar_camera)
|
|
||||||
val micString = mContext.resources.getString(
|
|
||||||
com.android.internal.R.string.status_bar_microphone)
|
|
||||||
|
|
||||||
assertThat(captor.value).containsExactly(cameraString, micString)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -170,13 +175,9 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
val captor = argumentCaptor<List<String>>()
|
verify(iconContainer).removeIgnoredSlot(cameraSlotName)
|
||||||
verify(iconContainer).setIgnoredSlots(capture(captor))
|
verify(iconContainer).removeIgnoredSlot(microphoneSlotName)
|
||||||
|
verify(iconContainer).addIgnoredSlot(locationSlotName)
|
||||||
val locationString = mContext.resources.getString(
|
|
||||||
com.android.internal.R.string.status_bar_location)
|
|
||||||
|
|
||||||
assertThat(captor.value).containsExactly(locationString)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -185,17 +186,9 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
val captor = argumentCaptor<List<String>>()
|
verify(iconContainer).addIgnoredSlot(cameraSlotName)
|
||||||
verify(iconContainer).setIgnoredSlots(capture(captor))
|
verify(iconContainer).addIgnoredSlot(microphoneSlotName)
|
||||||
|
verify(iconContainer).addIgnoredSlot(locationSlotName)
|
||||||
val cameraString = mContext.resources.getString(
|
|
||||||
com.android.internal.R.string.status_bar_camera)
|
|
||||||
val micString = mContext.resources.getString(
|
|
||||||
com.android.internal.R.string.status_bar_microphone)
|
|
||||||
val locationString = mContext.resources.getString(
|
|
||||||
com.android.internal.R.string.status_bar_location)
|
|
||||||
|
|
||||||
assertThat(captor.value).containsExactly(cameraString, micString, locationString)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -210,6 +203,71 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
|
|||||||
verify(privacyDialogController).showDialog(any(Context::class.java))
|
verify(privacyDialogController).showDialog(any(Context::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSingleCarrierListenerAttachedOnInit() {
|
||||||
|
controller.init()
|
||||||
|
|
||||||
|
verify(qsCarrierGroupController).setOnSingleCarrierChangedListener(any())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSingleCarrierSetOnViewOnInit_false() {
|
||||||
|
`when`(qsCarrierGroupController.isSingleCarrier).thenReturn(false)
|
||||||
|
controller.init()
|
||||||
|
|
||||||
|
verify(view).setIsSingleCarrier(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSingleCarrierSetOnViewOnInit_true() {
|
||||||
|
`when`(qsCarrierGroupController.isSingleCarrier).thenReturn(true)
|
||||||
|
controller.init()
|
||||||
|
|
||||||
|
verify(view).setIsSingleCarrier(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testRSSISlot_notCombined() {
|
||||||
|
`when`(featureFlags.isCombinedStatusBarSignalIconsEnabled).thenReturn(false)
|
||||||
|
controller.init()
|
||||||
|
|
||||||
|
val captor = argumentCaptor<List<String>>()
|
||||||
|
verify(view).onAttach(any(), any(), capture(captor))
|
||||||
|
|
||||||
|
assertThat(captor.value).containsExactly(
|
||||||
|
mContext.getString(com.android.internal.R.string.status_bar_mobile)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testRSSISlot_combined() {
|
||||||
|
`when`(featureFlags.isCombinedStatusBarSignalIconsEnabled).thenReturn(true)
|
||||||
|
controller.init()
|
||||||
|
|
||||||
|
val captor = argumentCaptor<List<String>>()
|
||||||
|
verify(view).onAttach(any(), any(), capture(captor))
|
||||||
|
|
||||||
|
assertThat(captor.value).containsExactly(
|
||||||
|
mContext.getString(com.android.internal.R.string.status_bar_no_calling),
|
||||||
|
mContext.getString(com.android.internal.R.string.status_bar_call_strength)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSingleCarrierCallback() {
|
||||||
|
controller.init()
|
||||||
|
reset(view)
|
||||||
|
|
||||||
|
val captor = argumentCaptor<QSCarrierGroupController.OnSingleCarrierChangedListener>()
|
||||||
|
verify(qsCarrierGroupController).setOnSingleCarrierChangedListener(capture(captor))
|
||||||
|
|
||||||
|
captor.value.onSingleCarrierChanged(true)
|
||||||
|
verify(view).setIsSingleCarrier(true)
|
||||||
|
|
||||||
|
captor.value.onSingleCarrierChanged(false)
|
||||||
|
verify(view).setIsSingleCarrier(false)
|
||||||
|
}
|
||||||
|
|
||||||
private fun stubViews() {
|
private fun stubViews() {
|
||||||
`when`(view.findViewById<View>(anyInt())).thenReturn(mockView)
|
`when`(view.findViewById<View>(anyInt())).thenReturn(mockView)
|
||||||
`when`(view.findViewById<QSCarrierGroup>(R.id.carrier_group)).thenReturn(qsCarrierGroup)
|
`when`(view.findViewById<QSCarrierGroup>(R.id.carrier_group)).thenReturn(qsCarrierGroup)
|
||||||
|
|||||||
@@ -17,15 +17,18 @@
|
|||||||
package com.android.systemui.qs.carrier;
|
package com.android.systemui.qs.carrier;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.reset;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.telephony.SubscriptionManager;
|
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -46,9 +49,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@TestableLooper.RunWithLooper
|
@TestableLooper.RunWithLooper
|
||||||
@@ -70,8 +71,18 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
|||||||
private CarrierTextManager mCarrierTextManager;
|
private CarrierTextManager mCarrierTextManager;
|
||||||
@Mock
|
@Mock
|
||||||
private CarrierConfigTracker mCarrierConfigTracker;
|
private CarrierConfigTracker mCarrierConfigTracker;
|
||||||
|
@Mock
|
||||||
|
private QSCarrier mQSCarrier1;
|
||||||
|
@Mock
|
||||||
|
private QSCarrier mQSCarrier2;
|
||||||
|
@Mock
|
||||||
|
private QSCarrier mQSCarrier3;
|
||||||
private TestableLooper mTestableLooper;
|
private TestableLooper mTestableLooper;
|
||||||
@Mock private FeatureFlags mFeatureFlags;
|
@Mock private FeatureFlags mFeatureFlags;
|
||||||
|
@Mock
|
||||||
|
private QSCarrierGroupController.OnSingleCarrierChangedListener mOnSingleCarrierChangedListener;
|
||||||
|
|
||||||
|
private FakeSlotIndexResolver mSlotIndexResolver;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
@@ -96,29 +107,31 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
|||||||
.setListening(any(CarrierTextManager.CarrierTextCallback.class));
|
.setListening(any(CarrierTextManager.CarrierTextCallback.class));
|
||||||
|
|
||||||
when(mQSCarrierGroup.getNoSimTextView()).thenReturn(new TextView(mContext));
|
when(mQSCarrierGroup.getNoSimTextView()).thenReturn(new TextView(mContext));
|
||||||
when(mQSCarrierGroup.getCarrier1View()).thenReturn(mock(QSCarrier.class));
|
when(mQSCarrierGroup.getCarrier1View()).thenReturn(mQSCarrier1);
|
||||||
when(mQSCarrierGroup.getCarrier2View()).thenReturn(mock(QSCarrier.class));
|
when(mQSCarrierGroup.getCarrier2View()).thenReturn(mQSCarrier2);
|
||||||
when(mQSCarrierGroup.getCarrier3View()).thenReturn(mock(QSCarrier.class));
|
when(mQSCarrierGroup.getCarrier3View()).thenReturn(mQSCarrier3);
|
||||||
when(mQSCarrierGroup.getCarrierDivider1()).thenReturn(new View(mContext));
|
when(mQSCarrierGroup.getCarrierDivider1()).thenReturn(new View(mContext));
|
||||||
when(mQSCarrierGroup.getCarrierDivider2()).thenReturn(new View(mContext));
|
when(mQSCarrierGroup.getCarrierDivider2()).thenReturn(new View(mContext));
|
||||||
|
|
||||||
|
mSlotIndexResolver = new FakeSlotIndexResolver();
|
||||||
|
|
||||||
mQSCarrierGroupController = new QSCarrierGroupController.Builder(
|
mQSCarrierGroupController = new QSCarrierGroupController.Builder(
|
||||||
mActivityStarter, handler, TestableLooper.get(this).getLooper(),
|
mActivityStarter, handler, TestableLooper.get(this).getLooper(),
|
||||||
mNetworkController, mCarrierTextControllerBuilder, mContext, mCarrierConfigTracker,
|
mNetworkController, mCarrierTextControllerBuilder, mContext, mCarrierConfigTracker,
|
||||||
mFeatureFlags)
|
mFeatureFlags, mSlotIndexResolver)
|
||||||
.setQSCarrierGroup(mQSCarrierGroup)
|
.setQSCarrierGroup(mQSCarrierGroup)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
mQSCarrierGroupController.setListening(true);
|
mQSCarrierGroupController.setListening(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitiallyMultiCarrier() {
|
||||||
|
assertFalse(mQSCarrierGroupController.isSingleCarrier());
|
||||||
|
}
|
||||||
|
|
||||||
@Test // throws no Exception
|
@Test // throws no Exception
|
||||||
public void testUpdateCarrierText_sameLengths() {
|
public void testUpdateCarrierText_sameLengths() {
|
||||||
QSCarrierGroupController spiedCarrierGroupController =
|
|
||||||
Mockito.spy(mQSCarrierGroupController);
|
|
||||||
when(spiedCarrierGroupController.getSlotIndex(anyInt())).thenAnswer(
|
|
||||||
(Answer<Integer>) invocationOnMock -> invocationOnMock.getArgument(0));
|
|
||||||
|
|
||||||
// listOfCarriers length 1, subscriptionIds length 1, anySims false
|
// listOfCarriers length 1, subscriptionIds length 1, anySims false
|
||||||
CarrierTextManager.CarrierTextCallbackInfo
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
c1 = new CarrierTextManager.CarrierTextCallbackInfo(
|
c1 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
@@ -160,11 +173,6 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
|||||||
|
|
||||||
@Test // throws no Exception
|
@Test // throws no Exception
|
||||||
public void testUpdateCarrierText_differentLength() {
|
public void testUpdateCarrierText_differentLength() {
|
||||||
QSCarrierGroupController spiedCarrierGroupController =
|
|
||||||
Mockito.spy(mQSCarrierGroupController);
|
|
||||||
when(spiedCarrierGroupController.getSlotIndex(anyInt())).thenAnswer(
|
|
||||||
(Answer<Integer>) invocationOnMock -> invocationOnMock.getArgument(0));
|
|
||||||
|
|
||||||
// listOfCarriers length 2, subscriptionIds length 1, anySims false
|
// listOfCarriers length 2, subscriptionIds length 1, anySims false
|
||||||
CarrierTextManager.CarrierTextCallbackInfo
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
c1 = new CarrierTextManager.CarrierTextCallbackInfo(
|
c1 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
@@ -205,10 +213,7 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
|||||||
|
|
||||||
@Test // throws no Exception
|
@Test // throws no Exception
|
||||||
public void testUpdateCarrierText_invalidSim() {
|
public void testUpdateCarrierText_invalidSim() {
|
||||||
QSCarrierGroupController spiedCarrierGroupController =
|
mSlotIndexResolver.overrideInvalid = true;
|
||||||
Mockito.spy(mQSCarrierGroupController);
|
|
||||||
when(spiedCarrierGroupController.getSlotIndex(anyInt())).thenReturn(
|
|
||||||
SubscriptionManager.INVALID_SIM_SLOT_INDEX);
|
|
||||||
|
|
||||||
CarrierTextManager.CarrierTextCallbackInfo
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
c4 = new CarrierTextManager.CarrierTextCallbackInfo(
|
c4 = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
@@ -222,6 +227,8 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
|||||||
|
|
||||||
@Test // throws no Exception
|
@Test // throws no Exception
|
||||||
public void testSetMobileDataIndicators_invalidSim() {
|
public void testSetMobileDataIndicators_invalidSim() {
|
||||||
|
mSlotIndexResolver.overrideInvalid = true;
|
||||||
|
|
||||||
MobileDataIndicators indicators = new MobileDataIndicators(
|
MobileDataIndicators indicators = new MobileDataIndicators(
|
||||||
mock(NetworkController.IconState.class),
|
mock(NetworkController.IconState.class),
|
||||||
mock(NetworkController.IconState.class),
|
mock(NetworkController.IconState.class),
|
||||||
@@ -242,4 +249,137 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
|
|||||||
mTestableLooper.processAllMessages();
|
mTestableLooper.processAllMessages();
|
||||||
assertEquals(View.GONE, mQSCarrierGroup.getNoSimTextView().getVisibility());
|
assertEquals(View.GONE, mQSCarrierGroup.getNoSimTextView().getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListenerNotCalledOnRegistreation() {
|
||||||
|
mQSCarrierGroupController
|
||||||
|
.setOnSingleCarrierChangedListener(mOnSingleCarrierChangedListener);
|
||||||
|
|
||||||
|
verify(mOnSingleCarrierChangedListener, never()).onSingleCarrierChanged(anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSingleCarrier() {
|
||||||
|
// Only one element in the info
|
||||||
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
info = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
|
"",
|
||||||
|
new CharSequence[]{""},
|
||||||
|
true,
|
||||||
|
new int[]{0},
|
||||||
|
false /* airplaneMode */);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(info);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
verify(mQSCarrier1).updateState(any(), eq(true));
|
||||||
|
verify(mQSCarrier2).updateState(any(), eq(true));
|
||||||
|
verify(mQSCarrier3).updateState(any(), eq(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMultiCarrier() {
|
||||||
|
// More than one element in the info
|
||||||
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
info = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
|
"",
|
||||||
|
new CharSequence[]{"", ""},
|
||||||
|
true,
|
||||||
|
new int[]{0, 1},
|
||||||
|
false /* airplaneMode */);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(info);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
verify(mQSCarrier1).updateState(any(), eq(false));
|
||||||
|
verify(mQSCarrier2).updateState(any(), eq(false));
|
||||||
|
verify(mQSCarrier3).updateState(any(), eq(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSingleMultiCarrierSwitch() {
|
||||||
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
singleCarrierInfo = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
|
"",
|
||||||
|
new CharSequence[]{""},
|
||||||
|
true,
|
||||||
|
new int[]{0},
|
||||||
|
false /* airplaneMode */);
|
||||||
|
|
||||||
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
multiCarrierInfo = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
|
"",
|
||||||
|
new CharSequence[]{"", ""},
|
||||||
|
true,
|
||||||
|
new int[]{0, 1},
|
||||||
|
false /* airplaneMode */);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(singleCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
mQSCarrierGroupController
|
||||||
|
.setOnSingleCarrierChangedListener(mOnSingleCarrierChangedListener);
|
||||||
|
reset(mOnSingleCarrierChangedListener);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(multiCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
verify(mOnSingleCarrierChangedListener).onSingleCarrierChanged(false);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(singleCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
verify(mOnSingleCarrierChangedListener).onSingleCarrierChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoCallbackIfSingleCarrierDoesntChange() {
|
||||||
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
singleCarrierInfo = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
|
"",
|
||||||
|
new CharSequence[]{""},
|
||||||
|
true,
|
||||||
|
new int[]{0},
|
||||||
|
false /* airplaneMode */);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(singleCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
mQSCarrierGroupController
|
||||||
|
.setOnSingleCarrierChangedListener(mOnSingleCarrierChangedListener);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(singleCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
verify(mOnSingleCarrierChangedListener, never()).onSingleCarrierChanged(anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoCallbackIfMultiCarrierDoesntChange() {
|
||||||
|
CarrierTextManager.CarrierTextCallbackInfo
|
||||||
|
multiCarrierInfo = new CarrierTextManager.CarrierTextCallbackInfo(
|
||||||
|
"",
|
||||||
|
new CharSequence[]{"", ""},
|
||||||
|
true,
|
||||||
|
new int[]{0, 1},
|
||||||
|
false /* airplaneMode */);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(multiCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
mQSCarrierGroupController
|
||||||
|
.setOnSingleCarrierChangedListener(mOnSingleCarrierChangedListener);
|
||||||
|
|
||||||
|
mCallback.updateCarrierInfo(multiCarrierInfo);
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
verify(mOnSingleCarrierChangedListener, never()).onSingleCarrierChanged(anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class FakeSlotIndexResolver implements QSCarrierGroupController.SlotIndexResolver {
|
||||||
|
public boolean overrideInvalid;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotIndex(int subscriptionId) {
|
||||||
|
return overrideInvalid ? -1 : subscriptionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.qs.carrier;
|
package com.android.systemui.qs.carrier;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ import android.testing.AndroidTestingRunner;
|
|||||||
import android.testing.TestableLooper;
|
import android.testing.TestableLooper;
|
||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
@@ -64,25 +66,64 @@ public class QSCarrierTest extends SysuiTestCase {
|
|||||||
public void testUpdateState_first() {
|
public void testUpdateState_first() {
|
||||||
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
assertTrue(mQSCarrier.updateState(c));
|
assertTrue(mQSCarrier.updateState(c, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_same() {
|
public void testUpdateState_same() {
|
||||||
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
assertTrue(mQSCarrier.updateState(c));
|
assertTrue(mQSCarrier.updateState(c, false));
|
||||||
assertFalse(mQSCarrier.updateState(c));
|
assertFalse(mQSCarrier.updateState(c, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateState_changed() {
|
public void testUpdateState_changed() {
|
||||||
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
assertTrue(mQSCarrier.updateState(c));
|
assertTrue(mQSCarrier.updateState(c, false));
|
||||||
|
|
||||||
CellSignalState other = c.changeVisibility(false);
|
CellSignalState other = c.changeVisibility(false);
|
||||||
|
|
||||||
assertTrue(mQSCarrier.updateState(other));
|
assertTrue(mQSCarrier.updateState(other, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_singleCarrier_first() {
|
||||||
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
|
assertTrue(mQSCarrier.updateState(c, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_singleCarrier_noShowIcon() {
|
||||||
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
|
mQSCarrier.updateState(c, true);
|
||||||
|
|
||||||
|
assertEquals(View.GONE, mQSCarrier.getRSSIView().getVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_multiCarrier_showIcon() {
|
||||||
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
|
mQSCarrier.updateState(c, false);
|
||||||
|
|
||||||
|
assertEquals(View.VISIBLE, mQSCarrier.getRSSIView().getVisibility());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_changeSingleMultiSingle() {
|
||||||
|
CellSignalState c = new CellSignalState(true, mSignalIconId, "", "", false, false);
|
||||||
|
|
||||||
|
mQSCarrier.updateState(c, true);
|
||||||
|
assertEquals(View.GONE, mQSCarrier.getRSSIView().getVisibility());
|
||||||
|
|
||||||
|
mQSCarrier.updateState(c, false);
|
||||||
|
assertEquals(View.VISIBLE, mQSCarrier.getRSSIView().getVisibility());
|
||||||
|
|
||||||
|
mQSCarrier.updateState(c, true);
|
||||||
|
assertEquals(View.GONE, mQSCarrier.getRSSIView().getVisibility());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user