119a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller/*
219a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * Copyright (C) 2012 The Android Open Source Project
319a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller *
419a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * Licensed under the Apache License, Version 2.0 (the "License");
519a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * you may not use this file except in compliance with the License.
619a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * You may obtain a copy of the License at
719a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller *
819a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller *      http://www.apache.org/licenses/LICENSE-2.0
919a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller *
1019a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * Unless required by applicable law or agreed to in writing, software
1119a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * distributed under the License is distributed on an "AS IS" BASIS,
1219a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * See the License for the specific language governing permissions and
1419a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * limitations under the License.
1519a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller */
1619a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller
175ecd81154fa039961f65bb4e36d18ac555b0d1d6Jim Millerpackage com.android.keyguard;
1819a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller
1919a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller/**
2019a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * Interface implemented by ViewGroup-derived layouts that implement
2119a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller * special logic for presenting security challenges to the user.
2219a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller */
2319a5267003e7dc70100a4bd4f1f449523b2ff38bJim Millerpublic interface ChallengeLayout {
2419a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    /**
2519a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * @return true if the security challenge area of this layout is currently visible
2619a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     */
2719a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    boolean isChallengeShowing();
2819a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller
2919a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    /**
3019a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * @return true if the challenge area significantly overlaps other content
3119a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     */
3219a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    boolean isChallengeOverlapping();
3319a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller
3419a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    /**
3519a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * Show or hide the challenge layout.
3619a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     *
3719a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * If you want to show the challenge layout in bouncer mode where applicable,
3819a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * use {@link #showBouncer()} instead.
3919a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     *
4019a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * @param b true to show, false to hide
4119a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     */
4219a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    void showChallenge(boolean b);
4319a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller
4419a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    /**
4519a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     * Show the bouncer challenge. This may block access to other child views.
4619a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller     */
4719a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller    void showBouncer();
48eee209313d564be37b8fc068f785b3844cd6597eAdam Powell
49eee209313d564be37b8fc068f785b3844cd6597eAdam Powell    /**
50eee209313d564be37b8fc068f785b3844cd6597eAdam Powell     * Hide the bouncer challenge if it is currently showing.
51eee209313d564be37b8fc068f785b3844cd6597eAdam Powell     * This may restore previously blocked access to other child views.
52eee209313d564be37b8fc068f785b3844cd6597eAdam Powell     */
53eee209313d564be37b8fc068f785b3844cd6597eAdam Powell    void hideBouncer();
54eee209313d564be37b8fc068f785b3844cd6597eAdam Powell
55eee209313d564be37b8fc068f785b3844cd6597eAdam Powell    /**
56eee209313d564be37b8fc068f785b3844cd6597eAdam Powell     * Returns true if the challenge is currently in bouncer mode,
57eee209313d564be37b8fc068f785b3844cd6597eAdam Powell     * potentially blocking access to other child views.
58eee209313d564be37b8fc068f785b3844cd6597eAdam Powell     */
59eee209313d564be37b8fc068f785b3844cd6597eAdam Powell    boolean isBouncing();
600b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell
610b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell    /**
6270c2f8736437ebb6073c3b6dab2e08e6dd9f39a6Winson Chung     * Returns the duration of the bounce animation.
6370c2f8736437ebb6073c3b6dab2e08e6dd9f39a6Winson Chung     */
6470c2f8736437ebb6073c3b6dab2e08e6dd9f39a6Winson Chung    int getBouncerAnimationDuration();
6570c2f8736437ebb6073c3b6dab2e08e6dd9f39a6Winson Chung
6670c2f8736437ebb6073c3b6dab2e08e6dd9f39a6Winson Chung    /**
670b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     * Set a listener that will respond to changes in bouncer state.
680b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     *
690b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     * @param listener listener to register
700b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     */
710b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell    void setOnBouncerStateChangedListener(OnBouncerStateChangedListener listener);
720b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell
730b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell    /**
740b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     * Listener interface that reports changes in bouncer state.
750b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     * The bouncer is
760b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell     */
770b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell    public interface OnBouncerStateChangedListener {
780b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell        /**
790b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * Called when the bouncer state changes.
800b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * The bouncer is activated when the user must pass a security challenge
810b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * to proceed with the requested action.
820b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         *
830b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * <p>This differs from simply showing or hiding the security challenge
840b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * as the bouncer will prevent interaction with other elements of the UI.
850b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * If the user attempts to escape from the bouncer, it will be dismissed,
860b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * this method will be called with false as the parameter, and the action
870b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * should be canceled. If the security component reports a successful
880b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * authentication and the containing code calls hideBouncer() as a result,
890b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * this method will also be called with a false parameter. It is up to the
900b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * caller of hideBouncer to be ready for this.</p>
910b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         *
920b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         * @param bouncerActive true if the bouncer is now active,
930b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         *                      false if the bouncer was dismissed.
940b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell         */
950b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell        public void onBouncerStateChanged(boolean bouncerActive);
960b1b552268bc6641cc5d01fb80c12258da9c6985Adam Powell    }
9719a5267003e7dc70100a4bd4f1f449523b2ff38bJim Miller}
98