SysUI: Refactor the NetworkControllerImpl

Minimal changes to interface/callbacks, all of the changes are
internal and prepare for MSIM.

Separate out AccessPoint and MobileData from the NetworkController
interface to give some space.

A SignalController class has been created as a base for both
WifiSignalController and MobileSignalController, both of which
internally handle the state of their respective connectivity and
only reach up into the NetworkControllerImpl when completely
necessary (such as for combined carrier label).

Bug: 18222975
Change-Id: I75b954bbece187371cdb8571dd8420e7d2cad978
This commit is contained in:
Jason Monk
2014-11-10 14:22:56 -05:00
parent b30d902ed4
commit d2263cd9db
17 changed files with 1482 additions and 1446 deletions

View File

@@ -29,7 +29,8 @@ import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QSTileView;
import com.android.systemui.qs.SignalTileView;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.DataUsageInfo;
import com.android.systemui.statusbar.policy.NetworkController.MobileDataController;
import com.android.systemui.statusbar.policy.NetworkController.MobileDataController.DataUsageInfo;
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
/** Quick settings tile: Cellular **/
@@ -38,11 +39,13 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
"com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
private final NetworkController mController;
private final MobileDataController mDataController;
private final CellularDetailAdapter mDetailAdapter;
public CellularTile(Host host) {
super(host);
mController = host.getNetworkController();
mDataController = mController.getMobileDataController();
mDetailAdapter = new CellularDetailAdapter();
}
@@ -72,7 +75,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
@Override
protected void handleClick() {
if (mController.isMobileDataSupported()) {
if (mDataController.isMobileDataSupported()) {
showDetail(true);
} else {
mHost.startSettingsActivity(CELLULAR_SETTINGS);
@@ -199,7 +202,8 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
@Override
public Boolean getToggleState() {
return mController.isMobileDataSupported() ? mController.isMobileDataEnabled() : null;
return mDataController.isMobileDataSupported()
? mDataController.isMobileDataEnabled() : null;
}
@Override
@@ -209,7 +213,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
@Override
public void setToggleState(boolean state) {
mController.setMobileDataEnabled(state);
mDataController.setMobileDataEnabled(state);
}
@Override
@@ -217,7 +221,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
final DataUsageDetailView v = (DataUsageDetailView) (convertView != null
? convertView
: LayoutInflater.from(mContext).inflate(R.layout.data_usage, parent, false));
final DataUsageInfo info = mController.getDataUsageInfo();
final DataUsageInfo info = mDataController.getDataUsageInfo();
if (info == null) return v;
v.bind(info);
return v;

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -61,7 +60,7 @@ public class DataUsageDetailView extends LinearLayout {
R.dimen.qs_data_usage_text_size);
}
public void bind(NetworkController.DataUsageInfo info) {
public void bind(NetworkController.MobileDataController.DataUsageInfo info) {
final Resources res = mContext.getResources();
final int titleId;
final long bytes;

View File

@@ -31,7 +31,8 @@ import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QSTileView;
import com.android.systemui.qs.SignalTileView;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.AccessPoint;
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController.AccessPoint;
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
/** Quick settings tile: Wifi **/
@@ -39,12 +40,14 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
private final NetworkController mController;
private final AccessPointController mWifiController;
private final WifiDetailAdapter mDetailAdapter;
private final QSTile.SignalState mStateBeforeClick = newTileState();
public WifiTile(Host host) {
super(host);
mController = host.getNetworkController();
mWifiController = mController.getAccessPointController();
mDetailAdapter = new WifiDetailAdapter();
}
@@ -62,10 +65,10 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
public void setListening(boolean listening) {
if (listening) {
mController.addNetworkSignalChangedCallback(mCallback);
mController.addAccessPointCallback(mDetailAdapter);
mWifiController.addAccessPointCallback(mDetailAdapter);
} else {
mController.removeNetworkSignalChangedCallback(mCallback);
mController.removeAccessPointCallback(mDetailAdapter);
mWifiController.removeAccessPointCallback(mDetailAdapter);
}
}
@@ -87,7 +90,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
@Override
protected void handleSecondaryClick() {
if (!mController.canConfigWifi()) {
if (!mWifiController.canConfigWifi()) {
mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
return;
}
@@ -231,7 +234,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
};
private final class WifiDetailAdapter implements DetailAdapter,
NetworkController.AccessPointCallback, QSDetailItems.Callback {
NetworkController.AccessPointController.AccessPointCallback, QSDetailItems.Callback {
private QSDetailItems mItems;
private AccessPoint[] mAccessPoints;
@@ -261,7 +264,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
public View createDetailView(Context context, View convertView, ViewGroup parent) {
if (DEBUG) Log.d(TAG, "createDetailView convertView=" + (convertView != null));
mAccessPoints = null;
mController.scanForAccessPoints();
mWifiController.scanForAccessPoints();
fireScanStateChanged(true);
mItems = QSDetailItems.convertOrInflate(context, convertView, parent);
mItems.setTagSuffix("Wifi");
@@ -287,7 +290,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
if (item == null || item.tag == null) return;
final AccessPoint ap = (AccessPoint) item.tag;
if (!ap.isConnected) {
if (mController.connect(ap)) {
if (mWifiController.connect(ap)) {
mHost.collapsePanels();
}
}

View File

@@ -48,6 +48,7 @@ public class SignalClusterView
private int mMobileStrengthId = 0, mMobileTypeId = 0;
private boolean mIsAirplaneMode = false;
private int mAirplaneIconId = 0;
private int mAirplaneContentDescription;
private String mWifiDescription, mMobileDescription, mMobileTypeDescription;
private boolean mIsMobileTypeIconWide;
@@ -160,9 +161,10 @@ public class SignalClusterView
}
@Override
public void setIsAirplaneMode(boolean is, int airplaneIconId) {
public void setIsAirplaneMode(boolean is, int airplaneIconId, int contentDescription) {
mIsAirplaneMode = is;
mAirplaneIconId = airplaneIconId;
mAirplaneContentDescription = contentDescription;
apply();
}
@@ -236,6 +238,8 @@ public class SignalClusterView
if (mIsAirplaneMode) {
mAirplane.setImageResource(mAirplaneIconId);
mAirplane.setContentDescription(mAirplaneContentDescription != 0 ?
mContext.getString(mAirplaneContentDescription) : "");
mAirplane.setVisibility(View.VISIBLE);
} else {
mAirplane.setVisibility(View.GONE);

View File

@@ -79,6 +79,7 @@ import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.EventLog;
@@ -821,7 +822,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
signalClusterQs.setNetworkController(mNetworkController);
final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
if (isAPhone) {
mNetworkController.addEmergencyLabelView(mHeader);
mNetworkController.addEmergencyListener(new NetworkControllerImpl.EmergencyListener() {
@Override
public void setEmergencyCallsOnly(boolean emergencyOnly) {
mHeader.setShowEmergencyCallsOnly(emergencyOnly);
}
});
}
mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
@@ -830,13 +836,19 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (mShowCarrierInPanel) {
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
// for mobile devices, we always show mobile connection info here (SPN/PLMN)
// for other devices, we show whatever network is connected
if (mNetworkController.hasMobileDataFeature()) {
mNetworkController.addMobileLabelView(mCarrierLabel);
} else {
mNetworkController.addCombinedLabelView(mCarrierLabel);
}
mNetworkController.addCarrierLabel(new NetworkControllerImpl.CarrierLabelListener() {
@Override
public void setCarrierLabel(String label) {
mCarrierLabel.setText(label);
if (mNetworkController.hasMobileDataFeature()) {
if (TextUtils.isEmpty(label)) {
mCarrierLabel.setVisibility(View.GONE);
} else {
mCarrierLabel.setVisibility(View.VISIBLE);
}
}
}
});
// set up the dynamic hide/show of the label
// TODO: uncomment, handle this for the Stack scroller aswell

View File

@@ -122,7 +122,7 @@ public class QSTileHost implements QSTile.Host {
tile.userSwitch(newUserId);
}
mSecurity.onUserSwitched(newUserId);
mNetwork.onUserSwitched(newUserId);
mNetwork.getAccessPointController().onUserSwitched(newUserId);
mObserver.register();
}
};

View File

@@ -36,15 +36,13 @@ import android.util.ArraySet;
import android.util.Log;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkController.AccessPoint;
import com.android.systemui.statusbar.policy.NetworkController.AccessPointCallback;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class AccessPointController {
public class AccessPointControllerImpl implements NetworkController.AccessPointController {
private static final String TAG = "AccessPointController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -69,7 +67,7 @@ public class AccessPointController {
private boolean mScanning;
private int mCurrentUser;
public AccessPointController(Context context) {
public AccessPointControllerImpl(Context context) {
mContext = context;
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
@@ -81,25 +79,28 @@ public class AccessPointController {
new UserHandle(mCurrentUser));
}
void onUserSwitched(int newUserId) {
public void onUserSwitched(int newUserId) {
mCurrentUser = newUserId;
}
public void addCallback(AccessPointCallback callback) {
@Override
public void addAccessPointCallback(AccessPointCallback callback) {
if (callback == null || mCallbacks.contains(callback)) return;
if (DEBUG) Log.d(TAG, "addCallback " + callback);
mCallbacks.add(callback);
mReceiver.setListening(!mCallbacks.isEmpty());
}
public void removeCallback(AccessPointCallback callback) {
@Override
public void removeAccessPointCallback(AccessPointCallback callback) {
if (callback == null) return;
if (DEBUG) Log.d(TAG, "removeCallback " + callback);
mCallbacks.remove(callback);
mReceiver.setListening(!mCallbacks.isEmpty());
}
public void scan() {
@Override
public void scanForAccessPoints() {
if (mScanning) return;
if (DEBUG) Log.d(TAG, "scan!");
mScanning = mWifiManager.startScan();

View File

@@ -33,11 +33,5 @@ public class AccessibilityContentDescriptions {
R.string.accessibility_wifi_three_bars,
R.string.accessibility_wifi_signal_full
};
static final int[] WIMAX_CONNECTION_STRENGTH = {
R.string.accessibility_no_wimax,
R.string.accessibility_wimax_one_bar,
R.string.accessibility_wimax_two_bars,
R.string.accessibility_wimax_three_bars,
R.string.accessibility_wimax_signal_full
};
static final int WIFI_NO_CONNECTION = R.string.accessibility_no_wifi;
}

View File

@@ -38,12 +38,10 @@ import android.text.format.DateUtils;
import android.text.format.Time;
import android.util.Log;
import com.android.systemui.statusbar.policy.NetworkController.DataUsageInfo;
import java.util.Date;
import java.util.Locale;
public class MobileDataController {
public class MobileDataControllerImpl implements NetworkController.MobileDataController {
private static final String TAG = "MobileDataController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -61,8 +59,9 @@ public class MobileDataController {
private INetworkStatsSession mSession;
private Callback mCallback;
private NetworkControllerImpl mNetworkController;
public MobileDataController(Context context) {
public MobileDataControllerImpl(Context context) {
mContext = context;
mTelephonyManager = TelephonyManager.from(context);
mConnectivityManager = ConnectivityManager.from(context);
@@ -71,6 +70,10 @@ public class MobileDataController {
mPolicyManager = NetworkPolicyManager.from(mContext);
}
public void setNetworkController(NetworkControllerImpl networkController) {
mNetworkController = networkController;
}
private INetworkStatsSession getSession() {
if (mSession == null) {
try {
@@ -155,6 +158,9 @@ public class MobileDataController {
} else {
usage.warningLevel = DEFAULT_WARNING_LEVEL;
}
if (usage != null) {
usage.carrier = mNetworkController.getMobileNetworkName();
}
return usage;
} catch (RemoteException e) {
return warn("remote call failed");

View File

@@ -22,6 +22,8 @@ public interface NetworkController {
void addNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
void removeNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
void setWifiEnabled(boolean enabled);
AccessPointController getAccessPointController();
MobileDataController getMobileDataController();
public interface NetworkSignalChangedCallback {
void onWifiSignalChanged(boolean enabled, boolean connected, int wifiSignalIconId,
@@ -36,38 +38,50 @@ public interface NetworkController {
void onMobileDataEnabled(boolean enabled);
}
void addAccessPointCallback(AccessPointCallback callback);
void removeAccessPointCallback(AccessPointCallback callback);
void scanForAccessPoints();
boolean connect(AccessPoint ap);
boolean isMobileDataSupported();
boolean isMobileDataEnabled();
void setMobileDataEnabled(boolean enabled);
DataUsageInfo getDataUsageInfo();
boolean canConfigWifi();
void onUserSwitched(int newUserId);
/**
* Tracks changes in access points. Allows listening for changes, scanning for new APs,
* and connecting to new ones.
*/
public interface AccessPointController {
void addAccessPointCallback(AccessPointCallback callback);
void removeAccessPointCallback(AccessPointCallback callback);
void scanForAccessPoints();
boolean connect(AccessPoint ap);
boolean canConfigWifi();
void onUserSwitched(int newUserId);
public interface AccessPointCallback {
void onAccessPointsChanged(AccessPoint[] accessPoints);
public interface AccessPointCallback {
void onAccessPointsChanged(AccessPoint[] accessPoints);
}
public static class AccessPoint {
public static final int NO_NETWORK = -1; // see WifiManager
public int networkId;
public int iconId;
public String ssid;
public boolean isConnected;
public boolean isConfigured;
public boolean hasSecurity;
public int level; // 0 - 5
}
}
public static class AccessPoint {
public static final int NO_NETWORK = -1; // see WifiManager
/**
* Tracks mobile data support and usage.
*/
public interface MobileDataController {
boolean isMobileDataSupported();
boolean isMobileDataEnabled();
void setMobileDataEnabled(boolean enabled);
DataUsageInfo getDataUsageInfo();
public int networkId;
public int iconId;
public String ssid;
public boolean isConnected;
public boolean isConfigured;
public boolean hasSecurity;
public int level; // 0 - 5
}
public static class DataUsageInfo {
public String carrier;
public String period;
public long limitLevel;
public long warningLevel;
public long usageLevel;
public static class DataUsageInfo {
public String carrier;
public String period;
public long limitLevel;
public long warningLevel;
public long usageLevel;
}
}
}

View File

@@ -17,11 +17,16 @@
package com.android.systemui.statusbar.policy;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.MobileSignalController.MobileIconGroup;
class TelephonyIcons {
//***** Signal strength icons
static final int TELEPHONY_NUM_LEVELS = 5;
//GSM/UMTS
static final int TELEPHONY_NO_NETWORK = R.drawable.stat_sys_signal_null;
static final int[][] TELEPHONY_SIGNAL_STRENGTH = {
{ R.drawable.stat_sys_signal_0,
R.drawable.stat_sys_signal_1,
@@ -35,6 +40,8 @@ class TelephonyIcons {
R.drawable.stat_sys_signal_4_fully }
};
static final int QS_TELEPHONY_NO_NETWORK = R.drawable.ic_qs_signal_no_signal;
static final int[][] QS_TELEPHONY_SIGNAL_STRENGTH = {
{ R.drawable.ic_qs_signal_0,
R.drawable.ic_qs_signal_1,
@@ -66,8 +73,6 @@ class TelephonyIcons {
R.drawable.ic_qs_signal_r
};
static final int[][] DATA_SIGNAL_STRENGTH = TELEPHONY_SIGNAL_STRENGTH;
//***** Data connection icons
//GSM/UMTS
@@ -191,6 +196,9 @@ class TelephonyIcons {
static final int FLIGHT_MODE_ICON = R.drawable.stat_sys_airplane_mode;
static final int ROAMING_ICON = R.drawable.stat_sys_data_fully_connected_roam;
static final int ICON_LTE = R.drawable.stat_sys_data_fully_connected_lte;
static final int ICON_G = R.drawable.stat_sys_data_fully_connected_g;
static final int ICON_E = R.drawable.stat_sys_data_fully_connected_e;
static final int ICON_H = R.drawable.stat_sys_data_fully_connected_h;
static final int ICON_3G = R.drawable.stat_sys_data_fully_connected_3g;
static final int ICON_4G = R.drawable.stat_sys_data_fully_connected_4g;
static final int ICON_1X = R.drawable.stat_sys_data_fully_connected_1x;
@@ -199,5 +207,137 @@ class TelephonyIcons {
static final int QS_ICON_3G = R.drawable.ic_qs_signal_3g;
static final int QS_ICON_4G = R.drawable.ic_qs_signal_4g;
static final int QS_ICON_1X = R.drawable.ic_qs_signal_1x;
static final MobileIconGroup THREE_G = new MobileIconGroup(
"3G",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_3g,
TelephonyIcons.ICON_3G,
true,
TelephonyIcons.QS_DATA_3G
);
static final MobileIconGroup UNKNOWN = new MobileIconGroup(
"Unknown",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
0, 0, false, new int[2]
);
static final MobileIconGroup E = new MobileIconGroup(
"E",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_edge,
TelephonyIcons.ICON_E,
false,
TelephonyIcons.QS_DATA_E
);
static final MobileIconGroup ONE_X = new MobileIconGroup(
"1X",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_cdma,
TelephonyIcons.ICON_1X,
true,
TelephonyIcons.QS_DATA_1X
);
static final MobileIconGroup G = new MobileIconGroup(
"G",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_gprs,
TelephonyIcons.ICON_G,
false,
TelephonyIcons.QS_DATA_G
);
static final MobileIconGroup H = new MobileIconGroup(
"H",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_3_5g,
TelephonyIcons.ICON_H,
false,
TelephonyIcons.QS_DATA_H
);
static final MobileIconGroup FOUR_G = new MobileIconGroup(
"4G",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_4g,
TelephonyIcons.ICON_4G,
true,
TelephonyIcons.QS_DATA_4G
);
static final MobileIconGroup LTE = new MobileIconGroup(
"LTE",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_lte,
TelephonyIcons.ICON_LTE,
true,
TelephonyIcons.QS_DATA_LTE
);
static final MobileIconGroup ROAMING = new MobileIconGroup(
"Roaming",
TelephonyIcons.TELEPHONY_SIGNAL_STRENGTH_ROAMING,
TelephonyIcons.QS_TELEPHONY_SIGNAL_STRENGTH,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH,
0, 0,
TelephonyIcons.TELEPHONY_NO_NETWORK,
TelephonyIcons.QS_TELEPHONY_NO_NETWORK,
AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH[0],
R.string.accessibility_data_connection_roaming,
TelephonyIcons.ROAMING_ICON,
false,
TelephonyIcons.QS_DATA_R
);
}

View File

@@ -45,5 +45,8 @@ class WifiIcons {
R.drawable.ic_qs_wifi_full_4 }
};
static final int QS_WIFI_NO_NETWORK = R.drawable.ic_qs_wifi_no_network;
static final int WIFI_NO_NETWORK = R.drawable.stat_sys_wifi_signal_null;
static final int WIFI_LEVEL_COUNT = WIFI_SIGNAL_STRENGTH[0].length;
}

View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.statusbar.policy;
import com.android.systemui.statusbar.policy.TelephonyIcons;
class WimaxIcons {
static final int[][] WIMAX_SIGNAL_STRENGTH = TelephonyIcons.DATA_SIGNAL_STRENGTH;
static final int WIMAX_DISCONNECTED = WIMAX_SIGNAL_STRENGTH[0][0];
static final int WIMAX_IDLE = WIMAX_DISCONNECTED; // XXX: unclear if we need a different icon
}

View File

@@ -17,6 +17,7 @@ import android.util.Log;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.Config;
import com.android.systemui.statusbar.policy.NetworkControllerImpl.SignalCluster;
import org.mockito.ArgumentCaptor;
@@ -44,6 +45,7 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
protected ConnectivityManager mMockCm;
protected WifiManager mMockWm;
protected TelephonyManager mMockTm;
protected Config mConfig;
@Override
protected void setUp() throws Exception {
@@ -59,16 +61,19 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
mSignalStrength = mock(SignalStrength.class);
mServiceState = mock(ServiceState.class);
mSignalCluster = mock(SignalCluster.class);
mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class);
mConfig = new Config();
mConfig.hspaDataDistinguishable = true;
mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm,
mock(AccessPointController.class), mock(MobileDataController.class));
mConfig, mock(AccessPointControllerImpl.class),
mock(MobileDataControllerImpl.class));
setupNetworkController();
}
protected void setupNetworkController() {
mPhoneStateListener = mNetworkController.mPhoneStateListener;
mPhoneStateListener = mNetworkController.mMobileSignalController.mPhoneStateListener;
mSignalCluster = mock(SignalCluster.class);
mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class);
mNetworkController.addSignalCluster(mSignalCluster);
mNetworkController.addNetworkSignalChangedCallback(mNetworkSignalChangedCallback);
}

View File

@@ -18,7 +18,8 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
// Create a new NetworkController as this is currently handled in constructor.
mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm,
mock(AccessPointController.class), mock(MobileDataController.class));
mConfig, mock(AccessPointControllerImpl.class),
mock(MobileDataControllerImpl.class));
setupNetworkController();
verifyLastMobileDataIndicators(false, 0, 0);

View File

@@ -6,8 +6,6 @@ import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import com.android.systemui.R;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -16,14 +14,10 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
private static final int MIN_RSSI = -100;
private static final int MAX_RSSI = -55;
// TODO: Move this into WifiIcons, remove all R.drawable from NetworkControllerImpl.
private static final int NULL_SIGNAL = R.drawable.stat_sys_wifi_signal_null;
private static final int QS_NO_NET = R.drawable.ic_qs_wifi_no_network;
public void testWifiIcon() {
String testSsid = "Test SSID";
setWifiEnabled(true);
verifyLastWifiIcon(false, NULL_SIGNAL);
verifyLastWifiIcon(false, WifiIcons.WIFI_NO_NETWORK);
setWifiState(true, testSsid);
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[0][0]);
@@ -42,10 +36,10 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
String testSsid = "Test SSID";
setWifiEnabled(false);
verifyLastQsWifiIcon(false, false, 0, null);
verifyLastQsWifiIcon(false, false, WifiIcons.QS_WIFI_NO_NETWORK, null);
setWifiEnabled(true);
verifyLastQsWifiIcon(true, false, QS_NO_NET, null);
verifyLastQsWifiIcon(true, false, WifiIcons.QS_WIFI_NO_NETWORK, null);
setWifiState(true, testSsid);
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
@@ -118,8 +112,7 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
protected void setWifiActivity(int activity) {
// TODO: Not this, because this variable probably isn't sticking around.
mNetworkController.mWifiActivity = activity;
mNetworkController.refreshViews();
mNetworkController.mWifiSignalController.setActivity(activity);
}
protected void setWifiLevel(int level) {