Merge "Updates data network name"

This commit is contained in:
Fabian Kozynski
2019-03-25 20:49:49 +00:00
committed by Android (Google) Code Review
4 changed files with 30 additions and 9 deletions

View File

@@ -470,10 +470,16 @@ public class MobileSignalController extends SignalController<
mNetworkController.recalculateEmergency();
}
// Fill in the network name if we think we have it.
if (mCurrentState.networkName == mNetworkNameDefault && mServiceState != null
if (mCurrentState.networkName.equals(mNetworkNameDefault) && mServiceState != null
&& !TextUtils.isEmpty(mServiceState.getOperatorAlphaShort())) {
mCurrentState.networkName = mServiceState.getOperatorAlphaShort();
}
// If this is the data subscription, update the currentState data name
if (mCurrentState.networkNameData.equals(mNetworkNameDefault) && mServiceState != null
&& mCurrentState.dataSim
&& !TextUtils.isEmpty(mServiceState.getDataOperatorAlphaShort())) {
mCurrentState.networkNameData = mServiceState.getDataOperatorAlphaShort();
}
notifyListenersIfNecessary();
}

View File

@@ -448,7 +448,12 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
}
}
protected void assertNetworkNameEquals(String expected) {
protected void assertNetworkNameEquals(String expected) {
assertEquals("Network name", expected, mMobileSignalController.getState().networkName);
}
}
protected void assertDataNetworkNameEquals(String expected) {
assertEquals("Data network name", expected, mNetworkController.getMobileDataNetworkName());
}
}

View File

@@ -285,6 +285,15 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
testDataActivity(TelephonyManager.DATA_ACTIVITY_INOUT, true, true);
}
@Test
public void testUpdateDataNetworkName() {
setupDefaultSignal();
String newDataName = "TestDataName";
when(mServiceState.getDataOperatorAlphaShort()).thenReturn(newDataName);
updateServiceState();
assertDataNetworkNameEquals(newDataName);
}
private void testDataActivity(int direction, boolean in, boolean out) {
updateDataActivity(direction);

View File

@@ -20,6 +20,7 @@ import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.content.Intent;
import android.net.ConnectivityManager;
@@ -55,7 +56,7 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
@Test
public void testNoIconWithoutMobile() {
// Turn off mobile network support.
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
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, mMockSm,
mConfig, Looper.getMainLooper(), mCallbackHandler,
@@ -117,7 +118,7 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
@Test
public void testNoSimlessIconWithoutMobile() {
// Turn off mobile network support.
Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false);
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, mMockSm,
mConfig, Looper.getMainLooper(), mCallbackHandler,
@@ -253,14 +254,14 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
// Generate a list of subscriptions we will tell the NetworkController to use.
SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
subscriptions.add(mockSubInfo);
}
assertTrue(mNetworkController.hasCorrectMobileControllers(subscriptions));
// Add a subscription that the NetworkController doesn't know about.
SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(notTestSubscription);
when(mockSubInfo.getSubscriptionId()).thenReturn(notTestSubscription);
subscriptions.add(mockSubInfo);
assertFalse(mNetworkController.hasCorrectMobileControllers(subscriptions));
}
@@ -290,8 +291,8 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
if (i != indexToSkipSubscription) {
// Generate a list of subscriptions we will tell the NetworkController to use.
SubscriptionInfo mockSubInfo = Mockito.mock(SubscriptionInfo.class);
Mockito.when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
Mockito.when(mockSubInfo.getSimSlotIndex()).thenReturn(testSubscriptions[i]);
when(mockSubInfo.getSubscriptionId()).thenReturn(testSubscriptions[i]);
when(mockSubInfo.getSimSlotIndex()).thenReturn(testSubscriptions[i]);
subscriptions.add(mockSubInfo);
}
}