1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.phone; 18 19 20 import static android.app.StatusBarManager.DISABLE2_SYSTEM_ICONS; 21 import static android.app.StatusBarManager.DISABLE_SYSTEM_INFO; 22 23 import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; 24 import static com.android.systemui.statusbar.StatusBarState.SHADE; 25 26 import static com.google.common.truth.Truth.assertThat; 27 28 import static org.junit.Assert.assertFalse; 29 import static org.junit.Assert.assertTrue; 30 import static org.mockito.ArgumentMatchers.any; 31 import static org.mockito.ArgumentMatchers.anyBoolean; 32 import static org.mockito.Mockito.clearInvocations; 33 import static org.mockito.Mockito.spy; 34 import static org.mockito.Mockito.verify; 35 import static org.mockito.Mockito.when; 36 37 import android.os.UserHandle; 38 import android.os.UserManager; 39 import android.provider.Settings; 40 import android.testing.AndroidTestingRunner; 41 import android.testing.TestableLooper; 42 import android.view.LayoutInflater; 43 import android.view.View; 44 45 import androidx.test.filters.SmallTest; 46 47 import com.android.keyguard.CarrierTextController; 48 import com.android.keyguard.KeyguardUpdateMonitor; 49 import com.android.keyguard.KeyguardUpdateMonitorCallback; 50 import com.android.keyguard.logging.KeyguardLogger; 51 import com.android.systemui.R; 52 import com.android.systemui.SysuiTestCase; 53 import com.android.systemui.battery.BatteryMeterViewController; 54 import com.android.systemui.plugins.statusbar.StatusBarStateController; 55 import com.android.systemui.shade.ShadeViewStateProvider; 56 import com.android.systemui.statusbar.CommandQueue; 57 import com.android.systemui.statusbar.NotificationMediaManager; 58 import com.android.systemui.statusbar.SysuiStatusBarStateController; 59 import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; 60 import com.android.systemui.statusbar.policy.BatteryController; 61 import com.android.systemui.statusbar.policy.ConfigurationController; 62 import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; 63 import com.android.systemui.statusbar.policy.KeyguardStateController; 64 import com.android.systemui.statusbar.policy.UserInfoController; 65 import com.android.systemui.user.ui.viewmodel.StatusBarUserChipViewModel; 66 import com.android.systemui.util.concurrency.FakeExecutor; 67 import com.android.systemui.util.settings.SecureSettings; 68 import com.android.systemui.util.time.FakeSystemClock; 69 70 import org.junit.Before; 71 import org.junit.Test; 72 import org.junit.runner.RunWith; 73 import org.mockito.ArgumentCaptor; 74 import org.mockito.Captor; 75 import org.mockito.Mock; 76 import org.mockito.MockitoAnnotations; 77 78 @SmallTest 79 @RunWith(AndroidTestingRunner.class) 80 @TestableLooper.RunWithLooper 81 public class KeyguardStatusBarViewControllerTest extends SysuiTestCase { 82 @Mock 83 private CarrierTextController mCarrierTextController; 84 @Mock 85 private ConfigurationController mConfigurationController; 86 @Mock 87 private SystemStatusAnimationScheduler mAnimationScheduler; 88 @Mock 89 private BatteryController mBatteryController; 90 @Mock 91 private UserInfoController mUserInfoController; 92 @Mock 93 private StatusBarIconController mStatusBarIconController; 94 @Mock 95 private StatusBarIconController.TintedIconManager.Factory mIconManagerFactory; 96 @Mock 97 private StatusBarIconController.TintedIconManager mIconManager; 98 @Mock 99 private BatteryMeterViewController mBatteryMeterViewController; 100 @Mock 101 private KeyguardStateController mKeyguardStateController; 102 @Mock 103 private KeyguardBypassController mKeyguardBypassController; 104 @Mock 105 private KeyguardUpdateMonitor mKeyguardUpdateMonitor; 106 @Mock 107 private BiometricUnlockController mBiometricUnlockController; 108 @Mock 109 private SysuiStatusBarStateController mStatusBarStateController; 110 @Mock 111 private StatusBarContentInsetsProvider mStatusBarContentInsetsProvider; 112 @Mock 113 private UserManager mUserManager; 114 @Mock 115 private StatusBarUserChipViewModel mStatusBarUserChipViewModel; 116 @Captor 117 private ArgumentCaptor<ConfigurationListener> mConfigurationListenerCaptor; 118 @Captor 119 private ArgumentCaptor<KeyguardUpdateMonitorCallback> mKeyguardCallbackCaptor; 120 @Mock private SecureSettings mSecureSettings; 121 @Mock private CommandQueue mCommandQueue; 122 @Mock private KeyguardLogger mLogger; 123 124 @Mock private NotificationMediaManager mNotificationMediaManager; 125 @Mock private StatusOverlayHoverListenerFactory mStatusOverlayHoverListenerFactory; 126 127 private TestShadeViewStateProvider mShadeViewStateProvider; 128 private KeyguardStatusBarView mKeyguardStatusBarView; 129 private KeyguardStatusBarViewController mController; 130 private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock()); 131 132 @Before setup()133 public void setup() throws Exception { 134 mShadeViewStateProvider = new TestShadeViewStateProvider(); 135 136 MockitoAnnotations.initMocks(this); 137 138 when(mIconManagerFactory.create(any(), any())).thenReturn(mIconManager); 139 140 allowTestableLooperAsMainThread(); 141 TestableLooper.get(this).runWithLooper(() -> { 142 mKeyguardStatusBarView = 143 spy((KeyguardStatusBarView) LayoutInflater.from(mContext) 144 .inflate(R.layout.keyguard_status_bar, null)); 145 when(mKeyguardStatusBarView.getDisplay()).thenReturn(mContext.getDisplay()); 146 }); 147 148 mController = createController(); 149 } 150 createController()151 private KeyguardStatusBarViewController createController() { 152 return new KeyguardStatusBarViewController( 153 mKeyguardStatusBarView, 154 mCarrierTextController, 155 mConfigurationController, 156 mAnimationScheduler, 157 mBatteryController, 158 mUserInfoController, 159 mStatusBarIconController, 160 mIconManagerFactory, 161 mBatteryMeterViewController, 162 mShadeViewStateProvider, 163 mKeyguardStateController, 164 mKeyguardBypassController, 165 mKeyguardUpdateMonitor, 166 mBiometricUnlockController, 167 mStatusBarStateController, 168 mStatusBarContentInsetsProvider, 169 mUserManager, 170 mStatusBarUserChipViewModel, 171 mSecureSettings, 172 mCommandQueue, 173 mFakeExecutor, 174 mLogger, 175 mNotificationMediaManager, 176 mStatusOverlayHoverListenerFactory 177 ); 178 } 179 180 @Test onViewAttached_callbacksRegistered()181 public void onViewAttached_callbacksRegistered() { 182 mController.onViewAttached(); 183 184 verify(mConfigurationController).addCallback(any()); 185 verify(mAnimationScheduler).addCallback(any()); 186 verify(mUserInfoController).addCallback(any()); 187 verify(mCommandQueue).addCallback(any()); 188 verify(mStatusBarIconController).addIconGroup(any()); 189 verify(mUserManager).isUserSwitcherEnabled(anyBoolean()); 190 } 191 192 @Test onConfigurationChanged_updatesUserSwitcherVisibility()193 public void onConfigurationChanged_updatesUserSwitcherVisibility() { 194 mController.onViewAttached(); 195 verify(mConfigurationController).addCallback(mConfigurationListenerCaptor.capture()); 196 clearInvocations(mUserManager); 197 clearInvocations(mKeyguardStatusBarView); 198 199 mConfigurationListenerCaptor.getValue().onConfigChanged(null); 200 verify(mUserManager).isUserSwitcherEnabled(anyBoolean()); 201 verify(mKeyguardStatusBarView).setUserSwitcherEnabled(anyBoolean()); 202 } 203 204 @Test onKeyguardVisibilityChanged_updatesUserSwitcherVisibility()205 public void onKeyguardVisibilityChanged_updatesUserSwitcherVisibility() { 206 mController.onViewAttached(); 207 verify(mKeyguardUpdateMonitor).registerCallback(mKeyguardCallbackCaptor.capture()); 208 clearInvocations(mUserManager); 209 clearInvocations(mKeyguardStatusBarView); 210 211 mKeyguardCallbackCaptor.getValue().onKeyguardVisibilityChanged(true); 212 verify(mUserManager).isUserSwitcherEnabled(anyBoolean()); 213 verify(mKeyguardStatusBarView).setUserSwitcherEnabled(anyBoolean()); 214 } 215 216 @Test onViewDetached_callbacksUnregistered()217 public void onViewDetached_callbacksUnregistered() { 218 // Set everything up first. 219 mController.onViewAttached(); 220 221 mController.onViewDetached(); 222 223 verify(mConfigurationController).removeCallback(any()); 224 verify(mAnimationScheduler).removeCallback(any()); 225 verify(mUserInfoController).removeCallback(any()); 226 verify(mCommandQueue).removeCallback(any()); 227 verify(mStatusBarIconController).removeIconGroup(any()); 228 } 229 230 @Test setBatteryListening_true_callbackAdded()231 public void setBatteryListening_true_callbackAdded() { 232 mController.setBatteryListening(true); 233 234 verify(mBatteryController).addCallback(any()); 235 } 236 237 @Test setBatteryListening_false_callbackRemoved()238 public void setBatteryListening_false_callbackRemoved() { 239 // First set to true so that we know setting to false is a change in state. 240 mController.setBatteryListening(true); 241 242 mController.setBatteryListening(false); 243 244 verify(mBatteryController).removeCallback(any()); 245 } 246 247 @Test setBatteryListening_trueThenTrue_callbackAddedOnce()248 public void setBatteryListening_trueThenTrue_callbackAddedOnce() { 249 mController.setBatteryListening(true); 250 mController.setBatteryListening(true); 251 252 verify(mBatteryController).addCallback(any()); 253 } 254 255 @Test updateTopClipping_viewClippingUpdated()256 public void updateTopClipping_viewClippingUpdated() { 257 int viewTop = 20; 258 mKeyguardStatusBarView.setTop(viewTop); 259 int notificationPanelTop = 30; 260 261 mController.updateTopClipping(notificationPanelTop); 262 263 assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo( 264 notificationPanelTop - viewTop); 265 } 266 267 @Test setNotTopClipping_viewClippingUpdatedToZero()268 public void setNotTopClipping_viewClippingUpdatedToZero() { 269 // Start out with some amount of top clipping. 270 mController.updateTopClipping(50); 271 assertThat(mKeyguardStatusBarView.getClipBounds().top).isGreaterThan(0); 272 273 mController.setNoTopClipping(); 274 275 assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(0); 276 } 277 278 @Test updateViewState_alphaAndVisibilityGiven_viewUpdated()279 public void updateViewState_alphaAndVisibilityGiven_viewUpdated() { 280 // Verify the initial values so we know the method triggers changes. 281 assertThat(mKeyguardStatusBarView.getAlpha()).isEqualTo(1f); 282 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 283 284 float newAlpha = 0.5f; 285 int newVisibility = View.INVISIBLE; 286 mController.updateViewState(newAlpha, newVisibility); 287 288 assertThat(mKeyguardStatusBarView.getAlpha()).isEqualTo(newAlpha); 289 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(newVisibility); 290 } 291 292 @Test updateViewState_paramVisibleButIsDisabled_viewIsInvisible()293 public void updateViewState_paramVisibleButIsDisabled_viewIsInvisible() { 294 mController.onViewAttached(); 295 setDisableSystemIcons(true); 296 297 mController.updateViewState(1f, View.VISIBLE); 298 299 // Since we're disabled, we stay invisible 300 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 301 } 302 303 @Test updateViewState_notKeyguardState_nothingUpdated()304 public void updateViewState_notKeyguardState_nothingUpdated() { 305 mController.onViewAttached(); 306 updateStateToNotKeyguard(); 307 308 float oldAlpha = mKeyguardStatusBarView.getAlpha(); 309 310 mController.updateViewState(); 311 312 assertThat(mKeyguardStatusBarView.getAlpha()).isEqualTo(oldAlpha); 313 } 314 315 @Test updateViewState_bypassEnabledAndShouldListenForFace_viewHidden()316 public void updateViewState_bypassEnabledAndShouldListenForFace_viewHidden() { 317 mController.onViewAttached(); 318 updateStateToKeyguard(); 319 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 320 321 when(mKeyguardUpdateMonitor.shouldListenForFace()).thenReturn(true); 322 when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true); 323 onFinishedGoingToSleep(); 324 325 mController.updateViewState(); 326 327 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 328 } 329 330 @Test updateViewState_bypassNotEnabled_viewShown()331 public void updateViewState_bypassNotEnabled_viewShown() { 332 mController.onViewAttached(); 333 updateStateToKeyguard(); 334 335 when(mKeyguardUpdateMonitor.shouldListenForFace()).thenReturn(true); 336 when(mKeyguardBypassController.getBypassEnabled()).thenReturn(false); 337 onFinishedGoingToSleep(); 338 339 mController.updateViewState(); 340 341 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 342 } 343 344 @Test updateViewState_shouldNotListenForFace_viewShown()345 public void updateViewState_shouldNotListenForFace_viewShown() { 346 mController.onViewAttached(); 347 updateStateToKeyguard(); 348 349 when(mKeyguardUpdateMonitor.shouldListenForFace()).thenReturn(false); 350 when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true); 351 onFinishedGoingToSleep(); 352 353 mController.updateViewState(); 354 355 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 356 } 357 358 @Test updateViewState_panelExpandedHeightZero_viewHidden()359 public void updateViewState_panelExpandedHeightZero_viewHidden() { 360 mController.onViewAttached(); 361 updateStateToKeyguard(); 362 363 mShadeViewStateProvider.setPanelViewExpandedHeight(0); 364 365 mController.updateViewState(); 366 367 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 368 } 369 370 @Test updateViewState_dragProgressOne_viewHidden()371 public void updateViewState_dragProgressOne_viewHidden() { 372 mController.onViewAttached(); 373 updateStateToKeyguard(); 374 375 mShadeViewStateProvider.setLockscreenShadeDragProgress(1f); 376 377 mController.updateViewState(); 378 379 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 380 } 381 382 @Test updateViewState_disableSystemInfoFalse_viewShown()383 public void updateViewState_disableSystemInfoFalse_viewShown() { 384 mController.onViewAttached(); 385 updateStateToKeyguard(); 386 setDisableSystemInfo(false); 387 388 mController.updateViewState(); 389 390 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 391 } 392 393 @Test updateViewState_disableSystemInfoTrue_viewHidden()394 public void updateViewState_disableSystemInfoTrue_viewHidden() { 395 mController.onViewAttached(); 396 updateStateToKeyguard(); 397 setDisableSystemInfo(true); 398 399 mController.updateViewState(); 400 401 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 402 } 403 404 @Test updateViewState_disableSystemIconsFalse_viewShown()405 public void updateViewState_disableSystemIconsFalse_viewShown() { 406 mController.onViewAttached(); 407 updateStateToKeyguard(); 408 setDisableSystemIcons(false); 409 410 mController.updateViewState(); 411 412 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 413 } 414 415 @Test updateViewState_disableSystemIconsTrue_viewHidden()416 public void updateViewState_disableSystemIconsTrue_viewHidden() { 417 mController.onViewAttached(); 418 updateStateToKeyguard(); 419 setDisableSystemIcons(true); 420 421 mController.updateViewState(); 422 423 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 424 } 425 426 @Test setAlpha_explicitAlpha_setsExplicitAlpha()427 public void setAlpha_explicitAlpha_setsExplicitAlpha() { 428 mController.onViewAttached(); 429 updateStateToKeyguard(); 430 431 mController.setAlpha(0.5f); 432 433 assertThat(mKeyguardStatusBarView.getAlpha()).isEqualTo(0.5f); 434 } 435 436 @Test setAlpha_explicitAlpha_thenMinusOneAlpha_setsAlphaBasedOnDefaultCriteria()437 public void setAlpha_explicitAlpha_thenMinusOneAlpha_setsAlphaBasedOnDefaultCriteria() { 438 mController.onViewAttached(); 439 updateStateToKeyguard(); 440 441 mController.setAlpha(0.5f); 442 mController.setAlpha(-1f); 443 444 assertThat(mKeyguardStatusBarView.getAlpha()).isGreaterThan(0); 445 assertThat(mKeyguardStatusBarView.getAlpha()).isNotEqualTo(0.5f); 446 } 447 448 // TODO(b/195442899): Add more tests for #updateViewState once CLs are finalized. 449 450 @Test updateForHeadsUp_headsUpShouldBeVisible_viewHidden()451 public void updateForHeadsUp_headsUpShouldBeVisible_viewHidden() { 452 mController.onViewAttached(); 453 updateStateToKeyguard(); 454 mKeyguardStatusBarView.setVisibility(View.VISIBLE); 455 456 mShadeViewStateProvider.setShouldHeadsUpBeVisible(true); 457 mController.updateForHeadsUp(/* animate= */ false); 458 459 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 460 } 461 462 @Test updateForHeadsUp_headsUpShouldNotBeVisible_viewShown()463 public void updateForHeadsUp_headsUpShouldNotBeVisible_viewShown() { 464 mController.onViewAttached(); 465 updateStateToKeyguard(); 466 467 // Start with the opposite state. 468 mShadeViewStateProvider.setShouldHeadsUpBeVisible(true); 469 mController.updateForHeadsUp(/* animate= */ false); 470 471 mShadeViewStateProvider.setShouldHeadsUpBeVisible(false); 472 mController.updateForHeadsUp(/* animate= */ false); 473 474 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.VISIBLE); 475 } 476 477 @Test testNewUserSwitcherDisablesAvatar_newUiOn()478 public void testNewUserSwitcherDisablesAvatar_newUiOn() { 479 // GIVEN the status bar user switcher chip is enabled 480 when(mStatusBarUserChipViewModel.getChipEnabled()).thenReturn(true); 481 482 // WHEN the controller is created 483 mController = createController(); 484 485 // THEN keyguard status bar view avatar is disabled 486 assertThat(mKeyguardStatusBarView.isKeyguardUserAvatarEnabled()).isFalse(); 487 } 488 489 @Test testNewUserSwitcherDisablesAvatar_newUiOff()490 public void testNewUserSwitcherDisablesAvatar_newUiOff() { 491 // GIVEN the status bar user switcher chip is disabled 492 when(mStatusBarUserChipViewModel.getChipEnabled()).thenReturn(false); 493 494 // WHEN the controller is created 495 mController = createController(); 496 497 // THEN keyguard status bar view avatar is enabled 498 assertThat(mKeyguardStatusBarView.isKeyguardUserAvatarEnabled()).isTrue(); 499 } 500 501 @Test testBlockedIcons_obeysSettingForVibrateIcon_settingOff()502 public void testBlockedIcons_obeysSettingForVibrateIcon_settingOff() { 503 String str = mContext.getString(com.android.internal.R.string.status_bar_volume); 504 505 // GIVEN the setting is off 506 when(mSecureSettings.getInt(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0)) 507 .thenReturn(0); 508 509 // WHEN CollapsedStatusBarFragment builds the blocklist 510 mController.updateBlockedIcons(); 511 512 // THEN status_bar_volume SHOULD be present in the list 513 boolean contains = mController.getBlockedIcons().contains(str); 514 assertTrue(contains); 515 } 516 517 @Test testBlockedIcons_obeysSettingForVibrateIcon_settingOn()518 public void testBlockedIcons_obeysSettingForVibrateIcon_settingOn() { 519 String str = mContext.getString(com.android.internal.R.string.status_bar_volume); 520 521 // GIVEN the setting is ON 522 when(mSecureSettings.getIntForUser(Settings.Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0, 523 UserHandle.USER_CURRENT)) 524 .thenReturn(1); 525 526 // WHEN CollapsedStatusBarFragment builds the blocklist 527 mController.updateBlockedIcons(); 528 529 // THEN status_bar_volume SHOULD NOT be present in the list 530 boolean contains = mController.getBlockedIcons().contains(str); 531 assertFalse(contains); 532 } 533 updateStateToNotKeyguard()534 private void updateStateToNotKeyguard() { 535 updateStatusBarState(SHADE); 536 } 537 updateStateToKeyguard()538 private void updateStateToKeyguard() { 539 updateStatusBarState(KEYGUARD); 540 } 541 updateStatusBarState(int state)542 private void updateStatusBarState(int state) { 543 ArgumentCaptor<StatusBarStateController.StateListener> statusBarStateListenerCaptor = 544 ArgumentCaptor.forClass(StatusBarStateController.StateListener.class); 545 verify(mStatusBarStateController).addCallback(statusBarStateListenerCaptor.capture()); 546 StatusBarStateController.StateListener callback = statusBarStateListenerCaptor.getValue(); 547 548 callback.onStateChanged(state); 549 } 550 551 @Test animateKeyguardStatusBarIn_isDisabled_viewStillHidden()552 public void animateKeyguardStatusBarIn_isDisabled_viewStillHidden() { 553 mController.onViewAttached(); 554 updateStateToKeyguard(); 555 setDisableSystemInfo(true); 556 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 557 558 mController.animateKeyguardStatusBarIn(); 559 560 // Since we're disabled, we don't actually animate in and stay invisible 561 assertThat(mKeyguardStatusBarView.getVisibility()).isEqualTo(View.INVISIBLE); 562 } 563 564 /** 565 * Calls {@link com.android.keyguard.KeyguardUpdateMonitorCallback#onFinishedGoingToSleep(int)} 566 * to ensure values are updated properly. 567 */ onFinishedGoingToSleep()568 private void onFinishedGoingToSleep() { 569 ArgumentCaptor<KeyguardUpdateMonitorCallback> keyguardUpdateCallbackCaptor = 570 ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback.class); 571 verify(mKeyguardUpdateMonitor).registerCallback(keyguardUpdateCallbackCaptor.capture()); 572 KeyguardUpdateMonitorCallback callback = keyguardUpdateCallbackCaptor.getValue(); 573 574 callback.onFinishedGoingToSleep(0); 575 } 576 setDisableSystemInfo(boolean disabled)577 private void setDisableSystemInfo(boolean disabled) { 578 CommandQueue.Callbacks callback = getCommandQueueCallback(); 579 int disabled1 = disabled ? DISABLE_SYSTEM_INFO : 0; 580 callback.disable(mContext.getDisplayId(), disabled1, 0, false); 581 } 582 setDisableSystemIcons(boolean disabled)583 private void setDisableSystemIcons(boolean disabled) { 584 CommandQueue.Callbacks callback = getCommandQueueCallback(); 585 int disabled2 = disabled ? DISABLE2_SYSTEM_ICONS : 0; 586 callback.disable(mContext.getDisplayId(), 0, disabled2, false); 587 } 588 getCommandQueueCallback()589 private CommandQueue.Callbacks getCommandQueueCallback() { 590 ArgumentCaptor<CommandQueue.Callbacks> captor = 591 ArgumentCaptor.forClass(CommandQueue.Callbacks.class); 592 verify(mCommandQueue).addCallback(captor.capture()); 593 return captor.getValue(); 594 } 595 596 private static class TestShadeViewStateProvider 597 implements ShadeViewStateProvider { 598 TestShadeViewStateProvider()599 TestShadeViewStateProvider() {} 600 601 private float mPanelViewExpandedHeight = 100f; 602 private boolean mShouldHeadsUpBeVisible = false; 603 private float mLockscreenShadeDragProgress = 0f; 604 605 @Override getPanelViewExpandedHeight()606 public float getPanelViewExpandedHeight() { 607 return mPanelViewExpandedHeight; 608 } 609 610 @Override shouldHeadsUpBeVisible()611 public boolean shouldHeadsUpBeVisible() { 612 return mShouldHeadsUpBeVisible; 613 } 614 615 @Override getLockscreenShadeDragProgress()616 public float getLockscreenShadeDragProgress() { 617 return mLockscreenShadeDragProgress; 618 } 619 setPanelViewExpandedHeight(float panelViewExpandedHeight)620 public void setPanelViewExpandedHeight(float panelViewExpandedHeight) { 621 this.mPanelViewExpandedHeight = panelViewExpandedHeight; 622 } 623 setShouldHeadsUpBeVisible(boolean shouldHeadsUpBeVisible)624 public void setShouldHeadsUpBeVisible(boolean shouldHeadsUpBeVisible) { 625 this.mShouldHeadsUpBeVisible = shouldHeadsUpBeVisible; 626 } 627 setLockscreenShadeDragProgress(float lockscreenShadeDragProgress)628 public void setLockscreenShadeDragProgress(float lockscreenShadeDragProgress) { 629 this.mLockscreenShadeDragProgress = lockscreenShadeDragProgress; 630 } 631 } 632 } 633