Fix NetworkController no longer tracking userSetup
A previous refactor of DeviceProvisionedController removed the semantics of getting a callback when adding a new listner. This change lets NetworkController check the initial state after registering for updates, and removes the doAnswer call from NetworkControllerBaseTest to mimic this behavior Also add the field to dumpsys Test: manual; check `adb shell -n dumpsys activity service com.android.systemui/.SystemUIService | grep -A1 "NetworkController state:"` Test: atest SystemUITests Bug: 210512851 Change-Id: I82c8b15ad1b2d43494fa28178715ea0d0721fea7
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