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

Commit 583fcb91 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Dispatch screen state change events to Views Bug #6120957"

parents a0b29f55 bb9908b8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -23374,6 +23374,7 @@ package android.view {
    method public void onResolvedTextDirectionReset();
    method protected void onRestoreInstanceState(android.os.Parcelable);
    method protected android.os.Parcelable onSaveInstanceState();
    method public void onScreenStateChanged(int);
    method protected void onScrollChanged(int, int, int, int);
    method protected boolean onSetAlpha(int);
    method protected void onSizeChanged(int, int, int, int);
@@ -23583,6 +23584,8 @@ package android.view {
    field public static final android.util.Property ROTATION_Y;
    field public static final android.util.Property SCALE_X;
    field public static final android.util.Property SCALE_Y;
    field public static final int SCREEN_STATE_OFF = 2; // 0x2
    field public static final int SCREEN_STATE_ON = 1; // 0x1
    field public static final int SCROLLBARS_INSIDE_INSET = 16777216; // 0x1000000
    field public static final int SCROLLBARS_INSIDE_OVERLAY = 0; // 0x0
    field public static final int SCROLLBARS_OUTSIDE_INSET = 50331648; // 0x3000000
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ oneway interface IWindow {
            boolean reportDraw, in Configuration newConfig);
    void dispatchAppVisibility(boolean visible);
    void dispatchGetNewSurface();
    void dispatchScreenStatus(boolean on);
    void dispatchScreenState(boolean on);

    /**
     * Tell the window that it is either gaining or losing focus.  Keep it up
+33 −0
Original line number Diff line number Diff line
@@ -1993,6 +1993,20 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
    public static final int FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS = 0x00000004;
    /**
     * Indicates that the screen has changed state and is now off.
     *
     * @see #onScreenStateChanged(int)
     */
    public static final int SCREEN_STATE_OFF = 0x0;
    /**
     * Indicates that the screen has changed state and is now on.
     *
     * @see #onScreenStateChanged(int 
     */
    public static final int SCREEN_STATE_ON = 0x1;
    /**
     * Controls the over-scroll mode for this view.
     * See {@link #overScrollBy(int, int, int, int, int, int, int, int, boolean)},
@@ -9603,6 +9617,25 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        }
    }
    /**
     * @see #onScreenStateChanged(int)
     */
    void dispatchScreenStateChanged(int screenState) {
        onScreenStateChanged(screenState);
    }
    /**
     * This method is called whenever the state of the screen this view is
     * attached to changes. A state change will usually occurs when the screen
     * turns on or off (whether it happens automatically or the user does it
     * manually.)
     *
     * @param screenState The new state of the screen. Can be either
     *                    {@link #SCREEN_STATE_ON} or {@link #SCREEN_STATE_OFF}
     */
    public void onScreenStateChanged(int screenState) {
    }
    /**
     * Resolve and cache the layout direction. LTR is set initially. This is implicitly supposing
     * that the parent directionality can and will be resolved before its children.
+11 −0
Original line number Diff line number Diff line
@@ -2253,6 +2253,17 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        }
    }

    @Override
    void dispatchScreenStateChanged(int screenState) {
        super.dispatchScreenStateChanged(screenState);

        final int count = mChildrenCount;
        final View[] children = mChildren;
        for (int i = 0; i < count; i++) {
            children[i].dispatchScreenStateChanged(screenState);
        }
    }

    @Override
    boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) {
        boolean handled = super.dispatchPopulateAccessibilityEventInternal(event);
+12 −9
Original line number Diff line number Diff line
@@ -761,9 +761,12 @@ public final class ViewRootImpl implements ViewParent,
        scheduleTraversals();
    }

    void handleScreenStatusChange(boolean on) {
    void handleScreenStateChange(boolean on) {
        if (on != mAttachInfo.mScreenOn) {
            mAttachInfo.mScreenOn = on;
            if (mView != null) {
                mView.dispatchScreenStateChanged(on ? View.SCREEN_STATE_ON : View.SCREEN_STATE_OFF);
            }
            if (on) {
                mFullRedrawNeeded = true;
                scheduleTraversals();
@@ -2500,7 +2503,7 @@ public final class ViewRootImpl implements ViewParent,
    private final static int MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_VIEW_ID = 21;
    private final static int MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_TEXT = 22;
    private final static int MSG_PROCESS_INPUT_EVENTS = 23;
    private final static int MSG_DISPATCH_SCREEN_STATUS = 24;
    private final static int MSG_DISPATCH_SCREEN_STATE = 24;

    final class ViewRootHandler extends Handler {
        @Override
@@ -2757,9 +2760,9 @@ public final class ViewRootImpl implements ViewParent,
                        .findAccessibilityNodeInfosByTextUiThread(msg);
                }
            } break;
            case MSG_DISPATCH_SCREEN_STATUS: {
            case MSG_DISPATCH_SCREEN_STATE: {
                if (mView != null) {
                    handleScreenStatusChange(msg.arg1 == 1);
                    handleScreenStateChange(msg.arg1 == 1);
                }
            } break;
            }
@@ -4142,8 +4145,8 @@ public final class ViewRootImpl implements ViewParent,
        mHandler.sendMessage(msg);
    }

    public void dispatchScreenStatusChange(boolean on) {
        Message msg = mHandler.obtainMessage(MSG_DISPATCH_SCREEN_STATUS);
    public void dispatchScreenStateChange(boolean on) {
        Message msg = mHandler.obtainMessage(MSG_DISPATCH_SCREEN_STATE);
        msg.arg1 = on ? 1 : 0;
        mHandler.sendMessage(msg);
    }
@@ -4349,10 +4352,10 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        public void dispatchScreenStatus(boolean on) {
        public void dispatchScreenState(boolean on) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (viewAncestor != null) {
                viewAncestor.dispatchScreenStatusChange(on);
                viewAncestor.dispatchScreenStateChange(on);
            }
        }

Loading