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

Commit bb5c9411 authored by John Spurlock's avatar John Spurlock
Browse files

Disable security handle when swiping into camera widget.

Bug:7444313
Change-Id: I3eb268a41bc8b8a4323e55577a775c5ab3cef10d
parent dd8ac785
Loading
Loading
Loading
Loading
+26 −22
Original line number Original line Diff line number Diff line
@@ -53,13 +53,14 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    private final Callbacks mCallbacks;
    private final Callbacks mCallbacks;
    private final WindowManager mWindowManager;
    private final WindowManager mWindowManager;
    private final Point mRenderedSize = new Point();
    private final Point mRenderedSize = new Point();
    private final int[] mScreenLocation = new int[2];


    private View mWidgetView;
    private View mWidgetView;
    private long mLaunchCameraStart;
    private long mLaunchCameraStart;
    private boolean mActive;
    private boolean mActive;
    private boolean mChallengeActive;
    private boolean mTransitioning;
    private boolean mTransitioning;
    private boolean mDown;
    private boolean mDown;
    private boolean mWindowFocused;


    private final Runnable mLaunchCameraRunnable = new Runnable() {
    private final Runnable mLaunchCameraRunnable = new Runnable() {
        @Override
        @Override
@@ -186,7 +187,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    }
    }


    private void transitionToCamera() {
    private void transitionToCamera() {
        if (mTransitioning || mChallengeActive || mDown) return;
        if (mTransitioning || mDown) return;


        mTransitioning = true;
        mTransitioning = true;


@@ -233,7 +234,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    public void onClick(View v) {
    public void onClick(View v) {
        if (DEBUG) Log.d(TAG, "clicked");
        if (DEBUG) Log.d(TAG, "clicked");
        if (mTransitioning) return;
        if (mTransitioning) return;
        if (mActive && !mChallengeActive) {
        if (mActive) {
            cancelTransitionToCamera();
            cancelTransitionToCamera();
            transitionToCamera();
            transitionToCamera();
        }
        }
@@ -242,6 +243,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    @Override
    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        super.onWindowFocusChanged(hasWindowFocus);
        super.onWindowFocusChanged(hasWindowFocus);
        mWindowFocused = hasWindowFocus;
        if (DEBUG) Log.d(TAG, "onWindowFocusChanged: " + hasWindowFocus);
        if (DEBUG) Log.d(TAG, "onWindowFocusChanged: " + hasWindowFocus);
        if (!hasWindowFocus) {
        if (!hasWindowFocus) {
            mTransitioning = false;
            mTransitioning = false;
@@ -265,13 +267,29 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
    }
    }


    @Override
    @Override
    public boolean onUserInteraction(int action) {
    public boolean onUserInteraction(MotionEvent event) {
        if (mTransitioning) return true;
        if (!mWindowFocused) {
        if (DEBUG) Log.d(TAG, "onUserInteraction " + action);
            if (DEBUG) Log.d(TAG, "onUserInteraction eaten: !mWindowFocused");
            return true;
        }
        if (mTransitioning) {
            if (DEBUG) Log.d(TAG, "onUserInteraction eaten: mTransitioning");
            return true;
        }

        getLocationOnScreen(mScreenLocation);
        int rawBottom = mScreenLocation[1] + getHeight();
        if (event.getRawY() > rawBottom) {
            if (DEBUG) Log.d(TAG, "onUserInteraction eaten: below widget");
            return true;
        }

        int action = event.getAction();
        mDown = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE;
        mDown = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE;
        if (mActive && !mChallengeActive) {
        if (mActive) {
            rescheduleTransitionToCamera();
            rescheduleTransitionToCamera();
        }
        }
        if (DEBUG) Log.d(TAG, "onUserInteraction observed, not eaten");
        return false;
        return false;
    }
    }


@@ -282,20 +300,6 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
        super.onFocusLost();
        super.onFocusLost();
    }
    }


    @Override
    public void onChallengeActive(boolean challengeActive) {
        if (DEBUG) Log.d(TAG, "onChallengeActive: " + challengeActive);
        mChallengeActive = challengeActive;
        if (mTransitioning) return;
        if (mActive) {
            if (mChallengeActive) {
                cancelTransitionToCamera();
            } else {
                rescheduleTransitionToCamera();
            }
        }
    }

    public void onScreenTurnedOff() {
    public void onScreenTurnedOff() {
        if (DEBUG) Log.d(TAG, "onScreenTurnedOff");
        if (DEBUG) Log.d(TAG, "onScreenTurnedOff");
        reset();
        reset();
@@ -321,7 +325,6 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
        if (DEBUG) Log.d(TAG, "reset");
        if (DEBUG) Log.d(TAG, "reset");
        mLaunchCameraStart = 0;
        mLaunchCameraStart = 0;
        mTransitioning = false;
        mTransitioning = false;
        mChallengeActive = false;
        mDown = false;
        mDown = false;
        cancelTransitionToCamera();
        cancelTransitionToCamera();
        animate().cancel();
        animate().cancel();
@@ -347,6 +350,7 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli
        WindowManager.LayoutParams wlp = (WindowManager.LayoutParams) lp;
        WindowManager.LayoutParams wlp = (WindowManager.LayoutParams) lp;
        int newWindowAnimations = isEnabled ? com.android.internal.R.style.Animation_LockScreen : 0;
        int newWindowAnimations = isEnabled ? com.android.internal.R.style.Animation_LockScreen : 0;
        if (newWindowAnimations != wlp.windowAnimations) {
        if (newWindowAnimations != wlp.windowAnimations) {
            if (DEBUG) Log.d(TAG, "setting windowAnimations to: " + newWindowAnimations);
            wlp.windowAnimations = newWindowAnimations;
            wlp.windowAnimations = newWindowAnimations;
            mWindowManager.updateViewLayout(root, wlp);
            mWindowManager.updateViewLayout(root, wlp);
        }
        }
+4 −0
Original line number Original line Diff line number Diff line
@@ -837,6 +837,10 @@ public class KeyguardHostView extends KeyguardViewBase {
                if (isCameraPage(mAppWidgetContainer.getCurrentPage())) {
                if (isCameraPage(mAppWidgetContainer.getCurrentPage())) {
                    mAppWidgetContainer.scrollLeft();
                    mAppWidgetContainer.scrollLeft();
                }
                }
                SlidingChallengeLayout slider = locateSlider();
                if (slider != null) {
                    slider.setHandleAlpha(1);
                }
                mShowSecurityWhenReturn = true;
                mShowSecurityWhenReturn = true;
            }
            }


+8 −4
Original line number Original line Diff line number Diff line
@@ -101,7 +101,14 @@ public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChalle
        ((View) mKeyguardSecurityContainer).animate().alpha(1f).setDuration(duration);
        ((View) mKeyguardSecurityContainer).animate().alpha(1f).setDuration(duration);
    }
    }


    public void onPageSwitch(View newPage, int newPageIndex) {
    public void onPageSwitching(View newPage, int newPageIndex) {
        if (mPagedView != null && mChallengeLayout instanceof SlidingChallengeLayout) {
            boolean isCameraPage = newPage instanceof CameraWidgetFrame;
            ((SlidingChallengeLayout) mChallengeLayout).setChallengeInteractive(!isCameraPage);
        }
    }

    public void onPageSwitched(View newPage, int newPageIndex) {
        // Reset the previous page size and ensure the current page is sized appropriately.
        // Reset the previous page size and ensure the current page is sized appropriately.
        // We only modify the page state if it is not currently under control by the slider.
        // We only modify the page state if it is not currently under control by the slider.
        // This prevents conflicts.
        // This prevents conflicts.
@@ -166,7 +173,6 @@ public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChalle
            if (!challengeOverlapping) {
            if (!challengeOverlapping) {
                frame.resetSize();
                frame.resetSize();
            }
            }
            frame.onChallengeActive(mChallengeLayout.isChallengeShowing());
            frame.hideFrame(this);
            frame.hideFrame(this);


            if (challengeOverlapping) {
            if (challengeOverlapping) {
@@ -200,8 +206,6 @@ public class KeyguardViewStateManager implements SlidingChallengeLayout.OnChalle
            }
            }
            // View is on the move.  Pause the security view until it completes.
            // View is on the move.  Pause the security view until it completes.
            mKeyguardSecurityContainer.onPause();
            mKeyguardSecurityContainer.onPause();

            frame.onChallengeActive(true);
        }
        }
        mLastScrollState = scrollState;
        mLastScrollState = scrollState;
    }
    }
+1 −5
Original line number Original line Diff line number Diff line
@@ -418,12 +418,8 @@ public class KeyguardWidgetFrame extends FrameLayout {
        // hook for subclasses
        // hook for subclasses
    }
    }


    public boolean onUserInteraction(int action) {
    public boolean onUserInteraction(MotionEvent event) {
        // hook for subclasses
        // hook for subclasses
        return false;
        return false;
    }
    }

    public void onChallengeActive(boolean challengeActive) {
        // hook for subclasses
    }
}
}
+10 −3
Original line number Original line Diff line number Diff line
@@ -119,7 +119,14 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
    }
    }


    @Override
    @Override
    public void onPageSwitch(View newPage, int newPageIndex) {
    public void onPageSwitching(View newPage, int newPageIndex) {
        if (mViewStateManager != null) {
            mViewStateManager.onPageSwitching(newPage, newPageIndex);
        }
    }

    @Override
    public void onPageSwitched(View newPage, int newPageIndex) {
        boolean showingStatusWidget = false;
        boolean showingStatusWidget = false;
        if (newPage instanceof ViewGroup) {
        if (newPage instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) newPage;
            ViewGroup vg = (ViewGroup) newPage;
@@ -158,7 +165,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
            }
            }
        }
        }
        if (mViewStateManager != null) {
        if (mViewStateManager != null) {
            mViewStateManager.onPageSwitch(newPage, newPageIndex);
            mViewStateManager.onPageSwitched(newPage, newPageIndex);
        }
        }
    }
    }


@@ -179,7 +186,7 @@ public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwit
    @Override
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
    public boolean onTouchEvent(MotionEvent ev) {
        KeyguardWidgetFrame currentWidgetPage = getWidgetPageAt(getCurrentPage());
        KeyguardWidgetFrame currentWidgetPage = getWidgetPageAt(getCurrentPage());
        if (currentWidgetPage != null && currentWidgetPage.onUserInteraction(ev.getAction())) {
        if (currentWidgetPage != null && currentWidgetPage.onUserInteraction(ev)) {
            return true;
            return true;
        }
        }
        return super.onTouchEvent(ev);
        return super.onTouchEvent(ev);
Loading