diff options
author | 2018-12-10 13:05:52 -0800 | |
---|---|---|
committer | 2019-01-04 10:08:56 -0800 | |
commit | 5fea55b2d2d27c5ff714897632735efb65a52d4c (patch) | |
tree | a0b8d0b9230c2b028452d8bfd18da49badcbb0fe | |
parent | beb7a0cf506936f95be64609a9c958925f6177f5 (diff) |
Remove usage of scoped connections.
Tracking SurfaceFlinger changes. Now to construct a child surface
we need the SurfaceControl as opposed to just the surface, and so
we parcel the SurfaceControl across relayout.
Test: Manual
Bug: 62536731
Bug: 111373437
Bug: 111297488
Change-Id: I0a034767e92becec63071d7b1e3e71b95d505b77
17 files changed, 97 insertions, 58 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index 0b5776e89524..f64e0671f459 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -320,7 +320,7 @@ public class ActivityView extends ViewGroup { public void surfaceCreated(SurfaceHolder surfaceHolder) { mTmpSurface = new Surface(); if (mVirtualDisplay == null) { - initVirtualDisplay(new SurfaceSession(surfaceHolder.getSurface())); + initVirtualDisplay(new SurfaceSession()); if (mVirtualDisplay != null && mActivityViewCallback != null) { mActivityViewCallback.onActivityViewReady(ActivityView.this); } @@ -382,6 +382,7 @@ public class ActivityView extends ViewGroup { mRootSurfaceControl = new SurfaceControl.Builder(surfaceSession) .setContainerLayer(true) + .setParent(mSurfaceView.getSurfaceControl()) .setName(DISPLAY_NAME) .build(); diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index a011d677fc6a..9079502fa6b2 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -56,6 +56,7 @@ import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InsetsState; import android.view.MotionEvent; +import android.view.SurfaceControl; import android.view.SurfaceHolder; import android.view.View; import android.view.ViewGroup; @@ -217,6 +218,8 @@ public abstract class WallpaperService extends Service { private Context mDisplayContext; private int mDisplayState; + SurfaceControl mSurfaceControl = new SurfaceControl(); + final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() { { mRequestedFormat = PixelFormat.RGBX_8888; @@ -843,8 +846,12 @@ public abstract class WallpaperService extends Service { mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, View.VISIBLE, 0, -1, mWinFrame, mOverscanInsets, mContentInsets, mVisibleInsets, mStableInsets, mOutsets, mBackdropFrame, - mDisplayCutout, mMergedConfiguration, mSurfaceHolder.mSurface, + mDisplayCutout, mMergedConfiguration, mSurfaceControl, mInsetsState); + if (mSurfaceControl.isValid()) { + mSurfaceHolder.mSurface.copyFrom(mSurfaceControl); + mSurfaceControl.release(); + } if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface + ", frame=" + mWinFrame); diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index d1115c7b4d1d..658f06ad21f9 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -99,7 +99,7 @@ interface IWindowSession { out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets, out Rect outOutsets, out Rect outBackdropFrame, out DisplayCutout.ParcelableWrapper displayCutout, - out MergedConfiguration outMergedConfiguration, out Surface outSurface, + out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl, out InsetsState insetsState); /* diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index aaec65aad4af..eec114a2fea7 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -683,7 +683,13 @@ public class SurfaceControl implements Parcelable { mName = in.readString(); mWidth = in.readInt(); mHeight = in.readInt(); - mNativeObject = nativeReadFromParcel(in); + + release(); + if (in.readInt() != 0) { + mNativeObject = nativeReadFromParcel(in); + } else { + mNativeObject = 0; + } } @Override @@ -696,7 +702,16 @@ public class SurfaceControl implements Parcelable { dest.writeString(mName); dest.writeInt(mWidth); dest.writeInt(mHeight); + if (mNativeObject == 0) { + dest.writeInt(0); + } else { + dest.writeInt(1); + } nativeWriteToParcel(mNativeObject, dest); + + if ((flags & Parcelable.PARCELABLE_WRITE_RETURN_VALUE) != 0) { + release(); + } } /** @@ -779,6 +794,10 @@ public class SurfaceControl implements Parcelable { "mNativeObject is null. Have you called release() already?"); } + public boolean isValid() { + return mNativeObject != 0; + } + /* * set surface parameters. * needs to be inside open/closeTransaction block diff --git a/core/java/android/view/SurfaceSession.java b/core/java/android/view/SurfaceSession.java index a4fa12a57e93..361ac932758e 100644 --- a/core/java/android/view/SurfaceSession.java +++ b/core/java/android/view/SurfaceSession.java @@ -30,7 +30,6 @@ public final class SurfaceSession { private long mNativeClient; // SurfaceComposerClient* private static native long nativeCreate(); - private static native long nativeCreateScoped(long surfacePtr); private static native void nativeDestroy(long ptr); private static native void nativeKill(long ptr); @@ -40,15 +39,6 @@ public final class SurfaceSession { mNativeClient = nativeCreate(); } - public SurfaceSession(Surface root) { - synchronized (root.mLock) { - if (root.mNativeObject == 0) { - throw new IllegalStateException("Surface is not initialized or has been released"); - } - mNativeClient = nativeCreateScoped(root.mNativeObject); - } - } - /* no user serviceable parts here ... */ @Override protected void finalize() throws Throwable { diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index a0af83d17abd..61fb00d3fe59 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -547,7 +547,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb if (creating) { viewRoot.createBoundsSurface(mSubLayer); - mSurfaceSession = new SurfaceSession(viewRoot.mBoundsSurface); + mSurfaceSession = new SurfaceSession(); mDeferredDestroySurfaceControl = mSurfaceControl; updateOpaqueFlag(); @@ -559,6 +559,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb new SurfaceControl.Builder(mSurfaceSession) .setBufferSize(mSurfaceWidth, mSurfaceHeight) .setFormat(mFormat) + .setParent(viewRoot.getSurfaceControl()) .setFlags(mSurfaceFlags)); } else if (mSurfaceControl == null) { return; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 6b07efc0b448..4504887f265b 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -25053,9 +25053,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } final ViewRootImpl root = mAttachInfo.mViewRootImpl; - final SurfaceSession session = new SurfaceSession(root.mSurface); + final SurfaceSession session = new SurfaceSession(); final SurfaceControl surfaceControl = new SurfaceControl.Builder(session) .setName("drag surface") + .setParent(root.getSurfaceControl()) .setBufferSize(shadowSize.x, shadowSize.y) .setFormat(PixelFormat.TRANSLUCENT) .build(); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 3f7a5127339d..c0b428359efc 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -432,6 +432,7 @@ public final class ViewRootImpl implements ViewParent, // Surface can never be reassigned or cleared (use Surface.clear()). @UnsupportedAppUsage public final Surface mSurface = new Surface(); + private final SurfaceControl mSurfaceControl = new SurfaceControl(); /** * Child surface of {@code mSurface} with the same bounds as its parent, and crop bounds @@ -1526,7 +1527,7 @@ public final class ViewRootImpl implements ViewParent, */ public void createBoundsSurface(int zOrderLayer) { if (mSurfaceSession == null) { - mSurfaceSession = new SurfaceSession(mSurface); + mSurfaceSession = new SurfaceSession(); } if (mBoundsSurfaceControl != null && mBoundsSurface.isValid()) { return; // surface control for bounds surface already exists. @@ -1534,6 +1535,7 @@ public final class ViewRootImpl implements ViewParent, mBoundsSurfaceControl = new SurfaceControl.Builder(mSurfaceSession) .setName("Bounds for - " + getTitle().toString()) + .setParent(mSurfaceControl) .build(); setBoundsSurfaceCrop(); @@ -1567,6 +1569,8 @@ public final class ViewRootImpl implements ViewParent, private void destroySurface() { mSurface.release(); + mSurfaceControl.release(); + mSurfaceSession = null; if (mBoundsSurfaceControl != null) { @@ -6801,7 +6805,12 @@ public final class ViewRootImpl implements ViewParent, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, frameNumber, mTmpFrame, mPendingOverscanInsets, mPendingContentInsets, mPendingVisibleInsets, mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingDisplayCutout, - mPendingMergedConfiguration, mSurface, mTempInsets); + mPendingMergedConfiguration, mSurfaceControl, mTempInsets); + if (mSurfaceControl.isValid()) { + mSurface.copyFrom(mSurfaceControl); + } else { + destroySurface(); + } mPendingAlwaysConsumeNavBar = (relayoutResult & WindowManagerGlobal.RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR) != 0; @@ -8483,6 +8492,10 @@ public final class ViewRootImpl implements ViewParent, mActivityRelaunched = true; } + public SurfaceControl getSurfaceControl() { + return mSurfaceControl; + } + /** * Class for managing the accessibility interaction connection * based on the global accessibility state. diff --git a/core/java/android/widget/Magnifier.java b/core/java/android/widget/Magnifier.java index 7d027574198d..886718d192e0 100644 --- a/core/java/android/widget/Magnifier.java +++ b/core/java/android/widget/Magnifier.java @@ -271,7 +271,7 @@ public final class Magnifier { if (mWindow == null) { synchronized (mLock) { mWindow = new InternalPopupWindow(mView.getContext(), mView.getDisplay(), - mParentSurface.mSurface, mWindowWidth, mWindowHeight, + mParentSurface.mSurfaceControl, mWindowWidth, mWindowHeight, mWindowElevation, mWindowCornerRadius, mOverlay != null ? mOverlay : new ColorDrawable(Color.TRANSPARENT), Handler.getMain() /* draw the magnifier on the UI thread */, mLock, @@ -528,17 +528,20 @@ public final class Magnifier { final int surfaceHeight = viewRootImpl.getHeight() + surfaceInsets.top + surfaceInsets.bottom; validMainWindowSurface = - new SurfaceInfo(mainWindowSurface, surfaceWidth, surfaceHeight, true); + new SurfaceInfo(viewRootImpl.getSurfaceControl(), mainWindowSurface, + surfaceWidth, surfaceHeight, true); } } // Get the surface backing the magnified view, if it is a SurfaceView. SurfaceInfo validSurfaceViewSurface = SurfaceInfo.NULL; if (mView instanceof SurfaceView) { + final SurfaceControl sc = ((SurfaceView) mView).getSurfaceControl(); final SurfaceHolder surfaceHolder = ((SurfaceView) mView).getHolder(); final Surface surfaceViewSurface = surfaceHolder.getSurface(); - if (surfaceViewSurface != null && surfaceViewSurface.isValid()) { + + if (sc != null && sc.isValid()) { final Rect surfaceFrame = surfaceHolder.getSurfaceFrame(); - validSurfaceViewSurface = new SurfaceInfo(surfaceViewSurface, + validSurfaceViewSurface = new SurfaceInfo(sc, surfaceViewSurface, surfaceFrame.right, surfaceFrame.bottom, false); } } @@ -733,15 +736,18 @@ public final class Magnifier { * Contains a surface and metadata corresponding to it. */ private static class SurfaceInfo { - public static final SurfaceInfo NULL = new SurfaceInfo(null, 0, 0, false); + public static final SurfaceInfo NULL = new SurfaceInfo(null, null, 0, 0, false); private Surface mSurface; + private SurfaceControl mSurfaceControl; private int mWidth; private int mHeight; private boolean mIsMainWindowSurface; - SurfaceInfo(final Surface surface, final int width, final int height, + SurfaceInfo(final SurfaceControl surfaceControl, final Surface surface, + final int width, final int height, final boolean isMainWindowSurface) { + mSurfaceControl = surfaceControl; mSurface = surface; mWidth = width; mHeight = height; @@ -819,7 +825,7 @@ public final class Magnifier { private Bitmap mCurrentContent; InternalPopupWindow(final Context context, final Display display, - final Surface parentSurface, final int width, final int height, + final SurfaceControl parentSurfaceControl, final int width, final int height, final float elevation, final float cornerRadius, final Drawable overlay, final Handler handler, final Object lock, final Callback callback) { mDisplay = display; @@ -834,12 +840,13 @@ public final class Magnifier { // Setup the surface we will use for drawing the content and shadow. mSurfaceWidth = mContentWidth + 2 * mOffsetX; mSurfaceHeight = mContentHeight + 2 * mOffsetY; - mSurfaceSession = new SurfaceSession(parentSurface); + mSurfaceSession = new SurfaceSession(); mSurfaceControl = new SurfaceControl.Builder(mSurfaceSession) .setFormat(PixelFormat.TRANSLUCENT) .setBufferSize(mSurfaceWidth, mSurfaceHeight) .setName("magnifier surface") .setFlags(SurfaceControl.HIDDEN) + .setParent(parentSurfaceControl) .build(); mSurface = new Surface(); mSurface.copyFrom(mSurfaceControl); diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index bff51f0a2ee3..030116b08f40 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -912,8 +912,10 @@ static jlong nativeCopyFromSurfaceControl(JNIEnv* env, jclass clazz, jlong surfa if (surface == nullptr) { return 0; } - surface->incStrong((void *)nativeCreate); - return reinterpret_cast<jlong>(surface.get()); + + sp<SurfaceControl> newSurface = new SurfaceControl(surface); + newSurface->incStrong((void *)nativeCreate); + return reinterpret_cast<jlong>(newSurface.get()); } static void nativeWriteToParcel(JNIEnv* env, jclass clazz, diff --git a/core/jni/android_view_SurfaceSession.cpp b/core/jni/android_view_SurfaceSession.cpp index 30c00302eefd..191f748d80bf 100644 --- a/core/jni/android_view_SurfaceSession.cpp +++ b/core/jni/android_view_SurfaceSession.cpp @@ -46,13 +46,6 @@ static jlong nativeCreate(JNIEnv* env, jclass clazz) { return reinterpret_cast<jlong>(client); } -static jlong nativeCreateScoped(JNIEnv* env, jclass clazz, jlong surfaceObject) { - Surface *parent = reinterpret_cast<Surface*>(surfaceObject); - SurfaceComposerClient* client = new SurfaceComposerClient(parent->getIGraphicBufferProducer()); - client->incStrong((void*)nativeCreate); - return reinterpret_cast<jlong>(client); -} - static void nativeDestroy(JNIEnv* env, jclass clazz, jlong ptr) { SurfaceComposerClient* client = reinterpret_cast<SurfaceComposerClient*>(ptr); client->decStrong((void*)nativeCreate); @@ -67,8 +60,6 @@ static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "nativeCreate", "()J", (void*)nativeCreate }, - { "nativeCreateScoped", "(J)J", - (void*)nativeCreateScoped }, { "nativeDestroy", "(J)V", (void*)nativeDestroy }, { "nativeKill", "(J)V", diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index d85fdb03e4a6..937c9d9fc809 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -187,7 +187,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { Rect outFrame, Rect outOverscanInsets, Rect outContentInsets, Rect outVisibleInsets, Rect outStableInsets, Rect outsets, Rect outBackdropFrame, DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration, - Surface outSurface, InsetsState outInsetsState) { + SurfaceControl outSurfaceControl, InsetsState outInsetsState) { if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from " + Binder.getCallingPid()); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mRelayoutTag); @@ -195,7 +195,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { requestedWidth, requestedHeight, viewFlags, flags, frameNumber, outFrame, outOverscanInsets, outContentInsets, outVisibleInsets, outStableInsets, outsets, outBackdropFrame, cutout, - mergedConfiguration, outSurface, outInsetsState); + mergedConfiguration, outSurfaceControl, outInsetsState); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); if (false) Slog.d(TAG_WM, "<<<<<< EXITING relayout to " + Binder.getCallingPid()); diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java index 9a56606aee7f..2d3e3aee4b7f 100644 --- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java +++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java @@ -111,6 +111,7 @@ class TaskSnapshotSurface implements StartingSurface { private static final String TITLE_FORMAT = "SnapshotStartingWindow for taskId=%s"; private final Window mWindow; private final Surface mSurface; + private SurfaceControl mSurfaceControl; private SurfaceControl mChildSurfaceControl; private final IWindowSession mSession; private final WindowManagerService mService; @@ -136,7 +137,7 @@ class TaskSnapshotSurface implements StartingSurface { final Window window = new Window(); final IWindowSession session = WindowManagerGlobal.getWindowSession(); window.setSession(session); - final Surface surface = new Surface(); + final SurfaceControl surfaceControl = new SurfaceControl(); final Rect tmpRect = new Rect(); final DisplayCutout.ParcelableWrapper tmpCutout = new DisplayCutout.ParcelableWrapper(); final Rect tmpFrame = new Rect(); @@ -213,14 +214,14 @@ class TaskSnapshotSurface implements StartingSurface { // Local call. } final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window, - surface, snapshot, layoutParams.getTitle(), backgroundColor, statusBarColor, + surfaceControl, snapshot, layoutParams.getTitle(), backgroundColor, statusBarColor, navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds, currentOrientation); window.setOuter(snapshotSurface); try { session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1, tmpFrame, tmpRect, tmpContentInsets, tmpRect, tmpStableInsets, tmpRect, tmpRect, - tmpCutout, tmpMergedConfiguration, surface, mTmpInsetsState); + tmpCutout, tmpMergedConfiguration, surfaceControl, mTmpInsetsState); } catch (RemoteException e) { // Local call. } @@ -230,15 +231,16 @@ class TaskSnapshotSurface implements StartingSurface { } @VisibleForTesting - TaskSnapshotSurface(WindowManagerService service, Window window, Surface surface, + TaskSnapshotSurface(WindowManagerService service, Window window, SurfaceControl surfaceControl, TaskSnapshot snapshot, CharSequence title, int backgroundColor, int statusBarColor, int navigationBarColor, int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds, int currentOrientation) { mService = service; + mSurface = new Surface(); mHandler = new Handler(mService.mH.getLooper()); mSession = WindowManagerGlobal.getWindowSession(); mWindow = window; - mSurface = surface; + mSurfaceControl = surfaceControl; mSnapshot = snapshot; mTitle = title; mBackgroundPaint.setColor(backgroundColor != 0 ? backgroundColor : WHITE); @@ -281,6 +283,8 @@ class TaskSnapshotSurface implements StartingSurface { private void drawSnapshot() { final GraphicBuffer buffer = mSnapshot.getSnapshot(); + mSurface.copyFrom(mSurfaceControl); + if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Drawing snapshot surface sizeMismatch=" + mSizeMismatch); if (mSizeMismatch) { @@ -310,13 +314,14 @@ class TaskSnapshotSurface implements StartingSurface { if (!mSurface.isValid()) { throw new IllegalStateException("mSurface does not hold a valid surface."); } - final SurfaceSession session = new SurfaceSession(mSurface); + final SurfaceSession session = new SurfaceSession(); // Keep a reference to it such that it doesn't get destroyed when finalized. mChildSurfaceControl = new SurfaceControl.Builder(session) .setName(mTitle + " - task-snapshot-surface") .setBufferSize(buffer.getWidth(), buffer.getHeight()) .setFormat(buffer.getFormat()) + .setParent(mSurfaceControl) .build(); Surface surface = new Surface(); surface.copyFrom(mChildSurfaceControl); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b6a4a51c41f2..6a15d97ae916 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1866,7 +1866,7 @@ public class WindowManagerService extends IWindowManager.Stub long frameNumber, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets, Rect outVisibleInsets, Rect outStableInsets, Rect outOutsets, Rect outBackdropFrame, DisplayCutout.ParcelableWrapper outCutout, MergedConfiguration mergedConfiguration, - Surface outSurface, InsetsState outInsetsState) { + SurfaceControl outSurfaceControl, InsetsState outInsetsState) { int result = 0; boolean configChanged; final boolean hasStatusBarPermission = @@ -2039,7 +2039,7 @@ public class WindowManagerService extends IWindowManager.Stub result = win.relayoutVisibleWindow(result, attrChanges, oldVisibility); try { - result = createSurfaceControl(outSurface, result, win, winAnimator); + result = createSurfaceControl(outSurfaceControl, result, win, winAnimator); } catch (Exception e) { displayContent.getInputMonitor().updateInputWindowsLw(true /*force*/); @@ -2070,7 +2070,7 @@ public class WindowManagerService extends IWindowManager.Stub // handled yet, or it might want to draw a last frame. If we already have a // surface, let the client use that, but don't create new surface at this point. Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "relayoutWindow: getSurface"); - winAnimator.mSurfaceController.getSurface(outSurface); + winAnimator.mSurfaceController.getSurfaceControl(outSurfaceControl); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } else { if (DEBUG_VISIBILITY) Slog.i(TAG_WM, "Releasing surface in: " + win); @@ -2078,7 +2078,7 @@ public class WindowManagerService extends IWindowManager.Stub try { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "wmReleaseOutSurface_" + win.mAttrs.getTitle()); - outSurface.release(); + outSurfaceControl.release(); } finally { Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } @@ -2174,7 +2174,7 @@ public class WindowManagerService extends IWindowManager.Stub + ", requestedHeight=" + requestedHeight + ", viewVisibility=" + viewVisibility + "\nRelayout returning frame=" + outFrame - + ", surface=" + outSurface); + + ", surface=" + outSurfaceControl); if (localLOGV || DEBUG_FOCUS) Slog.v( TAG_WM, "Relayout of " + win + ": focusMayChange=" + focusMayChange); @@ -2244,7 +2244,7 @@ public class WindowManagerService extends IWindowManager.Stub return focusMayChange; } - private int createSurfaceControl(Surface outSurface, int result, WindowState win, + private int createSurfaceControl(SurfaceControl outSurfaceControl, int result, WindowState win, WindowStateAnimator winAnimator) { if (!win.mHasSurface) { result |= RELAYOUT_RES_SURFACE_CHANGED; @@ -2258,13 +2258,13 @@ public class WindowManagerService extends IWindowManager.Stub Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } if (surfaceController != null) { - surfaceController.getSurface(outSurface); - if (SHOW_TRANSACTIONS) Slog.i(TAG_WM, " OUT SURFACE " + outSurface + ": copied"); + surfaceController.getSurfaceControl(outSurfaceControl); + if (SHOW_TRANSACTIONS) Slog.i(TAG_WM, " OUT SURFACE " + outSurfaceControl + ": copied"); } else { // For some reason there isn't a surface. Clear the // caller's object so they see the same state. Slog.w(TAG_WM, "Failed to create surface control for " + win); - outSurface.release(); + outSurfaceControl.release(); } return result; diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java index ce627e23e6ee..c2a8e7efb5a5 100644 --- a/services/core/java/com/android/server/wm/WindowSurfaceController.java +++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java @@ -478,8 +478,8 @@ class WindowSurfaceController { return mSurfaceControl.getHandle(); } - void getSurface(Surface outSurface) { - outSurface.copyFrom(mSurfaceControl); + void getSurfaceControl(SurfaceControl outSurfaceControl) { + outSurfaceControl.copyFrom(mSurfaceControl); } int getLayer() { diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java index 624ef9ba1653..ca815eca9a1f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java @@ -39,6 +39,7 @@ import android.graphics.PixelFormat; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.view.Surface; +import android.view.SurfaceControl; import androidx.test.filters.SmallTest; @@ -65,7 +66,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase { final TaskSnapshot snapshot = new TaskSnapshot(new ComponentName("", ""), buffer, ORIENTATION_PORTRAIT, contentInsets, false, 1.0f, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN, 0 /* systemUiVisibility */, false /* isTranslucent */); - mSurface = new TaskSnapshotSurface(mWm, new Window(), new Surface(), snapshot, "Test", + mSurface = new TaskSnapshotSurface(mWm, new Window(), new SurfaceControl(), snapshot, "Test", Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds, ORIENTATION_PORTRAIT); } diff --git a/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java b/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java index d5987a5373b4..85646987940f 100644 --- a/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java +++ b/tests/WindowManagerStressTest/src/test/windowmanagerstresstest/MainActivity.java @@ -28,6 +28,7 @@ import android.view.DisplayCutout; import android.view.IWindowSession; import android.view.InsetsState; import android.view.Surface; +import android.view.SurfaceControl; import android.view.View; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; @@ -106,7 +107,7 @@ public class MainActivity extends Activity { window.mSeq, mLayoutParams, -1, -1, View.VISIBLE, 0, -1, mTmpRect, mTmpRect, mTmpRect, mTmpRect, mTmpRect, mTmpRect, mTmpRect, new DisplayCutout.ParcelableWrapper(), new MergedConfiguration(), - new Surface(), new InsetsState()); + new SurfaceControl(), new InsetsState()); } catch (RemoteException e) { e.printStackTrace(); } |