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

Commit 3462f7a7 authored by Winson Chung's avatar Winson Chung
Browse files

Add mechanism to update the CloseGuard callsite of a SurfaceControl

- When a SurfaceControl is unparceled in a new process, the
  CloseGuard call site defaults to "readFromParcel" which does not
  provide much useful information in narrowing down which
  SurfaceControl was not explicitly released within the process
- This CL updates the call sites for some known fw classes and
  also tags specific areas in the Shell where we receive
  SurfaceControls from the system

Bug: 266978825
Test: Presubmit
Change-Id: I77d1554e62aa6f9f389b42281d825478f08f825c
parent 0973bdda
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -619,10 +619,11 @@ public class DragEvent implements Parcelable {
            }
            if (in.readInt() != 0) {
                event.mDragSurface = SurfaceControl.CREATOR.createFromParcel(in);
                event.mDragSurface.setUnreleasedWarningCallSite("DragEvent");
            }
            if (in.readInt() != 0) {
                event.mDragAndDropPermissions =
                        IDragAndDropPermissions.Stub.asInterface(in.readStrongBinder());;
                        IDragAndDropPermissions.Stub.asInterface(in.readStrongBinder());
            }
            return event;
        }
+6 −0
Original line number Diff line number Diff line
@@ -296,6 +296,9 @@ public class RemoteAnimationTarget implements Parcelable {
        taskId = in.readInt();
        mode = in.readInt();
        leash = in.readTypedObject(SurfaceControl.CREATOR);
        if (leash != null) {
            leash.setUnreleasedWarningCallSite("RemoteAnimationTarget[leash]");
        }
        isTranslucent = in.readBoolean();
        clipRect = in.readTypedObject(Rect.CREATOR);
        contentInsets = in.readTypedObject(Rect.CREATOR);
@@ -307,6 +310,9 @@ public class RemoteAnimationTarget implements Parcelable {
        windowConfiguration = in.readTypedObject(WindowConfiguration.CREATOR);
        isNotInRecents = in.readBoolean();
        startLeash = in.readTypedObject(SurfaceControl.CREATOR);
        if (startLeash != null) {
            startLeash.setUnreleasedWarningCallSite("RemoteAnimationTarget[startLeash]");
        }
        startBounds = in.readTypedObject(Rect.CREATOR);
        taskInfo = in.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR);
        allowEnterPip = in.readBoolean();
+14 −0
Original line number Diff line number Diff line
@@ -1289,6 +1289,20 @@ public final class SurfaceControl implements Parcelable {
        sDebugUsageAfterRelease = debug;
    }

    /**
     * Provides more information to show about the source of this SurfaceControl if it is finalized
     * without being released. This is primarily intended for callers to update the call site after
     * receiving a SurfaceControl from another process, which would otherwise get a generic default
     * call site.
     * @hide
     */
    public void setUnreleasedWarningCallSite(@NonNull String callsite) {
        if (!isValid()) {
            return;
        }
        mCloseGuard.openWithCallSite("release", callsite);
    }

    /**
     * Checks whether two {@link SurfaceControl} objects represent the same surface.
     *
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ public class SurfaceControlViewHost {
        private SurfacePackage(Parcel in) {
            mSurfaceControl = new SurfaceControl();
            mSurfaceControl.readFromParcel(in);
            mSurfaceControl.setUnreleasedWarningCallSite("SurfacePackage(Parcel)");
            mAccessibilityEmbeddedConnection = IAccessibilityEmbeddedConnection.Stub.asInterface(
                    in.readStrongBinder());
            mInputToken = in.readStrongBinder();
+1 −0
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ public final class TransitionInfo implements Parcelable {
        in.readTypedList(mChanges, Change.CREATOR);
        mRootLeash = new SurfaceControl();
        mRootLeash.readFromParcel(in);
        mRootLeash.setUnreleasedWarningCallSite("TransitionInfo");
        mRootOffset.readFromParcel(in);
        mOptions = in.readTypedObject(AnimationOptions.CREATOR);
    }
Loading