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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public class RootDisplayAreaOrganizer extends DisplayAreaOrganizer {
|
||||
+ " mDisplayAreasInfo.get():" + mDisplayAreasInfo.get(displayId));
|
||||
}
|
||||
|
||||
leash.setUnreleasedWarningCallSite("RootDisplayAreaOrganizer.onDisplayAreaAppeared");
|
||||
mDisplayAreasInfo.put(displayId, displayAreaInfo);
|
||||
mLeashes.put(displayId, leash);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {
|
||||
+ " mDisplayAreasInfo.get():" + mDisplayAreasInfo.get(displayId));
|
||||
}
|
||||
|
||||
leash.setUnreleasedWarningCallSite(
|
||||
"RootTaskDisplayAreaOrganizer.onDisplayAreaAppeared");
|
||||
mDisplayAreasInfo.put(displayId, displayAreaInfo);
|
||||
mLeashes.put(displayId, leash);
|
||||
|
||||
|
||||
@@ -464,6 +464,9 @@ public class ShellTaskOrganizer extends TaskOrganizer implements
|
||||
|
||||
@Override
|
||||
public void onTaskAppeared(RunningTaskInfo taskInfo, SurfaceControl leash) {
|
||||
if (leash != null) {
|
||||
leash.setUnreleasedWarningCallSite("ShellTaskOrganizer.onTaskAppeared");
|
||||
}
|
||||
synchronized (mLock) {
|
||||
onTaskAppeared(new TaskAppearedInfo(taskInfo, leash));
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ class HideDisplayCutoutOrganizer extends DisplayAreaOrganizer {
|
||||
@Override
|
||||
public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo,
|
||||
@NonNull SurfaceControl leash) {
|
||||
leash.setUnreleasedWarningCallSite("HideDisplayCutoutOrganizer.onDisplayAreaAppeared");
|
||||
if (!addDisplayAreaInfoAndLeashToMap(displayAreaInfo, leash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,8 @@ public class OneHandedDisplayAreaOrganizer extends DisplayAreaOrganizer {
|
||||
@Override
|
||||
public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo,
|
||||
@NonNull SurfaceControl leash) {
|
||||
leash.setUnreleasedWarningCallSite(
|
||||
"OneHandedSiaplyAreaOrganizer.onDisplayAreaAppeared");
|
||||
mDisplayAreaTokenMap.put(displayAreaInfo.token, leash);
|
||||
}
|
||||
|
||||
|
||||
@@ -1203,6 +1203,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
@Override
|
||||
public void stopSwipePipToHome(int taskId, ComponentName componentName,
|
||||
Rect destinationBounds, SurfaceControl overlay) {
|
||||
if (overlay != null) {
|
||||
overlay.setUnreleasedWarningCallSite("PipController.stopSwipePipToHome");
|
||||
}
|
||||
executeRemoteCallWithTaskPermission(mController, "stopSwipePipToHome",
|
||||
(controller) -> {
|
||||
controller.stopSwipePipToHome(taskId, componentName, destinationBounds,
|
||||
|
||||
Reference in New Issue
Block a user