Merge "Remove dependency on connectivity sticky broadcasts" into rvc-dev am: 54ba50a500
Change-Id: I8be42400615800be1f3a6b784398f958362954ee
This commit is contained in:
@@ -133,6 +133,35 @@ public class WifiStatusTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches initial state as if a WifiManager.NETWORK_STATE_CHANGED_ACTION have been received.
|
||||||
|
* This replaces the dependency on the initial sticky broadcast.
|
||||||
|
*/
|
||||||
|
public void fetchInitialState() {
|
||||||
|
if (mWifiManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateWifiState();
|
||||||
|
final NetworkInfo networkInfo =
|
||||||
|
mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||||
|
connected = networkInfo != null && networkInfo.isConnected();
|
||||||
|
mWifiInfo = null;
|
||||||
|
ssid = null;
|
||||||
|
if (connected) {
|
||||||
|
mWifiInfo = mWifiManager.getConnectionInfo();
|
||||||
|
if (mWifiInfo != null) {
|
||||||
|
if (mWifiInfo.isPasspointAp() || mWifiInfo.isOsuAp()) {
|
||||||
|
ssid = mWifiInfo.getPasspointProviderFriendlyName();
|
||||||
|
} else {
|
||||||
|
ssid = getValidSsid(mWifiInfo);
|
||||||
|
}
|
||||||
|
updateRssi(mWifiInfo.getRssi());
|
||||||
|
maybeRequestNetworkScore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateStatusLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public void handleBroadcast(Intent intent) {
|
public void handleBroadcast(Intent intent) {
|
||||||
if (mWifiManager == null) {
|
if (mWifiManager == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1301,6 +1301,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private FingerprintManager mFpm;
|
private FingerprintManager mFpm;
|
||||||
private FaceManager mFaceManager;
|
private FaceManager mFaceManager;
|
||||||
private boolean mFingerprintLockedOut;
|
private boolean mFingerprintLockedOut;
|
||||||
|
private TelephonyManager mTelephonyManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When we receive a
|
* When we receive a
|
||||||
@@ -1728,10 +1729,22 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
updateAirplaneModeState();
|
updateAirplaneModeState();
|
||||||
|
|
||||||
TelephonyManager telephony =
|
mTelephonyManager =
|
||||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (telephony != null) {
|
if (mTelephonyManager != null) {
|
||||||
telephony.listen(mPhoneStateListener, LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
|
mTelephonyManager.listen(mPhoneStateListener,
|
||||||
|
LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
|
||||||
|
// Set initial sim states values.
|
||||||
|
for (int slot = 0; slot < mTelephonyManager.getActiveModemCount(); slot++) {
|
||||||
|
int state = mTelephonyManager.getSimState(slot);
|
||||||
|
int[] subIds = mSubscriptionManager.getSubscriptionIds(slot);
|
||||||
|
if (subIds != null) {
|
||||||
|
for (int subId : subIds) {
|
||||||
|
mHandler.obtainMessage(MSG_SIM_STATE_CHANGE, subId, slot, state)
|
||||||
|
.sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ import com.android.systemui.statusbar.policy.PreviewInflater;
|
|||||||
import com.android.systemui.tuner.LockscreenFragment.LockButtonFactory;
|
import com.android.systemui.tuner.LockscreenFragment.LockButtonFactory;
|
||||||
import com.android.systemui.tuner.TunerService;
|
import com.android.systemui.tuner.TunerService;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for the bottom area of the Keyguard, including camera/phone affordance and status
|
* Implementation for the bottom area of the Keyguard, including camera/phone affordance and status
|
||||||
* text.
|
* text.
|
||||||
@@ -553,7 +555,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!mKeyguardStateController.canDismissLockScreen()) {
|
if (!mKeyguardStateController.canDismissLockScreen()) {
|
||||||
AsyncTask.execute(runnable);
|
Dependency.get(Executor.class).execute(runnable);
|
||||||
} else {
|
} else {
|
||||||
boolean dismissShade = !TextUtils.isEmpty(mRightButtonStr)
|
boolean dismissShade = !TextUtils.isEmpty(mRightButtonStr)
|
||||||
&& Dependency.get(TunerService.class).getValue(LOCKSCREEN_RIGHT_UNLOCK, 1) != 0;
|
&& Dependency.get(TunerService.class).getValue(LOCKSCREEN_RIGHT_UNLOCK, 1) != 0;
|
||||||
|
|||||||
@@ -357,7 +357,18 @@ public class NetworkControllerImpl extends BroadcastReceiver
|
|||||||
mBroadcastDispatcher.registerReceiverWithHandler(this, filter, mReceiverHandler);
|
mBroadcastDispatcher.registerReceiverWithHandler(this, filter, mReceiverHandler);
|
||||||
mListening = true;
|
mListening = true;
|
||||||
|
|
||||||
|
// Initial setup of connectivity. Handled as if we had received a sticky broadcast of
|
||||||
|
// ConnectivityManager.CONNECTIVITY_ACTION or ConnectivityManager.INET_CONDITION_ACTION.
|
||||||
|
mReceiverHandler.post(this::updateConnectivity);
|
||||||
|
|
||||||
|
// Initial setup of WifiSignalController. Handled as if we had received a sticky broadcast
|
||||||
|
// of WifiManager.WIFI_STATE_CHANGED_ACTION or WifiManager.NETWORK_STATE_CHANGED_ACTION
|
||||||
|
mReceiverHandler.post(mWifiSignalController::fetchInitialState);
|
||||||
updateMobileControllers();
|
updateMobileControllers();
|
||||||
|
|
||||||
|
// Initial setup of emergency information. Handled as if we had received a sticky broadcast
|
||||||
|
// of TelephonyManager.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED.
|
||||||
|
mReceiverHandler.post(this::recalculateEmergency);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterListeners() {
|
private void unregisterListeners() {
|
||||||
|
|||||||
@@ -101,6 +101,20 @@ public class WifiSignalController extends
|
|||||||
wifiDesc, mCurrentState.isTransient, mCurrentState.statusLabel);
|
wifiDesc, mCurrentState.isTransient, mCurrentState.statusLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches wifi initial state replacing the initial sticky broadcast.
|
||||||
|
*/
|
||||||
|
public void fetchInitialState() {
|
||||||
|
mWifiTracker.fetchInitialState();
|
||||||
|
mCurrentState.enabled = mWifiTracker.enabled;
|
||||||
|
mCurrentState.connected = mWifiTracker.connected;
|
||||||
|
mCurrentState.ssid = mWifiTracker.ssid;
|
||||||
|
mCurrentState.rssi = mWifiTracker.rssi;
|
||||||
|
mCurrentState.level = mWifiTracker.level;
|
||||||
|
mCurrentState.statusLabel = mWifiTracker.statusLabel;
|
||||||
|
notifyListenersIfNecessary();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract wifi state directly from broadcasts about changes in wifi state.
|
* Extract wifi state directly from broadcasts about changes in wifi state.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import android.os.UserManager;
|
|||||||
import android.telephony.ServiceState;
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
|
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.TestableContext;
|
import android.testing.TestableContext;
|
||||||
@@ -133,20 +134,23 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
@Mock
|
@Mock
|
||||||
private Executor mBackgroundExecutor;
|
|
||||||
@Mock
|
|
||||||
private RingerModeTracker mRingerModeTracker;
|
private RingerModeTracker mRingerModeTracker;
|
||||||
@Mock
|
@Mock
|
||||||
private LiveData<Integer> mRingerModeLiveData;
|
private LiveData<Integer> mRingerModeLiveData;
|
||||||
|
@Mock
|
||||||
|
private TelephonyManager mTelephonyManager;
|
||||||
|
// Direct executor
|
||||||
|
private Executor mBackgroundExecutor = Runnable::run;
|
||||||
private TestableLooper mTestableLooper;
|
private TestableLooper mTestableLooper;
|
||||||
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private TestableKeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
|
private TestableContext mSpiedContext;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
TestableContext context = spy(mContext);
|
mSpiedContext = spy(mContext);
|
||||||
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
|
||||||
when(context.getPackageManager()).thenReturn(mPackageManager);
|
when(mSpiedContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
doAnswer(invocation -> {
|
doAnswer(invocation -> {
|
||||||
IBiometricEnabledOnKeyguardCallback callback = invocation.getArgument(0);
|
IBiometricEnabledOnKeyguardCallback callback = invocation.getArgument(0);
|
||||||
callback.onChanged(BiometricSourceType.FACE, true /* enabled */,
|
callback.onChanged(BiometricSourceType.FACE, true /* enabled */,
|
||||||
@@ -161,19 +165,20 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
when(mStrongAuthTracker
|
when(mStrongAuthTracker
|
||||||
.isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */))
|
.isUnlockingWithBiometricAllowed(anyBoolean() /* isStrongBiometric */))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
context.addMockSystemService(TrustManager.class, mTrustManager);
|
mSpiedContext.addMockSystemService(TrustManager.class, mTrustManager);
|
||||||
context.addMockSystemService(FingerprintManager.class, mFingerprintManager);
|
mSpiedContext.addMockSystemService(FingerprintManager.class, mFingerprintManager);
|
||||||
context.addMockSystemService(BiometricManager.class, mBiometricManager);
|
mSpiedContext.addMockSystemService(BiometricManager.class, mBiometricManager);
|
||||||
context.addMockSystemService(FaceManager.class, mFaceManager);
|
mSpiedContext.addMockSystemService(FaceManager.class, mFaceManager);
|
||||||
context.addMockSystemService(UserManager.class, mUserManager);
|
mSpiedContext.addMockSystemService(UserManager.class, mUserManager);
|
||||||
context.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager);
|
mSpiedContext.addMockSystemService(DevicePolicyManager.class, mDevicePolicyManager);
|
||||||
context.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
|
mSpiedContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
|
||||||
|
mSpiedContext.addMockSystemService(TelephonyManager.class, mTelephonyManager);
|
||||||
|
|
||||||
when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData);
|
when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData);
|
||||||
|
|
||||||
mTestableLooper = TestableLooper.get(this);
|
mTestableLooper = TestableLooper.get(this);
|
||||||
allowTestableLooperAsMainThread();
|
allowTestableLooperAsMainThread();
|
||||||
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(context);
|
mKeyguardUpdateMonitor = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -191,6 +196,22 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
any(IntentFilter.class), any(Handler.class), eq(UserHandle.ALL));
|
any(IntentFilter.class), any(Handler.class), eq(UserHandle.ALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSimStateInitialized() {
|
||||||
|
final int subId = 3;
|
||||||
|
final int state = TelephonyManager.SIM_STATE_ABSENT;
|
||||||
|
|
||||||
|
when(mTelephonyManager.getActiveModemCount()).thenReturn(1);
|
||||||
|
when(mTelephonyManager.getSimState(anyInt())).thenReturn(state);
|
||||||
|
when(mSubscriptionManager.getSubscriptionIds(anyInt())).thenReturn(new int[] { subId });
|
||||||
|
|
||||||
|
KeyguardUpdateMonitor testKUM = new TestableKeyguardUpdateMonitor(mSpiedContext);
|
||||||
|
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
|
||||||
|
assertThat(testKUM.getSimState(subId)).isEqualTo(state);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoresSimStateCallback_rebroadcast() {
|
public void testIgnoresSimStateCallback_rebroadcast() {
|
||||||
Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
|||||||
import com.android.systemui.statusbar.phone.LockscreenLockIconController;
|
import com.android.systemui.statusbar.phone.LockscreenLockIconController;
|
||||||
import com.android.systemui.statusbar.phone.NotificationGroupManager;
|
import com.android.systemui.statusbar.phone.NotificationGroupManager;
|
||||||
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
|
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
|
||||||
|
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
|
||||||
import com.android.systemui.statusbar.phone.ShadeController;
|
import com.android.systemui.statusbar.phone.ShadeController;
|
||||||
import com.android.systemui.statusbar.policy.BatteryController;
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
@@ -183,6 +184,8 @@ public class BubbleControllerTest extends SysuiTestCase {
|
|||||||
private DumpManager mDumpManager;
|
private DumpManager mDumpManager;
|
||||||
@Mock
|
@Mock
|
||||||
private LockscreenLockIconController mLockIconController;
|
private LockscreenLockIconController mLockIconController;
|
||||||
|
@Mock
|
||||||
|
private NotificationShadeWindowView mNotificationShadeWindowView;
|
||||||
|
|
||||||
private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
|
private SuperStatusBarViewFactory mSuperStatusBarViewFactory;
|
||||||
private BubbleData mBubbleData;
|
private BubbleData mBubbleData;
|
||||||
@@ -219,8 +222,7 @@ public class BubbleControllerTest extends SysuiTestCase {
|
|||||||
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
|
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
|
||||||
mConfigurationController, mKeyguardBypassController, mColorExtractor,
|
mConfigurationController, mKeyguardBypassController, mColorExtractor,
|
||||||
mDumpManager);
|
mDumpManager);
|
||||||
mNotificationShadeWindowController.setNotificationShadeView(
|
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
|
||||||
mSuperStatusBarViewFactory.getNotificationShadeWindowView());
|
|
||||||
mNotificationShadeWindowController.attach();
|
mNotificationShadeWindowController.attach();
|
||||||
|
|
||||||
// Need notifications for bubbles
|
// Need notifications for bubbles
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
|||||||
import com.android.systemui.statusbar.phone.LockscreenLockIconController;
|
import com.android.systemui.statusbar.phone.LockscreenLockIconController;
|
||||||
import com.android.systemui.statusbar.phone.NotificationGroupManager;
|
import com.android.systemui.statusbar.phone.NotificationGroupManager;
|
||||||
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
|
import com.android.systemui.statusbar.phone.NotificationShadeWindowController;
|
||||||
|
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
|
||||||
import com.android.systemui.statusbar.phone.ShadeController;
|
import com.android.systemui.statusbar.phone.ShadeController;
|
||||||
import com.android.systemui.statusbar.policy.BatteryController;
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
@@ -134,6 +135,8 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
|||||||
private KeyguardBypassController mKeyguardBypassController;
|
private KeyguardBypassController mKeyguardBypassController;
|
||||||
@Mock
|
@Mock
|
||||||
private FloatingContentCoordinator mFloatingContentCoordinator;
|
private FloatingContentCoordinator mFloatingContentCoordinator;
|
||||||
|
@Mock
|
||||||
|
private NotificationShadeWindowView mNotificationShadeWindowView;
|
||||||
|
|
||||||
private SysUiState mSysUiState = new SysUiState();
|
private SysUiState mSysUiState = new SysUiState();
|
||||||
|
|
||||||
@@ -206,8 +209,7 @@ public class NewNotifPipelineBubbleControllerTest extends SysuiTestCase {
|
|||||||
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
|
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
|
||||||
mConfigurationController, mKeyguardBypassController, mColorExtractor,
|
mConfigurationController, mKeyguardBypassController, mColorExtractor,
|
||||||
mDumpManager);
|
mDumpManager);
|
||||||
mNotificationShadeWindowController.setNotificationShadeView(
|
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
|
||||||
mSuperStatusBarViewFactory.getNotificationShadeWindowView());
|
|
||||||
mNotificationShadeWindowController.attach();
|
mNotificationShadeWindowController.attach();
|
||||||
|
|
||||||
// Need notifications for bubbles
|
// Need notifications for bubbles
|
||||||
|
|||||||
@@ -6,11 +6,18 @@ import android.view.LayoutInflater
|
|||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
|
import com.android.systemui.assist.AssistManager
|
||||||
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
|
import com.android.systemui.statusbar.policy.AccessibilityController
|
||||||
|
import com.android.systemui.statusbar.policy.FlashlightController
|
||||||
|
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||||
|
import com.android.systemui.tuner.TunerService
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
import java.util.concurrent.Executor
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner::class)
|
@RunWith(AndroidTestingRunner::class)
|
||||||
@@ -24,6 +31,15 @@ class KeyguardBottomAreaTest : SysuiTestCase() {
|
|||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
|
// Mocked dependencies
|
||||||
|
mDependency.injectMockDependency(AccessibilityController::class.java)
|
||||||
|
mDependency.injectMockDependency(ActivityStarter::class.java)
|
||||||
|
mDependency.injectMockDependency(AssistManager::class.java)
|
||||||
|
mDependency.injectTestDependency(Executor::class.java, Executor { it.run() })
|
||||||
|
mDependency.injectMockDependency(FlashlightController::class.java)
|
||||||
|
mDependency.injectMockDependency(KeyguardStateController::class.java)
|
||||||
|
mDependency.injectMockDependency(TunerService::class.java)
|
||||||
|
|
||||||
mKeyguardBottomArea = LayoutInflater.from(mContext).inflate(
|
mKeyguardBottomArea = LayoutInflater.from(mContext).inflate(
|
||||||
R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView
|
R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView
|
||||||
mKeyguardBottomArea.setStatusBar(mStatusBar)
|
mKeyguardBottomArea.setStatusBar(mStatusBar)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.atLeastOnce;
|
|||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
@@ -222,7 +223,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
|||||||
|
|
||||||
ArgumentCaptor<ConnectivityManager.NetworkCallback> callbackArg =
|
ArgumentCaptor<ConnectivityManager.NetworkCallback> callbackArg =
|
||||||
ArgumentCaptor.forClass(ConnectivityManager.NetworkCallback.class);
|
ArgumentCaptor.forClass(ConnectivityManager.NetworkCallback.class);
|
||||||
Mockito.verify(mMockCm, atLeastOnce())
|
verify(mMockCm, atLeastOnce())
|
||||||
.registerDefaultNetworkCallback(callbackArg.capture(), isA(Handler.class));
|
.registerDefaultNetworkCallback(callbackArg.capture(), isA(Handler.class));
|
||||||
mNetworkCallback = callbackArg.getValue();
|
mNetworkCallback = callbackArg.getValue();
|
||||||
assertNotNull(mNetworkCallback);
|
assertNotNull(mNetworkCallback);
|
||||||
@@ -384,7 +385,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void verifyHasNoSims(boolean hasNoSimsVisible) {
|
protected void verifyHasNoSims(boolean hasNoSimsVisible) {
|
||||||
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setNoSims(
|
verify(mCallbackHandler, Mockito.atLeastOnce()).setNoSims(
|
||||||
eq(hasNoSimsVisible), eq(false));
|
eq(hasNoSimsVisible), eq(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,7 +396,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor<Boolean> dataInArg = ArgumentCaptor.forClass(Boolean.class);
|
ArgumentCaptor<Boolean> dataInArg = ArgumentCaptor.forClass(Boolean.class);
|
||||||
ArgumentCaptor<Boolean> dataOutArg = ArgumentCaptor.forClass(Boolean.class);
|
ArgumentCaptor<Boolean> dataOutArg = ArgumentCaptor.forClass(Boolean.class);
|
||||||
|
|
||||||
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
||||||
any(),
|
any(),
|
||||||
iconArg.capture(),
|
iconArg.capture(),
|
||||||
anyInt(),
|
anyInt(),
|
||||||
@@ -429,7 +430,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
|
ArgumentCaptor<Integer> typeIconArg = ArgumentCaptor.forClass(Integer.class);
|
||||||
|
|
||||||
// TODO: Verify all fields.
|
// TODO: Verify all fields.
|
||||||
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
||||||
iconArg.capture(),
|
iconArg.capture(),
|
||||||
any(),
|
any(),
|
||||||
typeIconArg.capture(),
|
typeIconArg.capture(),
|
||||||
@@ -475,7 +476,7 @@ public class NetworkControllerBaseTest extends SysuiTestCase {
|
|||||||
ArgumentCaptor<CharSequence> typeContentDescriptionHtmlArg =
|
ArgumentCaptor<CharSequence> typeContentDescriptionHtmlArg =
|
||||||
ArgumentCaptor.forClass(CharSequence.class);
|
ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
|
||||||
Mockito.verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
verify(mCallbackHandler, Mockito.atLeastOnce()).setMobileDataIndicators(
|
||||||
iconArg.capture(),
|
iconArg.capture(),
|
||||||
qsIconArg.capture(),
|
qsIconArg.capture(),
|
||||||
typeIconArg.capture(),
|
typeIconArg.capture(),
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ package com.android.systemui.statusbar.policy;
|
|||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyBoolean;
|
import static org.mockito.Matchers.anyBoolean;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
@@ -171,6 +173,32 @@ public class NetworkControllerWifiTest extends NetworkControllerBaseTest {
|
|||||||
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[1][testLevel]);
|
verifyLastWifiIcon(true, WifiIcons.WIFI_SIGNAL_STRENGTH[1][testLevel]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetchInitialData() {
|
||||||
|
mNetworkController.mWifiSignalController.fetchInitialState();
|
||||||
|
Mockito.verify(mMockWm).getWifiState();
|
||||||
|
Mockito.verify(mMockCm).getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetchInitialData_correctValues() {
|
||||||
|
String testSsid = "TEST";
|
||||||
|
|
||||||
|
when(mMockWm.getWifiState()).thenReturn(WifiManager.WIFI_STATE_ENABLED);
|
||||||
|
NetworkInfo networkInfo = mock(NetworkInfo.class);
|
||||||
|
when(networkInfo.isConnected()).thenReturn(true);
|
||||||
|
when(mMockCm.getNetworkInfo(ConnectivityManager.TYPE_WIFI)).thenReturn(networkInfo);
|
||||||
|
WifiInfo wifiInfo = mock(WifiInfo.class);
|
||||||
|
when(wifiInfo.getSSID()).thenReturn(testSsid);
|
||||||
|
when(mMockWm.getConnectionInfo()).thenReturn(wifiInfo);
|
||||||
|
|
||||||
|
mNetworkController.mWifiSignalController.fetchInitialState();
|
||||||
|
|
||||||
|
assertTrue(mNetworkController.mWifiSignalController.mCurrentState.enabled);
|
||||||
|
assertTrue(mNetworkController.mWifiSignalController.mCurrentState.connected);
|
||||||
|
assertEquals(testSsid, mNetworkController.mWifiSignalController.mCurrentState.ssid);
|
||||||
|
}
|
||||||
|
|
||||||
protected void setWifiActivity(int activity) {
|
protected void setWifiActivity(int activity) {
|
||||||
// TODO: Not this, because this variable probably isn't sticking around.
|
// TODO: Not this, because this variable probably isn't sticking around.
|
||||||
mNetworkController.mWifiSignalController.setActivity(activity);
|
mNetworkController.mWifiSignalController.setActivity(activity);
|
||||||
|
|||||||
Reference in New Issue
Block a user