Add callsite info to SurfaceControlViewHost
- Add callsite info for tracking leaks in SCVH - Use CloseGuard for tracking SCVH leakage Bug: 266978825 Test: Presubmit Change-Id: I0ba1a14cd4752699cbc24d17d10e977ceceece38
This commit is contained in:
@@ -166,7 +166,7 @@ public abstract class InlineSuggestionRenderService extends Service {
|
||||
PixelFormat.TRANSPARENT);
|
||||
|
||||
final SurfaceControlViewHost host = new SurfaceControlViewHost(this, getDisplay(),
|
||||
hostInputToken);
|
||||
hostInputToken, "InlineSuggestionRenderService");
|
||||
host.setView(suggestionRoot, lp);
|
||||
|
||||
// Set the suggestion view to be non-focusable so that if its background is set to a
|
||||
|
||||
@@ -125,7 +125,7 @@ public abstract class GameSessionService extends Service {
|
||||
final Context windowContext = createWindowContext(display,
|
||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, /*options=*/ null);
|
||||
SurfaceControlViewHost surfaceControlViewHost =
|
||||
new SurfaceControlViewHost(windowContext, display, hostToken);
|
||||
new SurfaceControlViewHost(windowContext, display, hostToken, "GameSessionService");
|
||||
|
||||
gameSession.attach(
|
||||
gameSessionController,
|
||||
|
||||
@@ -275,7 +275,7 @@ final class RemoteSelectionToolbar {
|
||||
mHostInputToken, mTransferTouchListener);
|
||||
contentHolder.addView(mContentContainer);
|
||||
mSurfaceControlViewHost = new SurfaceControlViewHost(mContext, mContext.getDisplay(),
|
||||
mHostInputToken);
|
||||
mHostInputToken, "RemoteSelectionToolbar");
|
||||
mSurfaceControlViewHost.setView(contentHolder, mPopupWidth, mPopupHeight);
|
||||
}
|
||||
if (mSurfacePackage == null) {
|
||||
|
||||
@@ -32,6 +32,8 @@ import android.view.accessibility.IAccessibilityEmbeddedConnection;
|
||||
import android.window.ISurfaceSyncGroup;
|
||||
import android.window.WindowTokenClient;
|
||||
|
||||
import dalvik.system.CloseGuard;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -51,6 +53,7 @@ import java.util.concurrent.TimeoutException;
|
||||
public class SurfaceControlViewHost {
|
||||
private final static String TAG = "SurfaceControlViewHost";
|
||||
private final ViewRootImpl mViewRoot;
|
||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||
private WindowlessWindowManager mWm;
|
||||
|
||||
private SurfaceControl mSurfaceControl;
|
||||
@@ -292,9 +295,10 @@ public class SurfaceControlViewHost {
|
||||
|
||||
/** @hide */
|
||||
public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d,
|
||||
@NonNull WindowlessWindowManager wwm) {
|
||||
@NonNull WindowlessWindowManager wwm, @NonNull String callsite) {
|
||||
mWm = wwm;
|
||||
mViewRoot = new ViewRootImpl(c, d, mWm, new WindowlessWindowLayout());
|
||||
mCloseGuard.openWithCallSite("release", callsite);
|
||||
addConfigCallback(c, d);
|
||||
|
||||
WindowManagerGlobal.getInstance().addWindowlessRoot(mViewRoot);
|
||||
@@ -316,15 +320,35 @@ public class SurfaceControlViewHost {
|
||||
*/
|
||||
public SurfaceControlViewHost(@NonNull Context context, @NonNull Display display,
|
||||
@Nullable IBinder hostToken) {
|
||||
this(context, display, hostToken, "untracked");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new SurfaceControlViewHost. The root Surface will be
|
||||
* allocated internally and is accessible via getSurfacePackage().
|
||||
*
|
||||
* The {@param hostToken} parameter, primarily used for ANR reporting,
|
||||
* must be obtained from whomever will be hosting the embedded hierarchy.
|
||||
* It's accessible from {@link SurfaceView#getHostToken}.
|
||||
*
|
||||
* @param context The Context object for your activity or application.
|
||||
* @param display The Display the hierarchy will be placed on.
|
||||
* @param hostToken The host token, as discussed above.
|
||||
* @param callsite The call site, used for tracking leakage of the host
|
||||
* @hide
|
||||
*/
|
||||
public SurfaceControlViewHost(@NonNull Context context, @NonNull Display display,
|
||||
@Nullable IBinder hostToken, @NonNull String callsite) {
|
||||
mSurfaceControl = new SurfaceControl.Builder()
|
||||
.setContainerLayer()
|
||||
.setName("SurfaceControlViewHost")
|
||||
.setCallsite("SurfaceControlViewHost")
|
||||
.setCallsite("SurfaceControlViewHost[" + callsite + "]")
|
||||
.build();
|
||||
mWm = new WindowlessWindowManager(context.getResources().getConfiguration(),
|
||||
mSurfaceControl, hostToken);
|
||||
|
||||
mViewRoot = new ViewRootImpl(context, display, mWm, new WindowlessWindowLayout());
|
||||
mCloseGuard.openWithCallSite("release", callsite);
|
||||
addConfigCallback(context, display);
|
||||
|
||||
WindowManagerGlobal.getInstance().addWindowlessRoot(mViewRoot);
|
||||
@@ -350,7 +374,9 @@ public class SurfaceControlViewHost {
|
||||
if (mReleased) {
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "SurfaceControlViewHost finalized without being released: " + this);
|
||||
if (mCloseGuard != null) {
|
||||
mCloseGuard.warnIfOpen();
|
||||
}
|
||||
// We aren't on the UI thread here so we need to pass false to doDie
|
||||
mViewRoot.die(false /* immediate */);
|
||||
WindowManagerGlobal.getInstance().removeWindowlessRoot(mViewRoot);
|
||||
@@ -466,6 +492,7 @@ public class SurfaceControlViewHost {
|
||||
mViewRoot.die(true /* immediate */);
|
||||
WindowManagerGlobal.getInstance().removeWindowlessRoot(mViewRoot);
|
||||
mReleased = true;
|
||||
mCloseGuard.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -333,7 +333,8 @@ public final class SplashScreenView extends FrameLayout {
|
||||
|
||||
SurfaceControlViewHost viewHost = new SurfaceControlViewHost(viewContext,
|
||||
viewContext.getDisplay(),
|
||||
surfaceView.getHostToken());
|
||||
surfaceView.getHostToken(),
|
||||
"SplashScreenView");
|
||||
ImageView imageView = new ImageView(viewContext);
|
||||
imageView.setBackground(mIconDrawable);
|
||||
viewHost.setView(imageView, mIconSize, mIconSize);
|
||||
|
||||
@@ -223,7 +223,7 @@ public class SystemWindows {
|
||||
}
|
||||
final Display display = mDisplayController.getDisplay(mDisplayId);
|
||||
SurfaceControlViewHost viewRoot =
|
||||
new SurfaceControlViewHost(view.getContext(), display, wwm);
|
||||
new SurfaceControlViewHost(view.getContext(), display, wwm, "SystemWindows");
|
||||
attrs.flags |= FLAG_HARDWARE_ACCELERATED;
|
||||
viewRoot.setView(view, attrs);
|
||||
mViewRoots.put(view, viewRoot);
|
||||
|
||||
@@ -114,7 +114,8 @@ public class SplitDecorManager extends WindowlessWindowManager {
|
||||
context = context.createWindowContext(context.getDisplay(), TYPE_APPLICATION_OVERLAY,
|
||||
null /* options */);
|
||||
mHostLeash = rootLeash;
|
||||
mViewHost = new SurfaceControlViewHost(context, context.getDisplay(), this);
|
||||
mViewHost = new SurfaceControlViewHost(context, context.getDisplay(), this,
|
||||
"SplitDecorManager");
|
||||
|
||||
mIconSize = context.getResources().getDimensionPixelSize(R.dimen.split_icon_size);
|
||||
final FrameLayout rootLayout = (FrameLayout) LayoutInflater.from(context)
|
||||
|
||||
@@ -113,7 +113,8 @@ public final class SplitWindowManager extends WindowlessWindowManager {
|
||||
"Try to inflate divider view again without release first");
|
||||
}
|
||||
|
||||
mViewHost = new SurfaceControlViewHost(mContext, mContext.getDisplay(), this);
|
||||
mViewHost = new SurfaceControlViewHost(mContext, mContext.getDisplay(), this,
|
||||
"SplitWindowManager");
|
||||
mDividerView = (DividerView) LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.split_divider, null /* root */);
|
||||
|
||||
|
||||
@@ -363,7 +363,8 @@ public abstract class CompatUIWindowManagerAbstract extends WindowlessWindowMana
|
||||
/** Creates a {@link SurfaceControlViewHost} for this window manager. */
|
||||
@VisibleForTesting(visibility = PRIVATE)
|
||||
public SurfaceControlViewHost createSurfaceViewHost() {
|
||||
return new SurfaceControlViewHost(mContext, mContext.getDisplay(), this);
|
||||
return new SurfaceControlViewHost(mContext, mContext.getDisplay(), this,
|
||||
getClass().getSimpleName());
|
||||
}
|
||||
|
||||
/** Gets the layout params. */
|
||||
|
||||
@@ -122,7 +122,8 @@ public final class BackgroundWindowManager extends WindowlessWindowManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
mViewHost = new SurfaceControlViewHost(mContext, mContext.getDisplay(), this);
|
||||
mViewHost = new SurfaceControlViewHost(mContext, mContext.getDisplay(), this,
|
||||
"BackgroundWindowManager");
|
||||
mBackgroundView = (View) LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.background_panel, null /* root */);
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
|
||||
|
||||
@@ -481,7 +481,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
||||
|
||||
interface SurfaceControlViewHostFactory {
|
||||
default SurfaceControlViewHost create(Context c, Display d, WindowlessWindowManager wmm) {
|
||||
return new SurfaceControlViewHost(c, d, wmm);
|
||||
return new SurfaceControlViewHost(c, d, wmm, "WindowDecoration");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SurfaceViewRequestReceiver {
|
||||
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
||||
mSurfaceControlViewHost = new SurfaceControlViewHost(context,
|
||||
dm.getDisplay(SurfaceViewRequestUtils.getDisplayId(bundle)),
|
||||
windowlessWindowManager);
|
||||
windowlessWindowManager, "SurfaceViewRequestReceiver");
|
||||
WindowManager.LayoutParams layoutParams =
|
||||
new WindowManager.LayoutParams(
|
||||
viewSize.getWidth(),
|
||||
|
||||
@@ -94,6 +94,7 @@ constructor(
|
||||
context,
|
||||
displayManager.getDisplay(bundle.getInt(KEY_DISPLAY_ID)),
|
||||
hostToken,
|
||||
"KeyguardPreviewRenderer"
|
||||
)
|
||||
disposables.add(DisposableHandle { host.release() })
|
||||
}
|
||||
|
||||
@@ -166,7 +166,8 @@ constructor(
|
||||
|
||||
overlayAddReason = reason
|
||||
|
||||
val newRoot = SurfaceControlViewHost(context, context.display!!, wwm)
|
||||
val newRoot = SurfaceControlViewHost(context, context.display!!, wwm,
|
||||
"UnfoldLightRevealOverlayAnimation")
|
||||
val params = getLayoutParams()
|
||||
val newView =
|
||||
LightRevealScrim(
|
||||
|
||||
Reference in New Issue
Block a user