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

Commit c463e06e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Idcc4cdd4,I75add6a9,I2aeda867,I1ff912c4

* changes:
  WindowManager: Include sigil in RemoteSurfaceTrace format.
  Pass SurfaceTrace through WM command in binary format.
  Log transaction state to RemoteSurfaceTrace.
  WindowManager RemoteSurfaceTrace infrastructure
parents 6bb05c21 b941108d
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -21,16 +21,22 @@ package com.android.commands.wm;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.util.AndroidException;
import android.util.DisplayMetrics;
import android.system.Os;
import android.view.Display;
import android.view.IWindowManager;
import com.android.internal.os.BaseCommand;

import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.PrintStream;
import java.lang.Runtime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -69,7 +75,9 @@ public class Wm extends BaseCommand {
                "wm screen-capture: enable/disable screen capture.\n" +
                "\n" +
                "wm dismiss-keyguard: dismiss the keyguard, prompting the user for auth if " +
                "necessary.\n"
                "necessary.\n" +
                "\n" +
                "wm surface-trace: log surface commands to stdout in a binary format.\n"
                );
    }

@@ -96,12 +104,29 @@ public class Wm extends BaseCommand {
            runSetScreenCapture();
        } else if (op.equals("dismiss-keyguard")) {
            runDismissKeyguard();
        } else if (op.equals("surface-trace")) {
            runSurfaceTrace();
        } else {
            showError("Error: unknown command '" + op + "'");
            return;
        }
    }

    private void runSurfaceTrace() throws Exception {
        ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(FileDescriptor.out);
        mWm.enableSurfaceTrace(pfd);

        try {
            // No one is going to wake us up, we are just waiting on SIGINT. Otherwise
            // the WM can happily continue writing to our stdout.
            synchronized (this) {
                this.wait();
            }
        } finally {
            mWm.disableSurfaceTrace();
        }
    }

    private void runSetScreenCapture() throws Exception {
        String userIdStr = nextArg();
        String enableStr = nextArg();
+8 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IRemoteCallback;
import android.os.ParcelFileDescriptor;
import android.view.IApplicationToken;
import android.view.IAppTransitionAnimationSpecsFuture;
import android.view.IDockedStackListener;
@@ -255,6 +256,13 @@ interface IWindowManager
     */
    void setScreenCaptureDisabled(int userId, boolean disabled);

    /**
     * Testing and debugging infrastructure for writing surface events
     * to given FD. See RemoteSurfaceTrace.java or Wm.java for format.
     */
    void enableSurfaceTrace(in ParcelFileDescriptor fd);
    void disableSurfaceTrace();

    /**
     * Cancels the window transitions for the given task.
     */
+11 −0
Original line number Diff line number Diff line
@@ -308,6 +308,17 @@ public class SurfaceControl {
        mCloseGuard.open("release");
    }

    // This is a transfer constructor, useful for transferring a live SurfaceControl native
    // object to another Java wrapper which could have some different behavior, e.g.
    // event logging.
    public SurfaceControl(SurfaceControl other) {
        mName = other.mName;
        mNativeObject = other.mNativeObject;
        other.mCloseGuard.close();
        other.mNativeObject = 0;
        mCloseGuard.open("release");
    }

    @Override
    protected void finalize() throws Throwable {
        try {
+4 −4
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class DimLayer {
    }

    private void constructSurface(WindowManagerService service) {
        SurfaceControl.openTransaction();
        service.openSurfaceTransaction();
        try {
            if (DEBUG_SURFACE_TRACE) {
                mDimSurface = new WindowSurfaceController.SurfaceTrace(service.mFxSession,
@@ -116,7 +116,7 @@ public class DimLayer {
        } catch (Exception e) {
            Slog.e(TAG_WM, "Exception creating Dim surface", e);
        } finally {
            SurfaceControl.closeTransaction();
            service.closeSurfaceTransaction();
        }
    }

@@ -227,12 +227,12 @@ public class DimLayer {
        mBounds.set(bounds);
        if (isDimming() && !mLastBounds.equals(bounds)) {
            try {
                SurfaceControl.openTransaction();
                mService.openSurfaceTransaction();
                adjustBounds();
            } catch (RuntimeException e) {
                Slog.w(TAG, "Failure setting size", e);
            } finally {
                SurfaceControl.closeTransaction();
                mService.closeSurfaceTransaction();
            }
        }
    }
+15 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.view.Surface;
import android.view.animation.Animation;
import com.android.internal.util.FastPrintWriter;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
@@ -1178,4 +1179,18 @@ class DisplayContent {
            taskForResize = null;
        }
    }

    void enableSurfaceTrace(FileDescriptor fd) {
        for (int i = mWindows.size()  - 1; i >= 0; i--) {
            final WindowState win = mWindows.get(i);
            win.mWinAnimator.enableSurfaceTrace(fd);
        }
    }

    void disableSurfaceTrace() {
        for (int i = mWindows.size()  - 1; i >= 0; i--) {
            final WindowState win = mWindows.get(i);
            win.mWinAnimator.disableSurfaceTrace();
        }
    }
}
Loading