Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c66f052 authored by Brian Colonna's avatar Brian Colonna Committed by Android (Google) Code Review
Browse files

Merge "Fix 5323545 - FaceLock no longer appears when taking a call"

parents d83baa4e 267cb2b2
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -21,5 +21,4 @@ import android.os.IBinder;
oneway interface IFaceLockCallback {
oneway interface IFaceLockCallback {
    void unlock();
    void unlock();
    void cancel();
    void cancel();
    void sleepDevice();
}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -593,4 +593,7 @@ public class KeyguardUpdateMonitor {
        return mClockVisible;
        return mClockVisible;
    }
    }


    public int getPhoneState() {
        return mPhoneState;
    }
}
}
+0 −9
Original line number Original line Diff line number Diff line
@@ -127,15 +127,6 @@ public abstract class KeyguardViewBase extends FrameLayout {
     */
     */
    abstract public void cleanUp();
    abstract public void cleanUp();


    /**
     * These were added to support FaceLock because the KeyguardViewManager needs to tell the 
     * LockPatternKeyguardView when to bind and and unbind with FaceLock service.  Although
     * implemented in LockPatternKeyguardView, these are not implemented in anything else
     * derived from KeyguardViewBase
     */
    abstract public void bindToFaceLock();
    abstract public void stopAndUnbindFromFaceLock();

    @Override
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (shouldEventKeepScreenOnWhileKeyguardShowing(event)) {
        if (shouldEventKeepScreenOnWhileKeyguardShowing(event)) {
+0 −12
Original line number Original line Diff line number Diff line
@@ -205,9 +205,6 @@ public class KeyguardViewManager implements KeyguardWindowController {
        mScreenOn = false;
        mScreenOn = false;
        if (mKeyguardView != null) {
        if (mKeyguardView != null) {
            mKeyguardView.onScreenTurnedOff();
            mKeyguardView.onScreenTurnedOff();

            // When screen is turned off, need to unbind from FaceLock service if using FaceLock
            mKeyguardView.stopAndUnbindFromFaceLock();
        }
        }
    }
    }


@@ -218,9 +215,6 @@ public class KeyguardViewManager implements KeyguardWindowController {
        if (mKeyguardView != null) {
        if (mKeyguardView != null) {
            mKeyguardView.onScreenTurnedOn();
            mKeyguardView.onScreenTurnedOn();


            // When screen is turned on, need to bind to FaceLock service if we are using FaceLock
            mKeyguardView.bindToFaceLock();

            // Caller should wait for this window to be shown before turning
            // Caller should wait for this window to be shown before turning
            // on the screen.
            // on the screen.
            if (mKeyguardHost.getVisibility() == View.VISIBLE) {
            if (mKeyguardHost.getVisibility() == View.VISIBLE) {
@@ -277,12 +271,6 @@ public class KeyguardViewManager implements KeyguardWindowController {
    public synchronized void hide() {
    public synchronized void hide() {
        if (DEBUG) Log.d(TAG, "hide()");
        if (DEBUG) Log.d(TAG, "hide()");


        if (mKeyguardView != null) {
            // When view is hidden, need to unbind from FaceLock service if we are using FaceLock
            // e.g., when device becomes unlocked
            mKeyguardView.stopAndUnbindFromFaceLock();
        }

        if (mKeyguardHost != null) {
        if (mKeyguardHost != null) {
            mKeyguardHost.setVisibility(View.GONE);
            mKeyguardHost.setVisibility(View.GONE);
            // Don't do this right away, so we can let the view continue to animate
            // Don't do this right away, so we can let the view continue to animate
+28 −28
Original line number Original line Diff line number Diff line
@@ -504,6 +504,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
        } else {
        } else {
            ((KeyguardScreen) mUnlockScreen).onPause();
            ((KeyguardScreen) mUnlockScreen).onPause();
        }
        }

        // When screen is turned off, need to unbind from FaceLock service if using FaceLock
        stopAndUnbindFromFaceLock();
    }
    }


    @Override
    @Override
@@ -514,6 +517,14 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
        } else {
        } else {
            ((KeyguardScreen) mUnlockScreen).onResume();
            ((KeyguardScreen) mUnlockScreen).onResume();
        }
        }

        // When screen is turned on, need to bind to FaceLock service if we are using FaceLock
        // But only if not dealing with a call
        if (mUpdateMonitor.getPhoneState() == TelephonyManager.CALL_STATE_IDLE) {
            bindToFaceLock();
        } else {
            mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
        }
    }
    }


    private void recreateLockScreen() {
    private void recreateLockScreen() {
@@ -543,6 +554,11 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
    @Override
    @Override
    protected void onDetachedFromWindow() {
    protected void onDetachedFromWindow() {
        removeCallbacks(mRecreateRunnable);
        removeCallbacks(mRecreateRunnable);

        // When view is hidden, need to unbind from FaceLock service if we are using FaceLock
        // e.g., when device becomes unlocked
        stopAndUnbindFromFaceLock();

        super.onDetachedFromWindow();
        super.onDetachedFromWindow();
    }
    }


@@ -952,8 +968,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
    // Everything below pertains to FaceLock - might want to separate this out
    // Everything below pertains to FaceLock - might want to separate this out


    // Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
    // Only pattern and pin unlock screens actually have a view for the FaceLock area, so it's not
    // uncommon for it to not exist.  But if it does exist, we need to make sure it's showing if
    // uncommon for it to not exist.  But if it does exist, we need to make sure it's shown (hiding
    // FaceLock is enabled, and make sure it's not showing if FaceLock is disabled
    // the fallback) if FaceLock is enabled, and make sure it's hidden (showing the unlock) if
    // FaceLock is disabled
    private void initializeFaceLockAreaView(View view) {
    private void initializeFaceLockAreaView(View view) {
        mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
        mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
        if (mFaceLockAreaView == null) {
        if (mFaceLockAreaView == null) {
@@ -997,9 +1014,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
                if (DEBUG) Log.d(TAG, "after bind to FaceLock service");
                if (DEBUG) Log.d(TAG, "after bind to FaceLock service");
                mBoundToFaceLockService = true;
                mBoundToFaceLockService = true;
            } else {
            } else {
                // On startup I've seen onScreenTurnedOn() get called twice without
                Log.w(TAG, "Attempt to bind to FaceLock when already bound");
                // onScreenTurnedOff() being called in between, which can cause this (bcolonna)
                if (DEBUG) Log.w(TAG, "Attempt to bind to FaceLock when already bound");
            }
            }
        }
        }
    }
    }
@@ -1017,7 +1032,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
            } else {
            } else {
                // This could probably happen after the session when someone activates FaceLock
                // This could probably happen after the session when someone activates FaceLock
                // because it wasn't active when the phone was turned on
                // because it wasn't active when the phone was turned on
                if (DEBUG) Log.w(TAG, "Attempt to unbind from FaceLock when not bound");
                Log.w(TAG, "Attempt to unbind from FaceLock when not bound");
            }
            }
        }
        }
    }
    }
@@ -1048,7 +1063,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
                mFaceLockService = null;
                mFaceLockService = null;
                mFaceLockServiceRunning = false;
                mFaceLockServiceRunning = false;
            }
            }
            if (DEBUG) Log.w(TAG, "Unexpected disconnect from FaceLock service");
            Log.w(TAG, "Unexpected disconnect from FaceLock service");
        }
        }
    };
    };


@@ -1099,36 +1114,21 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
        // Stops the FaceLock UI and indicates that the phone should be unlocked
        // Stops the FaceLock UI and indicates that the phone should be unlocked
        @Override
        @Override
        public void unlock() {
        public void unlock() {
            if (DEBUG) Log.d(TAG, "FaceLock unlock");
            if (DEBUG) Log.d(TAG, "FaceLock unlock()");
            // Note that we don't hide the client FaceLockAreaView because we want to keep the
            mHandler.sendEmptyMessage(MSG_SHOW_FACELOCK_AREA_VIEW); // Keep fallback covered
            // lock screen covered while the phone is unlocked

            stopFaceLock();
            stopFaceLock();

            mKeyguardScreenCallback.keyguardDone(true);
            mKeyguardScreenCallback.keyguardDone(true);
            mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
            mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
        }
        }


        // Stops the FaceLock UI and exposes the backup method without unlocking
        // Stops the FaceLock UI and exposes the backup method without unlocking
        // This means either the user has cancelled out or FaceLock failed to recognize them
        @Override
        @Override
        public void cancel() {
        public void cancel() {
            // In this case, either the user has cancelled out, or FaceLock failed to recognize them
            if (DEBUG) Log.d(TAG, "FaceLock cancel()");
            if (DEBUG) Log.d(TAG, "FaceLock cancel");
            mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW); // Expose fallback
            // Here we hide the client FaceLockViewArea to expose the underlying backup method
            mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
            stopFaceLock();
        }

        // Stops the FaceLock UI and puts the phone to sleep
        @Override
        public void sleepDevice() {
            // In this case, it appears the phone has been turned on accidentally
            if (DEBUG) Log.d(TAG, "FaceLock accidental turn on");
            // Here we hide the client FaceLockViewArea to expose the underlying backup method
            mHandler.sendEmptyMessage(MSG_HIDE_FACELOCK_AREA_VIEW);
            stopFaceLock();
            stopFaceLock();
            // TODO(bcolonna): how do we put the phone back to sleep (i.e., turn off the screen)
            // TODO(bcolonna): this should be removed once the service is no longer calling it
            // because we are just going to let the lockscreen timeout
        }
        }
    };
    };
}
}