103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi/* 203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * Copyright (C) 2014 The Android Open Source Project 303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * 403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * Licensed under the Apache License, Version 2.0 (the "License"); 503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * you may not use this file except in compliance with the License. 603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * You may obtain a copy of the License at 703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * 803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * http://www.apache.org/licenses/LICENSE-2.0 903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * 1003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * Unless required by applicable law or agreed to in writing, software 1103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * distributed under the License is distributed on an "AS IS" BASIS, 1203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * See the License for the specific language governing permissions and 1403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * limitations under the License 1503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi */ 1603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 1703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggipackage com.android.systemui.statusbar.phone; 1803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 1903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport android.content.Context; 20416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggiimport android.view.Choreographer; 21df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggiimport android.view.KeyEvent; 2203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport android.view.LayoutInflater; 2303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport android.view.View; 2403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport android.view.ViewGroup; 25c1dff8cee8cf334906c1572cc3c50fbff96d1839Jorim Jaggiimport android.view.accessibility.AccessibilityEvent; 2603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 2703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.internal.widget.LockPatternUtils; 286b88cdfba770efc5722338c240ccaada13d7b0d4Jorim Jaggiimport com.android.keyguard.KeyguardHostView; 293122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinekimport com.android.keyguard.KeyguardSecurityView; 3003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.keyguard.R; 3103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.keyguard.ViewMediatorCallback; 3286b273f1cc59185a14d5bab8a3f4db30c1a4c8a9Jorim Jaggiimport com.android.systemui.DejankUtils; 3303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 346b88cdfba770efc5722338c240ccaada13d7b0d4Jorim Jaggiimport static com.android.keyguard.KeyguardHostView.OnDismissAction; 35f18271cb300ed7263b39bd17d36a460c4883db88Jorim Jaggiimport static com.android.keyguard.KeyguardSecurityModel.SecurityMode; 36a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi 3703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi/** 3803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * A class which manages the bouncer on the lockscreen. 3903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi */ 4003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggipublic class KeyguardBouncer { 4103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 4203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private Context mContext; 4303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private ViewMediatorCallback mCallback; 4403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private LockPatternUtils mLockPatternUtils; 4503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private ViewGroup mContainer; 4603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private StatusBarWindowManager mWindowManager; 476b88cdfba770efc5722338c240ccaada13d7b0d4Jorim Jaggi private KeyguardHostView mKeyguardView; 4803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private ViewGroup mRoot; 49416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi private boolean mShowingSoon; 503122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek private int mBouncerPromptReason; 5103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 5203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi public KeyguardBouncer(Context context, ViewMediatorCallback callback, 5303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager, 5403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi ViewGroup container) { 5503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mContext = context; 5603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mCallback = callback; 5703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mLockPatternUtils = lockPatternUtils; 5803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mContainer = container; 5903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mWindowManager = windowManager; 6003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 6103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 6295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi public void show(boolean resetSecuritySelection) { 6303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi ensureView(); 6495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi if (resetSecuritySelection) { 6595e89caeb252a54807c76d60c7440766829e418cJorim Jaggi // showPrimarySecurityScreen() updates the current security method. This is needed in 6695e89caeb252a54807c76d60c7440766829e418cJorim Jaggi // case we are already showing and the current security method changed. 6795e89caeb252a54807c76d60c7440766829e418cJorim Jaggi mKeyguardView.showPrimarySecurityScreen(); 6895e89caeb252a54807c76d60c7440766829e418cJorim Jaggi } 69416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) { 702fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi return; 712fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi } 720bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi 730bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi // Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole 740bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi // Keyguard. If we need to authenticate, show the bouncer. 750bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi if (!mKeyguardView.dismiss()) { 76416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi mShowingSoon = true; 77416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi 78416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi // Split up the work over multiple frames. 7986b273f1cc59185a14d5bab8a3f4db30c1a4c8a9Jorim Jaggi DejankUtils.postAfterTraversal(mShowRunnable); 80416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi } 81416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi } 82416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi 83416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi private final Runnable mShowRunnable = new Runnable() { 84416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi @Override 85416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi public void run() { 860bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi mRoot.setVisibility(View.VISIBLE); 87a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi mKeyguardView.onResume(); 883122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek showPromptReason(mBouncerPromptReason); 89c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi mKeyguardView.startAppearAnimation(); 90416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi mShowingSoon = false; 91c1dff8cee8cf334906c1572cc3c50fbff96d1839Jorim Jaggi mKeyguardView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); 920bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi } 93416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi }; 94416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi 953122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek /** 963122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * Show a string explaining why the security view needs to be solved. 973122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * 983122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * @param reason a flag indicating which string should be shown, see 993122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * {@link KeyguardSecurityView#PROMPT_REASON_NONE} 1003122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek * and {@link KeyguardSecurityView#PROMPT_REASON_RESTART} 1013122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek */ 1023122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek public void showPromptReason(int reason) { 1033122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek mKeyguardView.showPromptReason(reason); 1043122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek } 1053122fa85b2f18c0a89f5fe1ef0942c530a271843Selim Cinek 106416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi private void cancelShowRunnable() { 10786b273f1cc59185a14d5bab8a3f4db30c1a4c8a9Jorim Jaggi DejankUtils.removeCallbacks(mShowRunnable); 108416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi mShowingSoon = false; 10903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 11003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 111d944986fbdb3d45fab9ae4120af76ca4f6b0909cJorim Jaggi public void showWithDismissAction(OnDismissAction r, Runnable cancelAction) { 1127d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos ensureView(); 113d944986fbdb3d45fab9ae4120af76ca4f6b0909cJorim Jaggi mKeyguardView.setOnDismissAction(r, cancelAction); 11495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi show(false /* resetSecuritySelection */); 1157d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos } 1167d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos 117a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi public void hide(boolean destroyView) { 118416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi cancelShowRunnable(); 119416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi if (mKeyguardView != null) { 120d944986fbdb3d45fab9ae4120af76ca4f6b0909cJorim Jaggi mKeyguardView.cancelDismissAction(); 12103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mKeyguardView.cleanUp(); 12203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 123a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi if (destroyView) { 124a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi removeView(); 125a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi } else if (mRoot != null) { 126a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi mRoot.setVisibility(View.INVISIBLE); 127a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi } 12803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 12903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 13076a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi /** 13176a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}. 13276a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi */ 13376a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi public void startPreHideAnimation(Runnable runnable) { 13476a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi if (mKeyguardView != null) { 13576a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi mKeyguardView.startDisappearAnimation(runnable); 1368de4311c51229efbe2f2d0afbf298982c5cadd96Jorim Jaggi } else if (runnable != null) { 13776a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi runnable.run(); 138e29b2dbc762bfa66093d76f5a65f55328d8753c9Jorim Jaggi } 139e29b2dbc762bfa66093d76f5a65f55328d8753c9Jorim Jaggi } 140e29b2dbc762bfa66093d76f5a65f55328d8753c9Jorim Jaggi 14103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi /** 14203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * Reset the state of the view. 14303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi */ 14403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi public void reset() { 145416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi cancelShowRunnable(); 14603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi inflateView(); 14703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 14803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 14903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi public void onScreenTurnedOff() { 1509ee256d2522f5ab779dfab65c6d1f389b5ddb59aDan Sandler if (mKeyguardView != null && mRoot != null && mRoot.getVisibility() == View.VISIBLE) { 151a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi mKeyguardView.onPause(); 15203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 15303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 15403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 155e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi public boolean isShowing() { 156416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi return mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE); 157e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi } 158e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi 1592fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi public void prepare() { 16095e89caeb252a54807c76d60c7440766829e418cJorim Jaggi boolean wasInitialized = mRoot != null; 1612fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi ensureView(); 16295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi if (wasInitialized) { 16395e89caeb252a54807c76d60c7440766829e418cJorim Jaggi mKeyguardView.showPrimarySecurityScreen(); 16495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi } 16586b273f1cc59185a14d5bab8a3f4db30c1a4c8a9Jorim Jaggi mBouncerPromptReason = mCallback.getBouncerPromptReason(); 1662fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi } 1672fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi 16803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private void ensureView() { 16903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi if (mRoot == null) { 17003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi inflateView(); 17103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 17203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 17303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 17403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private void inflateView() { 17503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi removeView(); 17603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mRoot = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.keyguard_bouncer, null); 1776b88cdfba770efc5722338c240ccaada13d7b0d4Jorim Jaggi mKeyguardView = (KeyguardHostView) mRoot.findViewById(R.id.keyguard_host_view); 17803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mKeyguardView.setLockPatternUtils(mLockPatternUtils); 17903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mKeyguardView.setViewMediatorCallback(mCallback); 18003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mContainer.addView(mRoot, mContainer.getChildCount()); 18103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mRoot.setVisibility(View.INVISIBLE); 18203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_HOME); 18303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 18403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi 18503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi private void removeView() { 18603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi if (mRoot != null && mRoot.getParent() == mContainer) { 18703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mContainer.removeView(mRoot); 18803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi mRoot = null; 18903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 19003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi } 191e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi 192e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi public boolean onBackPressed() { 193e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi return mKeyguardView != null && mKeyguardView.handleBackKey(); 194e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi } 195a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi 196a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi /** 19795e89caeb252a54807c76d60c7440766829e418cJorim Jaggi * @return True if and only if the security method should be shown before showing the 19895e89caeb252a54807c76d60c7440766829e418cJorim Jaggi * notifications on Keyguard, like SIM PIN/PUK. 199a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi */ 200a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi public boolean needsFullscreenBouncer() { 201edd32b881780e52b4ecc43f8df3b6b091e70a863Selim Cinek ensureView(); 202a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi if (mKeyguardView != null) { 203a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi SecurityMode mode = mKeyguardView.getSecurityMode(); 20495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk; 20595e89caeb252a54807c76d60c7440766829e418cJorim Jaggi } 20695e89caeb252a54807c76d60c7440766829e418cJorim Jaggi return false; 20795e89caeb252a54807c76d60c7440766829e418cJorim Jaggi } 20895e89caeb252a54807c76d60c7440766829e418cJorim Jaggi 20995e89caeb252a54807c76d60c7440766829e418cJorim Jaggi /** 21095e89caeb252a54807c76d60c7440766829e418cJorim Jaggi * Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which 21195e89caeb252a54807c76d60c7440766829e418cJorim Jaggi * makes this method much faster. 21295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi */ 21395e89caeb252a54807c76d60c7440766829e418cJorim Jaggi public boolean isFullscreenBouncer() { 21495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi if (mKeyguardView != null) { 21595e89caeb252a54807c76d60c7440766829e418cJorim Jaggi SecurityMode mode = mKeyguardView.getCurrentSecurityMode(); 21695e89caeb252a54807c76d60c7440766829e418cJorim Jaggi return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk; 217a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi } 218a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi return false; 219a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi } 2208c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi 2212231c6e1adefdb7636d9fe38a388f1b0660d30eaChristoph Studer /** 2222231c6e1adefdb7636d9fe38a388f1b0660d30eaChristoph Studer * WARNING: This method might cause Binder calls. 2232231c6e1adefdb7636d9fe38a388f1b0660d30eaChristoph Studer */ 2241568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi public boolean isSecure() { 2251568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi return mKeyguardView == null || mKeyguardView.getSecurityMode() != SecurityMode.None; 2261568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi } 2271568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi 2288c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi public boolean onMenuPressed() { 2298c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi ensureView(); 2308c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi if (mKeyguardView.handleMenuKey()) { 2318c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi 2328c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi // We need to show it in case it is secure. If not, it will get dismissed in any case. 2338c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi mRoot.setVisibility(View.VISIBLE); 2348c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi mKeyguardView.requestFocus(); 2358c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi mKeyguardView.onResume(); 2368c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi return true; 2378c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi } else { 2388c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi return false; 2398c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi } 2408c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi } 241df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi 242df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi public boolean interceptMediaKey(KeyEvent event) { 243df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi ensureView(); 244df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi return mKeyguardView.interceptMediaKey(event); 245df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi } 2465cc86599ce0e5596655859d09c52934030da240bJorim Jaggi 2475cc86599ce0e5596655859d09c52934030da240bJorim Jaggi public void notifyKeyguardAuthenticated() { 2485cc86599ce0e5596655859d09c52934030da240bJorim Jaggi ensureView(); 2495cc86599ce0e5596655859d09c52934030da240bJorim Jaggi mKeyguardView.finish(); 2505cc86599ce0e5596655859d09c52934030da240bJorim Jaggi } 25103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi} 252