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

Commit b961cd2c authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Don't report a resize unless the window's surface actually changed.

Change-Id: I133cf8e417753dba60d23a3bfc1c84ace983b335
parent 0f5d8441
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,7 @@ import java.util.List;
 */
 */
final class ActivityStack {
final class ActivityStack {
    static final String TAG = ActivityManagerService.TAG;
    static final String TAG = ActivityManagerService.TAG;
    static final boolean localLOGV = ActivityManagerService.localLOGV || true;
    static final boolean localLOGV = ActivityManagerService.localLOGV;
    static final boolean DEBUG_SWITCH = ActivityManagerService.DEBUG_SWITCH;
    static final boolean DEBUG_SWITCH = ActivityManagerService.DEBUG_SWITCH;
    static final boolean DEBUG_PAUSE = ActivityManagerService.DEBUG_PAUSE;
    static final boolean DEBUG_PAUSE = ActivityManagerService.DEBUG_PAUSE;
    static final boolean DEBUG_VISBILITY = ActivityManagerService.DEBUG_VISBILITY;
    static final boolean DEBUG_VISBILITY = ActivityManagerService.DEBUG_VISBILITY;
+5 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;
package com.android.server.wm;


import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;
@@ -152,6 +153,8 @@ final class InputMonitor {
        }
        }
        mUpdateInputWindowsNeeded = false;
        mUpdateInputWindowsNeeded = false;


        if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED updateInputWindowsLw");
        
        // Populate the input window list with information about all of the windows that
        // Populate the input window list with information about all of the windows that
        // could potentially receive input.
        // could potentially receive input.
        // As an optimization, we could try to prune the list of windows but this turns
        // As an optimization, we could try to prune the list of windows but this turns
@@ -232,6 +235,8 @@ final class InputMonitor {
        // Clear the list in preparation for the next round.
        // Clear the list in preparation for the next round.
        // Also avoids keeping InputChannel objects referenced unnecessarily.
        // Also avoids keeping InputChannel objects referenced unnecessarily.
        mTempInputWindows.clear();
        mTempInputWindows.clear();
        
        if (false) Slog.d(WindowManagerService.TAG, "<<<<<<< EXITED updateInputWindowsLw");
    }
    }


    /* Notifies that the input device configuration has changed. */
    /* Notifies that the input device configuration has changed. */
+4 −2
Original line number Original line Diff line number Diff line
@@ -153,11 +153,13 @@ final class Session extends IWindowSession.Stub
            int requestedWidth, int requestedHeight, int viewFlags,
            int requestedWidth, int requestedHeight, int viewFlags,
            boolean insetsPending, Rect outFrame, Rect outContentInsets,
            boolean insetsPending, Rect outFrame, Rect outContentInsets,
            Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
            Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
        //Log.d(TAG, ">>>>>> ENTERED relayout from " + Binder.getCallingPid());
        if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from "
                + Binder.getCallingPid());
        int res = mService.relayoutWindow(this, window, attrs,
        int res = mService.relayoutWindow(this, window, attrs,
                requestedWidth, requestedHeight, viewFlags, insetsPending,
                requestedWidth, requestedHeight, viewFlags, insetsPending,
                outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface);
                outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface);
        //Log.d(TAG, "<<<<<< EXITING relayout to " + Binder.getCallingPid());
        if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to "
                + Binder.getCallingPid());
        return res;
        return res;
    }
    }


+38 −38
Original line number Original line Diff line number Diff line
@@ -7817,6 +7817,7 @@ public class WindowManagerService extends IWindowManager.Stub
                            TAG, "Placing surface #" + i + " " + w.mSurface
                            TAG, "Placing surface #" + i + " " + w.mSurface
                            + ": new=" + w.mShownFrame);
                            + ": new=" + w.mShownFrame);


                    if (w.mSurface != null) {
                        int width, height;
                        int width, height;
                        if ((w.mAttrs.flags & w.mAttrs.FLAG_SCALED) != 0) {
                        if ((w.mAttrs.flags & w.mAttrs.FLAG_SCALED) != 0) {
                            // for a scaled surface, we just want to use
                            // for a scaled surface, we just want to use
@@ -7828,7 +7829,18 @@ public class WindowManagerService extends IWindowManager.Stub
                            height = w.mCompatFrame.height();
                            height = w.mCompatFrame.height();
                        }
                        }


                    if (w.mSurface != null) {
                        if (width < 1) {
                            width = 1;
                        }
                        if (height < 1) {
                            height = 1;
                        }
                        final boolean surfaceResized = w.mSurfaceW != width || w.mSurfaceH != height;
                        if (surfaceResized) {
                            w.mSurfaceW = width;
                            w.mSurfaceH = height;
                        }

                        if (w.mSurfaceX != w.mShownFrame.left
                        if (w.mSurfaceX != w.mShownFrame.left
                                || w.mSurfaceY != w.mShownFrame.top) {
                                || w.mSurfaceY != w.mShownFrame.top) {
                            try {
                            try {
@@ -7848,21 +7860,11 @@ public class WindowManagerService extends IWindowManager.Stub
                            }
                            }
                        }
                        }


                        if (width < 1) {
                        if (surfaceResized) {
                            width = 1;
                        }
                        if (height < 1) {
                            height = 1;
                        }

                        if (w.mSurfaceW != width || w.mSurfaceH != height) {
                            try {
                            try {
                                if (SHOW_TRANSACTIONS) logSurface(w,
                                if (SHOW_TRANSACTIONS) logSurface(w,
                                        "SIZE " + w.mShownFrame.width() + "x"
                                        "SIZE " + width + "x" + height, null);
                                        + w.mShownFrame.height(), null);
                                w.mSurfaceResized = true;
                                w.mSurfaceResized = true;
                                w.mSurfaceW = width;
                                w.mSurfaceH = height;
                                w.mSurface.setSize(width, height);
                                w.mSurface.setSize(width, height);
                            } catch (RuntimeException e) {
                            } catch (RuntimeException e) {
                                // If something goes wrong with the surface (such
                                // If something goes wrong with the surface (such
@@ -7878,9 +7880,9 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                    }


                    if (!w.mAppFreezing && w.mLayoutSeq == mLayoutSeq) {
                    if (!w.mAppFreezing && w.mLayoutSeq == mLayoutSeq) {
                        w.mContentInsetsChanged =
                        w.mContentInsetsChanged |=
                            !w.mLastContentInsets.equals(w.mContentInsets);
                            !w.mLastContentInsets.equals(w.mContentInsets);
                        w.mVisibleInsetsChanged =
                        w.mVisibleInsetsChanged |=
                            !w.mLastVisibleInsets.equals(w.mVisibleInsets);
                            !w.mLastVisibleInsets.equals(w.mVisibleInsets);
                        boolean configChanged =
                        boolean configChanged =
                            w.mConfiguration != mCurConfiguration
                            w.mConfiguration != mCurConfiguration
@@ -7892,24 +7894,20 @@ public class WindowManagerService extends IWindowManager.Stub
                        }
                        }
                        if (localLOGV) Slog.v(TAG, "Resizing " + w
                        if (localLOGV) Slog.v(TAG, "Resizing " + w
                                + ": configChanged=" + configChanged
                                + ": configChanged=" + configChanged
                                + " last=" + w.mLastCompatFrame + " frame=" + w.mCompatFrame);
                                + " last=" + w.mLastFrame + " frame=" + w.mFrame);
                        boolean frameChanged = !w.mLastCompatFrame.equals(w.mCompatFrame);
                        w.mLastFrame.set(w.mFrame);
                        if (frameChanged
                        if (w.mContentInsetsChanged
                                || w.mContentInsetsChanged
                                || w.mVisibleInsetsChanged
                                || w.mVisibleInsetsChanged
                                || w.mSurfaceResized
                                || w.mSurfaceResized
                                || configChanged) {
                                || configChanged) {
                            if (DEBUG_RESIZE || DEBUG_ORIENTATION) {
                            if (DEBUG_RESIZE || DEBUG_ORIENTATION) {
                                Slog.v(TAG, "Resize reasons: "
                                Slog.v(TAG, "Resize reasons: "
                                        + "frameChanged=" + frameChanged
                                        + " contentInsetsChanged=" + w.mContentInsetsChanged
                                        + " contentInsetsChanged=" + w.mContentInsetsChanged
                                        + " visibleInsetsChanged=" + w.mVisibleInsetsChanged
                                        + " visibleInsetsChanged=" + w.mVisibleInsetsChanged
                                        + " surfaceResized=" + w.mSurfaceResized
                                        + " surfaceResized=" + w.mSurfaceResized
                                        + " configChanged=" + configChanged);
                                        + " configChanged=" + configChanged);
                            }
                            }


                            w.mLastFrame.set(w.mFrame);
                            w.mLastCompatFrame.set(w.mCompatFrame);
                            w.mLastContentInsets.set(w.mContentInsets);
                            w.mLastContentInsets.set(w.mContentInsets);
                            w.mLastVisibleInsets.set(w.mVisibleInsets);
                            w.mLastVisibleInsets.set(w.mVisibleInsets);
                            // If the screen is currently frozen, then keep
                            // If the screen is currently frozen, then keep
@@ -7944,9 +7942,12 @@ public class WindowManagerService extends IWindowManager.Stub
                                    w.mAppToken.allDrawn = false;
                                    w.mAppToken.allDrawn = false;
                                }
                                }
                            }
                            }
                            if (!mResizingWindows.contains(w)) {
                                if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
                                if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
                                    "Resizing window " + w + " to " + w.mCompatFrame);
                                        "Resizing window " + w + " to " + w.mSurfaceW
                                        + "x" + w.mSurfaceH);
                                mResizingWindows.add(w);
                                mResizingWindows.add(w);
                            }
                        } else if (w.mOrientationChanging) {
                        } else if (w.mOrientationChanging) {
                            if (!w.mDrawPending && !w.mCommitDrawPending) {
                            if (!w.mDrawPending && !w.mCommitDrawPending) {
                                if (DEBUG_ORIENTATION) Slog.v(TAG,
                                if (DEBUG_ORIENTATION) Slog.v(TAG,
@@ -8241,13 +8242,12 @@ public class WindowManagerService extends IWindowManager.Stub
                    if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION)
                    if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION)
                            && configChanged) {
                            && configChanged) {
                        Slog.i(TAG, "Sending new config to window " + win + ": "
                        Slog.i(TAG, "Sending new config to window " + win + ": "
                                + win.mCompatFrame.width() + "x" + win.mCompatFrame.height()
                                + win.mSurfaceW + "x" + win.mSurfaceH
                                + " / " + mCurConfiguration + " / 0x"
                                + " / " + mCurConfiguration + " / 0x"
                                + Integer.toHexString(diff));
                                + Integer.toHexString(diff));
                    }
                    }
                    win.mConfiguration = mCurConfiguration;
                    win.mConfiguration = mCurConfiguration;
                    win.mClient.resized(win.mCompatFrame.width(),
                    win.mClient.resized(win.mSurfaceW, win.mSurfaceH, win.mLastContentInsets,
                            win.mCompatFrame.height(), win.mLastContentInsets,
                            win.mLastVisibleInsets, win.mDrawPending,
                            win.mLastVisibleInsets, win.mDrawPending,
                            configChanged ? win.mConfiguration : null);
                            configChanged ? win.mConfiguration : null);
                    win.mContentInsetsChanged = false;
                    win.mContentInsetsChanged = false;
+1 −6
Original line number Original line Diff line number Diff line
@@ -111,7 +111,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
     * applied).
     * applied).
     */
     */
    final Rect mShownFrame = new Rect();
    final Rect mShownFrame = new Rect();
    final Rect mLastShownFrame = new Rect();


    /**
    /**
     * Set when we have changed the size of the surface, to know that
     * Set when we have changed the size of the surface, to know that
@@ -182,7 +181,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    // Frame that is scaled to the application's coordinate space when in
    // Frame that is scaled to the application's coordinate space when in
    // screen size compatibility mode.
    // screen size compatibility mode.
    final Rect mCompatFrame = new Rect();
    final Rect mCompatFrame = new Rect();
    final Rect mLastCompatFrame = new Rect();


    final Rect mContainingFrame = new Rect();
    final Rect mContainingFrame = new Rect();
    final Rect mDisplayFrame = new Rect();
    final Rect mDisplayFrame = new Rect();
@@ -1584,15 +1582,12 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        }
        }
        pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
        pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
        pw.print(prefix); pw.print("mShownFrame=");
        pw.print(prefix); pw.print("mShownFrame=");
                mShownFrame.printShortString(pw);
                mShownFrame.printShortString(pw); pw.println();
                pw.print(" last="); mLastShownFrame.printShortString(pw);
                pw.println();
        pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
        pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
                pw.print(" last="); mLastFrame.printShortString(pw);
                pw.print(" last="); mLastFrame.printShortString(pw);
                pw.println();
                pw.println();
        if (mEnforceSizeCompat) {
        if (mEnforceSizeCompat) {
            pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
            pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
                    pw.print(" last="); mLastCompatFrame.printShortString(pw);
                    pw.println();
                    pw.println();
        }
        }
        pw.print(prefix); pw.print("mContainingFrame=");
        pw.print(prefix); pw.print("mContainingFrame=");