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

Commit 68e5c9e9 authored by Robert Carr's avatar Robert Carr
Browse files

Log transaction state to RemoteSurfaceTrace.

Test: cts-tradefed run singleCommand cts -o --module CtsWindowManagerHostTestCases --test android.server.cts.SurfaceViewMovementTests#testSurfaceMovesWithParent
Change-Id: I2aeda867f0071bf6ac715153ab842a9f16cafa44
parent 3b716249
Loading
Loading
Loading
Loading
+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();
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ public class DockedStackDividerController implements DimLayerUser {
    }

    void setResizeDimLayer(boolean visible, int targetStackId, float alpha) {
        SurfaceControl.openTransaction();
        mService.openSurfaceTransaction();
        final TaskStack stack = mDisplayContent.mService.mStackIdToStack.get(targetStackId);
        final TaskStack dockedStack = mDisplayContent.getDockedStackLocked();
        boolean visibleAndValid = visible && stack != null && dockedStack != null;
@@ -482,7 +482,7 @@ public class DockedStackDividerController implements DimLayerUser {
        if (!visibleAndValid) {
            mDimLayer.hide();
        }
        SurfaceControl.closeTransaction();
        mService.closeSurfaceTransaction();
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -432,14 +432,14 @@ class DragState {
        // Move the surface to the given touch
        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
                TAG_WM, ">>> OPEN TRANSACTION notifyMoveLw");
        SurfaceControl.openTransaction();
        mService.openSurfaceTransaction();
        try {
            mSurfaceControl.setPosition(x - mThumbOffsetX, y - mThumbOffsetY);
            if (SHOW_TRANSACTIONS) Slog.i(TAG_WM, "  DRAG "
                    + mSurfaceControl + ": pos=(" +
                    (int)(x - mThumbOffsetX) + "," + (int)(y - mThumbOffsetY) + ")");
        } finally {
            SurfaceControl.closeTransaction();
            mService.closeSurfaceTransaction();
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
                    TAG_WM, "<<< CLOSE TRANSACTION notifyMoveLw");
        }
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm;

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.DataOutputStream;

import android.util.Slog;
import android.os.Debug;

// Counterpart to remote surface trace for events which are not tied to a particular surface.
class RemoteEventTrace {
    private static final String TAG = "RemoteEventTrace";
    private final WindowManagerService mService;
    private final DataOutputStream mOut;

    RemoteEventTrace(WindowManagerService service, FileDescriptor fd) {
        mService = service;
        mOut = new DataOutputStream(new FileOutputStream(fd, false));
    }

    void openSurfaceTransaction() {
        try {
            mOut.writeUTF("OpenTransaction");
        } catch (Exception e) {
            logException(e);
            mService.disableSurfaceTrace();
        }
    }

    void closeSurfaceTransaction() {
        try {
            mOut.writeUTF("CloseTransaction");
        } catch (Exception e) {
            logException(e);
            mService.disableSurfaceTrace();
        }
    }

    static void logException(Exception e) {
        Slog.i(TAG, "Exception writing to SurfaceTrace (client vanished?): " + e.toString());
    }
}
+7 −4
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ class RemoteSurfaceTrace extends SurfaceControl {

    @Override
    public void setWindowCrop(Rect crop) {
        writeRectEvent("WindowCrop", crop);
        writeRectEvent("Crop", crop);
        super.setWindowCrop(crop);
    }

@@ -107,13 +107,13 @@ class RemoteSurfaceTrace extends SurfaceControl {

    @Override
    public void hide() {
        writeEvent("hide");
        writeEvent("Hide");
        super.hide();
    }

    @Override
    public void show() {
        writeEvent("show");
        writeEvent("Show");
        super.show();
    }

@@ -122,6 +122,7 @@ class RemoteSurfaceTrace extends SurfaceControl {
            mOut.writeUTF(tag);
            mOut.writeUTF(mWindow.getWindowTag().toString());
        } catch (Exception e) {
            RemoteEventTrace.logException(e);
            mService.disableSurfaceTrace();
        }
    }
@@ -134,6 +135,7 @@ class RemoteSurfaceTrace extends SurfaceControl {
                mOut.writeInt(value);
            }
        } catch (Exception e) {
            RemoteEventTrace.logException(e);
            mService.disableSurfaceTrace();
        }
    }
@@ -146,11 +148,12 @@ class RemoteSurfaceTrace extends SurfaceControl {
                mOut.writeFloat(value);
            }
        } catch (Exception e) {
            RemoteEventTrace.logException(e);
            mService.disableSurfaceTrace();
        }
    }

    private void writeRectEvent(String tag, Rect value) {
        writeFloatEvent(tag, value.top, value.left, value.right, value.bottom);
        writeFloatEvent(tag, value.left, value.top, value.right, value.bottom);
    }
}
Loading