Fields Summary |
---|
private static final String | TAG |
protected static final int | DEFAULT_LEVEL |
protected static final int | DEFAULT_SIGNAL_STRENGTH |
protected static final int | DEFAULT_QS_SIGNAL_STRENGTH |
protected static final int | DEFAULT_ICON |
protected static final int | DEFAULT_QS_ICON |
protected NetworkControllerImpl | mNetworkController |
protected android.telephony.PhoneStateListener | mPhoneStateListener |
protected com.android.systemui.statusbar.policy.NetworkControllerImpl.SignalCluster | mSignalCluster |
protected com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback | mNetworkSignalChangedCallback |
private android.telephony.SignalStrength | mSignalStrength |
private android.telephony.ServiceState | mServiceState |
protected android.net.ConnectivityManager | mMockCm |
protected android.net.wifi.WifiManager | mMockWm |
protected android.telephony.SubscriptionManager | mMockSm |
protected android.telephony.TelephonyManager | mMockTm |
protected com.android.systemui.statusbar.policy.NetworkControllerImpl.Config | mConfig |
private android.net.NetworkCapabilities | mNetCapabilities |
Methods Summary |
---|
public void | setCdmaEri(int index, int mode)
// TODO: Figure this out.
|
public void | setCdmaLevel(int level)
when(mSignalStrength.getCdmaLevel()).thenReturn(level);
updateSignalStrength();
|
public void | setCdmaRoaming(boolean isRoaming)
when(mServiceState.getCdmaEriIconIndex()).thenReturn(isRoaming ?
EriInfo.ROAMING_INDICATOR_ON : EriInfo.ROAMING_INDICATOR_OFF);
when(mServiceState.getCdmaEriIconMode()).thenReturn(isRoaming ?
EriInfo.ROAMING_ICON_MODE_NORMAL : -1);
updateServiceState();
|
public void | setConnectivity(int inetCondition, int networkType, boolean isConnected)
Intent i = new Intent(ConnectivityManager.INET_CONDITION_ACTION);
// TODO: Separate out into several NetworkCapabilities.
if (isConnected) {
mNetCapabilities.addTransportType(networkType);
} else {
mNetCapabilities.removeTransportType(networkType);
}
if (inetCondition != 0) {
mNetCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
} else {
mNetCapabilities.removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
}
mNetworkController.onReceive(mContext, i);
|
public void | setDataRegState(int dataRegState)
when(mServiceState.getDataRegState()).thenReturn(dataRegState);
updateServiceState();
|
public void | setGsmRoaming(boolean isRoaming)
when(mServiceState.getRoaming()).thenReturn(isRoaming);
updateServiceState();
|
public void | setIsEmergencyOnly(boolean isEmergency)
when(mServiceState.isEmergencyOnly()).thenReturn(isEmergency);
updateServiceState();
|
public void | setIsGsm(boolean gsm)
when(mSignalStrength.isGsm()).thenReturn(gsm);
updateSignalStrength();
|
public void | setLevel(int level)
when(mSignalStrength.getLevel()).thenReturn(level);
updateSignalStrength();
|
protected void | setUp()
super.setUp();
// Mockito stuff.
System.setProperty("dexmaker.dexcache", mContext.getCacheDir().getPath());
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
mMockWm = mock(WifiManager.class);
mMockTm = mock(TelephonyManager.class);
mMockSm = mock(SubscriptionManager.class);
mMockCm = mock(ConnectivityManager.class);
mNetCapabilities = new NetworkCapabilities();
when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(true);
when(mMockCm.getDefaultNetworkCapabilitiesForUser(0)).thenReturn(
new NetworkCapabilities[] { mNetCapabilities });
mSignalStrength = mock(SignalStrength.class);
mServiceState = mock(ServiceState.class);
mConfig = new Config();
mConfig.hspaDataDistinguishable = true;
mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, mMockSm,
mConfig, mock(AccessPointControllerImpl.class),
mock(MobileDataControllerImpl.class));
setupNetworkController();
|
public void | setVoiceRegState(int voiceRegState)
when(mServiceState.getVoiceRegState()).thenReturn(voiceRegState);
updateServiceState();
|
public void | setupDefaultSignal()
setIsGsm(true);
setVoiceRegState(ServiceState.STATE_IN_SERVICE);
setGsmRoaming(false);
setLevel(DEFAULT_LEVEL);
updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_UMTS);
setConnectivity(100, ConnectivityManager.TYPE_MOBILE, true);
|
protected void | setupNetworkController()
// For now just pretend to be the data sim, so we can test that too.
final int subId = SubscriptionManager.getDefaultDataSubId();
SubscriptionInfo subscription = mock(SubscriptionInfo.class);
List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
when(subscription.getSubscriptionId()).thenReturn(subId);
subs.add(subscription);
mNetworkController.setCurrentSubscriptions(subs);
mPhoneStateListener =
mNetworkController.mMobileSignalControllers.get(subId).mPhoneStateListener;
mSignalCluster = mock(SignalCluster.class);
mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class);
mNetworkController.addSignalCluster(mSignalCluster);
mNetworkController.addNetworkSignalChangedCallback(mNetworkSignalChangedCallback);
|
protected void | tearDown()
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
mNetworkController.dump(null, pw, null);
pw.flush();
Log.d(TAG, sw.toString());
super.tearDown();
|
public void | updateCallState(int state)
// Inputs not currently used in NetworkControllerImpl.
mPhoneStateListener.onCallStateChanged(state, "0123456789");
|
public void | updateDataActivity(int dataActivity)
mPhoneStateListener.onDataActivity(dataActivity);
|
public void | updateDataConnectionState(int dataState, int dataNetType)
mPhoneStateListener.onDataConnectionStateChanged(dataState, dataNetType);
|
private void | updateServiceState()
Log.d(TAG, "Sending Service State: " + mServiceState);
mPhoneStateListener.onServiceStateChanged(mServiceState);
|
private void | updateSignalStrength()
Log.d(TAG, "Sending Signal Strength: " + mSignalStrength);
mPhoneStateListener.onSignalStrengthsChanged(mSignalStrength);
|
protected void | verifyHasNoSims(boolean hasNoSimsVisible)
ArgumentCaptor<Boolean> hasNoSimsArg = ArgumentCaptor.forClass(Boolean.class);
Mockito.verify(mSignalCluster, Mockito.atLeastOnce()).setNoSims(hasNoSimsArg.capture());
assertEquals("No sims in status bar", hasNoSimsVisible, (boolean) hasNoSimsArg.getValue());
Mockito.verify(mNetworkSignalChangedCallback, Mockito.atLeastOnce())
.onNoSimVisibleChanged(hasNoSimsArg.capture());
assertEquals("No sims in quick settings", hasNoSimsVisible,
(boolean) hasNoSimsArg.getValue());
|
protected void | verifyLastMobileDataIndicators(boolean visible, int icon, int typeIcon)
ArgumentCaptor<Integer> iconArg = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Boolean> visibleArg = ArgumentCaptor.forClass(Boolean.class);
// TODO: Verify all fields.
Mockito.verify(mSignalCluster, Mockito.atLeastOnce()).setMobileDataIndicators(
visibleArg.capture(), iconArg.capture(), typeIconArg.capture(),
ArgumentCaptor.forClass(String.class).capture(),
ArgumentCaptor.forClass(String.class).capture(),
ArgumentCaptor.forClass(Boolean.class).capture(),
ArgumentCaptor.forClass(Integer.class).capture());
assertEquals("Signal icon in status bar", icon, (int) iconArg.getValue());
assertEquals("Data icon in status bar", typeIcon, (int) typeIconArg.getValue());
assertEquals("Visibility in status bar", visible, (boolean) visibleArg.getValue());
|
protected void | verifyLastQsMobileDataIndicators(boolean visible, int icon, int typeIcon, boolean dataIn, boolean dataOut)
ArgumentCaptor<Integer> iconArg = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Boolean> visibleArg = ArgumentCaptor.forClass(Boolean.class);
ArgumentCaptor<Boolean> dataInArg = ArgumentCaptor.forClass(Boolean.class);
ArgumentCaptor<Boolean> dataOutArg = ArgumentCaptor.forClass(Boolean.class);
Mockito.verify(mNetworkSignalChangedCallback, Mockito.atLeastOnce())
.onMobileDataSignalChanged(visibleArg.capture(), iconArg.capture(),
ArgumentCaptor.forClass(String.class).capture(),
typeIconArg.capture(),
dataInArg.capture(),
dataOutArg.capture(),
ArgumentCaptor.forClass(String.class).capture(),
ArgumentCaptor.forClass(String.class).capture(),
ArgumentCaptor.forClass(Boolean.class).capture());
assertEquals("Visibility in, quick settings", visible, (boolean) visibleArg.getValue());
assertEquals("Signal icon in, quick settings", icon, (int) iconArg.getValue());
assertEquals("Data icon in, quick settings", typeIcon, (int) typeIconArg.getValue());
assertEquals("Data direction in, in quick settings", dataIn,
(boolean) dataInArg.getValue());
assertEquals("Data direction out, in quick settings", dataOut,
(boolean) dataOutArg.getValue());
|