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

Commit 22ad682a authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Cancel camera launch on screen off." into jb-mr1-lockscreen-dev

parents 89c359c8 dbe24b7d
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -64,7 +64,10 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    private final Runnable mLaunchCameraRunnable = new Runnable() {
        @Override
        public void run() {
            if (!mTransitioning)
                return;
            mLaunchCameraStart = SystemClock.uptimeMillis();
            if (DEBUG) Log.d(TAG, "Launching camera at " + mLaunchCameraStart);
            mActivityLauncher.launchCamera();
        }};

@@ -274,7 +277,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli

    @Override
    protected void onFocusLost() {
        Log.d(TAG, "onFocusLost");
        if (DEBUG) Log.d(TAG, "onFocusLost");
        cancelTransitionToCamera();
        super.onFocusLost();
    }
@@ -293,6 +296,11 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
        }
    }

    public void onScreenTurnedOff() {
        if (DEBUG) Log.d(TAG, "onScreenTurnedOff");
        reset();
    }

    private void rescheduleTransitionToCamera() {
        if (DEBUG) Log.d(TAG, "rescheduleTransitionToCamera at " + SystemClock.uptimeMillis());
        mHandler.removeCallbacks(mTransitionToCameraRunnable);
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.MediaStore;
import android.util.Log;
@@ -132,6 +133,8 @@ public abstract class KeyguardActivityLauncher {
                Log.w(TAG, "can't dismiss keyguard on launch");
            }
            try {
                if (DEBUG) Log.d(TAG, String.format("Starting activity for intent %s at %s",
                        intent, SystemClock.uptimeMillis()));
                context.startActivityAsUser(intent, animation,
                        new UserHandle(UserHandle.USER_CURRENT));
            } catch (ActivityNotFoundException e) {
+16 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.os.Bundle;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
@@ -708,13 +709,18 @@ public class KeyguardHostView extends KeyguardViewBase {

    @Override
    public void onScreenTurnedOff() {
        if (DEBUG) Log.d(TAG, "screen off, instance " + Integer.toHexString(hashCode()));
        if (DEBUG) Log.d(TAG, String.format("screen off, instance %s at %s",
                Integer.toHexString(hashCode()), SystemClock.uptimeMillis()));
        // Once the screen turns off, we no longer consider this to be first boot and we want the
        // biometric unlock to start next time keyguard is shown.
        KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(true);
        saveStickyWidgetIndex();
        showPrimarySecurityScreen(true);
        getSecurityView(mCurrentSecuritySelection).onPause();
        CameraWidgetFrame cameraPage = findCameraPage();
        if (cameraPage != null) {
            cameraPage.onScreenTurnedOff();
        }
    }

    @Override
@@ -1140,6 +1146,15 @@ public class KeyguardHostView extends KeyguardViewBase {
        mAppWidgetContainer.setCurrentPage(pageToShow);
    }

    private CameraWidgetFrame findCameraPage() {
        for (int i = mAppWidgetContainer.getChildCount() - 1; i >= 0; i--) {
            if (isCameraPage(i)) {
                return (CameraWidgetFrame) mAppWidgetContainer.getChildAt(i);
            }
        }
        return null;
    }

    private boolean isCameraPage(int pageIndex) {
        View v = mAppWidgetContainer.getChildAt(pageIndex);
        return v != null && v instanceof CameraWidgetFrame;