Merge "Show status labels in wifi QS tile." into pi-dev
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 24a6804..584fc34 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -97,6 +97,12 @@
<!-- Summary for Connected wifi network without internet -->
<string name="wifi_connected_no_internet">Connected, no internet</string>
+ <!-- Wi-Fi status indicating that the current network is connected, but has no internet access. -->
+ <string name="wifi_status_no_internet">No internet</string>
+
+ <!-- Wi-Fi status indicating that the current network is connected requires sign in to access the internet. -->
+ <string name="wifi_status_sign_in_required">Sign in required</string>
+
<!-- Summary for networks failing to connect due to association rejection status 17, AP full -->
<string name="wifi_ap_unable_to_handle_new_sta">Access point temporarily full</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index c5c1169..78045f9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -1154,7 +1154,7 @@
@Nullable
@Speed
- private int roundToClosestSpeedEnum(int speed) {
+ private static int roundToClosestSpeedEnum(int speed) {
if (speed < Speed.SLOW) {
return Speed.NONE;
} else if (speed < (Speed.SLOW + Speed.MODERATE) / 2) {
@@ -1170,21 +1170,31 @@
@Nullable
String getSpeedLabel(@Speed int speed) {
+ return getSpeedLabel(mContext, speed);
+ }
+
+ private static String getSpeedLabel(Context context, int speed) {
switch (speed) {
case Speed.VERY_FAST:
- return mContext.getString(R.string.speed_label_very_fast);
+ return context.getString(R.string.speed_label_very_fast);
case Speed.FAST:
- return mContext.getString(R.string.speed_label_fast);
+ return context.getString(R.string.speed_label_fast);
case Speed.MODERATE:
- return mContext.getString(R.string.speed_label_okay);
+ return context.getString(R.string.speed_label_okay);
case Speed.SLOW:
- return mContext.getString(R.string.speed_label_slow);
+ return context.getString(R.string.speed_label_slow);
case Speed.NONE:
default:
return null;
}
}
+ /** Return the speed label for a {@link ScoredNetwork} at the specified {@code rssi} level. */
+ @Nullable
+ public static String getSpeedLabel(Context context, ScoredNetwork scoredNetwork, int rssi) {
+ return getSpeedLabel(context, roundToClosestSpeedEnum(scoredNetwork.calculateBadge(rssi)));
+ }
+
/** Return true if the current RSSI is reachable, and false otherwise. */
public boolean isReachable() {
return mRssi != UNREACHABLE_RSSI;
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
index 6e12e20..4cd23f9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiStatusTracker.java
@@ -10,28 +10,90 @@
package com.android.settingslib.wifi;
+import static android.net.NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL;
+import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
+
+import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
+import android.net.NetworkKey;
+import android.net.NetworkRequest;
+import android.net.NetworkScoreManager;
+import android.net.ScoredNetwork;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
+import android.net.wifi.WifiNetworkScoreCache;
import android.net.wifi.WifiSsid;
+import android.os.Handler;
+import android.os.Looper;
+
+import com.android.settingslib.R;
import java.util.List;
-public class WifiStatusTracker {
-
+public class WifiStatusTracker extends ConnectivityManager.NetworkCallback {
+ private final Context mContext;
+ private final WifiNetworkScoreCache mWifiNetworkScoreCache;
private final WifiManager mWifiManager;
+ private final NetworkScoreManager mNetworkScoreManager;
+ private final ConnectivityManager mConnectivityManager;
+ private final WifiNetworkScoreCache.CacheListener mCacheListener =
+ new WifiNetworkScoreCache.CacheListener(new Handler(Looper.getMainLooper())) {
+ @Override
+ public void networkCacheUpdated(List<ScoredNetwork> updatedNetworks) {
+ updateStatusLabel();
+ mCallback.run();
+ }
+ };
+ private final NetworkRequest mNetworkRequest = new NetworkRequest.Builder()
+ .clearCapabilities().addTransportType(NetworkCapabilities.TRANSPORT_WIFI).build();
+ private final ConnectivityManager.NetworkCallback mNetworkCallback = new ConnectivityManager
+ .NetworkCallback() {
+ @Override
+ public void onCapabilitiesChanged(
+ Network network, NetworkCapabilities networkCapabilities) {
+ updateStatusLabel();
+ mCallback.run();
+ }
+ };
+ private final Runnable mCallback;
+
+ private WifiInfo mWifiInfo;
public boolean enabled;
public int state;
public boolean connected;
- public boolean connecting;
public String ssid;
public int rssi;
public int level;
+ public String statusLabel;
- public WifiStatusTracker(WifiManager wifiManager) {
+ public WifiStatusTracker(Context context, WifiManager wifiManager,
+ NetworkScoreManager networkScoreManager, ConnectivityManager connectivityManager,
+ Runnable callback) {
+ mContext = context;
mWifiManager = wifiManager;
+ mWifiNetworkScoreCache = new WifiNetworkScoreCache(context);
+ mNetworkScoreManager = networkScoreManager;
+ mConnectivityManager = connectivityManager;
+ mCallback = callback;
+ }
+
+ public void setListening(boolean listening) {
+ if (listening) {
+ mNetworkScoreManager.registerNetworkScoreCache(NetworkKey.TYPE_WIFI,
+ mWifiNetworkScoreCache, NetworkScoreManager.CACHE_FILTER_CURRENT_NETWORK);
+ mWifiNetworkScoreCache.registerListener(mCacheListener);
+ mConnectivityManager.registerNetworkCallback(mNetworkRequest, mNetworkCallback);
+ } else {
+ mNetworkScoreManager.unregisterNetworkScoreCache(NetworkKey.TYPE_WIFI,
+ mWifiNetworkScoreCache);
+ mWifiNetworkScoreCache.unregisterListener();
+ mConnectivityManager.unregisterNetworkCallback(mNetworkCallback);
+ }
}
public void handleBroadcast(Intent intent) {
@@ -40,34 +102,59 @@
state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
WifiManager.WIFI_STATE_UNKNOWN);
enabled = state == WifiManager.WIFI_STATE_ENABLED;
-
-
- enabled = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
- WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_ENABLED;
} else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
- final NetworkInfo networkInfo = (NetworkInfo)
+ final NetworkInfo networkInfo =
intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
- connecting = networkInfo != null && !networkInfo.isConnected()
- && networkInfo.isConnectedOrConnecting();
connected = networkInfo != null && networkInfo.isConnected();
- // If Connected grab the signal strength and ssid.
+ mWifiInfo = null;
+ ssid = null;
if (connected) {
- WifiInfo info = mWifiManager.getConnectionInfo();
- if (info != null) {
- ssid = getValidSsid(info);
- } else {
- ssid = null;
+ mWifiInfo = mWifiManager.getConnectionInfo();
+ if (mWifiInfo != null) {
+ ssid = getValidSsid(mWifiInfo);
+ updateRssi(mWifiInfo.getRssi());
+ maybeRequestNetworkScore();
}
- } else if (!connected) {
- ssid = null;
}
+ updateStatusLabel();
} else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) {
// Default to -200 as its below WifiManager.MIN_RSSI.
- rssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200);
- level = WifiManager.calculateSignalLevel(rssi, 5);
+ updateRssi(intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200));
+ updateStatusLabel();
}
}
+ private void updateRssi(int newRssi) {
+ rssi = newRssi;
+ level = WifiManager.calculateSignalLevel(rssi, WifiManager.RSSI_LEVELS);
+ }
+
+ private void maybeRequestNetworkScore() {
+ NetworkKey networkKey = NetworkKey.createFromWifiInfo(mWifiInfo);
+ if (mWifiNetworkScoreCache.getScoredNetwork(networkKey) == null) {
+ mNetworkScoreManager.requestScores(new NetworkKey[]{ networkKey });
+ }
+ }
+
+ private void updateStatusLabel() {
+ final NetworkCapabilities networkCapabilities
+ = mConnectivityManager.getNetworkCapabilities(mWifiManager.getCurrentNetwork());
+ if (networkCapabilities != null) {
+ if (networkCapabilities.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL)) {
+ statusLabel = mContext.getString(R.string.wifi_status_sign_in_required);
+ return;
+ } else if (!networkCapabilities.hasCapability(NET_CAPABILITY_VALIDATED)) {
+ statusLabel = mContext.getString(R.string.wifi_status_no_internet);
+ return;
+ }
+ }
+
+ ScoredNetwork scoredNetwork =
+ mWifiNetworkScoreCache.getScoredNetwork(NetworkKey.createFromWifiInfo(mWifiInfo));
+ statusLabel = scoredNetwork == null
+ ? null : AccessPoint.getSpeedLabel(mContext, scoredNetwork, rssi);
+ }
+
private String getValidSsid(WifiInfo info) {
String ssid = info.getSSID();
if (ssid != null && !WifiSsid.NONE.equals(ssid)) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 28fdc11..8a1e4da 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -150,8 +150,8 @@
cb = mSignalCallback.mInfo;
}
boolean transientEnabling = arg == ARG_SHOW_TRANSIENT_ENABLING;
- boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null);
- boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.enabledDesc == null);
+ boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.ssid != null);
+ boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.ssid == null);
boolean enabledChanging = state.value != cb.enabled;
if (enabledChanging) {
mDetailAdapter.setItemsVisible(cb.enabled);
@@ -163,7 +163,7 @@
}
state.slash.isSlashed = false;
boolean isTransient = transientEnabling || cb.isTransient;
- state.secondaryLabel = getSecondaryLabel(isTransient);
+ state.secondaryLabel = getSecondaryLabel(isTransient, cb.statusLabel);
state.state = Tile.STATE_ACTIVE;
state.dualTarget = true;
state.value = transientEnabling || cb.enabled;
@@ -181,7 +181,7 @@
state.label = r.getString(R.string.quick_settings_wifi_label);
} else if (wifiConnected) {
state.icon = ResourceIcon.get(cb.wifiSignalIconId);
- state.label = removeDoubleQuotes(cb.enabledDesc);
+ state.label = removeDoubleQuotes(cb.ssid);
} else if (wifiNotConnected) {
state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_disconnected);
state.label = r.getString(R.string.quick_settings_wifi_label);
@@ -194,7 +194,7 @@
if (state.value) {
if (wifiConnected) {
minimalContentDescription.append(cb.wifiSignalContentDescription).append(",");
- minimalContentDescription.append(removeDoubleQuotes(cb.enabledDesc));
+ minimalContentDescription.append(removeDoubleQuotes(cb.ssid));
}
}
state.contentDescription = minimalContentDescription.toString();
@@ -203,10 +203,10 @@
state.expandedAccessibilityClassName = Switch.class.getName();
}
- private CharSequence getSecondaryLabel(boolean isTransient) {
+ private CharSequence getSecondaryLabel(boolean isTransient, String statusLabel) {
return isTransient
? mContext.getString(R.string.quick_settings_wifi_secondary_label_transient)
- : null;
+ : statusLabel;
}
@Override
@@ -246,11 +246,12 @@
boolean enabled;
boolean connected;
int wifiSignalIconId;
- String enabledDesc;
+ String ssid;
boolean activityIn;
boolean activityOut;
String wifiSignalContentDescription;
boolean isTransient;
+ public String statusLabel;
@Override
public String toString() {
@@ -258,7 +259,7 @@
.append("enabled=").append(enabled)
.append(",connected=").append(connected)
.append(",wifiSignalIconId=").append(wifiSignalIconId)
- .append(",enabledDesc=").append(enabledDesc)
+ .append(",ssid=").append(ssid)
.append(",activityIn=").append(activityIn)
.append(",activityOut=").append(activityOut)
.append(",wifiSignalContentDescription=").append(wifiSignalContentDescription)
@@ -272,16 +273,18 @@
@Override
public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
- boolean activityIn, boolean activityOut, String description, boolean isTransient) {
+ boolean activityIn, boolean activityOut, String description, boolean isTransient,
+ String statusLabel) {
if (DEBUG) Log.d(TAG, "onWifiSignalChanged enabled=" + enabled);
mInfo.enabled = enabled;
mInfo.connected = qsIcon.visible;
mInfo.wifiSignalIconId = qsIcon.icon;
- mInfo.enabledDesc = description;
+ mInfo.ssid = description;
mInfo.activityIn = activityIn;
mInfo.activityOut = activityOut;
mInfo.wifiSignalContentDescription = qsIcon.contentDescription;
mInfo.isTransient = isTransient;
+ mInfo.statusLabel = statusLabel;
if (isShowingDetail()) {
mDetailAdapter.updateItems();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 3cf7741..e7b768f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -55,7 +55,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Objects;
// Intimately tied to the design of res/layout/signal_cluster_view.xml
public class SignalClusterView extends LinearLayout implements NetworkControllerImpl.SignalCallback,
@@ -277,7 +276,8 @@
@Override
public void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
- boolean activityIn, boolean activityOut, String description, boolean isTransient) {
+ boolean activityIn, boolean activityOut, String description, boolean isTransient,
+ String secondaryLabel) {
mWifiVisible = statusIcon.visible && !mBlockWifi;
mWifiStrengthId = statusIcon.icon;
mWifiDescription = statusIcon.contentDescription;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
index 5159e8d..b76d536 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/CallbackHandler.java
@@ -109,13 +109,13 @@
@Override
public void setWifiIndicators(final boolean enabled, final IconState statusIcon,
final IconState qsIcon, final boolean activityIn, final boolean activityOut,
- final String description, boolean isTransient) {
+ final String description, boolean isTransient, String secondaryLabel) {
post(new Runnable() {
@Override
public void run() {
for (SignalCallback callback : mSignalCallbacks) {
callback.setWifiIndicators(enabled, statusIcon, qsIcon, activityIn, activityOut,
- description, isTransient);
+ description, isTransient, secondaryLabel);
}
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 76e3ad7..51fef7d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -47,7 +47,8 @@
public interface SignalCallback {
default void setWifiIndicators(boolean enabled, IconState statusIcon, IconState qsIcon,
- boolean activityIn, boolean activityOut, String description, boolean isTransient) {}
+ boolean activityIn, boolean activityOut, String description, boolean isTransient,
+ String statusLabel) {}
default void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
index 0f65421..e5e576d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
@@ -17,12 +17,15 @@
import android.content.Context;
import android.content.Intent;
+import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
+import android.net.NetworkScoreManager;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
@@ -37,7 +40,6 @@
public class WifiSignalController extends
SignalController<WifiSignalController.WifiState, SignalController.IconGroup> {
- private final WifiManager mWifiManager;
private final AsyncChannel mWifiChannel;
private final boolean mHasMobileData;
private final WifiStatusTracker mWifiTracker;
@@ -47,12 +49,17 @@
WifiManager wifiManager) {
super("WifiSignalController", context, NetworkCapabilities.TRANSPORT_WIFI,
callbackHandler, networkController);
- mWifiManager = wifiManager;
- mWifiTracker = new WifiStatusTracker(mWifiManager);
+ NetworkScoreManager networkScoreManager =
+ context.getSystemService(NetworkScoreManager.class);
+ ConnectivityManager connectivityManager =
+ context.getSystemService(ConnectivityManager.class);
+ mWifiTracker = new WifiStatusTracker(mContext, wifiManager, networkScoreManager,
+ connectivityManager, this::handleStatusUpdated);
+ mWifiTracker.setListening(true);
mHasMobileData = hasMobileData;
Handler handler = new WifiHandler(Looper.getMainLooper());
mWifiChannel = new AsyncChannel();
- Messenger wifiMessenger = mWifiManager.getWifiServiceMessenger();
+ Messenger wifiMessenger = wifiManager.getWifiServiceMessenger();
if (wifiMessenger != null) {
mWifiChannel.connect(context, handler, wifiMessenger);
}
@@ -68,7 +75,6 @@
WifiIcons.QS_WIFI_NO_NETWORK,
AccessibilityContentDescriptions.WIFI_NO_CONNECTION
);
-
}
@Override
@@ -87,13 +93,12 @@
if (mCurrentState.inetCondition == 0) {
contentDescription += ("," + mContext.getString(R.string.data_connection_no_internet));
}
-
IconState statusIcon = new IconState(wifiVisible, getCurrentIconId(), contentDescription);
IconState qsIcon = new IconState(mCurrentState.connected, getQsCurrentIconId(),
contentDescription);
callback.setWifiIndicators(mCurrentState.enabled, statusIcon, qsIcon,
ssidPresent && mCurrentState.activityIn, ssidPresent && mCurrentState.activityOut,
- wifiDesc, mCurrentState.isTransient);
+ wifiDesc, mCurrentState.isTransient, mCurrentState.statusLabel);
}
/**
@@ -106,6 +111,12 @@
mCurrentState.ssid = mWifiTracker.ssid;
mCurrentState.rssi = mWifiTracker.rssi;
mCurrentState.level = mWifiTracker.level;
+ mCurrentState.statusLabel = mWifiTracker.statusLabel;
+ notifyListenersIfNecessary();
+ }
+
+ private void handleStatusUpdated() {
+ mCurrentState.statusLabel = mWifiTracker.statusLabel;
notifyListenersIfNecessary();
}
@@ -150,6 +161,7 @@
static class WifiState extends SignalController.State {
String ssid;
boolean isTransient;
+ String statusLabel;
@Override
public void copyFrom(State s) {
@@ -157,20 +169,26 @@
WifiState state = (WifiState) s;
ssid = state.ssid;
isTransient = state.isTransient;
+ statusLabel = state.statusLabel;
}
@Override
protected void toString(StringBuilder builder) {
super.toString(builder);
- builder.append(',').append("ssid=").append(ssid);
- builder.append(',').append("isTransient=").append(isTransient);
+ builder.append(",ssid=").append(ssid)
+ .append(",isTransient=").append(isTransient)
+ .append(",statusLabel=").append(statusLabel);
}
@Override
public boolean equals(Object o) {
- return super.equals(o)
- && Objects.equals(((WifiState) o).ssid, ssid)
- && (((WifiState) o).isTransient == isTransient);
+ if (!super.equals(o)) {
+ return false;
+ }
+ WifiState other = (WifiState) o;
+ return Objects.equals(other.ssid, ssid)
+ && other.isTransient == isTransient
+ && TextUtils.equals(other.statusLabel, statusLabel);
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
index 2afb48c..ed0f9ab 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
@@ -18,7 +18,6 @@
import android.os.HandlerThread;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.SubscriptionInfo;
-import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
@@ -81,7 +80,8 @@
boolean in = true;
boolean out = true;
String description = "Test";
- mHandler.setWifiIndicators(enabled, status, qs, in, out, description, true);
+ String secondaryLabel = "Secondary label";
+ mHandler.setWifiIndicators(enabled, status, qs, in, out, description, true, secondaryLabel);
waitForCallbacks();
ArgumentCaptor<Boolean> enableArg = ArgumentCaptor.forClass(Boolean.class);
@@ -91,9 +91,10 @@
ArgumentCaptor<Boolean> outArg = ArgumentCaptor.forClass(Boolean.class);
ArgumentCaptor<String> descArg = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Boolean> isTransient = ArgumentCaptor.forClass(Boolean.class);
+ ArgumentCaptor<String> secondary = ArgumentCaptor.forClass(String.class);
Mockito.verify(mSignalCallback).setWifiIndicators(enableArg.capture(),
statusArg.capture(), qsArg.capture(), inArg.capture(), outArg.capture(),
- descArg.capture(), isTransient.capture());
+ descArg.capture(), isTransient.capture(), secondary.capture());
assertEquals(enabled, (boolean) enableArg.getValue());
assertEquals(status, statusArg.getValue());
assertEquals(qs, qsArg.getValue());
@@ -101,6 +102,7 @@
assertEquals(out, (boolean) outArg.getValue());
assertEquals(description, descArg.getValue());
assertTrue(isTransient.getValue());
+ assertEquals(secondaryLabel, secondary.getValue());
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
index fc3de84..d30e777 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerWifiTest.java
@@ -5,8 +5,6 @@
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.net.wifi.WifiSsid;
-import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
@@ -20,6 +18,7 @@
import static junit.framework.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.when;
@@ -39,6 +38,7 @@
verifyLastWifiIcon(false, WifiIcons.WIFI_NO_NETWORK);
setWifiState(true, testSsid);
+ setWifiLevel(0);
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[0][0]);
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
@@ -160,7 +160,8 @@
ArgumentCaptor<Boolean> outArg = ArgumentCaptor.forClass(Boolean.class);
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
- anyBoolean(), any(), any(), inArg.capture(), outArg.capture(), any(), anyBoolean());
+ anyBoolean(), any(), any(), inArg.capture(), outArg.capture(), any(), anyBoolean(),
+ any());
assertEquals("WiFi data in, in quick settings", in, (boolean) inArg.getValue());
assertEquals("WiFi data out, in quick settings", out, (boolean) outArg.getValue());
}
@@ -173,7 +174,7 @@
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
enabledArg.capture(), any(), iconArg.capture(), anyBoolean(),
- anyBoolean(), descArg.capture(), anyBoolean());
+ anyBoolean(), descArg.capture(), anyBoolean(), any());
IconState iconState = iconArg.getValue();
assertEquals("WiFi enabled, in quick settings", enabled, (boolean) enabledArg.getValue());
assertEquals("WiFi connected, in quick settings", connected, iconState.visible);
@@ -186,7 +187,7 @@
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setWifiIndicators(
anyBoolean(), iconArg.capture(), any(), anyBoolean(), anyBoolean(),
- any(), anyBoolean());
+ any(), anyBoolean(), any());
IconState iconState = iconArg.getValue();
assertEquals("WiFi visible, in status bar", visible, iconState.visible);
assertEquals("WiFi signal, in status bar", icon, iconState.icon);