Merge "Fix NetworkController no longer tracking userSetup" into sc-v2-dev
This commit is contained in:
@@ -335,6 +335,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
|||||||
setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
|
setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Get initial user setup state
|
||||||
|
setUserSetupComplete(deviceProvisionedController.isCurrentUserSetup());
|
||||||
|
|
||||||
WifiManager.ScanResultsCallback scanResultsCallback =
|
WifiManager.ScanResultsCallback scanResultsCallback =
|
||||||
new WifiManager.ScanResultsCallback() {
|
new WifiManager.ScanResultsCallback() {
|
||||||
@@ -999,6 +1001,11 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean isUserSetup() {
|
||||||
|
return mUserSetup;
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean hasCorrectMobileControllers(List<SubscriptionInfo> allSubscriptions) {
|
boolean hasCorrectMobileControllers(List<SubscriptionInfo> allSubscriptions) {
|
||||||
if (allSubscriptions.size() != mMobileSignalControllers.size()) {
|
if (allSubscriptions.size() != mMobileSignalControllers.size()) {
|
||||||
@@ -1144,6 +1151,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
|||||||
/** */
|
/** */
|
||||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
pw.println("NetworkController state:");
|
pw.println("NetworkController state:");
|
||||||
|
pw.println(" mUserSetup=" + mUserSetup);
|
||||||
|
|
||||||
pw.println(" - telephony ------");
|
pw.println(" - telephony ------");
|
||||||
pw.print(" hasVoiceCallingFeature()=");
|
pw.print(" hasVoiceCallingFeature()=");
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import static junit.framework.Assert.assertEquals;
|
|||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
import static junit.framework.Assert.assertTrue;
|
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.anyInt;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Matchers.isA;
|
import static org.mockito.Matchers.isA;
|
||||||
@@ -216,8 +216,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
|||||||
when(mMockProvisionController.isCurrentUserSetup()).thenReturn(true);
|
when(mMockProvisionController.isCurrentUserSetup()).thenReturn(true);
|
||||||
doAnswer(invocation -> {
|
doAnswer(invocation -> {
|
||||||
mUserCallback = (DeviceProvisionedListener) invocation.getArguments()[0];
|
mUserCallback = (DeviceProvisionedListener) invocation.getArguments()[0];
|
||||||
mUserCallback.onUserSetupChanged();
|
|
||||||
mUserCallback.onDeviceProvisionedChanged();
|
|
||||||
TestableLooper.get(this).processAllMessages();
|
TestableLooper.get(this).processAllMessages();
|
||||||
return null;
|
return null;
|
||||||
}).when(mMockProvisionController).addCallback(any());
|
}).when(mMockProvisionController).addCallback(any());
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import android.telephony.SubscriptionManager;
|
|||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
|
import android.testing.TestableLooper;
|
||||||
import android.testing.TestableLooper.RunWithLooper;
|
import android.testing.TestableLooper.RunWithLooper;
|
||||||
|
|
||||||
import com.android.settingslib.graph.SignalDrawable;
|
import com.android.settingslib.graph.SignalDrawable;
|
||||||
@@ -59,6 +60,72 @@ import java.util.List;
|
|||||||
@RunWithLooper
|
@RunWithLooper
|
||||||
public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
|
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
|
@Test
|
||||||
public void testNoIconWithoutMobile() {
|
public void testNoIconWithoutMobile() {
|
||||||
// Turn off mobile network support.
|
// Turn off mobile network support.
|
||||||
|
|||||||
Reference in New Issue
Block a user