Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import android.app.ActivityManagerNative; |
| 20 | import android.app.admin.DevicePolicyManager; |
| 21 | import android.content.BroadcastReceiver; |
| 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.content.IntentFilter; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 25 | import android.content.pm.PackageManager; |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 26 | import android.content.pm.ResolveInfo; |
Jorim Jaggi | e210cc8 | 2014-08-12 23:44:59 +0200 | [diff] [blame] | 27 | import android.content.res.Configuration; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 28 | import android.content.res.Resources; |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 29 | import android.graphics.drawable.Drawable; |
| 30 | import android.graphics.drawable.InsetDrawable; |
Jim Miller | fe6439f | 2015-04-11 18:07:57 -0700 | [diff] [blame] | 31 | import android.hardware.fingerprint.FingerprintManager; |
Yorke Lee | 583a2024 | 2014-08-12 18:47:08 -0700 | [diff] [blame] | 32 | import android.os.AsyncTask; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 33 | import android.os.Bundle; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 34 | import android.os.RemoteException; |
| 35 | import android.os.UserHandle; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 36 | import android.os.Vibrator; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 37 | import android.provider.MediaStore; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 38 | import android.provider.Settings; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 39 | import android.telecom.TelecomManager; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 40 | import android.util.AttributeSet; |
| 41 | import android.util.Log; |
Jorim Jaggi | e210cc8 | 2014-08-12 23:44:59 +0200 | [diff] [blame] | 42 | import android.util.TypedValue; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 43 | import android.view.View; |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 44 | import android.view.ViewGroup; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 45 | import android.view.accessibility.AccessibilityNodeInfo; |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 46 | import android.view.animation.AnimationUtils; |
| 47 | import android.view.animation.Interpolator; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 48 | import android.widget.FrameLayout; |
Jorim Jaggi | e210cc8 | 2014-08-12 23:44:59 +0200 | [diff] [blame] | 49 | import android.widget.TextView; |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 50 | |
| 51 | import com.android.internal.widget.LockPatternUtils; |
| 52 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 53 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 54 | import com.android.systemui.EventLogConstants; |
| 55 | import com.android.systemui.EventLogTags; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 56 | import com.android.systemui.R; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 57 | import com.android.systemui.statusbar.CommandQueue; |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 58 | import com.android.systemui.statusbar.KeyguardAffordanceView; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 59 | import com.android.systemui.statusbar.KeyguardIndicationController; |
| 60 | import com.android.systemui.statusbar.policy.AccessibilityController; |
| 61 | import com.android.systemui.statusbar.policy.FlashlightController; |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 62 | import com.android.systemui.statusbar.policy.PreviewInflater; |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 63 | |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 64 | import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; |
| 65 | import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; |
| 66 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 67 | /** |
| 68 | * Implementation for the bottom area of the Keyguard, including camera/phone affordance and status |
| 69 | * text. |
| 70 | */ |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 71 | public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickListener, |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 72 | UnlockMethodCache.OnUnlockMethodChangedListener, |
| 73 | AccessibilityController.AccessibilityStateChangedCallback, View.OnLongClickListener { |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 74 | |
| 75 | final static String TAG = "PhoneStatusBar/KeyguardBottomAreaView"; |
| 76 | |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 77 | private static final Intent SECURE_CAMERA_INTENT = |
| 78 | new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE) |
| 79 | .addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 80 | private static final Intent INSECURE_CAMERA_INTENT = |
| 81 | new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 82 | private static final Intent PHONE_INTENT = new Intent(Intent.ACTION_DIAL); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 83 | private static final int DOZE_ANIMATION_STAGGER_DELAY = 48; |
| 84 | private static final int DOZE_ANIMATION_ELEMENT_DURATION = 250; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 85 | private static final long TRANSIENT_FP_ERROR_TIMEOUT = 1300; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 86 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 87 | private KeyguardAffordanceView mCameraImageView; |
| 88 | private KeyguardAffordanceView mPhoneImageView; |
| 89 | private KeyguardAffordanceView mLockIcon; |
Jorim Jaggi | e210cc8 | 2014-08-12 23:44:59 +0200 | [diff] [blame] | 90 | private TextView mIndicationText; |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 91 | private ViewGroup mPreviewContainer; |
| 92 | |
| 93 | private View mPhonePreview; |
| 94 | private View mCameraPreview; |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 95 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 96 | private ActivityStarter mActivityStarter; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 97 | private UnlockMethodCache mUnlockMethodCache; |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 98 | private LockPatternUtils mLockPatternUtils; |
Adrian Roos | 1e1d6ac | 2014-07-22 17:18:55 +0200 | [diff] [blame] | 99 | private FlashlightController mFlashlightController; |
Jorim Jaggi | 781c29c | 2014-08-05 20:39:15 +0200 | [diff] [blame] | 100 | private PreviewInflater mPreviewInflater; |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 101 | private KeyguardIndicationController mIndicationController; |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 102 | private AccessibilityController mAccessibilityController; |
| 103 | private PhoneStatusBar mPhoneStatusBar; |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 104 | |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 105 | private final TrustDrawable mTrustDrawable; |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 106 | private final Interpolator mLinearOutSlowInInterpolator; |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 107 | private int mLastUnlockIconRes = 0; |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 108 | private boolean mPrewarmSent; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 109 | private boolean mTransientFpError; |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 110 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 111 | public KeyguardBottomAreaView(Context context) { |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 112 | this(context, null); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | public KeyguardBottomAreaView(Context context, AttributeSet attrs) { |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 116 | this(context, attrs, 0); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | public KeyguardBottomAreaView(Context context, AttributeSet attrs, int defStyleAttr) { |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 120 | this(context, attrs, defStyleAttr, 0); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | public KeyguardBottomAreaView(Context context, AttributeSet attrs, int defStyleAttr, |
| 124 | int defStyleRes) { |
| 125 | super(context, attrs, defStyleAttr, defStyleRes); |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 126 | mTrustDrawable = new TrustDrawable(mContext); |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 127 | mLinearOutSlowInInterpolator = |
| 128 | AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 129 | } |
| 130 | |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 131 | private AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() { |
| 132 | @Override |
| 133 | public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { |
| 134 | super.onInitializeAccessibilityNodeInfo(host, info); |
| 135 | String label = null; |
| 136 | if (host == mLockIcon) { |
| 137 | label = getResources().getString(R.string.unlock_label); |
| 138 | } else if (host == mCameraImageView) { |
| 139 | label = getResources().getString(R.string.camera_label); |
| 140 | } else if (host == mPhoneImageView) { |
| 141 | label = getResources().getString(R.string.phone_label); |
| 142 | } |
| 143 | info.addAction(new AccessibilityAction(ACTION_CLICK, label)); |
| 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public boolean performAccessibilityAction(View host, int action, Bundle args) { |
| 148 | if (action == ACTION_CLICK) { |
| 149 | if (host == mLockIcon) { |
| 150 | mPhoneStatusBar.animateCollapsePanels( |
Jorim Jaggi | 4eedc1d | 2014-10-27 13:45:56 +0100 | [diff] [blame] | 151 | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 152 | return true; |
| 153 | } else if (host == mCameraImageView) { |
| 154 | launchCamera(); |
| 155 | return true; |
| 156 | } else if (host == mPhoneImageView) { |
| 157 | launchPhone(); |
| 158 | return true; |
| 159 | } |
| 160 | } |
| 161 | return super.performAccessibilityAction(host, action, args); |
| 162 | } |
| 163 | }; |
| 164 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 165 | @Override |
| 166 | protected void onFinishInflate() { |
| 167 | super.onFinishInflate(); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 168 | mLockPatternUtils = new LockPatternUtils(mContext); |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 169 | mPreviewContainer = (ViewGroup) findViewById(R.id.preview_container); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 170 | mCameraImageView = (KeyguardAffordanceView) findViewById(R.id.camera_button); |
| 171 | mPhoneImageView = (KeyguardAffordanceView) findViewById(R.id.phone_button); |
| 172 | mLockIcon = (KeyguardAffordanceView) findViewById(R.id.lock_icon); |
Jorim Jaggi | e210cc8 | 2014-08-12 23:44:59 +0200 | [diff] [blame] | 173 | mIndicationText = (TextView) findViewById(R.id.keyguard_indication_text); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 174 | watchForCameraPolicyChanges(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 175 | updateCameraVisibility(); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 176 | updatePhoneVisibility(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 177 | mUnlockMethodCache = UnlockMethodCache.getInstance(getContext()); |
| 178 | mUnlockMethodCache.addListener(this); |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 179 | updateLockIcon(); |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 180 | setClipChildren(false); |
| 181 | setClipToPadding(false); |
Jorim Jaggi | 781c29c | 2014-08-05 20:39:15 +0200 | [diff] [blame] | 182 | mPreviewInflater = new PreviewInflater(mContext, new LockPatternUtils(mContext)); |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 183 | inflatePreviews(); |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 184 | mLockIcon.setOnClickListener(this); |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 185 | mLockIcon.setBackground(mTrustDrawable); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 186 | mLockIcon.setOnLongClickListener(this); |
| 187 | mCameraImageView.setOnClickListener(this); |
| 188 | mPhoneImageView.setOnClickListener(this); |
| 189 | initAccessibility(); |
| 190 | } |
| 191 | |
| 192 | private void initAccessibility() { |
| 193 | mLockIcon.setAccessibilityDelegate(mAccessibilityDelegate); |
| 194 | mPhoneImageView.setAccessibilityDelegate(mAccessibilityDelegate); |
| 195 | mCameraImageView.setAccessibilityDelegate(mAccessibilityDelegate); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 196 | } |
| 197 | |
Jorim Jaggi | e210cc8 | 2014-08-12 23:44:59 +0200 | [diff] [blame] | 198 | @Override |
| 199 | protected void onConfigurationChanged(Configuration newConfig) { |
| 200 | super.onConfigurationChanged(newConfig); |
| 201 | int indicationBottomMargin = getResources().getDimensionPixelSize( |
| 202 | R.dimen.keyguard_indication_margin_bottom); |
| 203 | MarginLayoutParams mlp = (MarginLayoutParams) mIndicationText.getLayoutParams(); |
| 204 | if (mlp.bottomMargin != indicationBottomMargin) { |
| 205 | mlp.bottomMargin = indicationBottomMargin; |
| 206 | mIndicationText.setLayoutParams(mlp); |
| 207 | } |
| 208 | |
| 209 | // Respect font size setting. |
| 210 | mIndicationText.setTextSize(TypedValue.COMPLEX_UNIT_PX, |
| 211 | getResources().getDimensionPixelSize( |
| 212 | com.android.internal.R.dimen.text_size_small_material)); |
| 213 | } |
| 214 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 215 | public void setActivityStarter(ActivityStarter activityStarter) { |
| 216 | mActivityStarter = activityStarter; |
| 217 | } |
| 218 | |
Adrian Roos | 1e1d6ac | 2014-07-22 17:18:55 +0200 | [diff] [blame] | 219 | public void setFlashlightController(FlashlightController flashlightController) { |
| 220 | mFlashlightController = flashlightController; |
| 221 | } |
| 222 | |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 223 | public void setAccessibilityController(AccessibilityController accessibilityController) { |
| 224 | mAccessibilityController = accessibilityController; |
| 225 | accessibilityController.addStateChangedCallback(this); |
| 226 | } |
| 227 | |
| 228 | public void setPhoneStatusBar(PhoneStatusBar phoneStatusBar) { |
| 229 | mPhoneStatusBar = phoneStatusBar; |
Dan Sandler | e163a64 | 2015-03-01 22:58:32 -0500 | [diff] [blame] | 230 | updateCameraVisibility(); // in case onFinishInflate() was called too early |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 231 | } |
| 232 | |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 233 | private Intent getCameraIntent() { |
| 234 | KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
| 235 | boolean currentUserHasTrust = updateMonitor.getUserHasTrust( |
| 236 | mLockPatternUtils.getCurrentUser()); |
| 237 | return mLockPatternUtils.isSecure() && !currentUserHasTrust |
| 238 | ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT; |
| 239 | } |
| 240 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 241 | private void updateCameraVisibility() { |
Dan Sandler | e163a64 | 2015-03-01 22:58:32 -0500 | [diff] [blame] | 242 | if (mCameraImageView == null) { |
| 243 | // Things are not set up yet; reply hazy, ask again later |
| 244 | return; |
| 245 | } |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 246 | ResolveInfo resolved = mContext.getPackageManager().resolveActivityAsUser(getCameraIntent(), |
| 247 | PackageManager.MATCH_DEFAULT_ONLY, |
| 248 | mLockPatternUtils.getCurrentUser()); |
Jorim Jaggi | 15dac5f | 2014-08-27 19:08:26 +0200 | [diff] [blame] | 249 | boolean visible = !isCameraDisabledByDpm() && resolved != null |
| 250 | && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 251 | mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 252 | } |
| 253 | |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 254 | private void updatePhoneVisibility() { |
| 255 | boolean visible = isPhoneVisible(); |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 256 | mPhoneImageView.setVisibility(visible ? View.VISIBLE : View.GONE); |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | private boolean isPhoneVisible() { |
| 260 | PackageManager pm = mContext.getPackageManager(); |
| 261 | return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY) |
| 262 | && pm.resolveActivity(PHONE_INTENT, 0) != null; |
| 263 | } |
| 264 | |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 265 | private boolean isCameraDisabledByDpm() { |
| 266 | final DevicePolicyManager dpm = |
| 267 | (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE); |
Dan Sandler | e163a64 | 2015-03-01 22:58:32 -0500 | [diff] [blame] | 268 | if (dpm != null && mPhoneStatusBar != null) { |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 269 | try { |
| 270 | final int userId = ActivityManagerNative.getDefault().getCurrentUser().id; |
| 271 | final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId); |
| 272 | final boolean disabledBecauseKeyguardSecure = |
| 273 | (disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0 |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 274 | && mPhoneStatusBar.isKeyguardSecure(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 275 | return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure; |
| 276 | } catch (RemoteException e) { |
| 277 | Log.e(TAG, "Can't get userId", e); |
| 278 | } |
| 279 | } |
| 280 | return false; |
| 281 | } |
| 282 | |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 283 | private void watchForCameraPolicyChanges() { |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 284 | final IntentFilter filter = new IntentFilter(); |
| 285 | filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 286 | getContext().registerReceiverAsUser(mDevicePolicyReceiver, |
| 287 | UserHandle.ALL, filter, null, null); |
| 288 | KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 291 | @Override |
| 292 | public void onStateChanged(boolean accessibilityEnabled, boolean touchExplorationEnabled) { |
| 293 | mCameraImageView.setClickable(touchExplorationEnabled); |
| 294 | mPhoneImageView.setClickable(touchExplorationEnabled); |
| 295 | mCameraImageView.setFocusable(accessibilityEnabled); |
| 296 | mPhoneImageView.setFocusable(accessibilityEnabled); |
| 297 | updateLockIconClickability(); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 300 | private void updateLockIconClickability() { |
| 301 | if (mAccessibilityController == null) { |
| 302 | return; |
| 303 | } |
Adrian Roos | 38fc7606 | 2014-09-22 17:34:56 +0200 | [diff] [blame] | 304 | boolean clickToUnlock = mAccessibilityController.isTouchExplorationEnabled(); |
| 305 | boolean clickToForceLock = mUnlockMethodCache.isTrustManaged() |
| 306 | && !mAccessibilityController.isAccessibilityEnabled(); |
| 307 | boolean longClickToForceLock = mUnlockMethodCache.isTrustManaged() |
| 308 | && !clickToForceLock; |
| 309 | mLockIcon.setClickable(clickToForceLock || clickToUnlock); |
| 310 | mLockIcon.setLongClickable(longClickToForceLock); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 311 | mLockIcon.setFocusable(mAccessibilityController.isAccessibilityEnabled()); |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 312 | } |
| 313 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 314 | @Override |
| 315 | public void onClick(View v) { |
| 316 | if (v == mCameraImageView) { |
| 317 | launchCamera(); |
| 318 | } else if (v == mPhoneImageView) { |
| 319 | launchPhone(); |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 320 | } if (v == mLockIcon) { |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 321 | if (!mAccessibilityController.isAccessibilityEnabled()) { |
| 322 | handleTrustCircleClick(); |
| 323 | } else { |
| 324 | mPhoneStatusBar.animateCollapsePanels( |
| 325 | CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); |
| 326 | } |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 327 | } |
| 328 | } |
| 329 | |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 330 | @Override |
| 331 | public boolean onLongClick(View v) { |
| 332 | handleTrustCircleClick(); |
| 333 | return true; |
| 334 | } |
| 335 | |
| 336 | private void handleTrustCircleClick() { |
Christoph Studer | b018399 | 2014-12-22 21:02:26 +0100 | [diff] [blame] | 337 | EventLogTags.writeSysuiLockscreenGesture( |
| 338 | EventLogConstants.SYSUI_LOCKSCREEN_GESTURE_TAP_LOCK, 0 /* lengthDp - N/A */, |
| 339 | 0 /* velocityDp - N/A */); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 340 | mIndicationController.showTransientIndication( |
| 341 | R.string.keyguard_indication_trust_disabled); |
| 342 | mLockPatternUtils.requireCredentialEntry(mLockPatternUtils.getCurrentUser()); |
| 343 | } |
| 344 | |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 345 | public void prewarmCamera() { |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 346 | Intent intent = getCameraIntent(); |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 347 | String targetPackage = PreviewInflater.getTargetPackage(mContext, intent, |
| 348 | mLockPatternUtils.getCurrentUser()); |
| 349 | if (targetPackage != null) { |
| 350 | Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_PREWARM); |
| 351 | prewarm.setPackage(targetPackage); |
| 352 | mPrewarmSent = true; |
| 353 | mContext.sendBroadcast(prewarm); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | public void maybeCooldownCamera() { |
| 358 | if (!mPrewarmSent) { |
| 359 | return; |
| 360 | } |
| 361 | mPrewarmSent = false; |
| 362 | Intent intent = getCameraIntent(); |
| 363 | String targetPackage = PreviewInflater.getTargetPackage(mContext, intent, |
| 364 | mLockPatternUtils.getCurrentUser()); |
| 365 | if (targetPackage != null) { |
| 366 | Intent prewarm = new Intent(MediaStore.ACTION_STILL_IMAGE_CAMERA_COOLDOWN); |
| 367 | prewarm.setPackage(targetPackage); |
| 368 | mContext.sendBroadcast(prewarm); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | public void launchCamera() { |
| 373 | |
| 374 | // Reset prewarm state. |
| 375 | mPrewarmSent = false; |
| 376 | final Intent intent = getCameraIntent(); |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 377 | boolean wouldLaunchResolverActivity = PreviewInflater.wouldLaunchResolverActivity( |
| 378 | mContext, intent, mLockPatternUtils.getCurrentUser()); |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 379 | if (intent == SECURE_CAMERA_INTENT && !wouldLaunchResolverActivity) { |
Jorim Jaggi | a86790b | 2015-04-02 16:32:29 -0700 | [diff] [blame] | 380 | AsyncTask.execute(new Runnable() { |
| 381 | @Override |
| 382 | public void run() { |
| 383 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
| 384 | } |
| 385 | }); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 386 | } else { |
Jorim Jaggi | 746f7fa | 2014-08-27 17:52:46 +0200 | [diff] [blame] | 387 | |
| 388 | // We need to delay starting the activity because ResolverActivity finishes itself if |
| 389 | // launched behind lockscreen. |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 390 | mActivityStarter.startActivity(intent, false /* dismissShade */); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 391 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 392 | } |
| 393 | |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 394 | public void launchPhone() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 395 | final TelecomManager tm = TelecomManager.from(mContext); |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 396 | if (tm.isInCall()) { |
Yorke Lee | 583a2024 | 2014-08-12 18:47:08 -0700 | [diff] [blame] | 397 | AsyncTask.execute(new Runnable() { |
| 398 | @Override |
| 399 | public void run() { |
Nancy Chen | 0eb1e40 | 2014-08-21 22:52:29 -0700 | [diff] [blame] | 400 | tm.showInCallScreen(false /* showDialpad */); |
Yorke Lee | 583a2024 | 2014-08-12 18:47:08 -0700 | [diff] [blame] | 401 | } |
| 402 | }); |
| 403 | } else { |
Jorim Jaggi | 85dc23c | 2014-09-08 14:42:29 +0200 | [diff] [blame] | 404 | mActivityStarter.startActivity(PHONE_INTENT, false /* dismissShade */); |
Yorke Lee | 583a2024 | 2014-08-12 18:47:08 -0700 | [diff] [blame] | 405 | } |
Jorim Jaggi | 97b63c4 | 2014-05-02 23:03:34 +0200 | [diff] [blame] | 406 | } |
| 407 | |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 408 | |
| 409 | @Override |
| 410 | protected void onVisibilityChanged(View changedView, int visibility) { |
| 411 | super.onVisibilityChanged(changedView, visibility); |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 412 | if (isShown()) { |
| 413 | mTrustDrawable.start(); |
| 414 | } else { |
| 415 | mTrustDrawable.stop(); |
| 416 | } |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 417 | if (changedView == this && visibility == VISIBLE) { |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 418 | updateLockIcon(); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 419 | updateCameraVisibility(); |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 423 | @Override |
| 424 | protected void onDetachedFromWindow() { |
| 425 | super.onDetachedFromWindow(); |
| 426 | mTrustDrawable.stop(); |
| 427 | } |
| 428 | |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 429 | private void updateLockIcon() { |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 430 | boolean visible = isShown() && KeyguardUpdateMonitor.getInstance(mContext).isScreenOn(); |
| 431 | if (visible) { |
| 432 | mTrustDrawable.start(); |
| 433 | } else { |
| 434 | mTrustDrawable.stop(); |
| 435 | } |
| 436 | if (!visible) { |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 437 | return; |
| 438 | } |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 439 | // TODO: Real icon for facelock. |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 440 | boolean isFingerprintIcon = |
| 441 | KeyguardUpdateMonitor.getInstance(mContext).isFingerprintDetectionRunning(); |
| 442 | boolean anyFingerprintIcon = isFingerprintIcon || mTransientFpError; |
| 443 | int iconRes = mTransientFpError ? R.drawable.ic_fingerprint_error |
| 444 | : isFingerprintIcon ? R.drawable.ic_fingerprint |
| 445 | : mUnlockMethodCache.isFaceUnlockRunning() |
| 446 | ? com.android.internal.R.drawable.ic_account_circle |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 447 | : mUnlockMethodCache.isCurrentlyInsecure() ? R.drawable.ic_lock_open_24dp |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 448 | : R.drawable.ic_lock_24dp; |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 449 | |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 450 | if (mLastUnlockIconRes != iconRes) { |
| 451 | Drawable icon = mContext.getDrawable(iconRes); |
| 452 | int iconHeight = getResources().getDimensionPixelSize( |
| 453 | R.dimen.keyguard_affordance_icon_height); |
| 454 | int iconWidth = getResources().getDimensionPixelSize( |
| 455 | R.dimen.keyguard_affordance_icon_width); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 456 | if (!anyFingerprintIcon && (icon.getIntrinsicHeight() != iconHeight |
| 457 | || icon.getIntrinsicWidth() != iconWidth)) { |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 458 | icon = new IntrinsicSizeDrawable(icon, iconWidth, iconHeight); |
| 459 | } |
| 460 | mLockIcon.setImageDrawable(icon); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 461 | mLockIcon.setPaddingRelative(0, 0, 0, anyFingerprintIcon |
| 462 | ? getResources().getDimensionPixelSize( |
| 463 | R.dimen.fingerprint_icon_additional_padding) |
| 464 | : 0); |
| 465 | mLockIcon.setRestingAlpha( |
| 466 | anyFingerprintIcon ? 1f : KeyguardAffordanceHelper.SWIPE_RESTING_ALPHA_AMOUNT); |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 467 | } |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 468 | |
| 469 | // Hide trust circle when fingerprint is running. |
| 470 | boolean trustManaged = mUnlockMethodCache.isTrustManaged() && !anyFingerprintIcon; |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 471 | mTrustDrawable.setTrustManaged(trustManaged); |
Jorim Jaggi | b2e104f | 2014-08-15 18:12:36 +0200 | [diff] [blame] | 472 | updateLockIconClickability(); |
Adrian Roos | 2fe592d | 2014-05-17 03:11:59 +0200 | [diff] [blame] | 473 | } |
| 474 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 475 | public KeyguardAffordanceView getPhoneView() { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 476 | return mPhoneImageView; |
| 477 | } |
| 478 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 479 | public KeyguardAffordanceView getCameraView() { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 480 | return mCameraImageView; |
| 481 | } |
| 482 | |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 483 | public View getPhonePreview() { |
| 484 | return mPhonePreview; |
| 485 | } |
| 486 | |
| 487 | public View getCameraPreview() { |
| 488 | return mCameraPreview; |
| 489 | } |
| 490 | |
Selim Cinek | baa2327 | 2014-07-08 18:01:07 +0200 | [diff] [blame] | 491 | public KeyguardAffordanceView getLockIcon() { |
Selim Cinek | 4c6969a | 2014-05-26 19:22:17 +0200 | [diff] [blame] | 492 | return mLockIcon; |
| 493 | } |
| 494 | |
Selim Cinek | f99d000 | 2014-06-13 07:36:01 +0200 | [diff] [blame] | 495 | public View getIndicationView() { |
| 496 | return mIndicationText; |
| 497 | } |
| 498 | |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 499 | @Override |
Jorim Jaggi | 2580a976 | 2014-06-25 03:08:25 +0200 | [diff] [blame] | 500 | public boolean hasOverlappingRendering() { |
| 501 | return false; |
| 502 | } |
| 503 | |
| 504 | @Override |
Christoph Studer | 2231c6e | 2014-12-19 12:40:13 +0100 | [diff] [blame] | 505 | public void onUnlockMethodStateChanged() { |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 506 | updateLockIcon(); |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 507 | updateCameraVisibility(); |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 508 | } |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 509 | |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 510 | private void inflatePreviews() { |
Jorim Jaggi | 781c29c | 2014-08-05 20:39:15 +0200 | [diff] [blame] | 511 | mPhonePreview = mPreviewInflater.inflatePreview(PHONE_INTENT); |
| 512 | mCameraPreview = mPreviewInflater.inflatePreview(getCameraIntent()); |
Jorim Jaggi | b6cdcbc | 2014-07-25 21:58:29 +0200 | [diff] [blame] | 513 | if (mPhonePreview != null) { |
| 514 | mPreviewContainer.addView(mPhonePreview); |
| 515 | mPhonePreview.setVisibility(View.INVISIBLE); |
| 516 | } |
| 517 | if (mCameraPreview != null) { |
| 518 | mPreviewContainer.addView(mCameraPreview); |
| 519 | mCameraPreview.setVisibility(View.INVISIBLE); |
| 520 | } |
| 521 | } |
| 522 | |
Jorim Jaggi | 16423aa | 2014-10-28 11:42:58 +0100 | [diff] [blame] | 523 | public void startFinishDozeAnimation() { |
| 524 | long delay = 0; |
| 525 | if (mPhoneImageView.getVisibility() == View.VISIBLE) { |
| 526 | startFinishDozeAnimationElement(mPhoneImageView, delay); |
| 527 | delay += DOZE_ANIMATION_STAGGER_DELAY; |
| 528 | } |
| 529 | startFinishDozeAnimationElement(mLockIcon, delay); |
| 530 | delay += DOZE_ANIMATION_STAGGER_DELAY; |
| 531 | if (mCameraImageView.getVisibility() == View.VISIBLE) { |
| 532 | startFinishDozeAnimationElement(mCameraImageView, delay); |
| 533 | } |
| 534 | mIndicationText.setAlpha(0f); |
| 535 | mIndicationText.animate() |
| 536 | .alpha(1f) |
| 537 | .setInterpolator(mLinearOutSlowInInterpolator) |
| 538 | .setDuration(NotificationPanelView.DOZE_ANIMATION_DURATION); |
| 539 | } |
| 540 | |
| 541 | private void startFinishDozeAnimationElement(View element, long delay) { |
| 542 | element.setAlpha(0f); |
| 543 | element.setTranslationY(element.getHeight() / 2); |
| 544 | element.animate() |
| 545 | .alpha(1f) |
| 546 | .translationY(0f) |
| 547 | .setInterpolator(mLinearOutSlowInInterpolator) |
| 548 | .setStartDelay(delay) |
| 549 | .setDuration(DOZE_ANIMATION_ELEMENT_DURATION); |
| 550 | } |
| 551 | |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 552 | private final BroadcastReceiver mDevicePolicyReceiver = new BroadcastReceiver() { |
| 553 | public void onReceive(Context context, Intent intent) { |
| 554 | post(new Runnable() { |
| 555 | @Override |
| 556 | public void run() { |
| 557 | updateCameraVisibility(); |
| 558 | } |
| 559 | }); |
| 560 | } |
| 561 | }; |
| 562 | |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 563 | private final Runnable mTransientFpErrorClearRunnable = new Runnable() { |
| 564 | @Override |
| 565 | public void run() { |
| 566 | mTransientFpError = false; |
| 567 | mIndicationController.hideTransientIndication(); |
| 568 | updateLockIcon(); |
| 569 | } |
| 570 | }; |
| 571 | |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 572 | private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = |
| 573 | new KeyguardUpdateMonitorCallback() { |
| 574 | @Override |
| 575 | public void onUserSwitchComplete(int userId) { |
| 576 | updateCameraVisibility(); |
| 577 | } |
Jorim Jaggi | e7b1252 | 2014-08-06 16:41:21 +0200 | [diff] [blame] | 578 | |
| 579 | @Override |
Adrian Roos | 2e3ccbb | 2014-08-19 22:23:37 +0200 | [diff] [blame] | 580 | public void onScreenTurnedOn() { |
| 581 | updateLockIcon(); |
| 582 | } |
| 583 | |
| 584 | @Override |
| 585 | public void onScreenTurnedOff(int why) { |
| 586 | updateLockIcon(); |
| 587 | } |
Adrian Roos | b9ae090 | 2014-10-27 14:20:30 +0100 | [diff] [blame] | 588 | |
| 589 | @Override |
| 590 | public void onKeyguardVisibilityChanged(boolean showing) { |
| 591 | updateLockIcon(); |
| 592 | } |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 593 | |
| 594 | @Override |
| 595 | public void onFingerprintAuthenticated(int userId) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | @Override |
| 599 | public void onFingerprintRunningStateChanged(boolean running) { |
| 600 | updateLockIcon(); |
| 601 | } |
| 602 | |
| 603 | @Override |
| 604 | public void onFingerprintHelp(int msgId, String helpString) { |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 605 | mTransientFpError = true; |
| 606 | mIndicationController.showTransientIndication(helpString, |
| 607 | getResources().getColor(R.color.system_warning_color, null)); |
| 608 | removeCallbacks(mTransientFpErrorClearRunnable); |
| 609 | postDelayed(mTransientFpErrorClearRunnable, TRANSIENT_FP_ERROR_TIMEOUT); |
| 610 | updateLockIcon(); |
| 611 | } |
| 612 | |
| 613 | @Override |
| 614 | public void onFingerprintError(int msgId, String errString) { |
| 615 | // TODO: Go to bouncer if this is "too many attempts" (lockout) error. |
| 616 | Log.i(TAG, "FP Error: " + errString); |
Jim Miller | fe6439f | 2015-04-11 18:07:57 -0700 | [diff] [blame] | 617 | updateLockIcon(); |
Jorim Jaggi | 27c9b74 | 2015-04-09 10:34:49 -0700 | [diff] [blame] | 618 | } |
Adrian Roos | a06905b | 2014-05-28 12:13:48 +0200 | [diff] [blame] | 619 | }; |
Adrian Roos | 4ebcdfd | 2014-08-12 23:33:49 +0200 | [diff] [blame] | 620 | |
| 621 | public void setKeyguardIndicationController( |
| 622 | KeyguardIndicationController keyguardIndicationController) { |
| 623 | mIndicationController = keyguardIndicationController; |
| 624 | } |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 625 | |
Adrian Roos | 72cc370 | 2014-09-18 17:25:09 +0200 | [diff] [blame] | 626 | /** |
| 627 | * A wrapper around another Drawable that overrides the intrinsic size. |
| 628 | */ |
| 629 | private static class IntrinsicSizeDrawable extends InsetDrawable { |
| 630 | |
| 631 | private final int mIntrinsicWidth; |
| 632 | private final int mIntrinsicHeight; |
| 633 | |
| 634 | public IntrinsicSizeDrawable(Drawable drawable, int intrinsicWidth, int intrinsicHeight) { |
| 635 | super(drawable, 0); |
| 636 | mIntrinsicWidth = intrinsicWidth; |
| 637 | mIntrinsicHeight = intrinsicHeight; |
| 638 | } |
| 639 | |
| 640 | @Override |
| 641 | public int getIntrinsicWidth() { |
| 642 | return mIntrinsicWidth; |
| 643 | } |
| 644 | |
| 645 | @Override |
| 646 | public int getIntrinsicHeight() { |
| 647 | return mIntrinsicHeight; |
| 648 | } |
| 649 | } |
Jorim Jaggi | a631029 | 2014-04-16 14:11:52 +0200 | [diff] [blame] | 650 | } |