Merge "SysUI: Refactor the NetworkControllerImpl" into lmp-mr1-dev
This commit is contained in:
@@ -29,7 +29,8 @@ import com.android.systemui.qs.QSTile;
|
|||||||
import com.android.systemui.qs.QSTileView;
|
import com.android.systemui.qs.QSTileView;
|
||||||
import com.android.systemui.qs.SignalTileView;
|
import com.android.systemui.qs.SignalTileView;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
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;
|
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
|
||||||
|
|
||||||
/** Quick settings tile: Cellular **/
|
/** Quick settings tile: Cellular **/
|
||||||
@@ -38,11 +39,13 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
|
|||||||
"com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
|
"com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
|
||||||
|
|
||||||
private final NetworkController mController;
|
private final NetworkController mController;
|
||||||
|
private final MobileDataController mDataController;
|
||||||
private final CellularDetailAdapter mDetailAdapter;
|
private final CellularDetailAdapter mDetailAdapter;
|
||||||
|
|
||||||
public CellularTile(Host host) {
|
public CellularTile(Host host) {
|
||||||
super(host);
|
super(host);
|
||||||
mController = host.getNetworkController();
|
mController = host.getNetworkController();
|
||||||
|
mDataController = mController.getMobileDataController();
|
||||||
mDetailAdapter = new CellularDetailAdapter();
|
mDetailAdapter = new CellularDetailAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleClick() {
|
protected void handleClick() {
|
||||||
if (mController.isMobileDataSupported()) {
|
if (mDataController.isMobileDataSupported()) {
|
||||||
showDetail(true);
|
showDetail(true);
|
||||||
} else {
|
} else {
|
||||||
mHost.startSettingsActivity(CELLULAR_SETTINGS);
|
mHost.startSettingsActivity(CELLULAR_SETTINGS);
|
||||||
@@ -199,7 +202,8 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean getToggleState() {
|
public Boolean getToggleState() {
|
||||||
return mController.isMobileDataSupported() ? mController.isMobileDataEnabled() : null;
|
return mDataController.isMobileDataSupported()
|
||||||
|
? mDataController.isMobileDataEnabled() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -209,7 +213,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setToggleState(boolean state) {
|
public void setToggleState(boolean state) {
|
||||||
mController.setMobileDataEnabled(state);
|
mDataController.setMobileDataEnabled(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -217,7 +221,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
|
|||||||
final DataUsageDetailView v = (DataUsageDetailView) (convertView != null
|
final DataUsageDetailView v = (DataUsageDetailView) (convertView != null
|
||||||
? convertView
|
? convertView
|
||||||
: LayoutInflater.from(mContext).inflate(R.layout.data_usage, parent, false));
|
: 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;
|
if (info == null) return v;
|
||||||
v.bind(info);
|
v.bind(info);
|
||||||
return v;
|
return v;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.content.Context;
|
|||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -61,7 +60,7 @@ public class DataUsageDetailView extends LinearLayout {
|
|||||||
R.dimen.qs_data_usage_text_size);
|
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 Resources res = mContext.getResources();
|
||||||
final int titleId;
|
final int titleId;
|
||||||
final long bytes;
|
final long bytes;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ import com.android.systemui.qs.QSTile;
|
|||||||
import com.android.systemui.qs.QSTileView;
|
import com.android.systemui.qs.QSTileView;
|
||||||
import com.android.systemui.qs.SignalTileView;
|
import com.android.systemui.qs.SignalTileView;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController;
|
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;
|
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
|
||||||
|
|
||||||
/** Quick settings tile: Wifi **/
|
/** 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 static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS);
|
||||||
|
|
||||||
private final NetworkController mController;
|
private final NetworkController mController;
|
||||||
|
private final AccessPointController mWifiController;
|
||||||
private final WifiDetailAdapter mDetailAdapter;
|
private final WifiDetailAdapter mDetailAdapter;
|
||||||
private final QSTile.SignalState mStateBeforeClick = newTileState();
|
private final QSTile.SignalState mStateBeforeClick = newTileState();
|
||||||
|
|
||||||
public WifiTile(Host host) {
|
public WifiTile(Host host) {
|
||||||
super(host);
|
super(host);
|
||||||
mController = host.getNetworkController();
|
mController = host.getNetworkController();
|
||||||
|
mWifiController = mController.getAccessPointController();
|
||||||
mDetailAdapter = new WifiDetailAdapter();
|
mDetailAdapter = new WifiDetailAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +65,10 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
|
|||||||
public void setListening(boolean listening) {
|
public void setListening(boolean listening) {
|
||||||
if (listening) {
|
if (listening) {
|
||||||
mController.addNetworkSignalChangedCallback(mCallback);
|
mController.addNetworkSignalChangedCallback(mCallback);
|
||||||
mController.addAccessPointCallback(mDetailAdapter);
|
mWifiController.addAccessPointCallback(mDetailAdapter);
|
||||||
} else {
|
} else {
|
||||||
mController.removeNetworkSignalChangedCallback(mCallback);
|
mController.removeNetworkSignalChangedCallback(mCallback);
|
||||||
mController.removeAccessPointCallback(mDetailAdapter);
|
mWifiController.removeAccessPointCallback(mDetailAdapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +90,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleSecondaryClick() {
|
protected void handleSecondaryClick() {
|
||||||
if (!mController.canConfigWifi()) {
|
if (!mWifiController.canConfigWifi()) {
|
||||||
mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -231,7 +234,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private final class WifiDetailAdapter implements DetailAdapter,
|
private final class WifiDetailAdapter implements DetailAdapter,
|
||||||
NetworkController.AccessPointCallback, QSDetailItems.Callback {
|
NetworkController.AccessPointController.AccessPointCallback, QSDetailItems.Callback {
|
||||||
|
|
||||||
private QSDetailItems mItems;
|
private QSDetailItems mItems;
|
||||||
private AccessPoint[] mAccessPoints;
|
private AccessPoint[] mAccessPoints;
|
||||||
@@ -261,7 +264,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
|
|||||||
public View createDetailView(Context context, View convertView, ViewGroup parent) {
|
public View createDetailView(Context context, View convertView, ViewGroup parent) {
|
||||||
if (DEBUG) Log.d(TAG, "createDetailView convertView=" + (convertView != null));
|
if (DEBUG) Log.d(TAG, "createDetailView convertView=" + (convertView != null));
|
||||||
mAccessPoints = null;
|
mAccessPoints = null;
|
||||||
mController.scanForAccessPoints();
|
mWifiController.scanForAccessPoints();
|
||||||
fireScanStateChanged(true);
|
fireScanStateChanged(true);
|
||||||
mItems = QSDetailItems.convertOrInflate(context, convertView, parent);
|
mItems = QSDetailItems.convertOrInflate(context, convertView, parent);
|
||||||
mItems.setTagSuffix("Wifi");
|
mItems.setTagSuffix("Wifi");
|
||||||
@@ -287,7 +290,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
|
|||||||
if (item == null || item.tag == null) return;
|
if (item == null || item.tag == null) return;
|
||||||
final AccessPoint ap = (AccessPoint) item.tag;
|
final AccessPoint ap = (AccessPoint) item.tag;
|
||||||
if (!ap.isConnected) {
|
if (!ap.isConnected) {
|
||||||
if (mController.connect(ap)) {
|
if (mWifiController.connect(ap)) {
|
||||||
mHost.collapsePanels();
|
mHost.collapsePanels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class SignalClusterView
|
|||||||
private int mMobileStrengthId = 0, mMobileTypeId = 0;
|
private int mMobileStrengthId = 0, mMobileTypeId = 0;
|
||||||
private boolean mIsAirplaneMode = false;
|
private boolean mIsAirplaneMode = false;
|
||||||
private int mAirplaneIconId = 0;
|
private int mAirplaneIconId = 0;
|
||||||
|
private int mAirplaneContentDescription;
|
||||||
private String mWifiDescription, mMobileDescription, mMobileTypeDescription;
|
private String mWifiDescription, mMobileDescription, mMobileTypeDescription;
|
||||||
private boolean mIsMobileTypeIconWide;
|
private boolean mIsMobileTypeIconWide;
|
||||||
|
|
||||||
@@ -160,9 +161,10 @@ public class SignalClusterView
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIsAirplaneMode(boolean is, int airplaneIconId) {
|
public void setIsAirplaneMode(boolean is, int airplaneIconId, int contentDescription) {
|
||||||
mIsAirplaneMode = is;
|
mIsAirplaneMode = is;
|
||||||
mAirplaneIconId = airplaneIconId;
|
mAirplaneIconId = airplaneIconId;
|
||||||
|
mAirplaneContentDescription = contentDescription;
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
}
|
}
|
||||||
@@ -236,6 +238,8 @@ public class SignalClusterView
|
|||||||
|
|
||||||
if (mIsAirplaneMode) {
|
if (mIsAirplaneMode) {
|
||||||
mAirplane.setImageResource(mAirplaneIconId);
|
mAirplane.setImageResource(mAirplaneIconId);
|
||||||
|
mAirplane.setContentDescription(mAirplaneContentDescription != 0 ?
|
||||||
|
mContext.getString(mAirplaneContentDescription) : "");
|
||||||
mAirplane.setVisibility(View.VISIBLE);
|
mAirplane.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mAirplane.setVisibility(View.GONE);
|
mAirplane.setVisibility(View.GONE);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import android.provider.Settings;
|
|||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
import android.service.notification.NotificationListenerService.RankingMap;
|
import android.service.notification.NotificationListenerService.RankingMap;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.EventLog;
|
import android.util.EventLog;
|
||||||
@@ -821,7 +822,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
signalClusterQs.setNetworkController(mNetworkController);
|
signalClusterQs.setNetworkController(mNetworkController);
|
||||||
final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
|
final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
|
||||||
if (isAPhone) {
|
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);
|
mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
|
||||||
@@ -830,13 +836,19 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
if (mShowCarrierInPanel) {
|
if (mShowCarrierInPanel) {
|
||||||
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
|
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|
||||||
// for mobile devices, we always show mobile connection info here (SPN/PLMN)
|
mNetworkController.addCarrierLabel(new NetworkControllerImpl.CarrierLabelListener() {
|
||||||
// for other devices, we show whatever network is connected
|
@Override
|
||||||
if (mNetworkController.hasMobileDataFeature()) {
|
public void setCarrierLabel(String label) {
|
||||||
mNetworkController.addMobileLabelView(mCarrierLabel);
|
mCarrierLabel.setText(label);
|
||||||
} else {
|
if (mNetworkController.hasMobileDataFeature()) {
|
||||||
mNetworkController.addCombinedLabelView(mCarrierLabel);
|
if (TextUtils.isEmpty(label)) {
|
||||||
}
|
mCarrierLabel.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
mCarrierLabel.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// set up the dynamic hide/show of the label
|
// set up the dynamic hide/show of the label
|
||||||
// TODO: uncomment, handle this for the Stack scroller aswell
|
// TODO: uncomment, handle this for the Stack scroller aswell
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class QSTileHost implements QSTile.Host {
|
|||||||
tile.userSwitch(newUserId);
|
tile.userSwitch(newUserId);
|
||||||
}
|
}
|
||||||
mSecurity.onUserSwitched(newUserId);
|
mSecurity.onUserSwitched(newUserId);
|
||||||
mNetwork.onUserSwitched(newUserId);
|
mNetwork.getAccessPointController().onUserSwitched(newUserId);
|
||||||
mObserver.register();
|
mObserver.register();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,15 +36,13 @@ import android.util.ArraySet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AccessPointController {
|
public class AccessPointControllerImpl implements NetworkController.AccessPointController {
|
||||||
private static final String TAG = "AccessPointController";
|
private static final String TAG = "AccessPointController";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
@@ -69,7 +67,7 @@ public class AccessPointController {
|
|||||||
private boolean mScanning;
|
private boolean mScanning;
|
||||||
private int mCurrentUser;
|
private int mCurrentUser;
|
||||||
|
|
||||||
public AccessPointController(Context context) {
|
public AccessPointControllerImpl(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||||
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||||
@@ -81,25 +79,28 @@ public class AccessPointController {
|
|||||||
new UserHandle(mCurrentUser));
|
new UserHandle(mCurrentUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUserSwitched(int newUserId) {
|
public void onUserSwitched(int newUserId) {
|
||||||
mCurrentUser = newUserId;
|
mCurrentUser = newUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCallback(AccessPointCallback callback) {
|
@Override
|
||||||
|
public void addAccessPointCallback(AccessPointCallback callback) {
|
||||||
if (callback == null || mCallbacks.contains(callback)) return;
|
if (callback == null || mCallbacks.contains(callback)) return;
|
||||||
if (DEBUG) Log.d(TAG, "addCallback " + callback);
|
if (DEBUG) Log.d(TAG, "addCallback " + callback);
|
||||||
mCallbacks.add(callback);
|
mCallbacks.add(callback);
|
||||||
mReceiver.setListening(!mCallbacks.isEmpty());
|
mReceiver.setListening(!mCallbacks.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCallback(AccessPointCallback callback) {
|
@Override
|
||||||
|
public void removeAccessPointCallback(AccessPointCallback callback) {
|
||||||
if (callback == null) return;
|
if (callback == null) return;
|
||||||
if (DEBUG) Log.d(TAG, "removeCallback " + callback);
|
if (DEBUG) Log.d(TAG, "removeCallback " + callback);
|
||||||
mCallbacks.remove(callback);
|
mCallbacks.remove(callback);
|
||||||
mReceiver.setListening(!mCallbacks.isEmpty());
|
mReceiver.setListening(!mCallbacks.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scan() {
|
@Override
|
||||||
|
public void scanForAccessPoints() {
|
||||||
if (mScanning) return;
|
if (mScanning) return;
|
||||||
if (DEBUG) Log.d(TAG, "scan!");
|
if (DEBUG) Log.d(TAG, "scan!");
|
||||||
mScanning = mWifiManager.startScan();
|
mScanning = mWifiManager.startScan();
|
||||||
@@ -33,11 +33,5 @@ public class AccessibilityContentDescriptions {
|
|||||||
R.string.accessibility_wifi_three_bars,
|
R.string.accessibility_wifi_three_bars,
|
||||||
R.string.accessibility_wifi_signal_full
|
R.string.accessibility_wifi_signal_full
|
||||||
};
|
};
|
||||||
static final int[] WIMAX_CONNECTION_STRENGTH = {
|
static final int WIFI_NO_CONNECTION = R.string.accessibility_no_wifi;
|
||||||
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
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,12 +38,10 @@ import android.text.format.DateUtils;
|
|||||||
import android.text.format.Time;
|
import android.text.format.Time;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.DataUsageInfo;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class MobileDataController {
|
public class MobileDataControllerImpl implements NetworkController.MobileDataController {
|
||||||
private static final String TAG = "MobileDataController";
|
private static final String TAG = "MobileDataController";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
@@ -61,8 +59,9 @@ public class MobileDataController {
|
|||||||
|
|
||||||
private INetworkStatsSession mSession;
|
private INetworkStatsSession mSession;
|
||||||
private Callback mCallback;
|
private Callback mCallback;
|
||||||
|
private NetworkControllerImpl mNetworkController;
|
||||||
|
|
||||||
public MobileDataController(Context context) {
|
public MobileDataControllerImpl(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mTelephonyManager = TelephonyManager.from(context);
|
mTelephonyManager = TelephonyManager.from(context);
|
||||||
mConnectivityManager = ConnectivityManager.from(context);
|
mConnectivityManager = ConnectivityManager.from(context);
|
||||||
@@ -71,6 +70,10 @@ public class MobileDataController {
|
|||||||
mPolicyManager = NetworkPolicyManager.from(mContext);
|
mPolicyManager = NetworkPolicyManager.from(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNetworkController(NetworkControllerImpl networkController) {
|
||||||
|
mNetworkController = networkController;
|
||||||
|
}
|
||||||
|
|
||||||
private INetworkStatsSession getSession() {
|
private INetworkStatsSession getSession() {
|
||||||
if (mSession == null) {
|
if (mSession == null) {
|
||||||
try {
|
try {
|
||||||
@@ -155,6 +158,9 @@ public class MobileDataController {
|
|||||||
} else {
|
} else {
|
||||||
usage.warningLevel = DEFAULT_WARNING_LEVEL;
|
usage.warningLevel = DEFAULT_WARNING_LEVEL;
|
||||||
}
|
}
|
||||||
|
if (usage != null) {
|
||||||
|
usage.carrier = mNetworkController.getMobileNetworkName();
|
||||||
|
}
|
||||||
return usage;
|
return usage;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
return warn("remote call failed");
|
return warn("remote call failed");
|
||||||
@@ -22,6 +22,8 @@ public interface NetworkController {
|
|||||||
void addNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
|
void addNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
|
||||||
void removeNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
|
void removeNetworkSignalChangedCallback(NetworkSignalChangedCallback cb);
|
||||||
void setWifiEnabled(boolean enabled);
|
void setWifiEnabled(boolean enabled);
|
||||||
|
AccessPointController getAccessPointController();
|
||||||
|
MobileDataController getMobileDataController();
|
||||||
|
|
||||||
public interface NetworkSignalChangedCallback {
|
public interface NetworkSignalChangedCallback {
|
||||||
void onWifiSignalChanged(boolean enabled, boolean connected, int wifiSignalIconId,
|
void onWifiSignalChanged(boolean enabled, boolean connected, int wifiSignalIconId,
|
||||||
@@ -36,38 +38,50 @@ public interface NetworkController {
|
|||||||
void onMobileDataEnabled(boolean enabled);
|
void onMobileDataEnabled(boolean enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addAccessPointCallback(AccessPointCallback callback);
|
/**
|
||||||
void removeAccessPointCallback(AccessPointCallback callback);
|
* Tracks changes in access points. Allows listening for changes, scanning for new APs,
|
||||||
void scanForAccessPoints();
|
* and connecting to new ones.
|
||||||
boolean connect(AccessPoint ap);
|
*/
|
||||||
boolean isMobileDataSupported();
|
public interface AccessPointController {
|
||||||
boolean isMobileDataEnabled();
|
void addAccessPointCallback(AccessPointCallback callback);
|
||||||
void setMobileDataEnabled(boolean enabled);
|
void removeAccessPointCallback(AccessPointCallback callback);
|
||||||
DataUsageInfo getDataUsageInfo();
|
void scanForAccessPoints();
|
||||||
boolean canConfigWifi();
|
boolean connect(AccessPoint ap);
|
||||||
void onUserSwitched(int newUserId);
|
boolean canConfigWifi();
|
||||||
|
void onUserSwitched(int newUserId);
|
||||||
|
|
||||||
public interface AccessPointCallback {
|
public interface AccessPointCallback {
|
||||||
void onAccessPointsChanged(AccessPoint[] accessPoints);
|
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 static class DataUsageInfo {
|
||||||
public int iconId;
|
public String carrier;
|
||||||
public String ssid;
|
public String period;
|
||||||
public boolean isConnected;
|
public long limitLevel;
|
||||||
public boolean isConfigured;
|
public long warningLevel;
|
||||||
public boolean hasSecurity;
|
public long usageLevel;
|
||||||
public int level; // 0 - 5
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class DataUsageInfo {
|
|
||||||
public String carrier;
|
|
||||||
public String period;
|
|
||||||
public long limitLevel;
|
|
||||||
public long warningLevel;
|
|
||||||
public long usageLevel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -17,11 +17,16 @@
|
|||||||
package com.android.systemui.statusbar.policy;
|
package com.android.systemui.statusbar.policy;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.statusbar.policy.NetworkControllerImpl.MobileSignalController.MobileIconGroup;
|
||||||
|
|
||||||
class TelephonyIcons {
|
class TelephonyIcons {
|
||||||
//***** Signal strength icons
|
//***** Signal strength icons
|
||||||
|
|
||||||
|
static final int TELEPHONY_NUM_LEVELS = 5;
|
||||||
|
|
||||||
//GSM/UMTS
|
//GSM/UMTS
|
||||||
|
static final int TELEPHONY_NO_NETWORK = R.drawable.stat_sys_signal_null;
|
||||||
|
|
||||||
static final int[][] TELEPHONY_SIGNAL_STRENGTH = {
|
static final int[][] TELEPHONY_SIGNAL_STRENGTH = {
|
||||||
{ R.drawable.stat_sys_signal_0,
|
{ R.drawable.stat_sys_signal_0,
|
||||||
R.drawable.stat_sys_signal_1,
|
R.drawable.stat_sys_signal_1,
|
||||||
@@ -35,6 +40,8 @@ class TelephonyIcons {
|
|||||||
R.drawable.stat_sys_signal_4_fully }
|
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 = {
|
static final int[][] QS_TELEPHONY_SIGNAL_STRENGTH = {
|
||||||
{ R.drawable.ic_qs_signal_0,
|
{ R.drawable.ic_qs_signal_0,
|
||||||
R.drawable.ic_qs_signal_1,
|
R.drawable.ic_qs_signal_1,
|
||||||
@@ -66,8 +73,6 @@ class TelephonyIcons {
|
|||||||
R.drawable.ic_qs_signal_r
|
R.drawable.ic_qs_signal_r
|
||||||
};
|
};
|
||||||
|
|
||||||
static final int[][] DATA_SIGNAL_STRENGTH = TELEPHONY_SIGNAL_STRENGTH;
|
|
||||||
|
|
||||||
//***** Data connection icons
|
//***** Data connection icons
|
||||||
|
|
||||||
//GSM/UMTS
|
//GSM/UMTS
|
||||||
@@ -191,6 +196,9 @@ class TelephonyIcons {
|
|||||||
static final int FLIGHT_MODE_ICON = R.drawable.stat_sys_airplane_mode;
|
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 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_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_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_4G = R.drawable.stat_sys_data_fully_connected_4g;
|
||||||
static final int ICON_1X = R.drawable.stat_sys_data_fully_connected_1x;
|
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_3G = R.drawable.ic_qs_signal_3g;
|
||||||
static final int QS_ICON_4G = R.drawable.ic_qs_signal_4g;
|
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 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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,5 +45,8 @@ class WifiIcons {
|
|||||||
R.drawable.ic_qs_wifi_full_4 }
|
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;
|
static final int WIFI_LEVEL_COUNT = WIFI_SIGNAL_STRENGTH[0].length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.internal.telephony.cdma.EriInfo;
|
import com.android.internal.telephony.cdma.EriInfo;
|
||||||
import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback;
|
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 com.android.systemui.statusbar.policy.NetworkControllerImpl.SignalCluster;
|
||||||
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -44,6 +45,7 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
|
|||||||
protected ConnectivityManager mMockCm;
|
protected ConnectivityManager mMockCm;
|
||||||
protected WifiManager mMockWm;
|
protected WifiManager mMockWm;
|
||||||
protected TelephonyManager mMockTm;
|
protected TelephonyManager mMockTm;
|
||||||
|
protected Config mConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
@@ -59,16 +61,19 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
|
|||||||
|
|
||||||
mSignalStrength = mock(SignalStrength.class);
|
mSignalStrength = mock(SignalStrength.class);
|
||||||
mServiceState = mock(ServiceState.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,
|
mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm,
|
||||||
mock(AccessPointController.class), mock(MobileDataController.class));
|
mConfig, mock(AccessPointControllerImpl.class),
|
||||||
|
mock(MobileDataControllerImpl.class));
|
||||||
setupNetworkController();
|
setupNetworkController();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupNetworkController() {
|
protected void setupNetworkController() {
|
||||||
mPhoneStateListener = mNetworkController.mPhoneStateListener;
|
mPhoneStateListener = mNetworkController.mMobileSignalController.mPhoneStateListener;
|
||||||
|
mSignalCluster = mock(SignalCluster.class);
|
||||||
|
mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class);
|
||||||
mNetworkController.addSignalCluster(mSignalCluster);
|
mNetworkController.addSignalCluster(mSignalCluster);
|
||||||
mNetworkController.addNetworkSignalChangedCallback(mNetworkSignalChangedCallback);
|
mNetworkController.addNetworkSignalChangedCallback(mNetworkSignalChangedCallback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
|
|||||||
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
|
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
|
||||||
// Create a new NetworkController as this is currently handled in constructor.
|
// Create a new NetworkController as this is currently handled in constructor.
|
||||||
mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm,
|
mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm,
|
||||||
mock(AccessPointController.class), mock(MobileDataController.class));
|
mConfig, mock(AccessPointControllerImpl.class),
|
||||||
|
mock(MobileDataControllerImpl.class));
|
||||||
setupNetworkController();
|
setupNetworkController();
|
||||||
|
|
||||||
verifyLastMobileDataIndicators(false, 0, 0);
|
verifyLastMobileDataIndicators(false, 0, 0);
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import android.net.NetworkInfo;
|
|||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
|
||||||
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
@@ -16,14 +14,10 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
|||||||
private static final int MIN_RSSI = -100;
|
private static final int MIN_RSSI = -100;
|
||||||
private static final int MAX_RSSI = -55;
|
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() {
|
public void testWifiIcon() {
|
||||||
String testSsid = "Test SSID";
|
String testSsid = "Test SSID";
|
||||||
setWifiEnabled(true);
|
setWifiEnabled(true);
|
||||||
verifyLastWifiIcon(false, NULL_SIGNAL);
|
verifyLastWifiIcon(false, WifiIcons.WIFI_NO_NETWORK);
|
||||||
|
|
||||||
setWifiState(true, testSsid);
|
setWifiState(true, testSsid);
|
||||||
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[0][0]);
|
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[0][0]);
|
||||||
@@ -42,10 +36,10 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
|||||||
String testSsid = "Test SSID";
|
String testSsid = "Test SSID";
|
||||||
|
|
||||||
setWifiEnabled(false);
|
setWifiEnabled(false);
|
||||||
verifyLastQsWifiIcon(false, false, 0, null);
|
verifyLastQsWifiIcon(false, false, WifiIcons.QS_WIFI_NO_NETWORK, null);
|
||||||
|
|
||||||
setWifiEnabled(true);
|
setWifiEnabled(true);
|
||||||
verifyLastQsWifiIcon(true, false, QS_NO_NET, null);
|
verifyLastQsWifiIcon(true, false, WifiIcons.QS_WIFI_NO_NETWORK, null);
|
||||||
|
|
||||||
setWifiState(true, testSsid);
|
setWifiState(true, testSsid);
|
||||||
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
|
for (int testLevel = 0; testLevel < WifiIcons.WIFI_LEVEL_COUNT; testLevel++) {
|
||||||
@@ -118,8 +112,7 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
|||||||
|
|
||||||
protected void setWifiActivity(int activity) {
|
protected void setWifiActivity(int activity) {
|
||||||
// TODO: Not this, because this variable probably isn't sticking around.
|
// TODO: Not this, because this variable probably isn't sticking around.
|
||||||
mNetworkController.mWifiActivity = activity;
|
mNetworkController.mWifiSignalController.setActivity(activity);
|
||||||
mNetworkController.refreshViews();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setWifiLevel(int level) {
|
protected void setWifiLevel(int level) {
|
||||||
|
|||||||
Reference in New Issue
Block a user