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

Commit aabd9c23 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #6634325: View.setKeepScreenOn and..." into jb-dev

parents f958732b 9d090891
Loading
Loading
Loading
Loading
+21 −4
Original line number Original line Diff line number Diff line
@@ -229,6 +229,7 @@ public final class ViewRootImpl implements ViewParent,
    boolean mWindowsAnimating;
    boolean mWindowsAnimating;
    boolean mIsDrawing;
    boolean mIsDrawing;
    int mLastSystemUiVisibility;
    int mLastSystemUiVisibility;
    int mClientWindowLayoutFlags;


    // Pool of queued input events.
    // Pool of queued input events.
    private static final int MAX_QUEUED_INPUT_EVENT_POOL_SIZE = 10;
    private static final int MAX_QUEUED_INPUT_EVENT_POOL_SIZE = 10;
@@ -485,6 +486,8 @@ public final class ViewRootImpl implements ViewParent,
                mFallbackEventHandler.setView(view);
                mFallbackEventHandler.setView(view);
                mWindowAttributes.copyFrom(attrs);
                mWindowAttributes.copyFrom(attrs);
                attrs = mWindowAttributes;
                attrs = mWindowAttributes;
                // Keep track of the actual window flags supplied by the client.
                mClientWindowLayoutFlags = attrs.flags;


                setAccessibilityFocusedHost(null);
                setAccessibilityFocusedHost(null);


@@ -760,6 +763,8 @@ public final class ViewRootImpl implements ViewParent,
    void setLayoutParams(WindowManager.LayoutParams attrs, boolean newView) {
    void setLayoutParams(WindowManager.LayoutParams attrs, boolean newView) {
        synchronized (this) {
        synchronized (this) {
            int oldSoftInputMode = mWindowAttributes.softInputMode;
            int oldSoftInputMode = mWindowAttributes.softInputMode;
            // Keep track of the actual window flags supplied by the client.
            mClientWindowLayoutFlags = attrs.flags;
            // preserve compatible window flag if exists.
            // preserve compatible window flag if exists.
            int compatibleWindowFlag =
            int compatibleWindowFlag =
                mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
                mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
@@ -769,6 +774,8 @@ public final class ViewRootImpl implements ViewParent,
            mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
            mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
            mWindowAttributes.flags |= compatibleWindowFlag;
            mWindowAttributes.flags |= compatibleWindowFlag;


            applyKeepScreenOnFlag(mWindowAttributes);

            if (newView) {
            if (newView) {
                mSoftInputMode = attrs.softInputMode;
                mSoftInputMode = attrs.softInputMode;
                requestLayout();
                requestLayout();
@@ -1000,6 +1007,18 @@ public final class ViewRootImpl implements ViewParent,
        }
        }
    }
    }


    private void applyKeepScreenOnFlag(WindowManager.LayoutParams params) {
        // Update window's global keep screen on flag: if a view has requested
        // that the screen be kept on, then it is always set; otherwise, it is
        // set to whatever the client last requested for the global state.
        if (mAttachInfo.mKeepScreenOn) {
            params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
        } else {
            params.flags = (params.flags&~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
                    | (mClientWindowLayoutFlags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    }

    private boolean collectViewAttributes() {
    private boolean collectViewAttributes() {
        final View.AttachInfo attachInfo = mAttachInfo;
        final View.AttachInfo attachInfo = mAttachInfo;
        if (attachInfo.mRecomputeGlobalAttributes) {
        if (attachInfo.mRecomputeGlobalAttributes) {
@@ -1017,9 +1036,7 @@ public final class ViewRootImpl implements ViewParent,
                    || attachInfo.mSystemUiVisibility != oldVis
                    || attachInfo.mSystemUiVisibility != oldVis
                    || attachInfo.mHasSystemUiListeners != oldHasSystemUiListeners) {
                    || attachInfo.mHasSystemUiListeners != oldHasSystemUiListeners) {
                WindowManager.LayoutParams params = mWindowAttributes;
                WindowManager.LayoutParams params = mWindowAttributes;
                if (attachInfo.mKeepScreenOn) {
                applyKeepScreenOnFlag(params);
                    params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
                }
                params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
                params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
                params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
                params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
                mView.dispatchWindowSystemUiVisiblityChanged(attachInfo.mSystemUiVisibility);
                mView.dispatchWindowSystemUiVisiblityChanged(attachInfo.mSystemUiVisibility);