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;
2803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.keyguard.KeyguardViewBase;
2903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.keyguard.R;
3003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.keyguard.ViewMediatorCallback;
3103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggiimport com.android.systemui.keyguard.KeyguardViewMediator;
3203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
337d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roosimport static com.android.keyguard.KeyguardHostView.OnDismissAction;
34f18271cb300ed7263b39bd17d36a460c4883db88Jorim Jaggiimport static com.android.keyguard.KeyguardSecurityModel.SecurityMode;
35a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi
3603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi/**
3703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi * A class which manages the bouncer on the lockscreen.
3803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi */
3903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggipublic class KeyguardBouncer {
4003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
4103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private Context mContext;
4203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private ViewMediatorCallback mCallback;
4303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private LockPatternUtils mLockPatternUtils;
4403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private ViewGroup mContainer;
4503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private StatusBarWindowManager mWindowManager;
4603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private KeyguardViewBase mKeyguardView;
4703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private ViewGroup mRoot;
48416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi    private boolean mShowingSoon;
49416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi    private Choreographer mChoreographer = Choreographer.getInstance();
5003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
5103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
5203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager,
5303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            ViewGroup container) {
5403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mContext = context;
5503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mCallback = callback;
5603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mLockPatternUtils = lockPatternUtils;
5703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mContainer = container;
5803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mWindowManager = windowManager;
5903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
6003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
6195e89caeb252a54807c76d60c7440766829e418cJorim Jaggi    public void show(boolean resetSecuritySelection) {
6203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        ensureView();
6395e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        if (resetSecuritySelection) {
6495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            // showPrimarySecurityScreen() updates the current security method. This is needed in
6595e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            // case we are already showing and the current security method changed.
6695e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            mKeyguardView.showPrimarySecurityScreen();
6795e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        }
68416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi        if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) {
692fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi            return;
702fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi        }
710bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi
720bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi        // Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole
730bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi        // Keyguard. If we need to authenticate, show the bouncer.
740bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi        if (!mKeyguardView.dismiss()) {
75416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi            mShowingSoon = true;
76416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi
77416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi            // Split up the work over multiple frames.
78416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi            mChoreographer.postCallbackDelayed(Choreographer.CALLBACK_ANIMATION, mShowRunnable,
7995e89caeb252a54807c76d60c7440766829e418cJorim Jaggi                    null, 16);
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();
88c14f829506a5273e8022b461db2d61038b18ac4bJorim Jaggi            mKeyguardView.startAppearAnimation();
89416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi            mShowingSoon = false;
90c1dff8cee8cf334906c1572cc3c50fbff96d1839Jorim Jaggi            mKeyguardView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
910bed7f258ba1fffc10f986ee043b769f1fd40ad3Jorim Jaggi        }
92416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi    };
93416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi
94416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi    private void cancelShowRunnable() {
95416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi        mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, mShowRunnable, null);
96416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi        mShowingSoon = false;
9703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
9803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
997d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos    public void showWithDismissAction(OnDismissAction r) {
1007d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos        ensureView();
1017d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos        mKeyguardView.setOnDismissAction(r);
10295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        show(false /* resetSecuritySelection */);
1037d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos    }
1047d7090d66692170b0584a5b9f4fe3e47285ee615Adrian Roos
105a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi    public void hide(boolean destroyView) {
106416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi        cancelShowRunnable();
107416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi         if (mKeyguardView != null) {
108559b41f42455377c70ac5a1a10516cd34e9324aeAdrian Roos            mKeyguardView.setOnDismissAction(null);
10903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            mKeyguardView.cleanUp();
11003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        }
111a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi        if (destroyView) {
112a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi            removeView();
113a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi        } else if (mRoot != null) {
114a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi            mRoot.setVisibility(View.INVISIBLE);
115a0be6d53a823f8115d3863773398d640ec2a8c44Jorim Jaggi        }
11603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
11703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
11876a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi    /**
11976a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
12076a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi     */
12176a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi    public void startPreHideAnimation(Runnable runnable) {
12276a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi        if (mKeyguardView != null) {
12376a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi            mKeyguardView.startDisappearAnimation(runnable);
1248de4311c51229efbe2f2d0afbf298982c5cadd96Jorim Jaggi        } else if (runnable != null) {
12576a1623afc170a13923b68f3256057d8adeb7937Jorim Jaggi            runnable.run();
126e29b2dbc762bfa66093d76f5a65f55328d8753c9Jorim Jaggi        }
127e29b2dbc762bfa66093d76f5a65f55328d8753c9Jorim Jaggi    }
128e29b2dbc762bfa66093d76f5a65f55328d8753c9Jorim Jaggi
12903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    /**
13003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi     * Reset the state of the view.
13103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi     */
13203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    public void reset() {
133416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi        cancelShowRunnable();
13403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        inflateView();
13503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
13603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
13703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    public void onScreenTurnedOff() {
1389ee256d2522f5ab779dfab65c6d1f389b5ddb59aDan Sandler        if (mKeyguardView != null && mRoot != null && mRoot.getVisibility() == View.VISIBLE) {
139a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi            mKeyguardView.onPause();
14003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        }
14103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
14203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
14303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    public long getUserActivityTimeout() {
14403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        if (mKeyguardView != null) {
14503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            long timeout = mKeyguardView.getUserActivityTimeout();
14603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            if (timeout >= 0) {
14703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi                return timeout;
14803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            }
14903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        }
15003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        return KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS;
15103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
15203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
153e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi    public boolean isShowing() {
154416493bf66dff0aa7fcd9ea505ed10dbff1f2906Jorim Jaggi        return mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE);
155e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi    }
156e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi
1572fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi    public void prepare() {
15895e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        boolean wasInitialized = mRoot != null;
1592fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi        ensureView();
16095e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        if (wasInitialized) {
16195e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            mKeyguardView.showPrimarySecurityScreen();
16295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        }
1632fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi    }
1642fbad7b6a724cf0a5b98b66fe639d58f5ab10af3Jorim Jaggi
16503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private void ensureView() {
16603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        if (mRoot == null) {
16703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            inflateView();
16803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        }
16903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
17003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
17103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private void inflateView() {
17203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        removeView();
17303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mRoot = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.keyguard_bouncer, null);
17403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mKeyguardView = (KeyguardViewBase) mRoot.findViewById(R.id.keyguard_host_view);
17503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mKeyguardView.setLockPatternUtils(mLockPatternUtils);
17603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mKeyguardView.setViewMediatorCallback(mCallback);
17703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mContainer.addView(mRoot, mContainer.getChildCount());
17803c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mRoot.setVisibility(View.INVISIBLE);
17903c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        mRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_HOME);
18003c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
18103c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi
18203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    private void removeView() {
18303c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        if (mRoot != null && mRoot.getParent() == mContainer) {
18403c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            mContainer.removeView(mRoot);
18503c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi            mRoot = null;
18603c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi        }
18703c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi    }
188e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi
189e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi    public boolean onBackPressed() {
190e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi        return mKeyguardView != null && mKeyguardView.handleBackKey();
191e5c7a894635d72514d6f1e952d0f18ba6035e86dJorim Jaggi    }
192a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi
193a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi    /**
19495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi     * @return True if and only if the security method should be shown before showing the
19595e89caeb252a54807c76d60c7440766829e418cJorim Jaggi     * notifications on Keyguard, like SIM PIN/PUK.
196a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi     */
197a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi    public boolean needsFullscreenBouncer() {
198a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi        if (mKeyguardView != null) {
199a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi            SecurityMode mode = mKeyguardView.getSecurityMode();
20095e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
20195e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        }
20295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        return false;
20395e89caeb252a54807c76d60c7440766829e418cJorim Jaggi    }
20495e89caeb252a54807c76d60c7440766829e418cJorim Jaggi
20595e89caeb252a54807c76d60c7440766829e418cJorim Jaggi    /**
20695e89caeb252a54807c76d60c7440766829e418cJorim Jaggi     * Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which
20795e89caeb252a54807c76d60c7440766829e418cJorim Jaggi     * makes this method much faster.
20895e89caeb252a54807c76d60c7440766829e418cJorim Jaggi     */
20995e89caeb252a54807c76d60c7440766829e418cJorim Jaggi    public boolean isFullscreenBouncer() {
21095e89caeb252a54807c76d60c7440766829e418cJorim Jaggi        if (mKeyguardView != null) {
21195e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            SecurityMode mode = mKeyguardView.getCurrentSecurityMode();
21295e89caeb252a54807c76d60c7440766829e418cJorim Jaggi            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
213a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi        }
214a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi        return false;
215a005f1b6853e8852c328f4fdc02fb8f9c9ae1cd6Jorim Jaggi    }
2168c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi
2172231c6e1adefdb7636d9fe38a388f1b0660d30eaChristoph Studer    /**
2182231c6e1adefdb7636d9fe38a388f1b0660d30eaChristoph Studer     * WARNING: This method might cause Binder calls.
2192231c6e1adefdb7636d9fe38a388f1b0660d30eaChristoph Studer     */
2201568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi    public boolean isSecure() {
2211568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi        return mKeyguardView == null || mKeyguardView.getSecurityMode() != SecurityMode.None;
2221568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi    }
2231568250853d81befcdaef63cc8588435353c3d12Jorim Jaggi
2248c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi    public boolean onMenuPressed() {
2258c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi        ensureView();
2268c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi        if (mKeyguardView.handleMenuKey()) {
2278c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi
2288c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi            // We need to show it in case it is secure. If not, it will get dismissed in any case.
2298c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi            mRoot.setVisibility(View.VISIBLE);
2308c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi            mKeyguardView.requestFocus();
2318c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi            mKeyguardView.onResume();
2328c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi            return true;
2338c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi        } else {
2348c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi            return false;
2358c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi        }
2368c8bcc160aba9a5e93c8df2a99a39a856fafffabJorim Jaggi    }
237df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi
238df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi    public boolean interceptMediaKey(KeyEvent event) {
239df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi        ensureView();
240df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi        return mKeyguardView.interceptMediaKey(event);
241df993513fbfe0e952175c1c5384458deaa1ff01aJorim Jaggi    }
24203c701ec58ff6de3cc3c53b05342a475a63a11cfJorim Jaggi}
243