Merge "For 1 sim devices, hide signal empty state" into qt-r1-dev

am: 805c23ac9a

Change-Id: I22b5e4370b5e95ae1b82bb2764f8c3bc0652cb6c
This commit is contained in:
Amin Shaikh
2019-05-27 01:21:35 -07:00
committed by android-build-merger
2 changed files with 20 additions and 6 deletions

View File

@@ -60,6 +60,7 @@ public class SignalDrawable extends DrawableWrapper {
private static final int NUM_LEVEL_MASK = 0xff << NUM_LEVEL_SHIFT;
private static final int STATE_SHIFT = 16;
private static final int STATE_MASK = 0xff << STATE_SHIFT;
private static final int STATE_EMPTY = 1;
private static final int STATE_CUT = 2;
private static final int STATE_CARRIER_CHANGE = 3;
@@ -203,7 +204,7 @@ public class SignalDrawable extends DrawableWrapper {
drawDotAndPadding(x - dotSpacing * 2, y, dotPadding, dotSize, 0);
canvas.drawPath(mCutoutPath, mTransparentPaint);
canvas.drawPath(mForegroundPath, mForegroundPaint);
} else if (isInState(STATE_CUT)) {
} else if (isInState(STATE_CUT) || isInState(STATE_EMPTY)) {
float cut = (CUT_OUT * width);
mCutoutPath.moveTo(width - padding, height - padding);
mCutoutPath.rLineTo(-cut, 0);
@@ -268,13 +269,14 @@ public class SignalDrawable extends DrawableWrapper {
/**
* Returns whether this drawable is in the specified state.
*
* @param state must be one of {@link #STATE_CARRIER_CHANGE} or {@link #STATE_CUT}
* @param state must be one of {@link #STATE_CARRIER_CHANGE}, {@link #STATE_CUT},
* or {@link #STATE_EMPTY}.
*/
private boolean isInState(int state) {
return getState(getLevel()) == state;
}
public static int getState(int fullState) {
private static int getState(int fullState) {
return (fullState & STATE_MASK) >> STATE_SHIFT;
}
@@ -286,7 +288,12 @@ public class SignalDrawable extends DrawableWrapper {
/** Returns the state representing empty mobile signal with the given number of levels. */
public static int getEmptyState(int numLevels) {
return getState(0, numLevels, true);
return (STATE_EMPTY << STATE_SHIFT) | (numLevels << NUM_LEVEL_SHIFT);
}
/** Returns whether fullState corresponds to the empty state. */
public static boolean isEmptyState(int fullState) {
return getState(fullState) == STATE_EMPTY;
}
/** Returns the state representing carrier change with the given number of levels. */

View File

@@ -22,6 +22,7 @@ import android.telephony.SubscriptionInfo;
import android.util.ArraySet;
import android.util.Log;
import com.android.settingslib.graph.SignalDrawable;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkController;
@@ -186,8 +187,8 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
// Visibility of the data type indicator changed
boolean typeChanged = statusType != state.typeId && (statusType == 0 || state.typeId == 0);
state.visible = statusIcon.visible && !mBlockMobile;
state.visible = statusIcon.visible && !mBlockMobile
&& !isInEmptyStateOnSingleSimDevice(subId, statusIcon.icon);
state.strengthId = statusIcon.icon;
state.typeId = statusType;
state.contentDescription = statusIcon.contentDescription;
@@ -209,6 +210,12 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
}
}
private boolean isInEmptyStateOnSingleSimDevice(int subId, int icon) {
return mMobileStates.size() == 1
&& mMobileStates.get(0).subId == subId
&& SignalDrawable.isEmptyState(icon);
}
private MobileIconState getState(int subId) {
for (MobileIconState state : mMobileStates) {
if (state.subId == subId) {