FileDocCategorySizeDatePackage
KeyguardFaceUnlockView.javaAPI DocAndroid 5.1 API13606Thu Mar 12 22:22:42 GMT 2015com.android.keyguard

KeyguardFaceUnlockView

public class KeyguardFaceUnlockView extends android.widget.LinearLayout implements KeyguardSecurityView

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
private KeyguardSecurityCallback
mKeyguardSecurityCallback
private com.android.internal.widget.LockPatternUtils
mLockPatternUtils
private BiometricSensorUnlock
mBiometricUnlock
private android.view.View
mFaceUnlockAreaView
private android.widget.ImageButton
mCancelButton
private SecurityMessageDisplay
mSecurityMessageDisplay
private android.view.View
mEcaView
private android.graphics.drawable.Drawable
mBouncerFrame
private boolean
mIsBouncerVisibleToUser
private final Object
mIsBouncerVisibleToUserLock
private int
mLastRotation
private boolean
mWatchingRotation
private final android.view.IWindowManager
mWindowManager
private final android.view.IRotationWatcher
mRotationWatcher
KeyguardUpdateMonitorCallback
mUpdateCallback
Constructors Summary
public KeyguardFaceUnlockView(android.content.Context context)


       
        this(context, null);
    
public KeyguardFaceUnlockView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
public KeyguardSecurityCallbackgetCallback()

        return mKeyguardSecurityCallback;
    
private voidhandleBouncerUserVisibilityChanged()

        boolean wasBouncerVisibleToUser;
        synchronized(mIsBouncerVisibleToUserLock) {
            wasBouncerVisibleToUser = mIsBouncerVisibleToUser;
            mIsBouncerVisibleToUser = isBouncerVisibleToUser();
        }

        if (mBiometricUnlock != null) {
            if (wasBouncerVisibleToUser && !mIsBouncerVisibleToUser) {
                mBiometricUnlock.stop();
            } else if (!wasBouncerVisibleToUser && mIsBouncerVisibleToUser) {
                maybeStartBiometricUnlock();
            }
        }
    
public voidhideBouncer(int duration)

        KeyguardSecurityViewHelper.
                hideBouncer(mSecurityMessageDisplay, mEcaView, mBouncerFrame, duration);
    
private voidinitializeBiometricUnlockView()

        if (DEBUG) Log.d(TAG, "initializeBiometricUnlockView()");
        mFaceUnlockAreaView = findViewById(R.id.face_unlock_area_view);
        if (mFaceUnlockAreaView != null) {
            mBiometricUnlock = new FaceUnlock(mContext);

            mCancelButton = (ImageButton) findViewById(R.id.face_unlock_cancel_button);
            mCancelButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mBiometricUnlock.stopAndShowBackup();
                }
            });
        } else {
            Log.w(TAG, "Couldn't find biometric unlock view");
        }
    
private booleanisBouncerVisibleToUser()

        KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
        return updateMonitor.isKeyguardBouncer() && updateMonitor.isKeyguardVisible() &&
                updateMonitor.isScreenOn();
    
private voidmaybeStartBiometricUnlock()
Starts the biometric unlock if it should be started based on a number of factors. If it should not be started, it either goes to the back up, or remains showing to prepare for it being started later.

        if (DEBUG) Log.d(TAG, "maybeStartBiometricUnlock()");
        if (mBiometricUnlock != null) {
            KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
            final boolean backupIsTimedOut = (
                    monitor.getFailedUnlockAttempts() >=
                    LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT);

            boolean isBouncerVisibleToUser;
            synchronized(mIsBouncerVisibleToUserLock) {
                isBouncerVisibleToUser = mIsBouncerVisibleToUser;
            }

            // Don't start it if the bouncer is not showing, but keep this view up because we want
            // it here and ready for when the bouncer does show.
            if (!isBouncerVisibleToUser) {
                mBiometricUnlock.stop(); // It shouldn't be running but calling this can't hurt.
                return;
            }

            // Although these same conditions are handled in KeyguardSecurityModel, they are still
            // necessary here.  When a tablet is rotated 90 degrees, a configuration change is
            // triggered and everything is torn down and reconstructed.  That means
            // KeyguardSecurityModel gets a chance to take care of the logic and doesn't even
            // reconstruct KeyguardFaceUnlockView if the biometric unlock should be suppressed.
            // However, for a 180 degree rotation, no configuration change is triggered, so only
            // the logic here is capable of suppressing Face Unlock.
            if (monitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE
                    && monitor.isAlternateUnlockEnabled()
                    && !monitor.getMaxBiometricUnlockAttemptsReached()
                    && !backupIsTimedOut) {
                mBiometricUnlock.start();
            } else {
                mBiometricUnlock.stopAndShowBackup();
            }
        }
    
public booleanneedsInput()

        return false;
    
public voidonDetachedFromWindow()

        if (DEBUG) Log.d(TAG, "onDetachedFromWindow()");
        if (mBiometricUnlock != null) {
            mBiometricUnlock.stop();
        }
        KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateCallback);
        if (mWatchingRotation) {
            try {
                mWindowManager.removeRotationWatcher(mRotationWatcher);
                mWatchingRotation = false;
            } catch (RemoteException e) {
                Log.e(TAG, "Remote exception when removing rotation watcher");
            }
        }
    
protected voidonFinishInflate()

        super.onFinishInflate();

        initializeBiometricUnlockView();

        mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
        mEcaView = findViewById(R.id.keyguard_selector_fade_container);
        View bouncerFrameView = findViewById(R.id.keyguard_bouncer_frame);
        if (bouncerFrameView != null) {
            mBouncerFrame = bouncerFrameView.getBackground();
        }
    
protected voidonLayout(boolean changed, int l, int t, int r, int b)

        super.onLayout(changed, l, t, r, b);
        mBiometricUnlock.initializeView(mFaceUnlockAreaView);
    
public voidonPause()

        if (DEBUG) Log.d(TAG, "onPause()");
        if (mBiometricUnlock != null) {
            mBiometricUnlock.stop();
        }
        KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateCallback);
        if (mWatchingRotation) {
            try {
                mWindowManager.removeRotationWatcher(mRotationWatcher);
                mWatchingRotation = false;
            } catch (RemoteException e) {
                Log.e(TAG, "Remote exception when removing rotation watcher");
            }
        }
    
public voidonResume(int reason)

        if (DEBUG) Log.d(TAG, "onResume()");
        synchronized (mIsBouncerVisibleToUserLock) {
            mIsBouncerVisibleToUser = isBouncerVisibleToUser();
        }
        KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback);

        // Registers a callback which handles stopping the biometric unlock and restarting it in
        // the new position for a 180 degree rotation change.
        if (!mWatchingRotation) {
            try {
                mLastRotation = mWindowManager.watchRotation(mRotationWatcher);
                mWatchingRotation = true;
            } catch (RemoteException e) {
                Log.e(TAG, "Remote exception when adding rotation watcher");
            }
        }
    
public voidreset()


    
public voidsetKeyguardCallback(KeyguardSecurityCallback callback)

        mKeyguardSecurityCallback = callback;
        // TODO: formalize this in the interface or factor it out
        ((FaceUnlock)mBiometricUnlock).setKeyguardCallback(callback);
    
public voidsetLockPatternUtils(com.android.internal.widget.LockPatternUtils utils)

        mLockPatternUtils = utils;
    
public voidshowBouncer(int duration)

        KeyguardSecurityViewHelper.
                showBouncer(mSecurityMessageDisplay, mEcaView, mBouncerFrame, duration);
    
public voidshowUsabilityHint()


    
       
    
public voidstartAppearAnimation()

        // TODO.
    
public booleanstartDisappearAnimation(java.lang.Runnable finishRunnable)

        return false;