Merge "Show standalone icon R for roaming indication"

This commit is contained in:
TreeHugger Robot
2021-01-27 16:47:51 +00:00
committed by Android (Google) Code Review
17 changed files with 97 additions and 37 deletions

View File

@@ -0,0 +1,24 @@
<!--
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="@dimen/signal_icon_size"
android:height="@dimen/signal_icon_size"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M14.21,12.81c0.36,-0.16 0.69,-0.36 0.97,-0.61c0.41,-0.38 0.72,-0.83 0.94,-1.37c0.21,-0.54 0.32,-1.14 0.32,-1.79c0,-0.92 -0.16,-1.7 -0.49,-2.33c-0.32,-0.64 -0.79,-1.12 -1.43,-1.45c-0.62,-0.33 -1.4,-0.49 -2.32,-0.49H8.23V19h1.8v-5.76h2.5L15.06,19h1.92v-0.12L14.21,12.81zM10.03,11.71V6.32h2.18c0.59,0 1.06,0.11 1.42,0.34c0.36,0.22 0.62,0.54 0.78,0.95c0.16,0.41 0.24,0.89 0.24,1.44c0,0.49 -0.09,0.93 -0.27,1.34c-0.18,0.4 -0.46,0.73 -0.82,0.97c-0.36,0.23 -0.82,0.35 -1.37,0.35H10.03z"/>
</vector>

View File

@@ -77,4 +77,11 @@
android:contentDescription="@string/data_connection_roaming"
android:visibility="gone" />
</FrameLayout>
<ImageView
android:id="@+id/mobile_roaming_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/stat_sys_roaming_large"
android:contentDescription="@string/data_connection_roaming"
android:visibility="gone" />
</com.android.keyguard.AlphaOptimizedLinearLayout>

View File

@@ -85,6 +85,13 @@
android:contentDescription="@string/data_connection_roaming"
android:visibility="gone" />
</FrameLayout>
<ImageView
android:id="@+id/mobile_roaming_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/stat_sys_roaming_large"
android:contentDescription="@string/data_connection_roaming"
android:visibility="gone" />
</com.android.keyguard.AlphaOptimizedLinearLayout>
</com.android.systemui.statusbar.StatusBarMobileView>

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.FeatureFlagUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -65,10 +66,13 @@ public class QSCarrier extends LinearLayout {
super.onFinishInflate();
mDualToneHandler = new DualToneHandler(getContext());
mMobileGroup = findViewById(R.id.mobile_combo);
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
mMobileRoaming = findViewById(R.id.mobile_roaming_large);
} else {
mMobileRoaming = findViewById(R.id.mobile_roaming);
}
mMobileSignal = findViewById(R.id.mobile_signal);
mMobileRoaming = findViewById(R.id.mobile_roaming);
mCarrierText = findViewById(R.id.qs_carrier_text);
mMobileSignal.setImageDrawable(new SignalDrawable(mContext));
int colorForeground = Utils.getColorAttrDefaultColor(mContext,

View File

@@ -71,7 +71,7 @@ public class QSCarrierGroupController {
boolean activityIn, boolean activityOut,
CharSequence typeContentDescription,
CharSequence typeContentDescriptionHtml, CharSequence description,
boolean isWide, int subId, boolean roaming) {
boolean isWide, int subId, boolean roaming, boolean showTriangle) {
int slotIndex = getSlotIndex(subId);
if (slotIndex >= SIM_SLOTS) {
Log.w(TAG, "setMobileDataIndicators - slot: " + slotIndex);

View File

@@ -268,7 +268,7 @@ public class CellularTile extends QSTileImpl<SignalState> {
int qsType, boolean activityIn, boolean activityOut,
CharSequence typeContentDescription,
CharSequence typeContentDescriptionHtml, CharSequence description,
boolean isWide, int subId, boolean roaming) {
boolean isWide, int subId, boolean roaming, boolean showTriangle) {
if (qsIcon == null) {
// Not data sim, don't display.
return;

View File

@@ -249,7 +249,7 @@ public class InternetTile extends QSTileImpl<SignalState> {
int qsType, boolean activityIn, boolean activityOut,
CharSequence typeContentDescription,
CharSequence typeContentDescriptionHtml, CharSequence description,
boolean isWide, int subId, boolean roaming) {
boolean isWide, int subId, boolean roaming, boolean showTriangle) {
if (DEBUG) {
Log.d(TAG, "setMobileDataIndicators: "
+ "statusIcon = " + (statusIcon == null ? "" : statusIcon.toString()) + ","
@@ -263,7 +263,8 @@ public class InternetTile extends QSTileImpl<SignalState> {
+ "description = " + description + ","
+ "isWide = " + isWide + ","
+ "subId = " + subId + ","
+ "roaming = " + roaming);
+ "roaming = " + roaming + ","
+ "showTriangle = " + showTriangle);
}
if (qsIcon == null) {
// Not data sim, don't display.

View File

@@ -27,6 +27,7 @@ import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.FeatureFlagUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -64,7 +65,6 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
LayoutInflater inflater = LayoutInflater.from(context);
StatusBarMobileView v = (StatusBarMobileView)
inflater.inflate(R.layout.status_bar_mobile_signal_group, null);
v.setSlot(slot);
v.init();
v.setVisibleState(STATE_ICON);
@@ -104,7 +104,11 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
mMobileGroup = findViewById(R.id.mobile_group);
mMobile = findViewById(R.id.mobile_signal);
mMobileType = findViewById(R.id.mobile_type);
mMobileRoaming = findViewById(R.id.mobile_roaming);
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
mMobileRoaming = findViewById(R.id.mobile_roaming_large);
} else {
mMobileRoaming = findViewById(R.id.mobile_roaming);
}
mMobileRoamingSpace = findViewById(R.id.mobile_roaming_space);
mIn = findViewById(R.id.mobile_in);
mOut = findViewById(R.id.mobile_out);
@@ -160,7 +164,7 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
} else {
mMobileType.setVisibility(View.GONE);
}
mMobile.setVisibility(mState.showTriangle ? View.VISIBLE : View.GONE);
mMobileRoaming.setVisibility(mState.roaming ? View.VISIBLE : View.GONE);
mMobileRoamingSpace.setVisibility(mState.roaming ? View.VISIBLE : View.GONE);
mIn.setVisibility(mState.activityIn ? View.VISIBLE : View.GONE);
@@ -191,6 +195,7 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
}
}
mMobile.setVisibility(state.showTriangle ? View.VISIBLE : View.GONE);
mMobileRoaming.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
mMobileRoamingSpace.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
mIn.setVisibility(state.activityIn ? View.VISIBLE : View.GONE);
@@ -200,7 +205,8 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
needsLayout |= state.roaming != mState.roaming
|| state.activityIn != mState.activityIn
|| state.activityOut != mState.activityOut;
|| state.activityOut != mState.activityOut
|| state.showTriangle != mState.showTriangle;
mState = state;
return needsLayout;

View File

@@ -221,7 +221,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
int qsType, boolean activityIn, boolean activityOut,
CharSequence typeContentDescription,
CharSequence typeContentDescriptionHtml, CharSequence description,
boolean isWide, int subId, boolean roaming) {
boolean isWide, int subId, boolean roaming, boolean showTriangle) {
if (DEBUG) {
Log.d(TAG, "setMobileDataIndicators: "
+ "statusIcon = " + (statusIcon == null ? "" : statusIcon.toString()) + ","
@@ -235,7 +235,8 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
+ "description = " + description + ","
+ "isWide = " + isWide + ","
+ "subId = " + subId + ","
+ "roaming = " + roaming);
+ "roaming = " + roaming + ","
+ "showTriangle = " + showTriangle);
}
MobileIconState state = getState(subId);
if (state == null) {
@@ -250,6 +251,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
state.typeId = statusType;
state.contentDescription = statusIcon.contentDescription;
state.typeContentDescription = typeContentDescription;
state.showTriangle = showTriangle;
state.roaming = roaming;
state.activityIn = activityIn && mActivityEnabled;
state.activityOut = activityOut && mActivityEnabled;
@@ -551,6 +553,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
public int subId;
public int strengthId;
public int typeId;
public boolean showTriangle;
public boolean roaming;
public boolean needsLeadingPadding;
public CharSequence typeContentDescription;
@@ -569,20 +572,21 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
return false;
}
MobileIconState that = (MobileIconState) o;
return subId == that.subId &&
strengthId == that.strengthId &&
typeId == that.typeId &&
roaming == that.roaming &&
needsLeadingPadding == that.needsLeadingPadding &&
Objects.equals(typeContentDescription, that.typeContentDescription);
return subId == that.subId
&& strengthId == that.strengthId
&& typeId == that.typeId
&& showTriangle == that.showTriangle
&& roaming == that.roaming
&& needsLeadingPadding == that.needsLeadingPadding
&& Objects.equals(typeContentDescription, that.typeContentDescription);
}
@Override
public int hashCode() {
return Objects
.hash(super.hashCode(), subId, strengthId, typeId, roaming, needsLeadingPadding,
typeContentDescription);
.hash(super.hashCode(), subId, strengthId, typeId, showTriangle, roaming,
needsLeadingPadding, typeContentDescription);
}
public MobileIconState copy() {
@@ -596,6 +600,7 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
other.subId = subId;
other.strengthId = strengthId;
other.typeId = typeId;
other.showTriangle = showTriangle;
other.roaming = roaming;
other.needsLeadingPadding = needsLeadingPadding;
other.typeContentDescription = typeContentDescription;
@@ -613,8 +618,9 @@ public class StatusBarSignalPolicy implements NetworkControllerImpl.SignalCallba
}
@Override public String toString() {
return "MobileIconState(subId=" + subId + ", strengthId=" + strengthId + ", roaming="
+ roaming + ", typeId=" + typeId + ", visible=" + visible + ")";
return "MobileIconState(subId=" + subId + ", strengthId=" + strengthId
+ ", showTriangle=" + showTriangle + ", roaming=" + roaming
+ ", typeId=" + typeId + ", visible=" + visible + ")";
}
}
}

View File

@@ -124,12 +124,13 @@ public class CallbackHandler extends Handler implements EmergencyListener, Signa
final int statusType, final int qsType, final boolean activityIn,
final boolean activityOut, final CharSequence typeContentDescription,
CharSequence typeContentDescriptionHtml, final CharSequence description,
final boolean isWide, final int subId, boolean roaming) {
final boolean isWide, final int subId, boolean roaming, boolean showTriangle) {
post(() -> {
for (SignalCallback signalCluster : mSignalCallbacks) {
signalCluster.setMobileDataIndicators(statusIcon, qsIcon, statusType, qsType,
activityIn, activityOut, typeContentDescription,
typeContentDescriptionHtml, description, isWide, subId, roaming);
typeContentDescriptionHtml, description, isWide, subId, roaming,
showTriangle);
}
});
}

View File

@@ -284,13 +284,15 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
&& !mCurrentState.carrierNetworkChangeMode
&& mCurrentState.activityOut;
showDataIcon &= mCurrentState.dataSim && mCurrentState.isDefault;
boolean showTriangle = showDataIcon && !mCurrentState.airplaneMode;
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
showDataIcon |= mCurrentState.roaming;
IconState statusIcon = new IconState(showDataIcon && !mCurrentState.airplaneMode,
getCurrentIconId(), contentDescription);
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
activityIn, activityOut, dataContentDescription, dataContentDescriptionHtml,
description, icons.isWide, mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming);
mCurrentState.roaming, showTriangle);
} else {
boolean showDataIcon = mCurrentState.dataConnected || dataDisabled;
IconState statusIcon = new IconState(
@@ -316,10 +318,11 @@ public class MobileSignalController extends SignalController<MobileState, Mobile
&& mCurrentState.activityOut;
showDataIcon &= mCurrentState.isDefault || dataDisabled;
int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.dataType : 0;
boolean showTriangle = mCurrentState.enabled && !mCurrentState.airplaneMode;
callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
activityIn, activityOut, dataContentDescription, dataContentDescriptionHtml,
description, icons.isWide, mSubscriptionInfo.getSubscriptionId(),
mCurrentState.roaming);
mCurrentState.roaming, showTriangle);
}
}

View File

@@ -66,12 +66,13 @@ public interface NetworkController extends CallbackController<SignalCallback>, D
* @param isWide //TODO: unused?
* @param subId subscription ID for which to update the UI
* @param roaming indicates roaming
* @param showTriangle whether to show the mobile triangle the in status bar
*/
default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
int qsType, boolean activityIn, boolean activityOut,
CharSequence typeContentDescription,
CharSequence typeContentDescriptionHtml, CharSequence description,
boolean isWide, int subId, boolean roaming) {
boolean isWide, int subId, boolean roaming, boolean showTriangle) {
}
default void setSubs(List<SubscriptionInfo> subs) {}

View File

@@ -150,7 +150,7 @@ public class WifiSignalController extends
callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, qsTypeIcon,
mCurrentState.activityIn, mCurrentState.activityOut, dataContentDescription,
dataContentDescriptionHtml, description, icons.isWide,
mCurrentState.subId, /* roaming= */ false);
mCurrentState.subId, /* roaming= */ false, /* showTriangle= */ true);
}
private int getCurrentIconIdForCarrierWifi() {

View File

@@ -218,7 +218,7 @@ public class QSCarrierGroupControllerTest extends LeakCheckedTest {
mSignalCallback.setMobileDataIndicators(
mock(NetworkController.IconState.class),
mock(NetworkController.IconState.class),
0, 0, true, true, "", "", "", true, 0, true);
0, 0, true, true, "", "", "", true, 0, true, true);
}
@Test

View File

@@ -125,7 +125,7 @@ public class CallbackHandlerTest extends SysuiTestCase {
int subId = 5;
boolean roaming = true;
mHandler.setMobileDataIndicators(status, qs, type, qsType, in, out, typeDescription,
typeDescriptionHtml, description, wide, subId, roaming);
typeDescriptionHtml, description, wide, subId, roaming, true);
waitForCallbacks();
ArgumentCaptor<IconState> statusArg = ArgumentCaptor.forClass(IconState.class);
@@ -143,7 +143,7 @@ public class CallbackHandlerTest extends SysuiTestCase {
Mockito.verify(mSignalCallback).setMobileDataIndicators(statusArg.capture(),
qsArg.capture(), typeIconArg.capture(), qsTypeIconArg.capture(), inArg.capture(),
outArg.capture(), typeContentArg.capture(), typeContentHtmlArg.capture(),
descArg.capture(), wideArg.capture(), subIdArg.capture(), eq(roaming));
descArg.capture(), wideArg.capture(), subIdArg.capture(), eq(roaming), eq(true));
assertEquals(status, statusArg.getValue());
assertEquals(qs, qsArg.getValue());
assertEquals(type, (int) typeIconArg.getValue());

View File

@@ -489,7 +489,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
anyInt(),
typeIconArg.capture(), dataInArg.capture(), dataOutArg.capture(),
any(CharSequence.class), any(CharSequence.class), any(CharSequence.class),
anyBoolean(), anyInt(), anyBoolean());
anyBoolean(), anyInt(), anyBoolean(), anyBoolean());
IconState iconState = iconArg.getValue();
int state = SignalDrawable.getState(icon, CellSignalStrength.getNumSignalStrengthLevels(),
false);
@@ -523,7 +523,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
typeIconArg.capture(),
anyInt(), anyBoolean(), anyBoolean(),
any(CharSequence.class), any(CharSequence.class), any(),
anyBoolean(), anyInt(), eq(roaming));
anyBoolean(), anyInt(), eq(roaming), anyBoolean());
IconState iconState = iconArg.getValue();
int state = icon == -1 ? 0
: SignalDrawable.getState(icon, CellSignalStrength.getNumSignalStrengthLevels(),
@@ -544,7 +544,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
typeIconArg.capture(),
anyInt(), anyBoolean(), anyBoolean(),
any(CharSequence.class), any(CharSequence.class), any(),
anyBoolean(), anyInt(), anyBoolean());
anyBoolean(), anyInt(), anyBoolean(), anyBoolean());
IconState iconState = iconArg.getValue();
int state = SignalDrawable.getState(
level, CellSignalStrength.getNumSignalStrengthLevels(), !inet);
@@ -591,7 +591,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
dataOutArg.capture(),
typeContentDescriptionArg.capture(),
typeContentDescriptionHtmlArg.capture(),
any(), anyBoolean(), anyInt(), anyBoolean());
any(), anyBoolean(), anyInt(), anyBoolean(), anyBoolean());
IconState iconState = iconArg.getValue();

View File

@@ -134,7 +134,7 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
// Still be on wifi though.
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_WIFI, true, true);
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false);
verifyLastMobileDataIndicators(false, DEFAULT_LEVEL, 0, true);
verifyLastMobileDataIndicators(true, DEFAULT_LEVEL, 0, true);
}
@Test