1 /* 2 * Copyright (C) 2014 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.notification.stack; 18 19 import static com.android.systemui.statusbar.notification.NotificationUtils.logKey; 20 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.content.Context; 24 import android.util.MathUtils; 25 26 import androidx.annotation.VisibleForTesting; 27 28 import com.android.systemui.Dumpable; 29 import com.android.systemui.dagger.SysUISingleton; 30 import com.android.systemui.dump.DumpManager; 31 import com.android.systemui.res.R; 32 import com.android.systemui.shade.transition.LargeScreenShadeInterpolator; 33 import com.android.systemui.statusbar.NotificationShelf; 34 import com.android.systemui.statusbar.StatusBarState; 35 import com.android.systemui.statusbar.notification.collection.NotificationEntry; 36 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; 37 import com.android.systemui.statusbar.notification.row.ExpandableView; 38 import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.BypassController; 39 import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.SectionProvider; 40 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 41 import com.android.systemui.statusbar.policy.AvalancheController; 42 43 import java.io.PrintWriter; 44 45 import javax.inject.Inject; 46 47 /** 48 * Global state to track all input states for 49 * {@link com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm}. 50 */ 51 @SysUISingleton 52 public class AmbientState implements Dumpable { 53 54 private static final float MAX_PULSE_HEIGHT = 100000f; 55 private static final boolean NOTIFICATIONS_HAVE_SHADOWS = false; 56 57 private final SectionProvider mSectionProvider; 58 private final BypassController mBypassController; 59 private final LargeScreenShadeInterpolator mLargeScreenShadeInterpolator; 60 private final AvalancheController mAvalancheController; 61 62 /** 63 * Used to read bouncer states. 64 */ 65 private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; 66 private int mScrollY; 67 private float mOverScrollTopAmount; 68 private float mOverScrollBottomAmount; 69 private boolean mDozing; 70 private boolean mHideSensitive; 71 private float mStackTranslation; 72 private int mLayoutHeight; 73 private int mTopPadding; 74 private boolean mShadeExpanded; 75 private float mMaxHeadsUpTranslation; 76 private boolean mClearAllInProgress; 77 private int mLayoutMinHeight; 78 private int mLayoutMaxHeight; 79 private NotificationShelf mShelf; 80 private int mZDistanceBetweenElements; 81 private int mBaseZHeight; 82 private int mContentHeight; 83 private ExpandableView mLastVisibleBackgroundChild; 84 private float mCurrentScrollVelocity; 85 private int mStatusBarState; 86 private float mExpandingVelocity; 87 private boolean mPanelTracking; 88 private boolean mExpansionChanging; 89 private boolean mIsSmallScreen; 90 private boolean mPulsing; 91 private float mHideAmount; 92 private boolean mAppearing; 93 private float mPulseHeight = MAX_PULSE_HEIGHT; 94 95 /** 96 * The ExpandableNotificationRow that is pulsing, or the one that was pulsing 97 * when the device started to transition from AOD to LockScreen. 98 */ 99 private ExpandableNotificationRow mPulsingRow; 100 101 /** Fraction of lockscreen to shade animation (on lockscreen swipe down). */ 102 private float mFractionToShade; 103 104 /** 105 * @param fractionToShade Fraction of lockscreen to shade transition 106 */ setFractionToShade(float fractionToShade)107 public void setFractionToShade(float fractionToShade) { 108 mFractionToShade = fractionToShade; 109 } 110 111 /** 112 * @return fractionToShade Fraction of lockscreen to shade transition 113 */ getFractionToShade()114 public float getFractionToShade() { 115 return mFractionToShade; 116 } 117 118 /** How we much we are sleeping. 1f fully dozing (AOD), 0f fully awake (for all other states) */ 119 private float mDozeAmount = 0.0f; 120 121 private Runnable mOnPulseHeightChangedListener; 122 private ExpandableNotificationRow mTrackedHeadsUpRow; 123 private float mAppearFraction; 124 private float mOverExpansion; 125 private int mStackTopMargin; 126 private boolean mUseSplitShade; 127 128 /** Distance of top of notifications panel from top of screen. */ 129 private float mStackY = 0; 130 131 /** Height of notifications panel. */ 132 private float mStackHeight = 0; 133 134 /** Fraction of shade expansion. */ 135 private float mExpansionFraction; 136 137 /** Height of the notifications panel without top padding when expansion completes. */ 138 private float mStackEndHeight; 139 140 /** Whether we are swiping up. */ 141 private boolean mIsSwipingUp; 142 143 /** Whether we are flinging the shade open or closed. */ 144 private boolean mIsFlinging; 145 146 /** 147 * Whether we need to do a fling down after swiping up on lockscreen. 148 * True right after we swipe up on lockscreen and have not finished the fling down that follows. 149 * False when we stop flinging or leave lockscreen. 150 */ 151 private boolean mIsFlingRequiredAfterLockScreenSwipeUp = false; 152 153 /** 154 * Whether the shade is currently closing. 155 */ 156 private boolean mIsClosing; 157 158 @VisibleForTesting isFlingRequiredAfterLockScreenSwipeUp()159 public boolean isFlingRequiredAfterLockScreenSwipeUp() { 160 return mIsFlingRequiredAfterLockScreenSwipeUp; 161 } 162 163 @VisibleForTesting setFlingRequiredAfterLockScreenSwipeUp(boolean value)164 public void setFlingRequiredAfterLockScreenSwipeUp(boolean value) { 165 mIsFlingRequiredAfterLockScreenSwipeUp = value; 166 } 167 168 /** 169 * @return Height of the notifications panel without top padding when expansion completes. 170 */ getStackEndHeight()171 public float getStackEndHeight() { 172 return mStackEndHeight; 173 } 174 175 /** 176 * @param stackEndHeight Height of the notifications panel without top padding 177 * when expansion completes. 178 */ setStackEndHeight(float stackEndHeight)179 public void setStackEndHeight(float stackEndHeight) { 180 mStackEndHeight = stackEndHeight; 181 } 182 183 /** 184 * @param stackY Distance of top of notifications panel from top of screen. 185 */ setStackY(float stackY)186 public void setStackY(float stackY) { 187 mStackY = stackY; 188 } 189 190 /** 191 * @return Distance of top of notifications panel from top of screen. 192 */ getStackY()193 public float getStackY() { 194 return mStackY; 195 } 196 197 /** 198 * @param expansionFraction Fraction of shade expansion. 199 */ setExpansionFraction(float expansionFraction)200 public void setExpansionFraction(float expansionFraction) { 201 mExpansionFraction = expansionFraction; 202 } 203 204 /** 205 * @param isSwipingUp Whether we are swiping up. 206 */ setSwipingUp(boolean isSwipingUp)207 public void setSwipingUp(boolean isSwipingUp) { 208 if (!isSwipingUp && mIsSwipingUp) { 209 // Just stopped swiping up. 210 mIsFlingRequiredAfterLockScreenSwipeUp = true; 211 } 212 mIsSwipingUp = isSwipingUp; 213 } 214 215 /** 216 * @return Whether we are swiping up. 217 */ isSwipingUp()218 public boolean isSwipingUp() { 219 return mIsSwipingUp; 220 } 221 222 /** 223 * @param isFlinging Whether we are flinging the shade open or closed. 224 */ setFlinging(boolean isFlinging)225 public void setFlinging(boolean isFlinging) { 226 if (isOnKeyguard() && !isFlinging && mIsFlinging) { 227 // Just stopped flinging. 228 mIsFlingRequiredAfterLockScreenSwipeUp = false; 229 } 230 mIsFlinging = isFlinging; 231 } 232 233 /** 234 * @param useSplitShade True if we are showing split shade. 235 */ setUseSplitShade(boolean useSplitShade)236 public void setUseSplitShade(boolean useSplitShade) { 237 mUseSplitShade = useSplitShade; 238 } 239 240 /** 241 * @return True if we are showing split shade. 242 */ getUseSplitShade()243 public boolean getUseSplitShade() { 244 return mUseSplitShade; 245 } 246 247 /** 248 * @return Fraction of shade expansion. 249 */ getExpansionFraction()250 public float getExpansionFraction() { 251 return mExpansionFraction; 252 } 253 254 /** 255 * @param stackHeight Height of notifications panel. 256 */ setStackHeight(float stackHeight)257 public void setStackHeight(float stackHeight) { 258 mStackHeight = stackHeight; 259 } 260 261 /** 262 * @return Height of notifications panel. 263 */ getStackHeight()264 public float getStackHeight() { 265 return mStackHeight; 266 } 267 268 @Inject AmbientState( @onNull Context context, @NonNull DumpManager dumpManager, @NonNull SectionProvider sectionProvider, @NonNull BypassController bypassController, @Nullable StatusBarKeyguardViewManager statusBarKeyguardViewManager, @NonNull LargeScreenShadeInterpolator largeScreenShadeInterpolator, AvalancheController avalancheController )269 public AmbientState( 270 @NonNull Context context, 271 @NonNull DumpManager dumpManager, 272 @NonNull SectionProvider sectionProvider, 273 @NonNull BypassController bypassController, 274 @Nullable StatusBarKeyguardViewManager statusBarKeyguardViewManager, 275 @NonNull LargeScreenShadeInterpolator largeScreenShadeInterpolator, 276 AvalancheController avalancheController 277 ) { 278 mSectionProvider = sectionProvider; 279 mBypassController = bypassController; 280 mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; 281 mLargeScreenShadeInterpolator = largeScreenShadeInterpolator; 282 mAvalancheController = avalancheController; 283 reload(context); 284 dumpManager.registerDumpable(this); 285 } 286 287 /** 288 * Reload the dimens e.g. if the density changed. 289 */ reload(Context context)290 public void reload(Context context) { 291 mZDistanceBetweenElements = getZDistanceBetweenElements(context); 292 mBaseZHeight = getBaseHeight(mZDistanceBetweenElements); 293 } 294 getAvalancheShowingHunKey()295 String getAvalancheShowingHunKey() { 296 // If we don't have a previous showing hun, we don't consider the showing hun as avalanche 297 if (isNullAvalancheKey(getAvalanchePreviousHunKey())) return ""; 298 return mAvalancheController.getShowingHunKey(); 299 } 300 getAvalanchePreviousHunKey()301 String getAvalanchePreviousHunKey() { 302 return mAvalancheController.getPreviousHunKey(); 303 } 304 isNullAvalancheKey(String key)305 boolean isNullAvalancheKey(String key) { 306 if (key == null || key.isEmpty()) return true; 307 return key.equals("HeadsUpEntry null") || key.equals("HeadsUpEntry.mEntry null"); 308 } 309 setOverExpansion(float overExpansion)310 void setOverExpansion(float overExpansion) { 311 mOverExpansion = overExpansion; 312 } 313 getOverExpansion()314 public float getOverExpansion() { 315 return mOverExpansion; 316 } 317 getZDistanceBetweenElements(Context context)318 private static int getZDistanceBetweenElements(Context context) { 319 return Math.max(1, context.getResources() 320 .getDimensionPixelSize(R.dimen.z_distance_between_notifications)); 321 } 322 getBaseHeight(int zdistanceBetweenElements)323 private static int getBaseHeight(int zdistanceBetweenElements) { 324 return NOTIFICATIONS_HAVE_SHADOWS ? 4 * zdistanceBetweenElements : 0; 325 } 326 327 /** 328 * @return the launch height for notifications that are launched 329 */ getNotificationLaunchHeight(Context context)330 public static int getNotificationLaunchHeight(Context context) { 331 int zDistance = getZDistanceBetweenElements(context); 332 return NOTIFICATIONS_HAVE_SHADOWS ? 2 * getBaseHeight(zDistance) : 4 * zDistance; 333 } 334 335 /** 336 * @return the basic Z height on which notifications remain. 337 */ getBaseZHeight()338 public int getBaseZHeight() { 339 return mBaseZHeight; 340 } 341 342 /** 343 * @return the distance in Z between two overlaying notifications. 344 */ getZDistanceBetweenElements()345 public int getZDistanceBetweenElements() { 346 return mZDistanceBetweenElements; 347 } 348 getScrollY()349 public int getScrollY() { 350 return mScrollY; 351 } 352 353 /** 354 * Set the new Scroll Y position. 355 */ setScrollY(int scrollY)356 public void setScrollY(int scrollY) { 357 // Because we're dealing with an overscroller, scrollY could sometimes become smaller than 358 // 0. However this is only for internal purposes and the scroll position when read 359 // should never be smaller than 0, otherwise it can lead to flickers. 360 this.mScrollY = Math.max(scrollY, 0); 361 } 362 363 /** While dozing, we draw as little as possible, assuming a black background */ setDozing(boolean dozing)364 public void setDozing(boolean dozing) { 365 mDozing = dozing; 366 } 367 368 /** Hide ratio of the status bar **/ setHideAmount(float hidemount)369 public void setHideAmount(float hidemount) { 370 if (hidemount == 1.0f && mHideAmount != hidemount) { 371 // Whenever we are fully hidden, let's reset the pulseHeight again 372 setPulseHeight(MAX_PULSE_HEIGHT); 373 } 374 mHideAmount = hidemount; 375 } 376 377 /** Returns the hide ratio of the status bar */ getHideAmount()378 public float getHideAmount() { 379 return mHideAmount; 380 } 381 setHideSensitive(boolean hideSensitive)382 public void setHideSensitive(boolean hideSensitive) { 383 mHideSensitive = hideSensitive; 384 } 385 isDozing()386 public boolean isDozing() { 387 return mDozing; 388 } 389 isHideSensitive()390 public boolean isHideSensitive() { 391 return mHideSensitive; 392 } 393 setOverScrollAmount(float amount, boolean onTop)394 public void setOverScrollAmount(float amount, boolean onTop) { 395 if (onTop) { 396 mOverScrollTopAmount = amount; 397 } else { 398 mOverScrollBottomAmount = amount; 399 } 400 } 401 402 /** 403 * Is bypass currently enabled? 404 */ isBypassEnabled()405 public boolean isBypassEnabled() { 406 return mBypassController.isBypassEnabled(); 407 } 408 getOverScrollAmount(boolean top)409 public float getOverScrollAmount(boolean top) { 410 return top ? mOverScrollTopAmount : mOverScrollBottomAmount; 411 } 412 getSectionProvider()413 public SectionProvider getSectionProvider() { 414 return mSectionProvider; 415 } 416 getStackTranslation()417 public float getStackTranslation() { 418 return mStackTranslation; 419 } 420 setStackTranslation(float stackTranslation)421 public void setStackTranslation(float stackTranslation) { 422 mStackTranslation = stackTranslation; 423 } 424 setLayoutHeight(int layoutHeight)425 public void setLayoutHeight(int layoutHeight) { 426 mLayoutHeight = layoutHeight; 427 } 428 setLayoutMaxHeight(int maxLayoutHeight)429 public void setLayoutMaxHeight(int maxLayoutHeight) { 430 mLayoutMaxHeight = maxLayoutHeight; 431 } 432 getLayoutMaxHeight()433 public int getLayoutMaxHeight() { 434 return mLayoutMaxHeight; 435 } 436 getTopPadding()437 public int getTopPadding() { 438 return mTopPadding; 439 } 440 setTopPadding(int topPadding)441 public void setTopPadding(int topPadding) { 442 mTopPadding = topPadding; 443 } 444 getInnerHeight()445 public int getInnerHeight() { 446 return getInnerHeight(false /* ignorePulseHeight */); 447 } 448 449 /** 450 * @param ignorePulseHeight ignore the pulse height for this request 451 * @return the inner height of the algorithm. 452 */ getInnerHeight(boolean ignorePulseHeight)453 public int getInnerHeight(boolean ignorePulseHeight) { 454 if (mDozeAmount == 1.0f && !isPulseExpanding()) { 455 return mShelf.getHeight(); 456 } 457 int height = (int) Math.max(mLayoutMinHeight, 458 Math.min(mLayoutHeight, mContentHeight) - mTopPadding); 459 if (ignorePulseHeight) { 460 return height; 461 } 462 float pulseHeight = Math.min(mPulseHeight, (float) height); 463 return (int) MathUtils.lerp(height, pulseHeight, mDozeAmount); 464 } 465 isPulseExpanding()466 public boolean isPulseExpanding() { 467 return mPulseHeight != MAX_PULSE_HEIGHT && mDozeAmount != 0.0f && mHideAmount != 1.0f; 468 } 469 isShadeExpanded()470 public boolean isShadeExpanded() { 471 return mShadeExpanded; 472 } 473 setShadeExpanded(boolean shadeExpanded)474 public void setShadeExpanded(boolean shadeExpanded) { 475 mShadeExpanded = shadeExpanded; 476 } 477 setMaxHeadsUpTranslation(float maxHeadsUpTranslation)478 public void setMaxHeadsUpTranslation(float maxHeadsUpTranslation) { 479 mMaxHeadsUpTranslation = maxHeadsUpTranslation; 480 } 481 getMaxHeadsUpTranslation()482 public float getMaxHeadsUpTranslation() { 483 return mMaxHeadsUpTranslation; 484 } 485 setClearAllInProgress(boolean clearAllInProgress)486 public void setClearAllInProgress(boolean clearAllInProgress) { 487 mClearAllInProgress = clearAllInProgress; 488 } 489 isClearAllInProgress()490 public boolean isClearAllInProgress() { 491 return mClearAllInProgress; 492 } 493 setLayoutMinHeight(int layoutMinHeight)494 public void setLayoutMinHeight(int layoutMinHeight) { 495 mLayoutMinHeight = layoutMinHeight; 496 } 497 setShelf(NotificationShelf shelf)498 public void setShelf(NotificationShelf shelf) { 499 mShelf = shelf; 500 } 501 502 @Nullable getShelf()503 public NotificationShelf getShelf() { 504 return mShelf; 505 } 506 setContentHeight(int contentHeight)507 public void setContentHeight(int contentHeight) { 508 mContentHeight = contentHeight; 509 } 510 getContentHeight()511 public float getContentHeight() { 512 return mContentHeight; 513 } 514 515 /** 516 * Sets the last visible view of the host layout, that has a background, i.e the very last 517 * view in the shade, without the clear all button. 518 */ setLastVisibleBackgroundChild( ExpandableView lastVisibleBackgroundChild)519 public void setLastVisibleBackgroundChild( 520 ExpandableView lastVisibleBackgroundChild) { 521 mLastVisibleBackgroundChild = lastVisibleBackgroundChild; 522 } 523 getLastVisibleBackgroundChild()524 public ExpandableView getLastVisibleBackgroundChild() { 525 return mLastVisibleBackgroundChild; 526 } 527 setCurrentScrollVelocity(float currentScrollVelocity)528 public void setCurrentScrollVelocity(float currentScrollVelocity) { 529 mCurrentScrollVelocity = currentScrollVelocity; 530 } 531 getCurrentScrollVelocity()532 public float getCurrentScrollVelocity() { 533 return mCurrentScrollVelocity; 534 } 535 isOnKeyguard()536 public boolean isOnKeyguard() { 537 return mStatusBarState == StatusBarState.KEYGUARD; 538 } 539 setStatusBarState(int statusBarState)540 public void setStatusBarState(int statusBarState) { 541 if (mStatusBarState != StatusBarState.KEYGUARD) { 542 mIsFlingRequiredAfterLockScreenSwipeUp = false; 543 } 544 mStatusBarState = statusBarState; 545 } 546 setExpandingVelocity(float expandingVelocity)547 public void setExpandingVelocity(float expandingVelocity) { 548 mExpandingVelocity = expandingVelocity; 549 } 550 setExpansionChanging(boolean expansionChanging)551 public void setExpansionChanging(boolean expansionChanging) { 552 mExpansionChanging = expansionChanging; 553 } 554 isExpansionChanging()555 public boolean isExpansionChanging() { 556 return mExpansionChanging; 557 } 558 getExpandingVelocity()559 public float getExpandingVelocity() { 560 return mExpandingVelocity; 561 } 562 setPanelTracking(boolean panelTracking)563 public void setPanelTracking(boolean panelTracking) { 564 mPanelTracking = panelTracking; 565 } 566 setPulsing(boolean hasPulsing)567 public void setPulsing(boolean hasPulsing) { 568 mPulsing = hasPulsing; 569 } 570 571 /** 572 * @return if we're pulsing in general 573 */ isPulsing()574 public boolean isPulsing() { 575 return mPulsing; 576 } 577 isPulsing(NotificationEntry entry)578 public boolean isPulsing(NotificationEntry entry) { 579 return mPulsing && entry.isHeadsUpEntry(); 580 } 581 setPulsingRow(ExpandableNotificationRow row)582 public void setPulsingRow(ExpandableNotificationRow row) { 583 mPulsingRow = row; 584 } 585 586 /** 587 * @param row The row to check 588 * @return true if row is the pulsing row when the device started to transition from AOD to lock 589 * screen 590 */ isPulsingRow(ExpandableView row)591 public boolean isPulsingRow(ExpandableView row) { 592 return mPulsingRow == row; 593 } 594 isPanelTracking()595 public boolean isPanelTracking() { 596 return mPanelTracking; 597 } 598 isSmallScreen()599 public boolean isSmallScreen() { 600 return mIsSmallScreen; 601 } 602 setSmallScreen(boolean smallScreen)603 public void setSmallScreen(boolean smallScreen) { 604 mIsSmallScreen = smallScreen; 605 } 606 607 /** 608 * @return Whether we need to do a fling down after swiping up on lockscreen. 609 */ isFlingingAfterSwipeUpOnLockscreen()610 public boolean isFlingingAfterSwipeUpOnLockscreen() { 611 return mIsFlinging && mIsFlingRequiredAfterLockScreenSwipeUp; 612 } 613 614 /** 615 * @return whether a view is dozing and not pulsing right now 616 */ isDozingAndNotPulsing(ExpandableView view)617 public boolean isDozingAndNotPulsing(ExpandableView view) { 618 if (view instanceof ExpandableNotificationRow) { 619 return isDozingAndNotPulsing((ExpandableNotificationRow) view); 620 } 621 return false; 622 } 623 624 /** 625 * @return whether a row is dozing and not pulsing right now 626 */ isDozingAndNotPulsing(ExpandableNotificationRow row)627 public boolean isDozingAndNotPulsing(ExpandableNotificationRow row) { 628 return isDozing() && !isPulsing(row.getEntry()); 629 } 630 631 /** 632 * @return {@code true } when shade is completely hidden: in AOD, ambient display or when 633 * bypassing. 634 */ isFullyHidden()635 public boolean isFullyHidden() { 636 return mHideAmount == 1; 637 } 638 isHiddenAtAll()639 public boolean isHiddenAtAll() { 640 return mHideAmount != 0; 641 } 642 setAppearing(boolean appearing)643 public void setAppearing(boolean appearing) { 644 mAppearing = appearing; 645 } 646 isAppearing()647 public boolean isAppearing() { 648 return mAppearing; 649 } 650 setPulseHeight(float height)651 public void setPulseHeight(float height) { 652 if (height != mPulseHeight) { 653 mPulseHeight = height; 654 if (mOnPulseHeightChangedListener != null) { 655 mOnPulseHeightChangedListener.run(); 656 } 657 } 658 } 659 getPulseHeight()660 public float getPulseHeight() { 661 if (mPulseHeight == MAX_PULSE_HEIGHT) { 662 // If we're not pulse expanding, the height should be 0 663 return 0; 664 } 665 return mPulseHeight; 666 } 667 setDozeAmount(float dozeAmount)668 public void setDozeAmount(float dozeAmount) { 669 if (dozeAmount != mDozeAmount) { 670 mDozeAmount = dozeAmount; 671 if (dozeAmount == 0.0f || dozeAmount == 1.0f) { 672 // We woke all the way up, let's reset the pulse height 673 setPulseHeight(MAX_PULSE_HEIGHT); 674 } 675 } 676 } 677 getDozeAmount()678 public float getDozeAmount() { 679 return mDozeAmount; 680 } 681 682 /** 683 * Is the device fully awake, which is different from not tark at all when there are pulsing 684 * notifications. 685 */ isFullyAwake()686 public boolean isFullyAwake() { 687 return mDozeAmount == 0.0f; 688 } 689 setOnPulseHeightChangedListener(Runnable onPulseHeightChangedListener)690 public void setOnPulseHeightChangedListener(Runnable onPulseHeightChangedListener) { 691 mOnPulseHeightChangedListener = onPulseHeightChangedListener; 692 } 693 setTrackedHeadsUpRow(ExpandableNotificationRow row)694 public void setTrackedHeadsUpRow(ExpandableNotificationRow row) { 695 mTrackedHeadsUpRow = row; 696 } 697 698 /** 699 * Returns the currently tracked heads up row, if there is one and it is currently above the 700 * shelf (still appearing). 701 */ getTrackedHeadsUpRow()702 public ExpandableNotificationRow getTrackedHeadsUpRow() { 703 if (mTrackedHeadsUpRow == null || !mTrackedHeadsUpRow.isAboveShelf()) { 704 return null; 705 } 706 return mTrackedHeadsUpRow; 707 } 708 setAppearFraction(float appearFraction)709 public void setAppearFraction(float appearFraction) { 710 mAppearFraction = appearFraction; 711 } 712 getAppearFraction()713 public float getAppearFraction() { 714 return mAppearFraction; 715 } 716 setStackTopMargin(int stackTopMargin)717 public void setStackTopMargin(int stackTopMargin) { 718 mStackTopMargin = stackTopMargin; 719 } 720 getStackTopMargin()721 public int getStackTopMargin() { 722 return mStackTopMargin; 723 } 724 725 /** 726 * Check to see if we are about to show bouncer. 727 * 728 * @return if bouncer expansion is between 0 and 1. 729 */ isBouncerInTransit()730 public boolean isBouncerInTransit() { 731 return mStatusBarKeyguardViewManager != null 732 && mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit(); 733 } 734 735 /** 736 * @param isClosing Whether the shade is currently closing. 737 */ setIsClosing(boolean isClosing)738 public void setIsClosing(boolean isClosing) { 739 mIsClosing = isClosing; 740 } 741 742 /** 743 * @return Whether the shade is currently closing. 744 */ isClosing()745 public boolean isClosing() { 746 return mIsClosing; 747 } 748 getLargeScreenShadeInterpolator()749 public LargeScreenShadeInterpolator getLargeScreenShadeInterpolator() { 750 return mLargeScreenShadeInterpolator; 751 } 752 753 @Override dump(PrintWriter pw, String[] args)754 public void dump(PrintWriter pw, String[] args) { 755 pw.println("mTopPadding=" + mTopPadding); 756 pw.println("mStackTopMargin=" + mStackTopMargin); 757 pw.println("mStackTranslation=" + mStackTranslation); 758 pw.println("mLayoutMinHeight=" + mLayoutMinHeight); 759 pw.println("mLayoutMaxHeight=" + mLayoutMaxHeight); 760 pw.println("mLayoutHeight=" + mLayoutHeight); 761 pw.println("mContentHeight=" + mContentHeight); 762 pw.println("mHideSensitive=" + mHideSensitive); 763 pw.println("mShadeExpanded=" + mShadeExpanded); 764 pw.println("mClearAllInProgress=" + mClearAllInProgress); 765 pw.println("mStatusBarState=" + StatusBarState.toString(mStatusBarState)); 766 pw.println("mExpansionChanging=" + mExpansionChanging); 767 pw.println("mPanelFullWidth=" + mIsSmallScreen); 768 pw.println("mPulsing=" + mPulsing); 769 pw.println("mPulseHeight=" + mPulseHeight); 770 pw.println("mTrackedHeadsUpRow.key=" + logKey(mTrackedHeadsUpRow)); 771 pw.println("mMaxHeadsUpTranslation=" + mMaxHeadsUpTranslation); 772 pw.println("mDozeAmount=" + mDozeAmount); 773 pw.println("mDozing=" + mDozing); 774 pw.println("mFractionToShade=" + mFractionToShade); 775 pw.println("mHideAmount=" + mHideAmount); 776 pw.println("mAppearFraction=" + mAppearFraction); 777 pw.println("mAppearing=" + mAppearing); 778 pw.println("mExpansionFraction=" + mExpansionFraction); 779 pw.println("mExpandingVelocity=" + mExpandingVelocity); 780 pw.println("mOverScrollTopAmount=" + mOverScrollTopAmount); 781 pw.println("mOverScrollBottomAmount=" + mOverScrollBottomAmount); 782 pw.println("mOverExpansion=" + mOverExpansion); 783 pw.println("mStackHeight=" + mStackHeight); 784 pw.println("mStackEndHeight=" + mStackEndHeight); 785 pw.println("mStackY=" + mStackY); 786 pw.println("mScrollY=" + mScrollY); 787 pw.println("mCurrentScrollVelocity=" + mCurrentScrollVelocity); 788 pw.println("mIsSwipingUp=" + mIsSwipingUp); 789 pw.println("mPanelTracking=" + mPanelTracking); 790 pw.println("mIsFlinging=" + mIsFlinging); 791 pw.println("mIsFlingRequiredAfterLockScreenSwipeUp=" 792 + mIsFlingRequiredAfterLockScreenSwipeUp); 793 pw.println("mZDistanceBetweenElements=" + mZDistanceBetweenElements); 794 pw.println("mBaseZHeight=" + mBaseZHeight); 795 pw.println("mIsClosing=" + mIsClosing); 796 } 797 } 798