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

Commit 2eb62737 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Cleanup window callbacks locking" into nyc-dev

parents a3e8bf3b 16b63192
Loading
Loading
Loading
Loading
+21 −25
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Scroller;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
import com.android.internal.policy.PhoneFallbackEventHandler;
@@ -154,7 +155,12 @@ public final class ViewRootImpl implements ViewParent,

    static final ArrayList<ComponentCallbacks> sConfigCallbacks = new ArrayList();

    final ArrayList<WindowCallbacks> mWindowCallbacks = new ArrayList();
    /**
     * This list must only be modified by the main thread, so a lock is only needed when changing
     * the list or when accessing the list from a non-main thread.
     */
    @GuardedBy("mWindowCallbacks")
    final ArrayList<WindowCallbacks> mWindowCallbacks = new ArrayList<>();
    final Context mContext;
    final IWindowSession mWindowSession;
    final Display mDisplay;
@@ -2437,12 +2443,10 @@ public final class ViewRootImpl implements ViewParent,
    @Override
    public void onHardwarePostDraw(DisplayListCanvas canvas) {
        drawAccessibilityFocusedDrawableIfNeeded(canvas);
        synchronized (mWindowCallbacks) {
        for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
            mWindowCallbacks.get(i).onPostDraw(canvas);
        }
    }
    }

    /**
     * @hide
@@ -7092,12 +7096,10 @@ public final class ViewRootImpl implements ViewParent,
            Rect stableInsets, int resizeMode) {
        if (!mDragResizing) {
            mDragResizing = true;
            synchronized (mWindowCallbacks) {
            for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
                mWindowCallbacks.get(i).onWindowDragResizeStart(initialBounds, fullscreen,
                        systemInsets, stableInsets, resizeMode);
            }
            }
            mFullRedrawNeeded = true;
        }
    }
@@ -7108,25 +7110,21 @@ public final class ViewRootImpl implements ViewParent,
    private void endDragResizing() {
        if (mDragResizing) {
            mDragResizing = false;
            synchronized (mWindowCallbacks) {
            for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
                mWindowCallbacks.get(i).onWindowDragResizeEnd();
            }
            }
            mFullRedrawNeeded = true;
        }
    }

    private boolean updateContentDrawBounds() {
        boolean updated = false;
        synchronized (mWindowCallbacks) {
        for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
            updated |= mWindowCallbacks.get(i).onContentDrawn(
                    mWindowAttributes.surfaceInsets.left,
                    mWindowAttributes.surfaceInsets.top,
                    mWidth, mHeight);
        }
        }
        return updated | (mDragResizing && mReportNextDraw);
    }

@@ -7134,12 +7132,10 @@ public final class ViewRootImpl implements ViewParent,
        if (mReportNextDraw) {
            mWindowDrawCountDown = new CountDownLatch(mWindowCallbacks.size());
        }
        synchronized (mWindowCallbacks) {
        for (int i = mWindowCallbacks.size() - 1; i >= 0; i--) {
            mWindowCallbacks.get(i).onRequestDraw(mReportNextDraw);
        }
    }
    }

    /**
     * Tells this instance that its corresponding activity has just relaunched. In this case, we