Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 19 | import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; |
| 20 | |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 21 | import android.annotation.IntDef; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 22 | import android.content.Context; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 23 | import android.content.res.ColorStateList; |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 24 | import android.content.res.Configuration; |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 25 | import android.content.res.TypedArray; |
Lucas Dupin | c90a6bf | 2018-10-10 13:53:20 -0700 | [diff] [blame] | 26 | import android.graphics.Color; |
Lucas Dupin | f3b2629 | 2019-03-14 16:06:22 -0700 | [diff] [blame] | 27 | import android.graphics.drawable.Animatable2; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 28 | import android.graphics.drawable.AnimatedVectorDrawable; |
| 29 | import android.graphics.drawable.Drawable; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 30 | import android.hardware.biometrics.BiometricSourceType; |
Ian | aee1b2a | 2019-05-10 16:48:22 -0700 | [diff] [blame] | 31 | import android.os.Trace; |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 32 | import android.provider.Settings; |
| 33 | import android.text.TextUtils; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 34 | import android.util.AttributeSet; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 35 | import android.view.ViewGroup; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 36 | import android.view.ViewTreeObserver; |
Selim Cinek | c99d9a95 | 2015-06-19 18:44:50 -0700 | [diff] [blame] | 37 | import android.view.accessibility.AccessibilityNodeInfo; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 38 | |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 39 | import androidx.annotation.Nullable; |
| 40 | |
Lucas Dupin | c90a6bf | 2018-10-10 13:53:20 -0700 | [diff] [blame] | 41 | import com.android.internal.graphics.ColorUtils; |
Lucas Dupin | da069d7 | 2019-05-04 11:29:47 -0700 | [diff] [blame] | 42 | import com.android.internal.telephony.IccCardConstants; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 43 | import com.android.keyguard.KeyguardUpdateMonitor; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 44 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 45 | import com.android.systemui.Interpolators; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 46 | import com.android.systemui.R; |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 47 | import com.android.systemui.dock.DockManager; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 48 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 49 | import com.android.systemui.statusbar.KeyguardAffordanceView; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 50 | import com.android.systemui.statusbar.StatusBarState; |
| 51 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 52 | import com.android.systemui.statusbar.phone.ScrimController.ScrimVisibility; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 53 | import com.android.systemui.statusbar.policy.AccessibilityController; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 54 | import com.android.systemui.statusbar.policy.ConfigurationController; |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 55 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 56 | import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 57 | import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 58 | |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 59 | import java.lang.annotation.Retention; |
| 60 | import java.lang.annotation.RetentionPolicy; |
| 61 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 62 | import javax.inject.Inject; |
| 63 | import javax.inject.Named; |
| 64 | |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 65 | /** |
| 66 | * Manages the different states and animations of the unlock icon. |
| 67 | */ |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 68 | public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChangedListener, |
| 69 | StatusBarStateController.StateListener, ConfigurationController.ConfigurationListener, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 70 | UnlockMethodCache.OnUnlockMethodChangedListener, |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 71 | NotificationWakeUpCoordinator.WakeUpListener, ViewTreeObserver.OnPreDrawListener, |
| 72 | OnHeadsUpChangedListener { |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 73 | |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 74 | private static final int STATE_LOCKED = 0; |
| 75 | private static final int STATE_LOCK_OPEN = 1; |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 76 | private static final int STATE_SCANNING_FACE = 2; |
| 77 | private static final int STATE_BIOMETRICS_ERROR = 3; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 78 | private final ConfigurationController mConfigurationController; |
| 79 | private final StatusBarStateController mStatusBarStateController; |
| 80 | private final UnlockMethodCache mUnlockMethodCache; |
| 81 | private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
| 82 | private final AccessibilityController mAccessibilityController; |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 83 | private final DockManager mDockManager; |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 84 | private final KeyguardMonitor mKeyguardMonitor; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 85 | private final KeyguardBypassController mBypassController; |
| 86 | private final NotificationWakeUpCoordinator mWakeUpCoordinator; |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 87 | private final HeadsUpManagerPhone mHeadsUpManager; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 88 | |
| 89 | private int mLastState = 0; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 90 | private boolean mForceUpdate; |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 91 | private boolean mTransientBiometricsError; |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 92 | private boolean mIsFaceUnlockState; |
Lucas Dupin | da069d7 | 2019-05-04 11:29:47 -0700 | [diff] [blame] | 93 | private boolean mSimLocked; |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 94 | private int mDensity; |
Lucas Dupin | f22194f | 2018-12-26 11:43:57 -0800 | [diff] [blame] | 95 | private boolean mPulsing; |
| 96 | private boolean mDozing; |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 97 | private boolean mDocked; |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 98 | private boolean mBlockUpdates; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 99 | private int mIconColor; |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 100 | private float mDozeAmount; |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 101 | private boolean mBouncerShowingScrimmed; |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 102 | private boolean mWakeAndUnlockRunning; |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 103 | private boolean mKeyguardShowing; |
Lucas Dupin | 23964c7 | 2019-05-21 16:12:45 -0700 | [diff] [blame] | 104 | private boolean mShowingLaunchAffordance; |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 105 | private boolean mKeyguardJustShown; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 106 | private boolean mUpdatePending; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 107 | |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 108 | private final KeyguardMonitor.Callback mKeyguardMonitorCallback = |
| 109 | new KeyguardMonitor.Callback() { |
| 110 | @Override |
| 111 | public void onKeyguardShowingChanged() { |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 112 | boolean force = false; |
| 113 | boolean wasShowing = mKeyguardShowing; |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 114 | mKeyguardShowing = mKeyguardMonitor.isShowing(); |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 115 | if (!wasShowing && mKeyguardShowing && mBlockUpdates) { |
| 116 | mBlockUpdates = false; |
| 117 | force = true; |
| 118 | } |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 119 | if (!wasShowing && mKeyguardShowing) { |
| 120 | mKeyguardJustShown = true; |
| 121 | } |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 122 | update(force); |
| 123 | } |
| 124 | |
| 125 | @Override |
| 126 | public void onKeyguardFadingAwayChanged() { |
| 127 | if (!mKeyguardMonitor.isKeyguardFadingAway() && mBlockUpdates) { |
| 128 | mBlockUpdates = false; |
| 129 | update(true /* force */); |
| 130 | } |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 131 | } |
| 132 | }; |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 133 | private final DockManager.DockEventListener mDockEventListener = |
| 134 | new DockManager.DockEventListener() { |
| 135 | @Override |
| 136 | public void onEvent(int event) { |
| 137 | boolean docked = event == DockManager.STATE_DOCKED |
| 138 | || event == DockManager.STATE_DOCKED_HIDE; |
| 139 | if (docked != mDocked) { |
| 140 | mDocked = docked; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 141 | update(); |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | }; |
Jorim Jaggi | 8dea48c | 2016-11-28 14:47:45 +0100 | [diff] [blame] | 145 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 146 | private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = |
| 147 | new KeyguardUpdateMonitorCallback() { |
| 148 | @Override |
Lucas Dupin | da069d7 | 2019-05-04 11:29:47 -0700 | [diff] [blame] | 149 | public void onSimStateChanged(int subId, int slotId, |
| 150 | IccCardConstants.State simState) { |
Lucas Dupin | da069d7 | 2019-05-04 11:29:47 -0700 | [diff] [blame] | 151 | mSimLocked = mKeyguardUpdateMonitor.isSimPinSecure(); |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 152 | update(); |
Lucas Dupin | da069d7 | 2019-05-04 11:29:47 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | @Override |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 156 | public void onKeyguardVisibilityChanged(boolean showing) { |
| 157 | update(); |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public void onBiometricRunningStateChanged(boolean running, |
| 162 | BiometricSourceType biometricSourceType) { |
| 163 | update(); |
| 164 | } |
| 165 | |
| 166 | @Override |
| 167 | public void onStrongAuthStateChanged(int userId) { |
| 168 | update(); |
| 169 | } |
| 170 | }; |
| 171 | |
| 172 | @Inject |
| 173 | public LockIcon(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs, |
| 174 | StatusBarStateController statusBarStateController, |
| 175 | ConfigurationController configurationController, |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 176 | AccessibilityController accessibilityController, |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 177 | KeyguardBypassController bypassController, |
| 178 | NotificationWakeUpCoordinator wakeUpCoordinator, |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 179 | KeyguardMonitor keyguardMonitor, |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 180 | @Nullable DockManager dockManager, |
| 181 | HeadsUpManagerPhone headsUpManager) { |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 182 | super(context, attrs); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 183 | mContext = context; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 184 | mUnlockMethodCache = UnlockMethodCache.getInstance(context); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 185 | mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
| 186 | mAccessibilityController = accessibilityController; |
| 187 | mConfigurationController = configurationController; |
| 188 | mStatusBarStateController = statusBarStateController; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 189 | mBypassController = bypassController; |
| 190 | mWakeUpCoordinator = wakeUpCoordinator; |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 191 | mKeyguardMonitor = keyguardMonitor; |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 192 | mDockManager = dockManager; |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 193 | mHeadsUpManager = headsUpManager; |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | @Override |
| 197 | protected void onAttachedToWindow() { |
| 198 | super.onAttachedToWindow(); |
| 199 | mStatusBarStateController.addCallback(this); |
| 200 | mConfigurationController.addCallback(this); |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 201 | mKeyguardMonitor.addCallback(mKeyguardMonitorCallback); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 202 | mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback); |
| 203 | mUnlockMethodCache.addListener(this); |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 204 | mWakeUpCoordinator.addListener(this); |
Lucas Dupin | da069d7 | 2019-05-04 11:29:47 -0700 | [diff] [blame] | 205 | mSimLocked = mKeyguardUpdateMonitor.isSimPinSecure(); |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 206 | if (mDockManager != null) { |
| 207 | mDockManager.addListener(mDockEventListener); |
| 208 | } |
Lucas Dupin | 12dab90 | 2019-04-19 11:10:48 -0700 | [diff] [blame] | 209 | onThemeChanged(); |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 210 | update(); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | @Override |
| 214 | protected void onDetachedFromWindow() { |
| 215 | super.onDetachedFromWindow(); |
| 216 | mStatusBarStateController.removeCallback(this); |
| 217 | mConfigurationController.removeCallback(this); |
| 218 | mKeyguardUpdateMonitor.removeCallback(mUpdateMonitorCallback); |
Lucas Dupin | 1cad65e | 2019-05-15 13:47:05 -0700 | [diff] [blame] | 219 | mKeyguardMonitor.removeCallback(mKeyguardMonitorCallback); |
Selim Cinek | 8ee02b1 | 2019-07-22 14:49:18 -0700 | [diff] [blame] | 220 | mWakeUpCoordinator.removeListener(this); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 221 | mUnlockMethodCache.removeListener(this); |
Lucas Dupin | d722135 | 2019-04-29 19:43:11 -0700 | [diff] [blame] | 222 | if (mDockManager != null) { |
| 223 | mDockManager.removeListener(mDockEventListener); |
| 224 | } |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public void onThemeChanged() { |
| 229 | TypedArray typedArray = mContext.getTheme().obtainStyledAttributes( |
| 230 | null, new int[]{ R.attr.wallpaperTextColor }, 0, 0); |
| 231 | mIconColor = typedArray.getColor(0, Color.WHITE); |
| 232 | typedArray.recycle(); |
| 233 | updateDarkTint(); |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | @Override |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 237 | public void onUserInfoChanged(String name, Drawable picture, String userAccount) { |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 238 | update(); |
| 239 | } |
| 240 | |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 241 | /** |
| 242 | * If we're currently presenting an authentication error message. |
| 243 | */ |
| 244 | public void setTransientBiometricsError(boolean transientBiometricsError) { |
| 245 | mTransientBiometricsError = transientBiometricsError; |
Jorim Jaggi | 864e64b | 2015-05-20 14:13:23 -0700 | [diff] [blame] | 246 | update(); |
| 247 | } |
| 248 | |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 249 | @Override |
| 250 | protected void onConfigurationChanged(Configuration newConfig) { |
| 251 | super.onConfigurationChanged(newConfig); |
| 252 | final int density = newConfig.densityDpi; |
| 253 | if (density != mDensity) { |
| 254 | mDensity = density; |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 255 | update(); |
| 256 | } |
| 257 | } |
| 258 | |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 259 | public void update() { |
Selim Cinek | 6ebba59 | 2016-05-31 15:28:28 -0700 | [diff] [blame] | 260 | update(false /* force */); |
| 261 | } |
| 262 | |
| 263 | public void update(boolean force) { |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 264 | if (force) { |
| 265 | mForceUpdate = true; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 266 | } |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 267 | if (!mUpdatePending) { |
| 268 | mUpdatePending = true; |
| 269 | getViewTreeObserver().addOnPreDrawListener(this); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | @Override |
| 274 | public boolean onPreDraw() { |
| 275 | mUpdatePending = false; |
| 276 | getViewTreeObserver().removeOnPreDrawListener(this); |
| 277 | |
| 278 | int state = getState(); |
| 279 | int lastState = mLastState; |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 280 | boolean keyguardJustShown = mKeyguardJustShown; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 281 | mIsFaceUnlockState = state == STATE_SCANNING_FACE; |
| 282 | mLastState = state; |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 283 | mKeyguardJustShown = false; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 284 | |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 285 | boolean shouldUpdate = lastState != state || mForceUpdate; |
| 286 | if (mBlockUpdates && canBlockUpdates()) { |
| 287 | shouldUpdate = false; |
| 288 | } |
| 289 | if (shouldUpdate) { |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 290 | mForceUpdate = false; |
| 291 | @LockAnimIndex final int lockAnimIndex = getAnimationIndexForTransition(lastState, |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 292 | state, mPulsing, mDozing, keyguardJustShown); |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 293 | boolean isAnim = lockAnimIndex != -1; |
| 294 | int iconRes = isAnim ? getThemedAnimationResId(lockAnimIndex) : getIconForState(state); |
| 295 | |
| 296 | Drawable icon = mContext.getDrawable(iconRes); |
| 297 | final AnimatedVectorDrawable animation = icon instanceof AnimatedVectorDrawable |
| 298 | ? (AnimatedVectorDrawable) icon |
| 299 | : null; |
| 300 | setImageDrawable(icon, false); |
| 301 | if (mIsFaceUnlockState) { |
| 302 | announceForAccessibility(getContext().getString( |
| 303 | R.string.accessibility_scanning_face)); |
| 304 | } |
| 305 | |
| 306 | if (animation != null && isAnim) { |
| 307 | animation.forceAnimationOnUI(); |
| 308 | animation.clearAnimationCallbacks(); |
| 309 | animation.registerAnimationCallback(new Animatable2.AnimationCallback() { |
| 310 | @Override |
| 311 | public void onAnimationEnd(Drawable drawable) { |
| 312 | if (getDrawable() == animation && state == getState() |
| 313 | && doesAnimationLoop(lockAnimIndex)) { |
| 314 | animation.start(); |
| 315 | } else { |
| 316 | Trace.endAsyncSection("LockIcon#Animation", state); |
| 317 | } |
| 318 | } |
| 319 | }); |
| 320 | Trace.beginAsyncSection("LockIcon#Animation", state); |
| 321 | animation.start(); |
| 322 | } |
| 323 | } |
| 324 | updateDarkTint(); |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 325 | |
Selim Cinek | a678b0e | 2019-07-23 13:12:55 -0700 | [diff] [blame] | 326 | updateIconVisibility(); |
| 327 | updateClickability(); |
| 328 | |
| 329 | return true; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Update the icon visibility |
| 334 | * @return true if the visibility changed |
| 335 | */ |
| 336 | private boolean updateIconVisibility() { |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 337 | boolean onAodNotPulsingOrDocked = mDozing && (!mPulsing || mDocked); |
Lucas Dupin | 23964c7 | 2019-05-21 16:12:45 -0700 | [diff] [blame] | 338 | boolean invisible = onAodNotPulsingOrDocked || mWakeAndUnlockRunning |
| 339 | || mShowingLaunchAffordance; |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 340 | if (mBypassController.getBypassEnabled() && !mBouncerShowingScrimmed) { |
Selim Cinek | 5bc77a1 | 2019-07-26 22:25:49 -0700 | [diff] [blame] | 341 | if ((mHeadsUpManager.isHeadsUpGoingAway() || mHeadsUpManager.hasPinnedHeadsUp() |
| 342 | || mStatusBarStateController.getState() == StatusBarState.KEYGUARD) |
Selim Cinek | a678b0e | 2019-07-23 13:12:55 -0700 | [diff] [blame] | 343 | && !mWakeUpCoordinator.getNotificationsFullyHidden()) { |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 344 | invisible = true; |
| 345 | } |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 346 | } |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 347 | boolean wasInvisible = getVisibility() == INVISIBLE; |
| 348 | if (invisible != wasInvisible) { |
| 349 | setVisibility(invisible ? INVISIBLE : VISIBLE); |
| 350 | animate().cancel(); |
| 351 | if (!invisible) { |
| 352 | setScaleX(0); |
| 353 | setScaleY(0); |
| 354 | animate() |
| 355 | .setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN) |
| 356 | .scaleX(1) |
| 357 | .scaleY(1) |
| 358 | .withLayer() |
| 359 | .setDuration(233) |
| 360 | .start(); |
| 361 | } |
Selim Cinek | a678b0e | 2019-07-23 13:12:55 -0700 | [diff] [blame] | 362 | return true; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 363 | } |
Selim Cinek | a678b0e | 2019-07-23 13:12:55 -0700 | [diff] [blame] | 364 | return false; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 367 | private boolean canBlockUpdates() { |
| 368 | return mKeyguardShowing || mKeyguardMonitor.isKeyguardFadingAway(); |
| 369 | } |
| 370 | |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 371 | private void updateClickability() { |
| 372 | if (mAccessibilityController == null) { |
| 373 | return; |
| 374 | } |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 375 | boolean canLock = mUnlockMethodCache.isMethodSecure() |
| 376 | && mUnlockMethodCache.canSkipBouncer(); |
Adrian Roos | a94e964 | 2017-08-17 17:29:19 +0200 | [diff] [blame] | 377 | boolean clickToUnlock = mAccessibilityController.isAccessibilityEnabled(); |
Lucas Dupin | 0df60fe | 2019-04-23 10:19:27 -0700 | [diff] [blame] | 378 | setClickable(clickToUnlock); |
| 379 | setLongClickable(canLock && !clickToUnlock); |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 380 | setFocusable(mAccessibilityController.isAccessibilityEnabled()); |
| 381 | } |
| 382 | |
Selim Cinek | c99d9a95 | 2015-06-19 18:44:50 -0700 | [diff] [blame] | 383 | @Override |
| 384 | public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { |
| 385 | super.onInitializeAccessibilityNodeInfo(info); |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 386 | boolean fingerprintRunning = mKeyguardUpdateMonitor.isFingerprintDetectionRunning(); |
| 387 | boolean unlockingAllowed = mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(); |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 388 | if (fingerprintRunning && unlockingAllowed) { |
Selim Cinek | c99d9a95 | 2015-06-19 18:44:50 -0700 | [diff] [blame] | 389 | AccessibilityNodeInfo.AccessibilityAction unlock |
| 390 | = new AccessibilityNodeInfo.AccessibilityAction( |
| 391 | AccessibilityNodeInfo.ACTION_CLICK, |
| 392 | getContext().getString(R.string.accessibility_unlock_without_fingerprint)); |
| 393 | info.addAction(unlock); |
Selim Cinek | 947c77c | 2017-03-23 14:20:32 -0700 | [diff] [blame] | 394 | info.setHintText(getContext().getString( |
| 395 | R.string.accessibility_waiting_for_fingerprint)); |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 396 | } else if (mIsFaceUnlockState) { |
Bingyu Zhang | bfe6dcf | 2018-04-25 10:20:36 -0700 | [diff] [blame] | 397 | //Avoid 'button' to be spoken for scanning face |
| 398 | info.setClassName(LockIcon.class.getName()); |
| 399 | info.setContentDescription(getContext().getString( |
| 400 | R.string.accessibility_scanning_face)); |
Selim Cinek | c99d9a95 | 2015-06-19 18:44:50 -0700 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | |
Lucas Dupin | 1aec88f | 2019-05-01 22:25:22 -0700 | [diff] [blame] | 404 | private int getIconForState(int state) { |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 405 | int iconRes; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 406 | switch (state) { |
| 407 | case STATE_LOCKED: |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 408 | // Scanning animation is a pulsing padlock. This means that the resting state is |
| 409 | // just a padlock. |
| 410 | case STATE_SCANNING_FACE: |
| 411 | // Error animation also starts and ands on the padlock. |
| 412 | case STATE_BIOMETRICS_ERROR: |
Lucas Dupin | ce56d3b | 2019-03-07 13:02:25 -0800 | [diff] [blame] | 413 | iconRes = com.android.internal.R.drawable.ic_lock; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 414 | break; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 415 | case STATE_LOCK_OPEN: |
Lucas Dupin | ce56d3b | 2019-03-07 13:02:25 -0800 | [diff] [blame] | 416 | iconRes = com.android.internal.R.drawable.ic_lock_open; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 417 | break; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 418 | default: |
| 419 | throw new IllegalArgumentException(); |
| 420 | } |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 421 | |
Lucas Dupin | 1aec88f | 2019-05-01 22:25:22 -0700 | [diff] [blame] | 422 | return iconRes; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 425 | private boolean doesAnimationLoop(@LockAnimIndex int lockAnimIndex) { |
| 426 | return lockAnimIndex == SCANNING; |
Lucas Dupin | f3b2629 | 2019-03-14 16:06:22 -0700 | [diff] [blame] | 427 | } |
| 428 | |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 429 | private static int getAnimationIndexForTransition(int oldState, int newState, boolean pulsing, |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 430 | boolean dozing, boolean keyguardJustShown) { |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 431 | |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 432 | // Never animate when screen is off |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 433 | if (dozing && !pulsing) { |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 434 | return -1; |
| 435 | } |
| 436 | |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 437 | if (newState == STATE_BIOMETRICS_ERROR) { |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 438 | return ERROR; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 439 | } else if (oldState != STATE_LOCK_OPEN && newState == STATE_LOCK_OPEN) { |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 440 | return UNLOCK; |
Lucas Dupin | 0fdd8f1 | 2019-07-17 15:28:18 -0700 | [diff] [blame] | 441 | } else if (oldState == STATE_LOCK_OPEN && newState == STATE_LOCKED && !keyguardJustShown) { |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 442 | return LOCK; |
Lucas Dupin | 71d2fb2 | 2019-05-30 18:26:54 -0700 | [diff] [blame] | 443 | } else if (newState == STATE_SCANNING_FACE) { |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 444 | return SCANNING; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 445 | } |
Lucas Dupin | c9e5d76 | 2019-01-28 09:34:30 -0800 | [diff] [blame] | 446 | return -1; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 449 | @Override |
| 450 | public void onFullyHiddenChanged(boolean isFullyHidden) { |
| 451 | if (mBypassController.getBypassEnabled()) { |
Selim Cinek | a678b0e | 2019-07-23 13:12:55 -0700 | [diff] [blame] | 452 | boolean changed = updateIconVisibility(); |
| 453 | if (changed) { |
| 454 | update(); |
| 455 | } |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 456 | } |
| 457 | } |
| 458 | |
Selim Cinek | 60ee7fd | 2019-06-26 13:06:00 -0700 | [diff] [blame] | 459 | public void setBouncerShowingScrimmed(boolean bouncerShowing) { |
| 460 | mBouncerShowingScrimmed = bouncerShowing; |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 461 | if (mBypassController.getBypassEnabled()) { |
| 462 | update(); |
| 463 | } |
| 464 | } |
| 465 | |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 466 | @Retention(RetentionPolicy.SOURCE) |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 467 | @IntDef({ERROR, UNLOCK, LOCK, SCANNING}) |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 468 | @interface LockAnimIndex {} |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 469 | private static final int ERROR = 0, UNLOCK = 1, LOCK = 2, SCANNING = 3; |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 470 | private static final int[][] LOCK_ANIM_RES_IDS = new int[][] { |
| 471 | { |
| 472 | R.anim.lock_to_error, |
| 473 | R.anim.lock_unlock, |
| 474 | R.anim.lock_lock, |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 475 | R.anim.lock_scanning |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 476 | }, |
| 477 | { |
| 478 | R.anim.lock_to_error_circular, |
| 479 | R.anim.lock_unlock_circular, |
| 480 | R.anim.lock_lock_circular, |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 481 | R.anim.lock_scanning_circular |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 482 | }, |
| 483 | { |
| 484 | R.anim.lock_to_error_filled, |
| 485 | R.anim.lock_unlock_filled, |
| 486 | R.anim.lock_lock_filled, |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 487 | R.anim.lock_scanning_filled |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 488 | }, |
| 489 | { |
| 490 | R.anim.lock_to_error_rounded, |
| 491 | R.anim.lock_unlock_rounded, |
| 492 | R.anim.lock_lock_rounded, |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 493 | R.anim.lock_scanning_rounded |
Amin Shaikh | 5877c02 | 2019-05-24 10:26:05 -0400 | [diff] [blame] | 494 | }, |
| 495 | }; |
| 496 | |
| 497 | private int getThemedAnimationResId(@LockAnimIndex int lockAnimIndex) { |
| 498 | final String setting = TextUtils.emptyIfNull( |
| 499 | Settings.Secure.getString(getContext().getContentResolver(), |
| 500 | Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES)); |
| 501 | if (setting.contains("com.android.theme.icon_pack.circular.android")) { |
| 502 | return LOCK_ANIM_RES_IDS[1][lockAnimIndex]; |
| 503 | } else if (setting.contains("com.android.theme.icon_pack.filled.android")) { |
| 504 | return LOCK_ANIM_RES_IDS[2][lockAnimIndex]; |
| 505 | } else if (setting.contains("com.android.theme.icon_pack.rounded.android")) { |
| 506 | return LOCK_ANIM_RES_IDS[3][lockAnimIndex]; |
| 507 | } |
| 508 | return LOCK_ANIM_RES_IDS[0][lockAnimIndex]; |
| 509 | } |
| 510 | |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 511 | private int getState() { |
Selim Cinek | 1fcafc4 | 2015-07-20 14:39:25 -0700 | [diff] [blame] | 512 | KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 513 | if ((mUnlockMethodCache.canSkipBouncer() || !mKeyguardShowing |
| 514 | || mKeyguardMonitor.isKeyguardGoingAway()) && !mSimLocked) { |
Selim Cinek | c384198 | 2015-08-25 18:34:29 -0700 | [diff] [blame] | 515 | return STATE_LOCK_OPEN; |
Kevin Chyn | ce135e6 | 2019-06-17 17:13:13 -0700 | [diff] [blame] | 516 | } else if (mTransientBiometricsError) { |
| 517 | return STATE_BIOMETRICS_ERROR; |
Lucas Dupin | ad2577e | 2019-06-25 19:52:26 -0700 | [diff] [blame] | 518 | } else if (updateMonitor.isFaceDetectionRunning() && !mPulsing) { |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 519 | return STATE_SCANNING_FACE; |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 520 | } else { |
| 521 | return STATE_LOCKED; |
| 522 | } |
| 523 | } |
Lucas Dupin | c90a6bf | 2018-10-10 13:53:20 -0700 | [diff] [blame] | 524 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 525 | @Override |
| 526 | public void onDozeAmountChanged(float linear, float eased) { |
| 527 | mDozeAmount = eased; |
Lucas Dupin | c90a6bf | 2018-10-10 13:53:20 -0700 | [diff] [blame] | 528 | updateDarkTint(); |
| 529 | } |
| 530 | |
Lucas Dupin | f22194f | 2018-12-26 11:43:57 -0800 | [diff] [blame] | 531 | /** |
| 532 | * When keyguard is in pulsing (AOD2) state. |
| 533 | * @param pulsing {@code true} when pulsing. |
Lucas Dupin | f22194f | 2018-12-26 11:43:57 -0800 | [diff] [blame] | 534 | */ |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 535 | public void setPulsing(boolean pulsing) { |
Lucas Dupin | f22194f | 2018-12-26 11:43:57 -0800 | [diff] [blame] | 536 | mPulsing = pulsing; |
| 537 | update(); |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Sets the dozing state of the keyguard. |
| 542 | */ |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 543 | @Override |
| 544 | public void onDozingChanged(boolean dozing) { |
Lucas Dupin | f22194f | 2018-12-26 11:43:57 -0800 | [diff] [blame] | 545 | mDozing = dozing; |
| 546 | update(); |
| 547 | } |
| 548 | |
Lucas Dupin | c90a6bf | 2018-10-10 13:53:20 -0700 | [diff] [blame] | 549 | private void updateDarkTint() { |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 550 | int color = ColorUtils.blendARGB(mIconColor, Color.WHITE, mDozeAmount); |
| 551 | setImageTintList(ColorStateList.valueOf(color)); |
Lucas Dupin | c90a6bf | 2018-10-10 13:53:20 -0700 | [diff] [blame] | 552 | } |
Lucas Dupin | 0590465 | 2019-04-09 16:16:15 -0700 | [diff] [blame] | 553 | |
Lucas Dupin | 2e838ac | 2019-04-17 16:50:58 -0700 | [diff] [blame] | 554 | @Override |
| 555 | public void onDensityOrFontScaleChanged() { |
| 556 | ViewGroup.LayoutParams lp = getLayoutParams(); |
| 557 | if (lp == null) { |
| 558 | return; |
| 559 | } |
| 560 | lp.width = getResources().getDimensionPixelSize(R.dimen.keyguard_lock_width); |
| 561 | lp.height = getResources().getDimensionPixelSize(R.dimen.keyguard_lock_height); |
| 562 | setLayoutParams(lp); |
| 563 | update(true /* force */); |
| 564 | } |
| 565 | |
| 566 | @Override |
| 567 | public void onLocaleListChanged() { |
| 568 | setContentDescription(getContext().getText(R.string.accessibility_unlock_button)); |
| 569 | update(true /* force */); |
| 570 | } |
| 571 | |
| 572 | @Override |
| 573 | public void onUnlockMethodStateChanged() { |
| 574 | update(); |
| 575 | } |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 576 | |
| 577 | /** |
| 578 | * We need to hide the lock whenever there's a fingerprint unlock, otherwise you'll see the |
| 579 | * icon on top of the black front scrim. |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 580 | * @param wakeAndUnlock are we wake and unlocking |
| 581 | * @param isUnlock are we currently unlocking |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 582 | */ |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 583 | public void onBiometricAuthModeChanged(boolean wakeAndUnlock, boolean isUnlock) { |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 584 | if (wakeAndUnlock) { |
| 585 | mWakeAndUnlockRunning = true; |
| 586 | } |
Selim Cinek | 390f1b9 | 2019-06-28 18:07:28 -0700 | [diff] [blame] | 587 | if (isUnlock && mBypassController.getBypassEnabled() && canBlockUpdates()) { |
| 588 | // We don't want the icon to change while we are unlocking |
| 589 | mBlockUpdates = true; |
| 590 | } |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 591 | update(); |
| 592 | } |
| 593 | |
| 594 | /** |
Lucas Dupin | 23964c7 | 2019-05-21 16:12:45 -0700 | [diff] [blame] | 595 | * When we're launching an affordance, like double pressing power to open camera. |
| 596 | */ |
| 597 | public void onShowingLaunchAffordanceChanged(boolean showing) { |
| 598 | mShowingLaunchAffordance = showing; |
| 599 | update(); |
| 600 | } |
| 601 | |
| 602 | /** |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 603 | * Called whenever the scrims become opaque, transparent or semi-transparent. |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 604 | */ |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 605 | public void onScrimVisibilityChanged(@ScrimVisibility int scrimsVisible) { |
| 606 | if (mWakeAndUnlockRunning |
Lyn Han | bde4820 | 2019-05-29 19:18:29 -0700 | [diff] [blame] | 607 | && scrimsVisible == ScrimController.TRANSPARENT) { |
Lucas Dupin | cdbb1cb | 2019-05-16 19:48:30 -0700 | [diff] [blame] | 608 | mWakeAndUnlockRunning = false; |
| 609 | update(); |
| 610 | } |
Lucas Dupin | 71f3804 | 2019-05-10 16:23:04 -0700 | [diff] [blame] | 611 | } |
Jorim Jaggi | 27267d6 | 2015-04-28 13:27:12 -0700 | [diff] [blame] | 612 | } |