Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 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.phone; |
| 18 | |
| 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.ValueAnimator; |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 22 | import android.annotation.IntDef; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 23 | import android.app.AlarmManager; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 24 | import android.content.Context; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 25 | import android.graphics.Color; |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 26 | import android.graphics.drawable.Drawable; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 27 | import android.os.Handler; |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 28 | import android.os.Trace; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 29 | import android.util.Log; |
Lucas Dupin | a0bf851 | 2017-05-24 17:04:47 -0700 | [diff] [blame] | 30 | import android.util.MathUtils; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 31 | import android.view.View; |
| 32 | import android.view.ViewTreeObserver; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 33 | import android.view.animation.DecelerateInterpolator; |
| 34 | import android.view.animation.Interpolator; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 35 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 36 | import com.android.internal.annotations.VisibleForTesting; |
Lucas Dupin | e2292a9 | 2017-07-06 14:35:30 -0700 | [diff] [blame] | 37 | import com.android.internal.colorextraction.ColorExtractor; |
| 38 | import com.android.internal.colorextraction.ColorExtractor.GradientColors; |
| 39 | import com.android.internal.colorextraction.ColorExtractor.OnColorsChangedListener; |
Lucas Dupin | 9324aa9 | 2017-07-26 20:29:38 -0700 | [diff] [blame] | 40 | import com.android.internal.graphics.ColorUtils; |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 41 | import com.android.internal.util.function.TriConsumer; |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 42 | import com.android.keyguard.KeyguardUpdateMonitor; |
Lucas Dupin | f8463ee | 2018-06-11 16:18:15 -0700 | [diff] [blame] | 43 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Lucas Dupin | 314d41f | 2017-05-08 15:52:58 -0700 | [diff] [blame] | 44 | import com.android.systemui.Dependency; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 45 | import com.android.systemui.Dumpable; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 46 | import com.android.systemui.R; |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 47 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 48 | import com.android.systemui.statusbar.ScrimView; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 49 | import com.android.systemui.statusbar.notification.stack.ViewState; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 50 | import com.android.systemui.util.AlarmTimeout; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 51 | import com.android.systemui.util.wakelock.DelayedWakeLock; |
| 52 | import com.android.systemui.util.wakelock.WakeLock; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 53 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 54 | import java.io.FileDescriptor; |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 55 | import java.io.PrintWriter; |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 56 | import java.lang.annotation.Retention; |
| 57 | import java.lang.annotation.RetentionPolicy; |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 58 | import java.util.function.Consumer; |
| 59 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 60 | /** |
| 61 | * Controls both the scrim behind the notifications and in front of the notifications (when a |
| 62 | * security method gets shown). |
| 63 | */ |
Selim Cinek | 99e9adf | 2018-03-15 09:17:47 -0700 | [diff] [blame] | 64 | public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnColorsChangedListener, |
| 65 | Dumpable { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 66 | |
Lucas Dupin | 55c6e80 | 2018-09-27 18:07:36 -0700 | [diff] [blame] | 67 | static final String TAG = "ScrimController"; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 68 | private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
| 69 | |
Lucas Dupin | 4749f1b | 2018-04-04 15:09:06 -0700 | [diff] [blame] | 70 | /** |
| 71 | * General scrim animation duration. |
| 72 | */ |
John Spurlock | 8b12f22 | 2014-09-09 11:54:11 -0400 | [diff] [blame] | 73 | public static final long ANIMATION_DURATION = 220; |
Lucas Dupin | 4749f1b | 2018-04-04 15:09:06 -0700 | [diff] [blame] | 74 | /** |
| 75 | * Longer duration, currently only used when going to AOD. |
| 76 | */ |
| 77 | public static final long ANIMATION_DURATION_LONG = 1000; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 78 | /** |
| 79 | * When both scrims have 0 alpha. |
| 80 | */ |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 81 | public static final int TRANSPARENT = 0; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 82 | /** |
| 83 | * When scrims aren't transparent (alpha 0) but also not opaque (alpha 1.) |
| 84 | */ |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 85 | public static final int SEMI_TRANSPARENT = 1; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 86 | /** |
| 87 | * When at least 1 scrim is fully opaque (alpha set to 1.) |
| 88 | */ |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 89 | public static final int OPAQUE = 2; |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 90 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 91 | @IntDef(prefix = {"VISIBILITY_"}, value = { |
| 92 | TRANSPARENT, |
| 93 | SEMI_TRANSPARENT, |
| 94 | OPAQUE |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 95 | }) |
| 96 | @Retention(RetentionPolicy.SOURCE) |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 97 | public @interface ScrimVisibility { |
| 98 | } |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 99 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 100 | /** |
| 101 | * Default alpha value for most scrims. |
| 102 | */ |
Lucas Dupin | 3d36dd8 | 2019-01-02 14:38:35 -0800 | [diff] [blame] | 103 | public static final float GRADIENT_SCRIM_ALPHA = 0.2f; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 104 | /** |
Lucas Dupin | 3113db6 | 2019-03-08 18:21:27 -0800 | [diff] [blame] | 105 | * Scrim opacity when the phone is about to wake-up. |
| 106 | */ |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 107 | public static final float WAKE_SENSOR_SCRIM_ALPHA = 0.6f; |
Lucas Dupin | 3113db6 | 2019-03-08 18:21:27 -0800 | [diff] [blame] | 108 | /** |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 109 | * A scrim varies its opacity based on a busyness factor, for example |
| 110 | * how many notifications are currently visible. |
| 111 | */ |
Lucas Dupin | de64ee0 | 2018-12-21 14:45:12 -0800 | [diff] [blame] | 112 | public static final float GRADIENT_SCRIM_ALPHA_BUSY = 0.7f; |
Lucas Dupin | de64ee0 | 2018-12-21 14:45:12 -0800 | [diff] [blame] | 113 | |
Lucas Dupin | 55c6e80 | 2018-09-27 18:07:36 -0700 | [diff] [blame] | 114 | /** |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 115 | * The most common scrim, the one under the keyguard. |
| 116 | */ |
Lucas Dupin | a0bf851 | 2017-05-24 17:04:47 -0700 | [diff] [blame] | 117 | protected static final float SCRIM_BEHIND_ALPHA_KEYGUARD = GRADIENT_SCRIM_ALPHA; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 118 | |
| 119 | static final int TAG_KEY_ANIM = R.id.scrim; |
Selim Cinek | 5104a6d | 2015-12-18 18:38:31 -0800 | [diff] [blame] | 120 | private static final int TAG_START_ALPHA = R.id.scrim_alpha_start; |
| 121 | private static final int TAG_END_ALPHA = R.id.scrim_alpha_end; |
Selim Cinek | 511f270 | 2017-04-10 19:53:01 -0700 | [diff] [blame] | 122 | private static final float NOT_INITIALIZED = -1; |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 123 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 124 | private ScrimState mState = ScrimState.UNINITIALIZED; |
| 125 | private final Context mContext; |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 126 | |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 127 | protected final ScrimView mScrimInFront; |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 128 | protected final ScrimView mScrimBehind; |
| 129 | protected final ScrimView mScrimForBubble; |
| 130 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 131 | private final UnlockMethodCache mUnlockMethodCache; |
Jorim Jaggi | e8fde5d | 2016-06-30 23:41:37 -0700 | [diff] [blame] | 132 | private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 133 | private final DozeParameters mDozeParameters; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 134 | private final AlarmTimeout mTimeTicker; |
Lucas Dupin | 690c6f5 | 2018-07-10 15:28:57 -0700 | [diff] [blame] | 135 | private final KeyguardVisibilityCallback mKeyguardVisibilityCallback; |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 136 | private final Handler mHandler; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 137 | |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 138 | private final SysuiColorExtractor mColorExtractor; |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 139 | private GradientColors mColors; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 140 | private boolean mNeedsDrawableColorUpdate; |
| 141 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 142 | protected float mScrimBehindAlpha; |
Lucas Dupin | 9324aa9 | 2017-07-26 20:29:38 -0700 | [diff] [blame] | 143 | protected float mScrimBehindAlphaResValue; |
Evan Rosky | 9a89501 | 2016-04-21 11:26:15 -0700 | [diff] [blame] | 144 | protected float mScrimBehindAlphaKeyguard = SCRIM_BEHIND_ALPHA_KEYGUARD; |
Xiaohui Chen | 4dab4b5 | 2016-03-07 12:31:14 -0800 | [diff] [blame] | 145 | |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 146 | // Assuming the shade is expanded during initialization |
| 147 | private float mExpansionFraction = 1f; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 148 | |
| 149 | private boolean mDarkenWhileDragging; |
Lucas Dupin | 67f0263 | 2018-03-12 11:08:31 -0700 | [diff] [blame] | 150 | private boolean mExpansionAffectsAlpha = true; |
Evan Rosky | 9a89501 | 2016-04-21 11:26:15 -0700 | [diff] [blame] | 151 | protected boolean mAnimateChange; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 152 | private boolean mUpdatePending; |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 153 | private boolean mTracking; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 154 | protected long mAnimationDuration = -1; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 155 | private long mAnimationDelay; |
| 156 | private Runnable mOnAnimationFinished; |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 157 | private boolean mDeferFinishedListener; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 158 | private final Interpolator mInterpolator = new DecelerateInterpolator(); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 159 | |
| 160 | private float mInFrontAlpha = NOT_INITIALIZED; |
| 161 | private float mBehindAlpha = NOT_INITIALIZED; |
| 162 | private float mBubbleAlpha = NOT_INITIALIZED; |
| 163 | |
| 164 | private int mInFrontTint; |
| 165 | private int mBehindTint; |
| 166 | private int mBubbleTint; |
| 167 | |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 168 | private boolean mWallpaperVisibilityTimedOut; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 169 | private int mScrimsVisibility; |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 170 | private final TriConsumer<ScrimState, Float, GradientColors> mScrimStateListener; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 171 | private final Consumer<Integer> mScrimVisibleListener; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 172 | private boolean mBlankScreen; |
| 173 | private boolean mScreenBlankingCallbackCalled; |
| 174 | private Callback mCallback; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 175 | private boolean mWallpaperSupportsAmbientMode; |
Lucas Dupin | 3a64ed7 | 2018-02-12 12:44:37 -0800 | [diff] [blame] | 176 | private boolean mScreenOn; |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 177 | |
| 178 | // Scrim blanking callbacks |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 179 | private Runnable mPendingFrameCallback; |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 180 | private Runnable mBlankingTransitionRunnable; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 181 | |
| 182 | private final WakeLock mWakeLock; |
| 183 | private boolean mWakeLockHeld; |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 184 | private boolean mKeyguardOccluded; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 185 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 186 | public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront, ScrimView scrimForBubble, |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 187 | TriConsumer<ScrimState, Float, GradientColors> scrimStateListener, |
shawnlin | 317db37 | 2018-04-09 19:49:48 +0800 | [diff] [blame] | 188 | Consumer<Integer> scrimVisibleListener, DozeParameters dozeParameters, |
| 189 | AlarmManager alarmManager) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 190 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 191 | mScrimBehind = scrimBehind; |
| 192 | mScrimInFront = scrimInFront; |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 193 | mScrimForBubble = scrimForBubble; |
| 194 | |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 195 | mScrimStateListener = scrimStateListener; |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 196 | mScrimVisibleListener = scrimVisibleListener; |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 197 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 198 | mContext = scrimBehind.getContext(); |
| 199 | mUnlockMethodCache = UnlockMethodCache.getInstance(mContext); |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 200 | mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 201 | mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
Lucas Dupin | 690c6f5 | 2018-07-10 15:28:57 -0700 | [diff] [blame] | 202 | mKeyguardVisibilityCallback = new KeyguardVisibilityCallback(); |
| 203 | mKeyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 204 | mScrimBehindAlphaResValue = mContext.getResources().getFloat(R.dimen.scrim_behind_alpha); |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 205 | mHandler = getHandler(); |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 206 | mTimeTicker = new AlarmTimeout(alarmManager, this::onHideWallpaperTimeout, |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 207 | "hide_aod_wallpaper", mHandler); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 208 | mWakeLock = createWakeLock(); |
Lucas Dupin | 9324aa9 | 2017-07-26 20:29:38 -0700 | [diff] [blame] | 209 | // Scrim alpha is initially set to the value on the resource but might be changed |
| 210 | // to make sure that text on top of it is legible. |
| 211 | mScrimBehindAlpha = mScrimBehindAlphaResValue; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 212 | mDozeParameters = dozeParameters; |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 213 | |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 214 | mColorExtractor = Dependency.get(SysuiColorExtractor.class); |
Lucas Dupin | 314d41f | 2017-05-08 15:52:58 -0700 | [diff] [blame] | 215 | mColorExtractor.addOnColorsChangedListener(this); |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 216 | mColors = mColorExtractor.getNeutralColors(); |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 217 | mNeedsDrawableColorUpdate = true; |
| 218 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 219 | final ScrimState[] states = ScrimState.values(); |
| 220 | for (int i = 0; i < states.length; i++) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 221 | states[i].init(mScrimInFront, mScrimBehind, mScrimForBubble, mDozeParameters); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 222 | states[i].setScrimBehindAlphaKeyguard(mScrimBehindAlphaKeyguard); |
| 223 | } |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 224 | |
Lucas Dupin | 373356b | 2018-04-07 10:50:25 -0700 | [diff] [blame] | 225 | mScrimBehind.setDefaultFocusHighlightEnabled(false); |
| 226 | mScrimInFront.setDefaultFocusHighlightEnabled(false); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 227 | mScrimForBubble.setDefaultFocusHighlightEnabled(false); |
Lucas Dupin | 373356b | 2018-04-07 10:50:25 -0700 | [diff] [blame] | 228 | |
Selim Cinek | 511f270 | 2017-04-10 19:53:01 -0700 | [diff] [blame] | 229 | updateScrims(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 230 | } |
| 231 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 232 | public void transitionTo(ScrimState state) { |
| 233 | transitionTo(state, null); |
| 234 | } |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 235 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 236 | public void transitionTo(ScrimState state, Callback callback) { |
| 237 | if (state == mState) { |
Lucas Dupin | 19aba8e | 2017-12-11 12:42:26 -0800 | [diff] [blame] | 238 | // Call the callback anyway, unless it's already enqueued |
| 239 | if (callback != null && mCallback != callback) { |
| 240 | callback.onFinished(); |
| 241 | } |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 242 | return; |
| 243 | } else if (DEBUG) { |
| 244 | Log.d(TAG, "State changed to: " + state); |
| 245 | } |
| 246 | |
| 247 | if (state == ScrimState.UNINITIALIZED) { |
| 248 | throw new IllegalArgumentException("Cannot change to UNINITIALIZED."); |
| 249 | } |
| 250 | |
Lucas Dupin | 8635c44 | 2017-12-08 10:36:28 -0800 | [diff] [blame] | 251 | final ScrimState oldState = mState; |
| 252 | mState = state; |
Lucas Dupin | 5866aaf | 2018-02-02 14:45:31 -0800 | [diff] [blame] | 253 | Trace.traceCounter(Trace.TRACE_TAG_APP, "scrim_state", mState.getIndex()); |
Lucas Dupin | 8635c44 | 2017-12-08 10:36:28 -0800 | [diff] [blame] | 254 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 255 | if (mCallback != null) { |
| 256 | mCallback.onCancelled(); |
| 257 | } |
| 258 | mCallback = callback; |
| 259 | |
Lucas Dupin | 8635c44 | 2017-12-08 10:36:28 -0800 | [diff] [blame] | 260 | state.prepare(oldState); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 261 | mScreenBlankingCallbackCalled = false; |
| 262 | mAnimationDelay = 0; |
| 263 | mBlankScreen = state.getBlanksScreen(); |
| 264 | mAnimateChange = state.getAnimateChange(); |
| 265 | mAnimationDuration = state.getAnimationDuration(); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 266 | |
| 267 | mInFrontTint = state.getFrontTint(); |
| 268 | mBehindTint = state.getBehindTint(); |
| 269 | mBubbleTint = state.getBubbleTint(); |
| 270 | |
| 271 | mInFrontAlpha = state.getFrontAlpha(); |
| 272 | mBehindAlpha = state.getBehindAlpha(); |
| 273 | mBubbleAlpha = state.getBubbleAlpha(); |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 274 | applyExpansionToAlpha(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 275 | |
Lucas Dupin | 38962d7 | 2018-03-14 12:41:39 -0700 | [diff] [blame] | 276 | // Scrim might acquire focus when user is navigating with a D-pad or a keyboard. |
| 277 | // We need to disable focus otherwise AOD would end up with a gray overlay. |
| 278 | mScrimInFront.setFocusable(!state.isLowPowerState()); |
| 279 | mScrimBehind.setFocusable(!state.isLowPowerState()); |
| 280 | |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 281 | // Cancel blanking transitions that were pending before we requested a new state |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 282 | if (mPendingFrameCallback != null) { |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 283 | mScrimBehind.removeCallbacks(mPendingFrameCallback); |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 284 | mPendingFrameCallback = null; |
| 285 | } |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 286 | if (mHandler.hasCallbacks(mBlankingTransitionRunnable)) { |
| 287 | mHandler.removeCallbacks(mBlankingTransitionRunnable); |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 288 | mBlankingTransitionRunnable = null; |
| 289 | } |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 290 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 291 | // Showing/hiding the keyguard means that scrim colors have to be switched, not necessary |
| 292 | // to do the same when you're just showing the brightness mirror. |
| 293 | mNeedsDrawableColorUpdate = state != ScrimState.BRIGHTNESS_MIRROR; |
| 294 | |
Lucas Dupin | eea53b3 | 2017-12-18 13:47:14 -0800 | [diff] [blame] | 295 | // The device might sleep if it's entering AOD, we need to make sure that |
| 296 | // the animation plays properly until the last frame. |
| 297 | // It's important to avoid holding the wakelock unless necessary because |
| 298 | // WakeLock#aqcuire will trigger an IPC and will cause jank. |
Lucas Dupin | 38962d7 | 2018-03-14 12:41:39 -0700 | [diff] [blame] | 299 | if (mState.isLowPowerState()) { |
Lucas Dupin | eea53b3 | 2017-12-18 13:47:14 -0800 | [diff] [blame] | 300 | holdWakeLock(); |
| 301 | } |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 302 | |
TYM Tsai | a71c892 | 2019-01-07 15:57:53 +0800 | [diff] [blame] | 303 | // AOD wallpapers should fade away after a while. |
| 304 | // Docking pulses may take a long time, wallpapers should also fade away after a while. |
Lucas Dupin | 023d727 | 2019-01-28 14:31:40 -0800 | [diff] [blame] | 305 | if (mWallpaperSupportsAmbientMode && mDozeParameters.getAlwaysOn() |
| 306 | && mState == ScrimState.AOD) { |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 307 | if (!mWallpaperVisibilityTimedOut) { |
| 308 | mTimeTicker.schedule(mDozeParameters.getWallpaperAodDuration(), |
| 309 | AlarmTimeout.MODE_IGNORE_IF_SCHEDULED); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 310 | } |
Lucas Dupin | c780404 | 2018-12-21 12:26:33 -0800 | [diff] [blame] | 311 | } else { |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 312 | mTimeTicker.cancel(); |
| 313 | mWallpaperVisibilityTimedOut = false; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Lucas Dupin | ff307d5 | 2018-02-05 21:16:39 -0800 | [diff] [blame] | 316 | if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 317 | // In case the user isn't unlocked, make sure to delay a bit because the system is hosed |
| 318 | // with too many things at this case, in order to not skip the initial frames. |
| 319 | mScrimInFront.postOnAnimationDelayed(this::scheduleUpdate, 16); |
| 320 | mAnimationDelay = StatusBar.FADE_KEYGUARD_START_DELAY; |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 321 | } else if ((!mDozeParameters.getAlwaysOn() && oldState == ScrimState.AOD) |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 322 | || (mState == ScrimState.AOD && !mDozeParameters.getDisplayNeedsBlanking())) { |
| 323 | // Scheduling a frame isn't enough when: |
| 324 | // • Leaving doze and we need to modify scrim color immediately |
| 325 | // • ColorFade will not kick-in and scrim cannot wait for pre-draw. |
Lucas Dupin | ff307d5 | 2018-02-05 21:16:39 -0800 | [diff] [blame] | 326 | onPreDraw(); |
| 327 | } else { |
| 328 | scheduleUpdate(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 329 | } |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 330 | |
| 331 | dispatchScrimState(mScrimBehind.getViewAlpha()); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | public ScrimState getState() { |
| 335 | return mState; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 336 | } |
| 337 | |
Lucas Dupin | bc9aac1 | 2018-03-04 20:18:15 -0800 | [diff] [blame] | 338 | protected void setScrimBehindValues(float scrimBehindAlphaKeyguard) { |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 339 | mScrimBehindAlphaKeyguard = scrimBehindAlphaKeyguard; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 340 | ScrimState[] states = ScrimState.values(); |
| 341 | for (int i = 0; i < states.length; i++) { |
| 342 | states[i].setScrimBehindAlphaKeyguard(scrimBehindAlphaKeyguard); |
| 343 | } |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 344 | scheduleUpdate(); |
| 345 | } |
| 346 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 347 | public void onTrackingStarted() { |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 348 | mTracking = true; |
Selim Cinek | e8bae62 | 2015-07-15 13:24:06 -0700 | [diff] [blame] | 349 | mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 350 | } |
| 351 | |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 352 | public void onExpandingFinished() { |
Jorim Jaggi | e93698b | 2016-11-11 18:24:38 -0800 | [diff] [blame] | 353 | mTracking = false; |
Jorim Jaggi | 2fbad7b | 2014-05-26 22:38:00 +0200 | [diff] [blame] | 354 | } |
| 355 | |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 356 | @VisibleForTesting |
| 357 | protected void onHideWallpaperTimeout() { |
TYM Tsai | a71c892 | 2019-01-07 15:57:53 +0800 | [diff] [blame] | 358 | if (mState != ScrimState.AOD && mState != ScrimState.PULSING) { |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 359 | return; |
| 360 | } |
| 361 | |
| 362 | holdWakeLock(); |
| 363 | mWallpaperVisibilityTimedOut = true; |
| 364 | mAnimateChange = true; |
| 365 | mAnimationDuration = mDozeParameters.getWallpaperFadeOutDuration(); |
| 366 | scheduleUpdate(); |
| 367 | } |
| 368 | |
| 369 | private void holdWakeLock() { |
| 370 | if (!mWakeLockHeld) { |
| 371 | if (mWakeLock != null) { |
| 372 | mWakeLockHeld = true; |
Lucas Dupin | ee4c9b7 | 2019-02-18 17:04:58 -0800 | [diff] [blame] | 373 | mWakeLock.acquire(TAG); |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 374 | } else { |
| 375 | Log.w(TAG, "Cannot hold wake lock, it has not been set yet"); |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 380 | /** |
| 381 | * Current state of the shade expansion when pulling it from the top. |
| 382 | * This value is 1 when on top of the keyguard and goes to 0 as the user drags up. |
| 383 | * |
| 384 | * The expansion fraction is tied to the scrim opacity. |
| 385 | * |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 386 | * @param fraction From 0 to 1 where 0 means collapsed and 1 expanded. |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 387 | */ |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 388 | public void setPanelExpansion(float fraction) { |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 389 | if (mExpansionFraction != fraction) { |
| 390 | mExpansionFraction = fraction; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 391 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 392 | boolean relevantState = (mState == ScrimState.UNLOCKED |
| 393 | || mState == ScrimState.KEYGUARD |
| 394 | || mState == ScrimState.PULSING |
| 395 | || mState == ScrimState.BUBBLE_EXPANDED); |
| 396 | if (!(relevantState && mExpansionAffectsAlpha)) { |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 397 | return; |
| 398 | } |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 399 | applyExpansionToAlpha(); |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 400 | if (mUpdatePending) { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 401 | return; |
| 402 | } |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 403 | setOrAdaptCurrentAnimation(mScrimBehind); |
| 404 | setOrAdaptCurrentAnimation(mScrimInFront); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 405 | setOrAdaptCurrentAnimation(mScrimForBubble); |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 406 | dispatchScrimState(mScrimBehind.getViewAlpha()); |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | |
| 410 | private void setOrAdaptCurrentAnimation(View scrim) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 411 | float alpha = getCurrentScrimAlpha(scrim); |
| 412 | if (isAnimating(scrim)) { |
| 413 | // Adapt current animation. |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 414 | ValueAnimator previousAnimator = (ValueAnimator) scrim.getTag(TAG_KEY_ANIM); |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 415 | float previousEndValue = (Float) scrim.getTag(TAG_END_ALPHA); |
| 416 | float previousStartValue = (Float) scrim.getTag(TAG_START_ALPHA); |
| 417 | float relativeDiff = alpha - previousEndValue; |
| 418 | float newStartValue = previousStartValue + relativeDiff; |
| 419 | scrim.setTag(TAG_START_ALPHA, newStartValue); |
| 420 | scrim.setTag(TAG_END_ALPHA, alpha); |
| 421 | previousAnimator.setCurrentPlayTime(previousAnimator.getCurrentPlayTime()); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 422 | } else { |
| 423 | // Set animation. |
| 424 | updateScrimColor(scrim, alpha, getCurrentScrimTint(scrim)); |
Jorim Jaggi | 93439da | 2014-06-30 23:53:39 +0200 | [diff] [blame] | 425 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 426 | } |
| 427 | |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 428 | private void applyExpansionToAlpha() { |
Lucas Dupin | 67f0263 | 2018-03-12 11:08:31 -0700 | [diff] [blame] | 429 | if (!mExpansionAffectsAlpha) { |
| 430 | return; |
| 431 | } |
| 432 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 433 | if (mState == ScrimState.UNLOCKED || mState == ScrimState.BUBBLE_EXPANDED) { |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 434 | // Darken scrim as you pull down the shade when unlocked |
| 435 | float behindFraction = getInterpolatedFraction(); |
| 436 | behindFraction = (float) Math.pow(behindFraction, 0.8f); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 437 | mBehindAlpha = behindFraction * GRADIENT_SCRIM_ALPHA_BUSY; |
| 438 | mInFrontAlpha = 0; |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 439 | } else if (mState == ScrimState.KEYGUARD || mState == ScrimState.PULSING) { |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 440 | // Either darken of make the scrim transparent when you |
| 441 | // pull down the shade |
| 442 | float interpolatedFract = getInterpolatedFraction(); |
Lucas Dupin | 3d36dd8 | 2019-01-02 14:38:35 -0800 | [diff] [blame] | 443 | float alphaBehind = mState.getBehindAlpha(); |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 444 | if (mDarkenWhileDragging) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 445 | mBehindAlpha = MathUtils.lerp(GRADIENT_SCRIM_ALPHA_BUSY, alphaBehind, |
Lucas Dupin | b380c88 | 2018-02-25 21:57:17 -0800 | [diff] [blame] | 446 | interpolatedFract); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 447 | mInFrontAlpha = 0; |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 448 | } else { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 449 | mBehindAlpha = MathUtils.lerp(0 /* start */, alphaBehind, |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 450 | interpolatedFract); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 451 | mInFrontAlpha = 0; |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 452 | } |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 453 | mBehindTint = ColorUtils.blendARGB(ScrimState.BOUNCER.getBehindTint(), |
Lucas Dupin | 4cf0106 | 2019-03-08 17:07:49 -0800 | [diff] [blame] | 454 | mState.getBehindTint(), interpolatedFract); |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 455 | } |
| 456 | } |
| 457 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 458 | /** |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 459 | * Sets the given drawable as the background of the scrim that shows up behind the |
| 460 | * notifications. |
| 461 | */ |
| 462 | public void setScrimBehindDrawable(Drawable drawable) { |
| 463 | mScrimBehind.setDrawable(drawable); |
| 464 | } |
| 465 | |
Michael Wright | cae8875 | 2018-04-16 23:13:54 +0100 | [diff] [blame] | 466 | /** |
Lucas Dupin | 69bda60 | 2018-05-18 17:24:52 -0700 | [diff] [blame] | 467 | * Sets the front scrim opacity in AOD so it's not as bright. |
| 468 | * <p> |
| 469 | * Displays usually don't support multiple dimming settings when in low power mode. |
| 470 | * The workaround is to modify the front scrim opacity when in AOD, so it's not as |
| 471 | * bright when you're at the movies or lying down on bed. |
| 472 | * <p> |
| 473 | * This value will be lost during transitions and only updated again after the the |
| 474 | * device is dozing when the light sensor is on. |
Michael Wright | cae8875 | 2018-04-16 23:13:54 +0100 | [diff] [blame] | 475 | */ |
| 476 | public void setAodFrontScrimAlpha(float alpha) { |
Lucas Dupin | 69bda60 | 2018-05-18 17:24:52 -0700 | [diff] [blame] | 477 | if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn() |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 478 | && mInFrontAlpha != alpha) { |
| 479 | mInFrontAlpha = alpha; |
Lucas Dupin | 8523d13 | 2018-05-31 17:34:32 -0700 | [diff] [blame] | 480 | updateScrims(); |
Michael Wright | cae8875 | 2018-04-16 23:13:54 +0100 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | mState.AOD.setAodFrontScrimAlpha(alpha); |
| 484 | } |
| 485 | |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 486 | /** |
| 487 | * If the lock screen sensor is active. |
| 488 | */ |
| 489 | public void setWakeLockScreenSensorActive(boolean active) { |
| 490 | for (ScrimState state : ScrimState.values()) { |
| 491 | state.setWakeLockScreenSensorActive(active); |
| 492 | } |
| 493 | |
| 494 | if (mState == ScrimState.PULSING) { |
| 495 | float newBehindAlpha = mState.getBehindAlpha(); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 496 | if (mBehindAlpha != newBehindAlpha) { |
| 497 | mBehindAlpha = newBehindAlpha; |
Lucas Dupin | 5f00fa5 | 2019-03-27 22:46:53 -0700 | [diff] [blame] | 498 | updateScrims(); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | |
Evan Rosky | 9a89501 | 2016-04-21 11:26:15 -0700 | [diff] [blame] | 503 | protected void scheduleUpdate() { |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 504 | if (mUpdatePending) return; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 505 | |
| 506 | // Make sure that a frame gets scheduled. |
| 507 | mScrimBehind.invalidate(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 508 | mScrimBehind.getViewTreeObserver().addOnPreDrawListener(this); |
| 509 | mUpdatePending = true; |
| 510 | } |
| 511 | |
Xiaohui Chen | 5da7135 | 2016-02-22 10:04:41 -0800 | [diff] [blame] | 512 | protected void updateScrims() { |
Lucas Dupin | 9324aa9 | 2017-07-26 20:29:38 -0700 | [diff] [blame] | 513 | // Make sure we have the right gradients and their opacities will satisfy GAR. |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 514 | if (mNeedsDrawableColorUpdate) { |
| 515 | mNeedsDrawableColorUpdate = false; |
Lucas Dupin | f8463ee | 2018-06-11 16:18:15 -0700 | [diff] [blame] | 516 | // Only animate scrim color if the scrim view is actually visible |
| 517 | boolean animateScrimInFront = mScrimInFront.getViewAlpha() != 0 && !mBlankScreen; |
| 518 | boolean animateScrimBehind = mScrimBehind.getViewAlpha() != 0 && !mBlankScreen; |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 519 | boolean animateScrimForBubble = mScrimForBubble.getViewAlpha() != 0 && !mBlankScreen; |
| 520 | |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 521 | mScrimInFront.setColors(mColors, animateScrimInFront); |
| 522 | mScrimBehind.setColors(mColors, animateScrimBehind); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 523 | mScrimForBubble.setColors(mColors, animateScrimForBubble); |
Lucas Dupin | 9324aa9 | 2017-07-26 20:29:38 -0700 | [diff] [blame] | 524 | |
| 525 | // Calculate minimum scrim opacity for white or black text. |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 526 | int textColor = mColors.supportsDarkText() ? Color.BLACK : Color.WHITE; |
| 527 | int mainColor = mColors.getMainColor(); |
Lucas Dupin | 9324aa9 | 2017-07-26 20:29:38 -0700 | [diff] [blame] | 528 | float minOpacity = ColorUtils.calculateMinimumBackgroundAlpha(textColor, mainColor, |
| 529 | 4.5f /* minimumContrast */) / 255f; |
| 530 | mScrimBehindAlpha = Math.max(mScrimBehindAlphaResValue, minOpacity); |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 531 | dispatchScrimState(mScrimBehind.getViewAlpha()); |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 534 | // We want to override the back scrim opacity for the AOD state |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 535 | // when it's time to fade the wallpaper away. |
TYM Tsai | a71c892 | 2019-01-07 15:57:53 +0800 | [diff] [blame] | 536 | boolean aodWallpaperTimeout = (mState == ScrimState.AOD || mState == ScrimState.PULSING) |
| 537 | && mWallpaperVisibilityTimedOut; |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 538 | // We also want to hide FLAG_SHOW_WHEN_LOCKED activities under the scrim. |
| 539 | boolean occludedKeyguard = (mState == ScrimState.PULSING || mState == ScrimState.AOD) |
| 540 | && mKeyguardOccluded; |
| 541 | if (aodWallpaperTimeout || occludedKeyguard) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 542 | mBehindAlpha = 1; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 543 | } |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 544 | setScrimAlpha(mScrimInFront, mInFrontAlpha); |
| 545 | setScrimAlpha(mScrimBehind, mBehindAlpha); |
| 546 | setScrimAlpha(mScrimForBubble, mBubbleAlpha); |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 547 | dispatchScrimsVisible(); |
| 548 | } |
| 549 | |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 550 | private void dispatchScrimState(float alpha) { |
| 551 | mScrimStateListener.accept(mState, alpha, mScrimInFront.getColors()); |
| 552 | } |
| 553 | |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 554 | private void dispatchScrimsVisible() { |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 555 | final int currentScrimVisibility; |
| 556 | if (mScrimInFront.getViewAlpha() == 1 || mScrimBehind.getViewAlpha() == 1) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 557 | currentScrimVisibility = OPAQUE; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 558 | } else if (mScrimInFront.getViewAlpha() == 0 && mScrimBehind.getViewAlpha() == 0) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 559 | currentScrimVisibility = TRANSPARENT; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 560 | } else { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 561 | currentScrimVisibility = SEMI_TRANSPARENT; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 562 | } |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 563 | |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 564 | if (mScrimsVisibility != currentScrimVisibility) { |
| 565 | mScrimsVisibility = currentScrimVisibility; |
| 566 | mScrimVisibleListener.accept(currentScrimVisibility); |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 567 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 568 | } |
| 569 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 570 | private float getInterpolatedFraction() { |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 571 | float frac = mExpansionFraction; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 572 | // let's start this 20% of the way down the screen |
| 573 | frac = frac * 1.2f - 0.2f; |
| 574 | if (frac <= 0) { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 575 | return 0; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 576 | } else { |
| 577 | // woo, special effects |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 578 | return (float) (1f - 0.5f * (1f - Math.cos(3.14159f * Math.pow(1f - frac, 2f)))); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 582 | private void setScrimAlpha(ScrimView scrim, float alpha) { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 583 | if (alpha == 0f) { |
| 584 | scrim.setClickable(false); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 585 | } else { |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 586 | // Eat touch events (unless dozing). |
| 587 | scrim.setClickable(mState != ScrimState.AOD); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 588 | } |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 589 | updateScrim(scrim, alpha); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 590 | } |
| 591 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 592 | private String getScrimName(ScrimView scrim) { |
| 593 | if (scrim == mScrimInFront) { |
| 594 | return "front_scrim"; |
| 595 | } else if (scrim == mScrimBehind) { |
| 596 | return "back_scrim"; |
| 597 | } else if (scrim == mScrimForBubble) { |
| 598 | return "bubble_scrim"; |
| 599 | } |
| 600 | return "unknown_scrim"; |
| 601 | } |
| 602 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 603 | private void updateScrimColor(View scrim, float alpha, int tint) { |
| 604 | alpha = Math.max(0, Math.min(1.0f, alpha)); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 605 | if (scrim instanceof ScrimView) { |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 606 | ScrimView scrimView = (ScrimView) scrim; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 607 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 608 | Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_alpha", |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 609 | (int) (alpha * 255)); |
| 610 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 611 | Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_tint", |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 612 | Color.alpha(tint)); |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 613 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 614 | scrimView.setTint(tint); |
| 615 | scrimView.setViewAlpha(alpha); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 616 | } else { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 617 | scrim.setAlpha(alpha); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 618 | } |
Selim Cinek | 8cd8040 | 2017-08-01 10:44:29 -0700 | [diff] [blame] | 619 | dispatchScrimsVisible(); |
Jorim Jaggi | 048af1f | 2014-11-11 22:51:10 +0100 | [diff] [blame] | 620 | } |
| 621 | |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 622 | private void startScrimAnimation(final View scrim, float current) { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 623 | ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); |
| 624 | final int initialScrimTint = scrim instanceof ScrimView ? ((ScrimView) scrim).getTint() : |
| 625 | Color.TRANSPARENT; |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 626 | anim.addUpdateListener(animation -> { |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 627 | final float startAlpha = (Float) scrim.getTag(TAG_START_ALPHA); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 628 | final float animAmount = (float) animation.getAnimatedValue(); |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 629 | final int finalScrimTint = getCurrentScrimTint(scrim); |
| 630 | final float finalScrimAlpha = getCurrentScrimAlpha(scrim); |
| 631 | float alpha = MathUtils.lerp(startAlpha, finalScrimAlpha, animAmount); |
| 632 | alpha = MathUtils.constrain(alpha, 0f, 1f); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 633 | int tint = ColorUtils.blendARGB(initialScrimTint, finalScrimTint, animAmount); |
| 634 | updateScrimColor(scrim, alpha, tint); |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 635 | dispatchScrimsVisible(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 636 | }); |
Lucas Dupin | 3503c5f | 2018-03-02 19:04:00 -0800 | [diff] [blame] | 637 | anim.setInterpolator(mInterpolator); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 638 | anim.setStartDelay(mAnimationDelay); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 639 | anim.setDuration(mAnimationDuration); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 640 | anim.addListener(new AnimatorListenerAdapter() { |
Joanne Chung | a393ad6 | 2019-01-16 21:41:31 +0800 | [diff] [blame] | 641 | private Callback lastCallback = mCallback; |
| 642 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 643 | @Override |
| 644 | public void onAnimationEnd(Animator animation) { |
Joanne Chung | a393ad6 | 2019-01-16 21:41:31 +0800 | [diff] [blame] | 645 | onFinished(lastCallback); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 646 | |
| 647 | scrim.setTag(TAG_KEY_ANIM, null); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 648 | dispatchScrimsVisible(); |
| 649 | |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 650 | if (!mDeferFinishedListener && mOnAnimationFinished != null) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 651 | mOnAnimationFinished.run(); |
| 652 | mOnAnimationFinished = null; |
| 653 | } |
| 654 | } |
| 655 | }); |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 656 | |
| 657 | // Cache alpha values because we might want to update this animator in the future if |
| 658 | // the user expands the panel while the animation is still running. |
| 659 | scrim.setTag(TAG_START_ALPHA, current); |
| 660 | scrim.setTag(TAG_END_ALPHA, getCurrentScrimAlpha(scrim)); |
| 661 | |
John Spurlock | bf37099 | 2014-06-17 13:58:31 -0400 | [diff] [blame] | 662 | scrim.setTag(TAG_KEY_ANIM, anim); |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 663 | anim.start(); |
| 664 | } |
| 665 | |
| 666 | private float getCurrentScrimAlpha(View scrim) { |
| 667 | if (scrim == mScrimInFront) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 668 | return mInFrontAlpha; |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 669 | } else if (scrim == mScrimBehind) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 670 | return mBehindAlpha; |
| 671 | } else if (scrim == mScrimForBubble) { |
| 672 | return mBubbleAlpha; |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 673 | } else { |
| 674 | throw new IllegalArgumentException("Unknown scrim view"); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | private int getCurrentScrimTint(View scrim) { |
| 679 | if (scrim == mScrimInFront) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 680 | return mInFrontTint; |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 681 | } else if (scrim == mScrimBehind) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 682 | return mBehindTint; |
| 683 | } else if (scrim == mScrimForBubble) { |
| 684 | return mBubbleTint; |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 685 | } else { |
| 686 | throw new IllegalArgumentException("Unknown scrim view"); |
| 687 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 688 | } |
| 689 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 690 | @Override |
| 691 | public boolean onPreDraw() { |
| 692 | mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this); |
| 693 | mUpdatePending = false; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 694 | if (mCallback != null) { |
| 695 | mCallback.onStart(); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 696 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 697 | updateScrims(); |
Lucas Dupin | 3503c5f | 2018-03-02 19:04:00 -0800 | [diff] [blame] | 698 | if (mOnAnimationFinished != null && !isAnimating(mScrimInFront) |
| 699 | && !isAnimating(mScrimBehind)) { |
| 700 | mOnAnimationFinished.run(); |
| 701 | mOnAnimationFinished = null; |
| 702 | } |
Selim Cinek | edd32b8 | 2015-06-23 22:05:58 -0400 | [diff] [blame] | 703 | return true; |
| 704 | } |
| 705 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 706 | private void onFinished() { |
Joanne Chung | a393ad6 | 2019-01-16 21:41:31 +0800 | [diff] [blame] | 707 | onFinished(mCallback); |
| 708 | } |
| 709 | |
| 710 | private void onFinished(Callback callback) { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 711 | if (mWakeLockHeld) { |
Lucas Dupin | ee4c9b7 | 2019-02-18 17:04:58 -0800 | [diff] [blame] | 712 | mWakeLock.release(TAG); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 713 | mWakeLockHeld = false; |
| 714 | } |
Joanne Chung | a393ad6 | 2019-01-16 21:41:31 +0800 | [diff] [blame] | 715 | |
| 716 | if (callback != null) { |
| 717 | callback.onFinished(); |
| 718 | |
| 719 | if (callback == mCallback) { |
| 720 | mCallback = null; |
| 721 | } |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 722 | } |
Joanne Chung | a393ad6 | 2019-01-16 21:41:31 +0800 | [diff] [blame] | 723 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 724 | // When unlocking with fingerprint, we'll fade the scrims from black to transparent. |
| 725 | // At the end of the animation we need to remove the tint. |
| 726 | if (mState == ScrimState.UNLOCKED) { |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 727 | mInFrontTint = Color.TRANSPARENT; |
| 728 | mBehindTint = Color.TRANSPARENT; |
| 729 | mBubbleTint = Color.TRANSPARENT; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 730 | } |
| 731 | } |
| 732 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 733 | private boolean isAnimating(View scrim) { |
| 734 | return scrim.getTag(TAG_KEY_ANIM) != null; |
| 735 | } |
| 736 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 737 | @VisibleForTesting |
| 738 | void setOnAnimationFinished(Runnable onAnimationFinished) { |
| 739 | mOnAnimationFinished = onAnimationFinished; |
| 740 | } |
Adrian Roos | 5f72c92 | 2016-03-08 15:54:26 -0800 | [diff] [blame] | 741 | |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 742 | private void updateScrim(ScrimView scrim, float alpha) { |
| 743 | final float currentAlpha = scrim.getViewAlpha(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 744 | |
| 745 | ValueAnimator previousAnimator = ViewState.getChildTag(scrim, TAG_KEY_ANIM); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 746 | if (previousAnimator != null) { |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 747 | if (mAnimateChange) { |
Jorim Jaggi | f5304ad | 2017-07-17 18:31:13 +0200 | [diff] [blame] | 748 | // We are not done yet! Defer calling the finished listener. |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 749 | mDeferFinishedListener = true; |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 750 | } |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 751 | // Previous animators should always be cancelled. Not doing so would cause |
| 752 | // overlap, especially on states that don't animate, leading to flickering, |
| 753 | // and in the worst case, an internal state that doesn't represent what |
| 754 | // transitionTo requested. |
| 755 | cancelAnimator(previousAnimator); |
| 756 | mDeferFinishedListener = false; |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 757 | } |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 758 | |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 759 | if (mPendingFrameCallback != null) { |
| 760 | // Display is off and we're waiting. |
| 761 | return; |
| 762 | } else if (mBlankScreen) { |
| 763 | // Need to blank the display before continuing. |
| 764 | blankDisplay(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 765 | return; |
| 766 | } else if (!mScreenBlankingCallbackCalled) { |
| 767 | // Not blanking the screen. Letting the callback know that we're ready |
| 768 | // to replace what was on the screen before. |
| 769 | if (mCallback != null) { |
| 770 | mCallback.onDisplayBlanked(); |
| 771 | mScreenBlankingCallbackCalled = true; |
| 772 | } |
| 773 | } |
| 774 | |
Lucas Dupin | 6afae37 | 2017-11-30 13:09:22 -0500 | [diff] [blame] | 775 | if (scrim == mScrimBehind) { |
Yohei Yukawa | 795f010 | 2018-04-13 14:55:30 -0700 | [diff] [blame] | 776 | dispatchScrimState(alpha); |
Lucas Dupin | 6afae37 | 2017-11-30 13:09:22 -0500 | [diff] [blame] | 777 | } |
| 778 | |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 779 | final boolean wantsAlphaUpdate = alpha != currentAlpha; |
Lucas Dupin | 3503c5f | 2018-03-02 19:04:00 -0800 | [diff] [blame] | 780 | final boolean wantsTintUpdate = scrim.getTint() != getCurrentScrimTint(scrim); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 781 | |
| 782 | if (wantsAlphaUpdate || wantsTintUpdate) { |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 783 | if (mAnimateChange) { |
| 784 | startScrimAnimation(scrim, currentAlpha); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 785 | } else { |
Lucas Dupin | 3daf3b0 | 2018-02-27 17:23:41 -0800 | [diff] [blame] | 786 | // update the alpha directly |
| 787 | updateScrimColor(scrim, alpha, getCurrentScrimTint(scrim)); |
| 788 | onFinished(); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 789 | } |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 790 | } else { |
| 791 | onFinished(); |
Selim Cinek | aac9325 | 2015-04-14 20:04:12 -0700 | [diff] [blame] | 792 | } |
| 793 | } |
| 794 | |
Lucas Dupin | 80a3fcc | 2018-02-07 10:49:55 -0800 | [diff] [blame] | 795 | @VisibleForTesting |
| 796 | protected void cancelAnimator(ValueAnimator previousAnimator) { |
| 797 | if (previousAnimator != null) { |
| 798 | previousAnimator.cancel(); |
| 799 | } |
| 800 | } |
| 801 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 802 | private void blankDisplay() { |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 803 | updateScrimColor(mScrimInFront, 1, Color.BLACK); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 804 | |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 805 | // Notify callback that the screen is completely black and we're |
| 806 | // ready to change the display power mode |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 807 | mPendingFrameCallback = () -> { |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 808 | if (mCallback != null) { |
| 809 | mCallback.onDisplayBlanked(); |
| 810 | mScreenBlankingCallbackCalled = true; |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 811 | } |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 812 | |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 813 | mBlankingTransitionRunnable = () -> { |
| 814 | mBlankingTransitionRunnable = null; |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 815 | mPendingFrameCallback = null; |
| 816 | mBlankScreen = false; |
| 817 | // Try again. |
| 818 | updateScrims(); |
| 819 | }; |
| 820 | |
| 821 | // Setting power states can happen after we push out the frame. Make sure we |
| 822 | // stay fully opaque until the power state request reaches the lower levels. |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 823 | final int delay = mScreenOn ? 32 : 500; |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 824 | if (DEBUG) { |
Lucas Dupin | 3a64ed7 | 2018-02-12 12:44:37 -0800 | [diff] [blame] | 825 | Log.d(TAG, "Fading out scrims with delay: " + delay); |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 826 | } |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 827 | mHandler.postDelayed(mBlankingTransitionRunnable, delay); |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 828 | }; |
| 829 | doOnTheNextFrame(mPendingFrameCallback); |
| 830 | } |
| 831 | |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 832 | /** |
| 833 | * Executes a callback after the frame has hit the display. |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 834 | * |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 835 | * @param callback What to run. |
| 836 | */ |
Lucas Dupin | 8c7cb02 | 2018-02-05 10:49:03 -0800 | [diff] [blame] | 837 | @VisibleForTesting |
Lucas Dupin | 0791d97 | 2018-03-26 13:32:16 -0700 | [diff] [blame] | 838 | protected void doOnTheNextFrame(Runnable callback) { |
| 839 | // Just calling View#postOnAnimation isn't enough because the frame might not have reached |
| 840 | // the display yet. A timeout is the safest solution. |
| 841 | mScrimBehind.postOnAnimationDelayed(callback, 32 /* delayMillis */); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | @VisibleForTesting |
| 845 | protected Handler getHandler() { |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 846 | return new Handler(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 847 | } |
| 848 | |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 849 | public int getBackgroundColor() { |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 850 | int color = mColors.getMainColor(); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 851 | return Color.argb((int) (mScrimBehind.getViewAlpha() * Color.alpha(color)), |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 852 | Color.red(color), Color.green(color), Color.blue(color)); |
Selim Cinek | d35c279 | 2016-01-21 13:20:57 -0800 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | public void setScrimBehindChangeRunnable(Runnable changeRunnable) { |
| 856 | mScrimBehind.setChangeRunnable(changeRunnable); |
| 857 | } |
Selim Cinek | e803491c | 2016-04-09 21:24:45 -0700 | [diff] [blame] | 858 | |
Jorim Jaggi | e31f6b8 | 2016-07-01 16:15:09 -0700 | [diff] [blame] | 859 | public void setCurrentUser(int currentUser) { |
| 860 | // Don't care in the base class. |
| 861 | } |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 862 | |
| 863 | @Override |
Lucas Dupin | 7aaa353 | 2017-05-28 08:51:07 -0700 | [diff] [blame] | 864 | public void onColorsChanged(ColorExtractor colorExtractor, int which) { |
Lucas Dupin | 2bd3af6 | 2019-03-25 17:44:28 -0700 | [diff] [blame] | 865 | mColors = mColorExtractor.getNeutralColors(); |
| 866 | mNeedsDrawableColorUpdate = true; |
| 867 | scheduleUpdate(); |
Lucas Dupin | 8da8f2e9 | 2017-04-21 14:02:16 -0700 | [diff] [blame] | 868 | } |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 869 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 870 | @VisibleForTesting |
| 871 | protected WakeLock createWakeLock() { |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 872 | return new DelayedWakeLock(mHandler, WakeLock.createPartial(mContext, "Scrims")); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 873 | } |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 874 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 875 | @Override |
| 876 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Lucas Dupin | 3fcdd47 | 2018-01-19 19:06:45 -0800 | [diff] [blame] | 877 | pw.println(" ScrimController: "); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 878 | pw.print(" state: "); |
| 879 | pw.println(mState); |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 880 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 881 | pw.print(" frontScrim:"); |
| 882 | pw.print(" viewAlpha="); |
| 883 | pw.print(mScrimInFront.getViewAlpha()); |
| 884 | pw.print(" alpha="); |
| 885 | pw.print(mInFrontAlpha); |
| 886 | pw.print(" tint=0x"); |
| 887 | pw.println(Integer.toHexString(mScrimInFront.getTint())); |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 888 | |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 889 | pw.print(" backScrim:"); |
| 890 | pw.print(" viewAlpha="); |
| 891 | pw.print(mScrimBehind.getViewAlpha()); |
| 892 | pw.print(" alpha="); |
| 893 | pw.print(mBehindAlpha); |
| 894 | pw.print(" tint=0x"); |
| 895 | pw.println(Integer.toHexString(mScrimBehind.getTint())); |
| 896 | |
| 897 | pw.print(" bubbleScrim:"); |
| 898 | pw.print(" viewAlpha="); |
| 899 | pw.print(mScrimForBubble.getViewAlpha()); |
| 900 | pw.print(" alpha="); |
| 901 | pw.print(mBubbleAlpha); |
| 902 | pw.print(" tint=0x"); |
| 903 | pw.println(Integer.toHexString(mScrimForBubble.getTint())); |
| 904 | |
| 905 | pw.print(" mTracking="); |
| 906 | pw.println(mTracking); |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 907 | } |
| 908 | |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 909 | public void setWallpaperSupportsAmbientMode(boolean wallpaperSupportsAmbientMode) { |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 910 | mWallpaperSupportsAmbientMode = wallpaperSupportsAmbientMode; |
| 911 | ScrimState[] states = ScrimState.values(); |
| 912 | for (int i = 0; i < states.length; i++) { |
| 913 | states[i].setWallpaperSupportsAmbientMode(wallpaperSupportsAmbientMode); |
| 914 | } |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 917 | /** |
| 918 | * Interrupts blanking transitions once the display notifies that it's already on. |
| 919 | */ |
| 920 | public void onScreenTurnedOn() { |
Lucas Dupin | 3a64ed7 | 2018-02-12 12:44:37 -0800 | [diff] [blame] | 921 | mScreenOn = true; |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 922 | if (mHandler.hasCallbacks(mBlankingTransitionRunnable)) { |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 923 | if (DEBUG) { |
| 924 | Log.d(TAG, "Shorter blanking because screen turned on. All good."); |
| 925 | } |
Lucas Dupin | 54fbfb3 | 2019-03-05 18:08:13 -0800 | [diff] [blame] | 926 | mHandler.removeCallbacks(mBlankingTransitionRunnable); |
Lucas Dupin | 53cf12a | 2018-02-05 16:14:45 -0800 | [diff] [blame] | 927 | mBlankingTransitionRunnable.run(); |
| 928 | } |
| 929 | } |
| 930 | |
Lucas Dupin | 3a64ed7 | 2018-02-12 12:44:37 -0800 | [diff] [blame] | 931 | public void onScreenTurnedOff() { |
| 932 | mScreenOn = false; |
| 933 | } |
| 934 | |
Lucas Dupin | 67f0263 | 2018-03-12 11:08:31 -0700 | [diff] [blame] | 935 | public void setExpansionAffectsAlpha(boolean expansionAffectsAlpha) { |
| 936 | mExpansionAffectsAlpha = expansionAffectsAlpha; |
| 937 | } |
| 938 | |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 939 | public void setKeyguardOccluded(boolean keyguardOccluded) { |
| 940 | mKeyguardOccluded = keyguardOccluded; |
Lucas Dupin | 63d7217 | 2018-06-06 11:42:55 -0700 | [diff] [blame] | 941 | updateScrims(); |
Lucas Dupin | d510730 | 2018-03-19 15:30:29 -0700 | [diff] [blame] | 942 | } |
| 943 | |
Lucas Dupin | f8463ee | 2018-06-11 16:18:15 -0700 | [diff] [blame] | 944 | public void setHasBackdrop(boolean hasBackdrop) { |
Lucas Dupin | 193677c | 2018-06-11 19:16:03 -0700 | [diff] [blame] | 945 | for (ScrimState state : ScrimState.values()) { |
| 946 | state.setHasBackdrop(hasBackdrop); |
| 947 | } |
Lucas Dupin | 9bee582 | 2018-07-09 14:32:53 -0700 | [diff] [blame] | 948 | |
| 949 | // Backdrop event may arrive after state was already applied, |
| 950 | // in this case, back-scrim needs to be re-evaluated |
| 951 | if (mState == ScrimState.AOD || mState == ScrimState.PULSING) { |
Lucas Dupin | 3d36dd8 | 2019-01-02 14:38:35 -0800 | [diff] [blame] | 952 | float newBehindAlpha = mState.getBehindAlpha(); |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 953 | if (mBehindAlpha != newBehindAlpha) { |
| 954 | mBehindAlpha = newBehindAlpha; |
Lucas Dupin | 9bee582 | 2018-07-09 14:32:53 -0700 | [diff] [blame] | 955 | updateScrims(); |
| 956 | } |
| 957 | } |
Lucas Dupin | 193677c | 2018-06-11 19:16:03 -0700 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | public void setLaunchingAffordanceWithPreview(boolean launchingAffordanceWithPreview) { |
| 961 | for (ScrimState state : ScrimState.values()) { |
| 962 | state.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview); |
Lucas Dupin | f8463ee | 2018-06-11 16:18:15 -0700 | [diff] [blame] | 963 | } |
| 964 | } |
| 965 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 966 | public interface Callback { |
| 967 | default void onStart() { |
| 968 | } |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 969 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 970 | default void onDisplayBlanked() { |
| 971 | } |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 972 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 973 | default void onFinished() { |
| 974 | } |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame^] | 975 | |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 976 | default void onCancelled() { |
| 977 | } |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 978 | } |
Lucas Dupin | 690c6f5 | 2018-07-10 15:28:57 -0700 | [diff] [blame] | 979 | |
| 980 | /** |
| 981 | * Simple keyguard callback that updates scrims when keyguard visibility changes. |
| 982 | */ |
| 983 | private class KeyguardVisibilityCallback extends KeyguardUpdateMonitorCallback { |
| 984 | |
| 985 | @Override |
| 986 | public void onKeyguardVisibilityChanged(boolean showing) { |
| 987 | mNeedsDrawableColorUpdate = true; |
| 988 | scheduleUpdate(); |
| 989 | } |
| 990 | } |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 991 | } |