Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +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; |
| 18 | |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 19 | import static com.android.systemui.DejankUtils.whitelistIpcs; |
| 20 | |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 21 | import android.animation.Animator; |
| 22 | import android.animation.AnimatorListenerAdapter; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 23 | import android.app.admin.DevicePolicyManager; |
| 24 | import android.content.BroadcastReceiver; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 25 | import android.content.Context; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 26 | import android.content.Intent; |
| 27 | import android.content.IntentFilter; |
Jason Chang | 2386a37 | 2018-04-24 16:05:30 +0800 | [diff] [blame] | 28 | import android.content.res.ColorStateList; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 29 | import android.graphics.Color; |
Lucas Dupin | ff6628d | 2018-10-15 10:12:37 -0700 | [diff] [blame] | 30 | import android.hardware.biometrics.BiometricSourceType; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 31 | import android.hardware.face.FaceManager; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 32 | import android.hardware.fingerprint.FingerprintManager; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 33 | import android.os.BatteryManager; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 34 | import android.os.Handler; |
| 35 | import android.os.Message; |
| 36 | import android.os.RemoteException; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 37 | import android.text.TextUtils; |
| 38 | import android.text.format.Formatter; |
| 39 | import android.util.Log; |
| 40 | import android.view.View; |
Bartosz Fabianowski | 5f04500 | 2016-12-01 10:36:18 +0100 | [diff] [blame] | 41 | import android.view.ViewGroup; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 42 | |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 43 | import com.android.internal.annotations.VisibleForTesting; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 44 | import com.android.internal.app.IBatteryStats; |
Lucas Dupin | eff8ef0 | 2019-06-06 11:14:01 -0700 | [diff] [blame] | 45 | import com.android.internal.widget.ViewClippingUtil; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 46 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 47 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jason Monk | 58be7a6 | 2017-02-01 20:17:51 -0500 | [diff] [blame] | 48 | import com.android.settingslib.Utils; |
Raff Tsai | f4ea562 | 2019-06-26 16:15:21 +0800 | [diff] [blame] | 49 | import com.android.settingslib.fuelgauge.BatteryStatus; |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 50 | import com.android.systemui.Interpolators; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 51 | import com.android.systemui.R; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 52 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 53 | import com.android.systemui.dock.DockManager; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 54 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
| 55 | import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 56 | import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 57 | import com.android.systemui.statusbar.phone.LockscreenLockIconController; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 58 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 59 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 60 | import com.android.systemui.util.wakelock.SettableWakeLock; |
| 61 | import com.android.systemui.util.wakelock.WakeLock; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 62 | |
Lucas Dupin | 3fcdd47 | 2018-01-19 19:06:45 -0800 | [diff] [blame] | 63 | import java.io.FileDescriptor; |
| 64 | import java.io.PrintWriter; |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 65 | import java.text.NumberFormat; |
Lucas Dupin | 8d595d2 | 2018-03-08 10:34:58 -0800 | [diff] [blame] | 66 | import java.util.IllegalFormatConversionException; |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 67 | |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 68 | import javax.inject.Inject; |
| 69 | import javax.inject.Singleton; |
| 70 | |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 71 | /** |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 72 | * Controls the indications and error messages shown on the Keyguard |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 73 | */ |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 74 | @Singleton |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 75 | public class KeyguardIndicationController implements StateListener, |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 76 | KeyguardStateController.Callback { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 77 | |
Adrian Roos | 0c859ae | 2015-11-23 16:47:50 -0800 | [diff] [blame] | 78 | private static final String TAG = "KeyguardIndication"; |
| 79 | private static final boolean DEBUG_CHARGING_SPEED = false; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 80 | |
| 81 | private static final int MSG_HIDE_TRANSIENT = 1; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 82 | private static final int MSG_CLEAR_BIOMETRIC_MSG = 2; |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 83 | private static final int MSG_SWIPE_UP_TO_UNLOCK = 3; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 84 | private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300; |
Robert Snoeberger | ddfb065 | 2019-06-21 16:41:46 -0400 | [diff] [blame] | 85 | private static final float BOUNCE_ANIMATION_FINAL_Y = 0f; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 86 | |
| 87 | private final Context mContext; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 88 | private final BroadcastDispatcher mBroadcastDispatcher; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 89 | private final KeyguardStateController mKeyguardStateController; |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 90 | private final StatusBarStateController mStatusBarStateController; |
| 91 | private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 92 | private ViewGroup mIndicationArea; |
| 93 | private KeyguardIndicationTextView mTextView; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 94 | private KeyguardIndicationTextView mDisclosure; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 95 | private final IBatteryStats mBatteryInfo; |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 96 | private final SettableWakeLock mWakeLock; |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 97 | private final DockManager mDockManager; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 98 | private final DevicePolicyManager mDevicePolicyManager; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 99 | |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 100 | private BroadcastReceiver mBroadcastReceiver; |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 101 | private LockscreenLockIconController mLockIconController; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 102 | private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 103 | |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 104 | private String mRestingIndication; |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 105 | private String mAlignmentIndication; |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 106 | private CharSequence mTransientIndication; |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 107 | private boolean mTransientTextIsError; |
Jason Chang | 2386a37 | 2018-04-24 16:05:30 +0800 | [diff] [blame] | 108 | private ColorStateList mInitialTextColorState; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 109 | private boolean mVisible; |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 110 | private boolean mHideTransientMessageOnScreenOff; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 111 | |
| 112 | private boolean mPowerPluggedIn; |
Beverly | 2034c83 | 2018-03-19 11:18:51 -0400 | [diff] [blame] | 113 | private boolean mPowerPluggedInWired; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 114 | private boolean mPowerCharged; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 115 | private int mChargingSpeed; |
Adrian Roos | 0c859ae | 2015-11-23 16:47:50 -0800 | [diff] [blame] | 116 | private int mChargingWattage; |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 117 | private int mBatteryLevel; |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 118 | private long mChargingTimeRemaining; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 119 | private float mDisclosureMaxAlpha; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 120 | private String mMessageToShowOnScreenOn; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 121 | |
Zachary Iqbal | 8f4c242 | 2017-04-20 17:56:42 -0700 | [diff] [blame] | 122 | private KeyguardUpdateMonitorCallback mUpdateMonitorCallback; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 123 | |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 124 | private boolean mDozing; |
Lucas Dupin | eff8ef0 | 2019-06-06 11:14:01 -0700 | [diff] [blame] | 125 | private final ViewClippingUtil.ClippingParameters mClippingParams = |
| 126 | new ViewClippingUtil.ClippingParameters() { |
| 127 | @Override |
| 128 | public boolean shouldFinish(View view) { |
| 129 | return view == mIndicationArea; |
| 130 | } |
| 131 | }; |
Bartosz Fabianowski | 5f04500 | 2016-12-01 10:36:18 +0100 | [diff] [blame] | 132 | |
Adrian Roos | af45b60 | 2017-03-14 13:10:25 -0700 | [diff] [blame] | 133 | /** |
| 134 | * Creates a new KeyguardIndicationController and registers callbacks. |
| 135 | */ |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 136 | @Inject |
| 137 | KeyguardIndicationController(Context context, |
| 138 | WakeLock.Builder wakeLockBuilder, |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 139 | KeyguardStateController keyguardStateController, |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 140 | StatusBarStateController statusBarStateController, |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 141 | KeyguardUpdateMonitor keyguardUpdateMonitor, |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 142 | DockManager dockManager, |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 143 | BroadcastDispatcher broadcastDispatcher, |
| 144 | DevicePolicyManager devicePolicyManager, |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 145 | IBatteryStats iBatteryStats) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 146 | mContext = context; |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 147 | mBroadcastDispatcher = broadcastDispatcher; |
| 148 | mDevicePolicyManager = devicePolicyManager; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 149 | mKeyguardStateController = keyguardStateController; |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 150 | mStatusBarStateController = statusBarStateController; |
| 151 | mKeyguardUpdateMonitor = keyguardUpdateMonitor; |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 152 | mDockManager = dockManager; |
Wilson Wu | 0e72713 | 2019-12-26 16:17:56 +0800 | [diff] [blame] | 153 | mDockManager.addAlignmentStateListener( |
| 154 | alignState -> mHandler.post(() -> handleAlignStateChanged(alignState))); |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 155 | mWakeLock = new SettableWakeLock( |
| 156 | wakeLockBuilder.setTag("Doze:KeyguardIndication").build(), TAG); |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 157 | mBatteryInfo = iBatteryStats; |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 158 | |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 159 | mKeyguardUpdateMonitor.registerCallback(getKeyguardCallback()); |
| 160 | mKeyguardUpdateMonitor.registerCallback(mTickReceiver); |
| 161 | mStatusBarStateController.addCallback(this); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 162 | mKeyguardStateController.addCallback(this); |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 163 | } |
| 164 | |
Lucas Dupin | 00ebe13 | 2019-04-26 16:17:56 -0700 | [diff] [blame] | 165 | public void setIndicationArea(ViewGroup indicationArea) { |
| 166 | mIndicationArea = indicationArea; |
| 167 | mTextView = indicationArea.findViewById(R.id.keyguard_indication_text); |
| 168 | mInitialTextColorState = mTextView != null ? |
| 169 | mTextView.getTextColors() : ColorStateList.valueOf(Color.WHITE); |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 170 | mDisclosure = indicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure); |
| 171 | mDisclosureMaxAlpha = mDisclosure.getAlpha(); |
Lucas Dupin | 00ebe13 | 2019-04-26 16:17:56 -0700 | [diff] [blame] | 172 | updateIndication(false /* animate */); |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 173 | updateDisclosure(); |
| 174 | |
| 175 | if (mBroadcastReceiver == null) { |
| 176 | // Update the disclosure proactively to avoid IPC on the critical path. |
| 177 | mBroadcastReceiver = new BroadcastReceiver() { |
| 178 | @Override |
| 179 | public void onReceive(Context context, Intent intent) { |
| 180 | updateDisclosure(); |
| 181 | } |
| 182 | }; |
| 183 | mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, new IntentFilter( |
| 184 | DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED)); |
| 185 | } |
Bartosz Fabianowski | 5f04500 | 2016-12-01 10:36:18 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 188 | public void setLockIconController(LockscreenLockIconController lockIconController) { |
| 189 | mLockIconController = lockIconController; |
Lucas Dupin | 0df60fe | 2019-04-23 10:19:27 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 192 | private void handleAlignStateChanged(int alignState) { |
| 193 | String alignmentIndication = ""; |
| 194 | if (alignState == DockManager.ALIGN_STATE_POOR) { |
| 195 | alignmentIndication = |
| 196 | mContext.getResources().getString(R.string.dock_alignment_slow_charging); |
| 197 | } else if (alignState == DockManager.ALIGN_STATE_TERRIBLE) { |
| 198 | alignmentIndication = |
| 199 | mContext.getResources().getString(R.string.dock_alignment_not_charging); |
| 200 | } |
| 201 | if (!alignmentIndication.equals(mAlignmentIndication)) { |
| 202 | mAlignmentIndication = alignmentIndication; |
| 203 | updateIndication(false); |
| 204 | } |
| 205 | } |
| 206 | |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 207 | /** |
| 208 | * Gets the {@link KeyguardUpdateMonitorCallback} instance associated with this |
| 209 | * {@link KeyguardIndicationController}. |
| 210 | * |
| 211 | * <p>Subclasses may override this method to extend or change the callback behavior by extending |
| 212 | * the {@link BaseKeyguardCallback}. |
| 213 | * |
| 214 | * @return A KeyguardUpdateMonitorCallback. Multiple calls to this method <b>must</b> return the |
| 215 | * same instance. |
| 216 | */ |
| 217 | protected KeyguardUpdateMonitorCallback getKeyguardCallback() { |
Zachary Iqbal | 8f4c242 | 2017-04-20 17:56:42 -0700 | [diff] [blame] | 218 | if (mUpdateMonitorCallback == null) { |
| 219 | mUpdateMonitorCallback = new BaseKeyguardCallback(); |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 220 | } |
Zachary Iqbal | 8f4c242 | 2017-04-20 17:56:42 -0700 | [diff] [blame] | 221 | return mUpdateMonitorCallback; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 224 | private void updateDisclosure() { |
| 225 | // NOTE: Because this uses IPC, avoid calling updateDisclosure() on a critical path. |
| 226 | if (whitelistIpcs(mDevicePolicyManager::isDeviceManaged)) { |
| 227 | final CharSequence organizationName = |
| 228 | mDevicePolicyManager.getDeviceOwnerOrganizationName(); |
| 229 | if (organizationName != null) { |
| 230 | mDisclosure.switchIndication(mContext.getResources().getString( |
| 231 | R.string.do_disclosure_with_name, organizationName)); |
| 232 | } else { |
| 233 | mDisclosure.switchIndication(R.string.do_disclosure_generic); |
| 234 | } |
| 235 | mDisclosure.setVisibility(View.VISIBLE); |
| 236 | } else { |
| 237 | mDisclosure.setVisibility(View.GONE); |
| 238 | } |
| 239 | } |
| 240 | |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 241 | public void setVisible(boolean visible) { |
| 242 | mVisible = visible; |
Bartosz Fabianowski | 5f04500 | 2016-12-01 10:36:18 +0100 | [diff] [blame] | 243 | mIndicationArea.setVisibility(visible ? View.VISIBLE : View.GONE); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 244 | if (visible) { |
Kevin Chyn | 4c4001c | 2017-08-25 14:23:36 -0700 | [diff] [blame] | 245 | // If this is called after an error message was already shown, we should not clear it. |
| 246 | // Otherwise the error message won't be shown |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 247 | if (!mHandler.hasMessages(MSG_HIDE_TRANSIENT)) { |
Kevin Chyn | 4c4001c | 2017-08-25 14:23:36 -0700 | [diff] [blame] | 248 | hideTransientIndication(); |
| 249 | } |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 250 | updateIndication(false); |
Kevin Chyn | 4c4001c | 2017-08-25 14:23:36 -0700 | [diff] [blame] | 251 | } else if (!visible) { |
| 252 | // If we unlock and return to keyguard quickly, previous error should not be shown |
| 253 | hideTransientIndication(); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Sets the indication that is shown if nothing else is showing. |
| 259 | */ |
| 260 | public void setRestingIndication(String restingIndication) { |
| 261 | mRestingIndication = restingIndication; |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 262 | updateIndication(false); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | /** |
Zachary Iqbal | 8f4c242 | 2017-04-20 17:56:42 -0700 | [diff] [blame] | 266 | * Returns the indication text indicating that trust has been granted. |
| 267 | * |
| 268 | * @return {@code null} or an empty string if a trust indication text should not be shown. |
| 269 | */ |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 270 | @VisibleForTesting |
| 271 | String getTrustGrantedIndication() { |
Lucas Dupin | 859f2c8 | 2019-04-17 18:30:00 -0700 | [diff] [blame] | 272 | return mContext.getString(R.string.keyguard_indication_trust_unlocked); |
Zachary Iqbal | dc05aa0 | 2017-05-17 18:52:49 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | /** |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 276 | * Sets if the device is plugged in |
| 277 | */ |
| 278 | @VisibleForTesting |
| 279 | void setPowerPluggedIn(boolean plugged) { |
| 280 | mPowerPluggedIn = plugged; |
| 281 | } |
| 282 | |
| 283 | /** |
Zachary Iqbal | dc05aa0 | 2017-05-17 18:52:49 -0700 | [diff] [blame] | 284 | * Returns the indication text indicating that trust is currently being managed. |
| 285 | * |
| 286 | * @return {@code null} or an empty string if a trust managed text should not be shown. |
| 287 | */ |
Lucas Dupin | 859f2c8 | 2019-04-17 18:30:00 -0700 | [diff] [blame] | 288 | private String getTrustManagedIndication() { |
Zachary Iqbal | 8f4c242 | 2017-04-20 17:56:42 -0700 | [diff] [blame] | 289 | return null; |
| 290 | } |
| 291 | |
| 292 | /** |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 293 | * Hides transient indication in {@param delayMs}. |
| 294 | */ |
| 295 | public void hideTransientIndicationDelayed(long delayMs) { |
| 296 | mHandler.sendMessageDelayed( |
| 297 | mHandler.obtainMessage(MSG_HIDE_TRANSIENT), delayMs); |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Shows {@param transientIndication} until it is hidden by {@link #hideTransientIndication}. |
| 302 | */ |
| 303 | public void showTransientIndication(int transientIndication) { |
| 304 | showTransientIndication(mContext.getResources().getString(transientIndication)); |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Shows {@param transientIndication} until it is hidden by {@link #hideTransientIndication}. |
| 309 | */ |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 310 | public void showTransientIndication(CharSequence transientIndication) { |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 311 | showTransientIndication(transientIndication, false /* isError */, |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 312 | false /* hideOnScreenOff */); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Shows {@param transientIndication} until it is hidden by {@link #hideTransientIndication}. |
| 317 | */ |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 318 | private void showTransientIndication(CharSequence transientIndication, |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 319 | boolean isError, boolean hideOnScreenOff) { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 320 | mTransientIndication = transientIndication; |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 321 | mHideTransientMessageOnScreenOff = hideOnScreenOff && transientIndication != null; |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 322 | mTransientTextIsError = isError; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 323 | mHandler.removeMessages(MSG_HIDE_TRANSIENT); |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 324 | mHandler.removeMessages(MSG_SWIPE_UP_TO_UNLOCK); |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 325 | if (mDozing && !TextUtils.isEmpty(mTransientIndication)) { |
| 326 | // Make sure this doesn't get stuck and burns in. Acquire wakelock until its cleared. |
| 327 | mWakeLock.setAcquired(true); |
| 328 | hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS); |
| 329 | } |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 330 | |
| 331 | updateIndication(false); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Hides transient indication. |
| 336 | */ |
| 337 | public void hideTransientIndication() { |
| 338 | if (mTransientIndication != null) { |
| 339 | mTransientIndication = null; |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 340 | mHideTransientMessageOnScreenOff = false; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 341 | mHandler.removeMessages(MSG_HIDE_TRANSIENT); |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 342 | updateIndication(false); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 346 | protected final void updateIndication(boolean animate) { |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 347 | if (TextUtils.isEmpty(mTransientIndication)) { |
| 348 | mWakeLock.setAcquired(false); |
| 349 | } |
| 350 | |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 351 | if (mVisible) { |
Lucas Dupin | 53d5062 | 2017-05-13 15:54:14 -0700 | [diff] [blame] | 352 | // Walk down a precedence-ordered list of what indication |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 353 | // should be shown based on user or device state |
Lucas Dupin | ff6628d | 2018-10-15 10:12:37 -0700 | [diff] [blame] | 354 | if (mDozing) { |
Lucas Dupin | 07ed3df | 2019-03-26 21:23:59 -0700 | [diff] [blame] | 355 | // When dozing we ignore any text color and use white instead, because |
| 356 | // colors can be hard to read in low brightness. |
| 357 | mTextView.setTextColor(Color.WHITE); |
Lucas Dupin | ff6628d | 2018-10-15 10:12:37 -0700 | [diff] [blame] | 358 | if (!TextUtils.isEmpty(mTransientIndication)) { |
Lucas Dupin | ff6628d | 2018-10-15 10:12:37 -0700 | [diff] [blame] | 359 | mTextView.switchIndication(mTransientIndication); |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 360 | } else if (!TextUtils.isEmpty(mAlignmentIndication)) { |
| 361 | mTextView.switchIndication(mAlignmentIndication); |
Wilson Wu | bb51d09 | 2020-04-21 16:00:59 +0800 | [diff] [blame] | 362 | mTextView.setTextColor(mContext.getColor(R.color.misalignment_text_color)); |
Lucas Dupin | 07ed3df | 2019-03-26 21:23:59 -0700 | [diff] [blame] | 363 | } else if (mPowerPluggedIn) { |
| 364 | String indication = computePowerIndication(); |
| 365 | if (animate) { |
| 366 | animateText(mTextView, indication); |
| 367 | } else { |
| 368 | mTextView.switchIndication(indication); |
| 369 | } |
| 370 | } else { |
| 371 | String percentage = NumberFormat.getPercentInstance() |
| 372 | .format(mBatteryLevel / 100f); |
| 373 | mTextView.switchIndication(percentage); |
Lucas Dupin | ff6628d | 2018-10-15 10:12:37 -0700 | [diff] [blame] | 374 | } |
Lucas Dupin | ff6628d | 2018-10-15 10:12:37 -0700 | [diff] [blame] | 375 | return; |
| 376 | } |
| 377 | |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 378 | int userId = KeyguardUpdateMonitor.getCurrentUser(); |
Zachary Iqbal | dc05aa0 | 2017-05-17 18:52:49 -0700 | [diff] [blame] | 379 | String trustGrantedIndication = getTrustGrantedIndication(); |
| 380 | String trustManagedIndication = getTrustManagedIndication(); |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 381 | |
| 382 | String powerIndication = null; |
| 383 | if (mPowerPluggedIn) { |
| 384 | powerIndication = computePowerIndication(); |
| 385 | } |
| 386 | |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 387 | boolean isError = false; |
Lucas Dupin | 6c6d573 | 2019-08-27 17:36:05 -0700 | [diff] [blame] | 388 | if (!mKeyguardUpdateMonitor.isUserUnlocked(userId)) { |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 389 | mTextView.switchIndication(com.android.internal.R.string.lockscreen_storage_locked); |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 390 | } else if (!TextUtils.isEmpty(mTransientIndication)) { |
Lucas Dupin | d9af631 | 2020-03-23 17:30:15 -0700 | [diff] [blame] | 391 | if (powerIndication != null && !mTransientIndication.equals(powerIndication)) { |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 392 | String indication = mContext.getResources().getString( |
| 393 | R.string.keyguard_indication_trust_unlocked_plugged_in, |
| 394 | mTransientIndication, powerIndication); |
| 395 | mTextView.switchIndication(indication); |
| 396 | } else { |
| 397 | mTextView.switchIndication(mTransientIndication); |
| 398 | } |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 399 | isError = mTransientTextIsError; |
Zachary Iqbal | dc05aa0 | 2017-05-17 18:52:49 -0700 | [diff] [blame] | 400 | } else if (!TextUtils.isEmpty(trustGrantedIndication) |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 401 | && mKeyguardUpdateMonitor.getUserHasTrust(userId)) { |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 402 | if (powerIndication != null) { |
| 403 | String indication = mContext.getResources().getString( |
| 404 | R.string.keyguard_indication_trust_unlocked_plugged_in, |
| 405 | trustGrantedIndication, powerIndication); |
| 406 | mTextView.switchIndication(indication); |
| 407 | } else { |
| 408 | mTextView.switchIndication(trustGrantedIndication); |
| 409 | } |
Jerry Chang | 6a8fb02 | 2019-11-15 06:52:54 +0800 | [diff] [blame] | 410 | } else if (!TextUtils.isEmpty(mAlignmentIndication)) { |
| 411 | mTextView.switchIndication(mAlignmentIndication); |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 412 | isError = true; |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 413 | } else if (mPowerPluggedIn) { |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 414 | if (DEBUG_CHARGING_SPEED) { |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 415 | powerIndication += ", " + (mChargingWattage / 1000) + " mW"; |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 416 | } |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 417 | if (animate) { |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 418 | animateText(mTextView, powerIndication); |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 419 | } else { |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 420 | mTextView.switchIndication(powerIndication); |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 421 | } |
Zachary Iqbal | dc05aa0 | 2017-05-17 18:52:49 -0700 | [diff] [blame] | 422 | } else if (!TextUtils.isEmpty(trustManagedIndication) |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 423 | && mKeyguardUpdateMonitor.getUserTrustIsManaged(userId) |
| 424 | && !mKeyguardUpdateMonitor.getUserHasTrust(userId)) { |
Zachary Iqbal | dc05aa0 | 2017-05-17 18:52:49 -0700 | [diff] [blame] | 425 | mTextView.switchIndication(trustManagedIndication); |
Jeff Sharkey | b6edaa9 | 2016-07-27 15:51:31 -0600 | [diff] [blame] | 426 | } else { |
| 427 | mTextView.switchIndication(mRestingIndication); |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 428 | } |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 429 | mTextView.setTextColor(isError ? Utils.getColorError(mContext) |
| 430 | : mInitialTextColorState); |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 431 | } |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 432 | } |
| 433 | |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 434 | // animates textView - textView moves up and bounces down |
| 435 | private void animateText(KeyguardIndicationTextView textView, String indication) { |
| 436 | int yTranslation = mContext.getResources().getInteger( |
| 437 | R.integer.wired_charging_keyguard_text_animation_distance); |
| 438 | int animateUpDuration = mContext.getResources().getInteger( |
| 439 | R.integer.wired_charging_keyguard_text_animation_duration_up); |
| 440 | int animateDownDuration = mContext.getResources().getInteger( |
| 441 | R.integer.wired_charging_keyguard_text_animation_duration_down); |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 442 | textView.animate().cancel(); |
Lucas Dupin | eff8ef0 | 2019-06-06 11:14:01 -0700 | [diff] [blame] | 443 | ViewClippingUtil.setClippingDeactivated(textView, true, mClippingParams); |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 444 | textView.animate() |
| 445 | .translationYBy(yTranslation) |
| 446 | .setInterpolator(Interpolators.LINEAR) |
| 447 | .setDuration(animateUpDuration) |
| 448 | .setListener(new AnimatorListenerAdapter() { |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 449 | private boolean mCancelled; |
| 450 | |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 451 | @Override |
| 452 | public void onAnimationStart(Animator animation) { |
| 453 | textView.switchIndication(indication); |
| 454 | } |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 455 | |
| 456 | @Override |
| 457 | public void onAnimationCancel(Animator animation) { |
Robert Snoeberger | ddfb065 | 2019-06-21 16:41:46 -0400 | [diff] [blame] | 458 | textView.setTranslationY(BOUNCE_ANIMATION_FINAL_Y); |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 459 | mCancelled = true; |
| 460 | } |
| 461 | |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 462 | @Override |
| 463 | public void onAnimationEnd(Animator animation) { |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 464 | if (mCancelled) { |
Lucas Dupin | eff8ef0 | 2019-06-06 11:14:01 -0700 | [diff] [blame] | 465 | ViewClippingUtil.setClippingDeactivated(textView, false, |
| 466 | mClippingParams); |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 467 | return; |
| 468 | } |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 469 | textView.animate() |
| 470 | .setDuration(animateDownDuration) |
| 471 | .setInterpolator(Interpolators.BOUNCE) |
Robert Snoeberger | ddfb065 | 2019-06-21 16:41:46 -0400 | [diff] [blame] | 472 | .translationY(BOUNCE_ANIMATION_FINAL_Y) |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 473 | .setListener(new AnimatorListenerAdapter() { |
| 474 | @Override |
Lucas Dupin | eff8ef0 | 2019-06-06 11:14:01 -0700 | [diff] [blame] | 475 | public void onAnimationEnd(Animator animation) { |
Robert Snoeberger | ddfb065 | 2019-06-21 16:41:46 -0400 | [diff] [blame] | 476 | textView.setTranslationY(BOUNCE_ANIMATION_FINAL_Y); |
Lucas Dupin | eff8ef0 | 2019-06-06 11:14:01 -0700 | [diff] [blame] | 477 | ViewClippingUtil.setClippingDeactivated(textView, false, |
| 478 | mClippingParams); |
| 479 | } |
Lucas Dupin | def4369 | 2018-07-02 15:22:58 -0700 | [diff] [blame] | 480 | }); |
Beverly | 85499d9 | 2018-02-14 15:55:16 -0500 | [diff] [blame] | 481 | } |
| 482 | }); |
| 483 | } |
| 484 | |
Scott Warner | 778db33 | 2020-01-21 09:45:56 -0500 | [diff] [blame] | 485 | @VisibleForTesting |
| 486 | String computePowerIndication() { |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 487 | if (mPowerCharged) { |
| 488 | return mContext.getResources().getString(R.string.keyguard_charged); |
| 489 | } |
| 490 | |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 491 | final boolean hasChargingTime = mChargingTimeRemaining > 0; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 492 | int chargingId; |
Beverly | 7d7f699 | 2019-02-11 13:58:27 -0500 | [diff] [blame] | 493 | if (mPowerPluggedInWired) { |
| 494 | switch (mChargingSpeed) { |
Raff Tsai | f4ea562 | 2019-06-26 16:15:21 +0800 | [diff] [blame] | 495 | case BatteryStatus.CHARGING_FAST: |
Beverly | 7d7f699 | 2019-02-11 13:58:27 -0500 | [diff] [blame] | 496 | chargingId = hasChargingTime |
| 497 | ? R.string.keyguard_indication_charging_time_fast |
| 498 | : R.string.keyguard_plugged_in_charging_fast; |
| 499 | break; |
Raff Tsai | f4ea562 | 2019-06-26 16:15:21 +0800 | [diff] [blame] | 500 | case BatteryStatus.CHARGING_SLOWLY: |
Beverly | 7d7f699 | 2019-02-11 13:58:27 -0500 | [diff] [blame] | 501 | chargingId = hasChargingTime |
| 502 | ? R.string.keyguard_indication_charging_time_slowly |
| 503 | : R.string.keyguard_plugged_in_charging_slowly; |
| 504 | break; |
| 505 | default: |
| 506 | chargingId = hasChargingTime |
| 507 | ? R.string.keyguard_indication_charging_time |
| 508 | : R.string.keyguard_plugged_in; |
| 509 | break; |
| 510 | } |
| 511 | } else { |
| 512 | chargingId = hasChargingTime |
| 513 | ? R.string.keyguard_indication_charging_time_wireless |
| 514 | : R.string.keyguard_plugged_in_wireless; |
Adrian Roos | 7b04311 | 2015-07-10 13:00:33 -0700 | [diff] [blame] | 515 | } |
Adrian Roos | 7e39e59 | 2015-09-23 17:03:47 -0700 | [diff] [blame] | 516 | |
Lucas Dupin | 8d595d2 | 2018-03-08 10:34:58 -0800 | [diff] [blame] | 517 | String percentage = NumberFormat.getPercentInstance() |
| 518 | .format(mBatteryLevel / 100f); |
Adrian Roos | 7e39e59 | 2015-09-23 17:03:47 -0700 | [diff] [blame] | 519 | if (hasChargingTime) { |
Lucas Dupin | 8d595d2 | 2018-03-08 10:34:58 -0800 | [diff] [blame] | 520 | // We now have battery percentage in these strings and it's expected that all |
| 521 | // locales will also have it in the future. For now, we still have to support the old |
| 522 | // format until all languages get the new translations. |
Adrian Roos | 7e39e59 | 2015-09-23 17:03:47 -0700 | [diff] [blame] | 523 | String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes( |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 524 | mContext, mChargingTimeRemaining); |
Lucas Dupin | 8d595d2 | 2018-03-08 10:34:58 -0800 | [diff] [blame] | 525 | try { |
| 526 | return mContext.getResources().getString(chargingId, chargingTimeFormatted, |
| 527 | percentage); |
| 528 | } catch (IllegalFormatConversionException e) { |
| 529 | return mContext.getResources().getString(chargingId, chargingTimeFormatted); |
| 530 | } |
Adrian Roos | 7e39e59 | 2015-09-23 17:03:47 -0700 | [diff] [blame] | 531 | } else { |
Lucas Dupin | 8d595d2 | 2018-03-08 10:34:58 -0800 | [diff] [blame] | 532 | // Same as above |
| 533 | try { |
| 534 | return mContext.getResources().getString(chargingId, percentage); |
| 535 | } catch (IllegalFormatConversionException e) { |
| 536 | return mContext.getResources().getString(chargingId); |
| 537 | } |
Adrian Roos | 7e39e59 | 2015-09-23 17:03:47 -0700 | [diff] [blame] | 538 | } |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 539 | } |
| 540 | |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 541 | public void setStatusBarKeyguardViewManager( |
| 542 | StatusBarKeyguardViewManager statusBarKeyguardViewManager) { |
| 543 | mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; |
| 544 | } |
| 545 | |
Lucas Dupin | 7e171e2 | 2018-12-20 11:29:35 -0800 | [diff] [blame] | 546 | private final KeyguardUpdateMonitorCallback mTickReceiver = |
| 547 | new KeyguardUpdateMonitorCallback() { |
| 548 | @Override |
| 549 | public void onTimeChanged() { |
| 550 | if (mVisible) { |
| 551 | updateIndication(false /* animate */); |
| 552 | } |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 553 | } |
Lucas Dupin | 7e171e2 | 2018-12-20 11:29:35 -0800 | [diff] [blame] | 554 | }; |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 555 | |
| 556 | private final Handler mHandler = new Handler() { |
| 557 | @Override |
| 558 | public void handleMessage(Message msg) { |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 559 | if (msg.what == MSG_HIDE_TRANSIENT) { |
| 560 | hideTransientIndication(); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 561 | } else if (msg.what == MSG_CLEAR_BIOMETRIC_MSG) { |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 562 | if (mLockIconController != null) { |
| 563 | mLockIconController.setTransientBiometricsError(false); |
| 564 | } |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 565 | } else if (msg.what == MSG_SWIPE_UP_TO_UNLOCK) { |
| 566 | showSwipeUpToUnlock(); |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | }; |
| 570 | |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 571 | private void showSwipeUpToUnlock() { |
| 572 | if (mDozing) { |
| 573 | return; |
| 574 | } |
| 575 | |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 576 | if (mStatusBarKeyguardViewManager.isBouncerShowing()) { |
Lucas Dupin | adce353 | 2019-08-02 11:17:39 -0700 | [diff] [blame] | 577 | String message = mContext.getString(R.string.keyguard_retry); |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 578 | mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState); |
| 579 | } else if (mKeyguardUpdateMonitor.isScreenOn()) { |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 580 | showTransientIndication(mContext.getString(R.string.keyguard_unlock), |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 581 | false /* isError */, true /* hideOnScreenOff */); |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 582 | hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS); |
| 583 | } |
| 584 | } |
| 585 | |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 586 | public void setDozing(boolean dozing) { |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 587 | if (mDozing == dozing) { |
| 588 | return; |
| 589 | } |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 590 | mDozing = dozing; |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 591 | if (mHideTransientMessageOnScreenOff && mDozing) { |
| 592 | hideTransientIndication(); |
| 593 | } else { |
| 594 | updateIndication(false); |
| 595 | } |
Adrian Roos | 91ba307 | 2017-02-14 16:50:46 +0100 | [diff] [blame] | 596 | } |
| 597 | |
Lucas Dupin | 3fcdd47 | 2018-01-19 19:06:45 -0800 | [diff] [blame] | 598 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 599 | pw.println("KeyguardIndicationController:"); |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 600 | pw.println(" mTransientTextIsError: " + mTransientTextIsError); |
Jason Chang | 2386a37 | 2018-04-24 16:05:30 +0800 | [diff] [blame] | 601 | pw.println(" mInitialTextColorState: " + mInitialTextColorState); |
Beverly | 2034c83 | 2018-03-19 11:18:51 -0400 | [diff] [blame] | 602 | pw.println(" mPowerPluggedInWired: " + mPowerPluggedInWired); |
Lucas Dupin | 3fcdd47 | 2018-01-19 19:06:45 -0800 | [diff] [blame] | 603 | pw.println(" mPowerPluggedIn: " + mPowerPluggedIn); |
| 604 | pw.println(" mPowerCharged: " + mPowerCharged); |
| 605 | pw.println(" mChargingSpeed: " + mChargingSpeed); |
| 606 | pw.println(" mChargingWattage: " + mChargingWattage); |
| 607 | pw.println(" mMessageToShowOnScreenOn: " + mMessageToShowOnScreenOn); |
| 608 | pw.println(" mDozing: " + mDozing); |
| 609 | pw.println(" mBatteryLevel: " + mBatteryLevel); |
| 610 | pw.println(" mTextView.getText(): " + (mTextView == null ? null : mTextView.getText())); |
| 611 | pw.println(" computePowerIndication(): " + computePowerIndication()); |
| 612 | } |
| 613 | |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 614 | @Override |
| 615 | public void onStateChanged(int newState) { |
| 616 | // don't care |
| 617 | } |
| 618 | |
| 619 | @Override |
| 620 | public void onDozingChanged(boolean isDozing) { |
| 621 | setDozing(isDozing); |
| 622 | } |
| 623 | |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 624 | @Override |
Jeff DeCew | a87cddb | 2020-06-12 12:13:52 -0400 | [diff] [blame] | 625 | public void onDozeAmountChanged(float linear, float eased) { |
| 626 | mDisclosure.setAlpha((1 - linear) * mDisclosureMaxAlpha); |
| 627 | } |
| 628 | |
| 629 | @Override |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 630 | public void onUnlockedChanged() { |
Lucas Dupin | 8e2fd01 | 2019-04-25 16:40:54 -0700 | [diff] [blame] | 631 | updateIndication(!mDozing); |
| 632 | } |
| 633 | |
Zachary Iqbal | f50284c | 2017-01-22 18:54:46 -0800 | [diff] [blame] | 634 | protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback { |
Adrian Roos | 5602189 | 2017-02-27 20:25:09 +0100 | [diff] [blame] | 635 | public static final int HIDE_DELAY_MS = 5000; |
Selim Cinek | 3e45194 | 2016-07-14 18:07:53 -0700 | [diff] [blame] | 636 | |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 637 | @Override |
Raff Tsai | f4ea562 | 2019-06-26 16:15:21 +0800 | [diff] [blame] | 638 | public void onRefreshBatteryInfo(BatteryStatus status) { |
Adrian Roos | ad3bc7f | 2014-10-30 18:29:38 +0100 | [diff] [blame] | 639 | boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 640 | || status.status == BatteryManager.BATTERY_STATUS_FULL; |
Adrian Roos | 5602189 | 2017-02-27 20:25:09 +0100 | [diff] [blame] | 641 | boolean wasPluggedIn = mPowerPluggedIn; |
Beverly | 2034c83 | 2018-03-19 11:18:51 -0400 | [diff] [blame] | 642 | mPowerPluggedInWired = status.isPluggedInWired() && isChargingOrFull; |
Adrian Roos | ad3bc7f | 2014-10-30 18:29:38 +0100 | [diff] [blame] | 643 | mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull; |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 644 | mPowerCharged = status.isCharged(); |
Adrian Roos | 0c859ae | 2015-11-23 16:47:50 -0800 | [diff] [blame] | 645 | mChargingWattage = status.maxChargingWattage; |
Raff Tsai | f4ea562 | 2019-06-26 16:15:21 +0800 | [diff] [blame] | 646 | mChargingSpeed = status.getChargingSpeed(mContext); |
Lucas Dupin | 4272f44 | 2018-01-13 22:00:35 -0800 | [diff] [blame] | 647 | mBatteryLevel = status.level; |
Lucas Dupin | 9131b28 | 2019-11-19 16:25:03 -0800 | [diff] [blame] | 648 | try { |
| 649 | mChargingTimeRemaining = mPowerPluggedIn |
| 650 | ? mBatteryInfo.computeChargeTimeRemaining() : -1; |
| 651 | } catch (RemoteException e) { |
| 652 | Log.e(TAG, "Error calling IBatteryStats: ", e); |
| 653 | mChargingTimeRemaining = -1; |
| 654 | } |
Beverly | 2034c83 | 2018-03-19 11:18:51 -0400 | [diff] [blame] | 655 | updateIndication(!wasPluggedIn && mPowerPluggedInWired); |
Adrian Roos | c1b5032 | 2017-02-27 21:07:58 +0100 | [diff] [blame] | 656 | if (mDozing) { |
| 657 | if (!wasPluggedIn && mPowerPluggedIn) { |
| 658 | showTransientIndication(computePowerIndication()); |
| 659 | hideTransientIndicationDelayed(HIDE_DELAY_MS); |
| 660 | } else if (wasPluggedIn && !mPowerPluggedIn) { |
| 661 | hideTransientIndication(); |
| 662 | } |
Adrian Roos | 5602189 | 2017-02-27 20:25:09 +0100 | [diff] [blame] | 663 | } |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 664 | } |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 665 | |
| 666 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 667 | public void onBiometricHelp(int msgId, String helpString, |
| 668 | BiometricSourceType biometricSourceType) { |
Haining Chen | c06c481 | 2020-01-13 20:38:53 -0800 | [diff] [blame] | 669 | // TODO(b/141025588): refactor to reduce repetition of code/comments |
| 670 | // Only checking if unlocking with Biometric is allowed (no matter strong or non-strong |
| 671 | // as long as primary auth, i.e. PIN/pattern/password, is not required), so it's ok to |
| 672 | // pass true for isStrongBiometric to isUnlockingWithBiometricAllowed() to bypass the |
| 673 | // check of whether non-strong biometric is allowed |
| 674 | if (!mKeyguardUpdateMonitor |
| 675 | .isUnlockingWithBiometricAllowed(true /* isStrongBiometric */)) { |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 676 | return; |
| 677 | } |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 678 | boolean showSwipeToUnlock = |
| 679 | msgId == KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 680 | if (mStatusBarKeyguardViewManager.isBouncerShowing()) { |
Jason Chang | 2386a37 | 2018-04-24 16:05:30 +0800 | [diff] [blame] | 681 | mStatusBarKeyguardViewManager.showBouncerMessage(helpString, |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 682 | mInitialTextColorState); |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 683 | } else if (mKeyguardUpdateMonitor.isScreenOn()) { |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 684 | showTransientIndication(helpString, false /* isError */, showSwipeToUnlock); |
Lucas Dupin | 51996bb | 2019-05-16 17:56:43 -0700 | [diff] [blame] | 685 | if (!showSwipeToUnlock) { |
| 686 | hideTransientIndicationDelayed(TRANSIENT_BIOMETRIC_ERROR_TIMEOUT); |
| 687 | } |
| 688 | } |
| 689 | if (showSwipeToUnlock) { |
| 690 | mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SWIPE_UP_TO_UNLOCK), |
| 691 | TRANSIENT_BIOMETRIC_ERROR_TIMEOUT); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 692 | } |
| 693 | } |
| 694 | |
| 695 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 696 | public void onBiometricError(int msgId, String errString, |
| 697 | BiometricSourceType biometricSourceType) { |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 698 | if (shouldSuppressBiometricError(msgId, biometricSourceType, mKeyguardUpdateMonitor)) { |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 699 | return; |
| 700 | } |
Lucas Dupin | e54ad1d | 2019-04-09 17:08:46 -0700 | [diff] [blame] | 701 | animatePadlockError(); |
Lucas Dupin | adce353 | 2019-08-02 11:17:39 -0700 | [diff] [blame] | 702 | if (msgId == FaceManager.FACE_ERROR_TIMEOUT) { |
| 703 | // The face timeout message is not very actionable, let's ask the user to |
| 704 | // manually retry. |
| 705 | showSwipeUpToUnlock(); |
| 706 | } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) { |
Lucas Dupin | e54ad1d | 2019-04-09 17:08:46 -0700 | [diff] [blame] | 707 | mStatusBarKeyguardViewManager.showBouncerMessage(errString, mInitialTextColorState); |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 708 | } else if (mKeyguardUpdateMonitor.isScreenOn()) { |
Lucas Dupin | c2d11b3 | 2019-03-06 16:02:18 -0800 | [diff] [blame] | 709 | showTransientIndication(errString); |
Selim Cinek | 3e45194 | 2016-07-14 18:07:53 -0700 | [diff] [blame] | 710 | // We want to keep this message around in case the screen was off |
Adrian Roos | 5602189 | 2017-02-27 20:25:09 +0100 | [diff] [blame] | 711 | hideTransientIndicationDelayed(HIDE_DELAY_MS); |
Selim Cinek | 3e45194 | 2016-07-14 18:07:53 -0700 | [diff] [blame] | 712 | } else { |
| 713 | mMessageToShowOnScreenOn = errString; |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 714 | } |
Lucas Dupin | e54ad1d | 2019-04-09 17:08:46 -0700 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | private void animatePadlockError() { |
Dave Mankoff | c0d9a7d | 2020-02-27 17:15:52 -0500 | [diff] [blame] | 718 | if (mLockIconController != null) { |
| 719 | mLockIconController.setTransientBiometricsError(true); |
| 720 | } |
Lucas Dupin | e54ad1d | 2019-04-09 17:08:46 -0700 | [diff] [blame] | 721 | mHandler.removeMessages(MSG_CLEAR_BIOMETRIC_MSG); |
| 722 | mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CLEAR_BIOMETRIC_MSG), |
| 723 | TRANSIENT_BIOMETRIC_ERROR_TIMEOUT); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 724 | } |
| 725 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 726 | private boolean shouldSuppressBiometricError(int msgId, |
| 727 | BiometricSourceType biometricSourceType, KeyguardUpdateMonitor updateMonitor) { |
| 728 | if (biometricSourceType == BiometricSourceType.FINGERPRINT) |
| 729 | return shouldSuppressFingerprintError(msgId, updateMonitor); |
| 730 | if (biometricSourceType == BiometricSourceType.FACE) |
| 731 | return shouldSuppressFaceError(msgId, updateMonitor); |
| 732 | return false; |
| 733 | } |
| 734 | |
| 735 | private boolean shouldSuppressFingerprintError(int msgId, |
| 736 | KeyguardUpdateMonitor updateMonitor) { |
Haining Chen | c06c481 | 2020-01-13 20:38:53 -0800 | [diff] [blame] | 737 | // Only checking if unlocking with Biometric is allowed (no matter strong or non-strong |
| 738 | // as long as primary auth, i.e. PIN/pattern/password, is not required), so it's ok to |
| 739 | // pass true for isStrongBiometric to isUnlockingWithBiometricAllowed() to bypass the |
| 740 | // check of whether non-strong biometric is allowed |
| 741 | return ((!updateMonitor.isUnlockingWithBiometricAllowed(true /* isStrongBiometric */) |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 742 | && msgId != FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT) |
| 743 | || msgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED); |
| 744 | } |
| 745 | |
| 746 | private boolean shouldSuppressFaceError(int msgId, KeyguardUpdateMonitor updateMonitor) { |
Haining Chen | c06c481 | 2020-01-13 20:38:53 -0800 | [diff] [blame] | 747 | // Only checking if unlocking with Biometric is allowed (no matter strong or non-strong |
| 748 | // as long as primary auth, i.e. PIN/pattern/password, is not required), so it's ok to |
| 749 | // pass true for isStrongBiometric to isUnlockingWithBiometricAllowed() to bypass the |
| 750 | // check of whether non-strong biometric is allowed |
| 751 | return ((!updateMonitor.isUnlockingWithBiometricAllowed(true /* isStrongBiometric */) |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 752 | && msgId != FaceManager.FACE_ERROR_LOCKOUT_PERMANENT) |
| 753 | || msgId == FaceManager.FACE_ERROR_CANCELED); |
| 754 | } |
| 755 | |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 756 | @Override |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 757 | public void onTrustAgentErrorMessage(CharSequence message) { |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 758 | showTransientIndication(message, true /* isError */, false /* hideOnScreenOff */); |
Lucas Dupin | ef88654 | 2018-01-03 16:03:07 -0800 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | @Override |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 762 | public void onScreenTurnedOn() { |
| 763 | if (mMessageToShowOnScreenOn != null) { |
Lucas Dupin | aff4236 | 2020-03-27 16:28:20 -0700 | [diff] [blame] | 764 | showTransientIndication(mMessageToShowOnScreenOn, true /* isError */, |
Lucas Dupin | 85ea420 | 2019-11-04 16:01:51 -0800 | [diff] [blame] | 765 | false /* hideOnScreenOff */); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 766 | // We want to keep this message around in case the screen was off |
Adrian Roos | 5602189 | 2017-02-27 20:25:09 +0100 | [diff] [blame] | 767 | hideTransientIndicationDelayed(HIDE_DELAY_MS); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 768 | mMessageToShowOnScreenOn = null; |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 773 | public void onBiometricRunningStateChanged(boolean running, |
| 774 | BiometricSourceType biometricSourceType) { |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 775 | if (running) { |
Lucas Dupin | 8f3faac | 2019-03-12 15:28:49 -0700 | [diff] [blame] | 776 | // Let's hide any previous messages when authentication starts, otherwise |
| 777 | // multiple auth attempts would overlap. |
| 778 | hideTransientIndication(); |
Selim Cinek | cfafe4e | 2015-08-11 14:58:44 -0700 | [diff] [blame] | 779 | mMessageToShowOnScreenOn = null; |
| 780 | } |
| 781 | } |
Selim Cinek | 3e45194 | 2016-07-14 18:07:53 -0700 | [diff] [blame] | 782 | |
| 783 | @Override |
Haining Chen | c06c481 | 2020-01-13 20:38:53 -0800 | [diff] [blame] | 784 | public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType, |
| 785 | boolean isStrongBiometric) { |
| 786 | super.onBiometricAuthenticated(userId, biometricSourceType, isStrongBiometric); |
Kevin Chyn | 6d793bd | 2019-03-27 15:36:13 -0700 | [diff] [blame] | 787 | mHandler.sendEmptyMessage(MSG_HIDE_TRANSIENT); |
Selim Cinek | 3e45194 | 2016-07-14 18:07:53 -0700 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | @Override |
Lucas Dupin | 6c6d573 | 2019-08-27 17:36:05 -0700 | [diff] [blame] | 791 | public void onUserSwitchComplete(int userId) { |
| 792 | if (mVisible) { |
| 793 | updateIndication(false); |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | @Override |
Jorim Jaggi | dadafd4 | 2016-09-30 07:20:25 -0700 | [diff] [blame] | 798 | public void onUserUnlocked() { |
| 799 | if (mVisible) { |
Beverly | 8c78589 | 2018-01-31 17:25:52 -0500 | [diff] [blame] | 800 | updateIndication(false); |
Jorim Jaggi | dadafd4 | 2016-09-30 07:20:25 -0700 | [diff] [blame] | 801 | } |
| 802 | } |
Lucas Dupin | 71d2fb2 | 2019-05-30 18:26:54 -0700 | [diff] [blame] | 803 | } |
Adrian Roos | 12c1ef5 | 2014-06-04 13:54:08 +0200 | [diff] [blame] | 804 | } |