Merge "Fix NetworkController no longer tracking userSetup" into sc-v2-dev am: 43c6f30d8d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16488206 Change-Id: I637570722b3c92530bcd8500b22a620a600c1a41
This commit is contained in:
@@ -335,6 +335,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
|
||||
}
|
||||
});
|
||||
// Get initial user setup state
|
||||
setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
|
||||
|
||||
WifiManager.ScanResultsCallback scanResultsCallback =
|
||||
new WifiManager.ScanResultsCallback() {
|
||||
@@ -999,6 +1001,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isUserSetup() {
|
||||
return mUserSetup;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean hasCorrectMobileControllers(List<SubscriptionInfo> allSubscriptions) {
|
||||
if (allSubscriptions.size() != mMobileSignalControllers.size()) {
|
||||
@@ -1144,6 +1151,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
||||
/** */
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
pw.println("NetworkController state:");
|
||||
pw.println(" mUserSetup=" + mUserSetup);
|
||||
|
||||
pw.println(" - telephony ------");
|
||||
pw.print(" hasVoiceCallingFeature()=");
|
||||
|
||||
@@ -23,7 +23,7 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.isA;
|
||||
@@ -216,8 +216,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
||||
when(mMockProvisionController.isCurrentUserSetup()).thenReturn(true);
|
||||
doAnswer(invocation -> {
|
||||
mUserCallback = (DeviceProvisionedListener) invocation.getArguments()[0];
|
||||
mUserCallback.onUserSetupChanged();
|
||||
mUserCallback.onDeviceProvisionedChanged();
|
||||
TestableLooper.get(this).processAllMessages();
|
||||
return null;
|
||||
}).when(mMockProvisionController).addCallback(any());
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
|
||||
import com.android.settingslib.graph.SignalDrawable;
|
||||
@@ -59,6 +60,72 @@ import java.util.List;
|
||||
@RunWithLooper
|
||||
public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
|
||||
|
||||
@Test
|
||||
public void testDeviceProvisioned_userNotSetUp() {
|
||||
// GIVEN - user is not setup
|
||||
when(mMockProvisionController.isCurrentUserSetup()).thenReturn(false);
|
||||
|
||||
// WHEN - a NetworkController is created
|
||||
mNetworkController = new NetworkControllerImpl(mContext,
|
||||
mMockCm,
|
||||
mMockTm,
|
||||
mTelephonyListenerManager,
|
||||
mMockWm,
|
||||
mMockNsm,
|
||||
mMockSm,
|
||||
mConfig,
|
||||
TestableLooper.get(this).getLooper(),
|
||||
mFakeExecutor,
|
||||
mCallbackHandler,
|
||||
mock(AccessPointControllerImpl.class),
|
||||
mock(DataUsageController.class),
|
||||
mMockSubDefaults,
|
||||
mMockProvisionController,
|
||||
mMockBd,
|
||||
mDemoModeController,
|
||||
mCarrierConfigTracker,
|
||||
mFeatureFlags,
|
||||
mock(DumpManager.class)
|
||||
);
|
||||
TestableLooper.get(this).processAllMessages();
|
||||
|
||||
// THEN - NetworkController claims the user is not setup
|
||||
assertFalse("User has not been set up", mNetworkController.isUserSetup());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeviceProvisioned_userSetUp() {
|
||||
// GIVEN - user is not setup
|
||||
when(mMockProvisionController.isCurrentUserSetup()).thenReturn(true);
|
||||
|
||||
// WHEN - a NetworkController is created
|
||||
mNetworkController = new NetworkControllerImpl(mContext,
|
||||
mMockCm,
|
||||
mMockTm,
|
||||
mTelephonyListenerManager,
|
||||
mMockWm,
|
||||
mMockNsm,
|
||||
mMockSm,
|
||||
mConfig,
|
||||
TestableLooper.get(this).getLooper(),
|
||||
mFakeExecutor,
|
||||
mCallbackHandler,
|
||||
mock(AccessPointControllerImpl.class),
|
||||
mock(DataUsageController.class),
|
||||
mMockSubDefaults,
|
||||
mMockProvisionController,
|
||||
mMockBd,
|
||||
mDemoModeController,
|
||||
mCarrierConfigTracker,
|
||||
mFeatureFlags,
|
||||
mock(DumpManager.class)
|
||||
);
|
||||
TestableLooper.get(this).processAllMessages();
|
||||
|
||||
// THEN - NetworkController claims the user is not setup
|
||||
assertTrue("User has been set up", mNetworkController.isUserSetup());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoIconWithoutMobile() {
|
||||
// Turn off mobile network support.
|
||||
|
||||
Reference in New Issue
Block a user