Loading services/core/java/com/android/server/wm/ActivityRecord.java +3 −4 Original line number Diff line number Diff line Loading @@ -6405,8 +6405,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } clearThumbnail(); final Transaction transaction = getAnimatingContainer().getPendingTransaction(); mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory, transaction, getAnimatingContainer(), thumbnailHeader); mThumbnail = new WindowContainerThumbnail(transaction, getAnimatingContainer(), thumbnailHeader); mThumbnail.startAnimation(transaction, loadThumbnailAnimation(thumbnailHeader)); } Loading Loading @@ -6435,8 +6435,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } final Transaction transaction = getPendingTransaction(); mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory, transaction, getTask(), thumbnail); mThumbnail = new WindowContainerThumbnail(transaction, getTask(), thumbnail); final Animation animation = getDisplayContent().mAppTransition.createCrossProfileAppsThumbnailAnimationLocked( frame); Loading services/core/java/com/android/server/wm/DisplayContent.java +6 −5 Original line number Diff line number Diff line Loading @@ -154,6 +154,8 @@ import android.content.pm.ActivityInfo.ScreenOrientation; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.ColorSpace; import android.graphics.GraphicBuffer; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -3821,7 +3823,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp final ActivityRecord activity = mImeLayeringTarget.mActivityRecord; final SurfaceControl imeSurface = mWmService.mSurfaceControlFactory.apply(null) .setName("IME-snapshot-surface") .setBufferSize(buffer.getWidth(), buffer.getHeight()) .setBLASTLayer() .setFormat(buffer.getFormat()) .setParent(activity.getSurfaceControl()) .setCallsite("DisplayContent.attachAndShowImeScreenshotOnTarget") Loading @@ -3829,10 +3831,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // Make IME snapshot as trusted overlay InputMonitor.setTrustedOverlayInputInfo(imeSurface, t, getDisplayId(), "IME-snapshot-surface"); Surface surface = mWmService.mSurfaceFactory.get(); surface.copyFrom(imeSurface); surface.attachAndQueueBufferWithColorSpace(buffer, null); surface.release(); GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(buffer); t.setBuffer(imeSurface, graphicBuffer); t.setColorSpace(mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB)); t.setRelativeLayer(imeSurface, activity.getSurfaceControl(), 1); t.setPosition(imeSurface, mInputMethodWindow.getDisplayFrame().left, mInputMethodWindow.getDisplayFrame().top); Loading services/core/java/com/android/server/wm/TaskScreenshotAnimatable.java +6 −6 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package com.android.server.wm; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS; import android.graphics.GraphicBuffer; import android.hardware.HardwareBuffer; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; Loading Loading @@ -51,14 +51,14 @@ class TaskScreenshotAnimatable implements SurfaceAnimator.Animatable { task, mWidth, mHeight); mSurfaceControl = surfaceControlFactory.apply(new SurfaceSession()) .setName("RecentTaskScreenshotSurface") .setBufferSize(mWidth, mHeight) .setBLASTLayer() .setCallsite("TaskScreenshotAnimatable") .build(); if (buffer != null) { final Surface surface = new Surface(); surface.copyFrom(mSurfaceControl); surface.attachAndQueueBufferWithColorSpace(buffer, screenshotBuffer.getColorSpace()); surface.release(); GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(buffer); getPendingTransaction().setBuffer(mSurfaceControl, graphicBuffer); getPendingTransaction().setColorSpace(mSurfaceControl, screenshotBuffer.getColorSpace()); final float scale = 1.0f * mTask.getBounds().width() / mWidth; getPendingTransaction().setMatrix(mSurfaceControl, scale, 0, 0, scale); } Loading services/core/java/com/android/server/wm/WindowContainerThumbnail.java +10 −28 Original line number Diff line number Diff line Loading @@ -28,12 +28,13 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION; import android.graphics.ColorSpace; import android.graphics.GraphicBuffer; import android.graphics.PixelFormat; import android.graphics.Point; import android.hardware.HardwareBuffer; import android.os.Process; import android.util.proto.ProtoOutputStream; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Builder; import android.view.SurfaceControl.Transaction; Loading @@ -43,8 +44,6 @@ import com.android.internal.protolog.common.ProtoLog; import com.android.server.wm.SurfaceAnimator.Animatable; import com.android.server.wm.SurfaceAnimator.AnimationType; import java.util.function.Supplier; /** * Represents a surface that is displayed over a subclass of {@link WindowContainer} */ Loading @@ -57,30 +56,20 @@ class WindowContainerThumbnail implements Animatable { private final SurfaceAnimator mSurfaceAnimator; private final int mWidth; private final int mHeight; private final boolean mRelative; WindowContainerThumbnail(Supplier<Surface> surfaceFactory, Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader) { this(surfaceFactory, t, container, thumbnailHeader, false /* relative */); } /** * @param t Transaction to create the thumbnail in. * @param container The sub-class of {@link WindowContainer} to associate this thumbnail with. * @param thumbnailHeader A thumbnail or placeholder for thumbnail to initialize with. * @param relative Whether this thumbnail will be a child of the container (and thus positioned * relative to it) or not. */ WindowContainerThumbnail(Supplier<Surface> surfaceFactory, Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader, boolean relative) { this(t, container, thumbnailHeader, relative, surfaceFactory.get(), null); WindowContainerThumbnail(Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader) { this(t, container, thumbnailHeader, null /* animator */); } WindowContainerThumbnail(Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader, boolean relative, Surface drawSurface, SurfaceAnimator animator) { HardwareBuffer thumbnailHeader, SurfaceAnimator animator) { mWindowContainer = container; mRelative = relative; if (animator != null) { mSurfaceAnimator = animator; } else { Loading @@ -99,7 +88,7 @@ class WindowContainerThumbnail implements Animatable { // this to the task. mSurfaceControl = mWindowContainer.makeChildSurface(mWindowContainer.getTopChild()) .setName("thumbnail anim: " + mWindowContainer.toString()) .setBufferSize(mWidth, mHeight) .setBLASTLayer() .setFormat(PixelFormat.TRANSLUCENT) .setMetadata(METADATA_WINDOW_TYPE, mWindowContainer.getWindowingMode()) .setMetadata(METADATA_OWNER_UID, Process.myUid()) Loading @@ -108,18 +97,14 @@ class WindowContainerThumbnail implements Animatable { ProtoLog.i(WM_SHOW_TRANSACTIONS, " THUMBNAIL %s: CREATE", mSurfaceControl); // Transfer the thumbnail to the surface drawSurface.copyFrom(mSurfaceControl); drawSurface.attachAndQueueBufferWithColorSpace(thumbnailHeader, null); drawSurface.release(); GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(thumbnailHeader); t.setBuffer(mSurfaceControl, graphicBuffer); t.setColorSpace(mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB)); t.show(mSurfaceControl); // We parent the thumbnail to the container, and just place it on top of anything else in // the container. t.setLayer(mSurfaceControl, Integer.MAX_VALUE); if (relative) { t.reparent(mSurfaceControl, mWindowContainer.getSurfaceControl()); } } void startAnimation(Transaction t, Animation anim) { Loading Loading @@ -194,9 +179,6 @@ class WindowContainerThumbnail implements Animatable { @Override public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) { t.setLayer(leash, Integer.MAX_VALUE); if (mRelative) { t.reparent(leash, mWindowContainer.getSurfaceControl()); } } @Override Loading services/tests/wmtests/src/com/android/server/wm/WindowContainerThumbnailTest.java +3 −4 Original line number Diff line number Diff line Loading @@ -18,14 +18,13 @@ package com.android.server.wm; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; import static org.mockito.ArgumentMatchers.any; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import android.hardware.HardwareBuffer; import android.platform.test.annotations.Presubmit; import android.view.Surface; import androidx.test.filters.FlakyTest; import androidx.test.filters.SmallTest; Loading @@ -51,8 +50,8 @@ public class WindowContainerThumbnailTest extends WindowTestsBase { when(mockAr.getPendingTransaction()).thenReturn(new StubTransaction()); when(mockAr.makeChildSurface(any())).thenReturn(new MockSurfaceControlBuilder()); when(mockAr.makeSurface()).thenReturn(new MockSurfaceControlBuilder()); return new WindowContainerThumbnail(new StubTransaction(), mockAr, buffer, false, mock(Surface.class), mock(SurfaceAnimator.class)); return new WindowContainerThumbnail(new StubTransaction(), mockAr, buffer, mock(SurfaceAnimator.class)); } @Test Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +3 −4 Original line number Diff line number Diff line Loading @@ -6405,8 +6405,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } clearThumbnail(); final Transaction transaction = getAnimatingContainer().getPendingTransaction(); mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory, transaction, getAnimatingContainer(), thumbnailHeader); mThumbnail = new WindowContainerThumbnail(transaction, getAnimatingContainer(), thumbnailHeader); mThumbnail.startAnimation(transaction, loadThumbnailAnimation(thumbnailHeader)); } Loading Loading @@ -6435,8 +6435,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } final Transaction transaction = getPendingTransaction(); mThumbnail = new WindowContainerThumbnail(mWmService.mSurfaceFactory, transaction, getTask(), thumbnail); mThumbnail = new WindowContainerThumbnail(transaction, getTask(), thumbnail); final Animation animation = getDisplayContent().mAppTransition.createCrossProfileAppsThumbnailAnimationLocked( frame); Loading
services/core/java/com/android/server/wm/DisplayContent.java +6 −5 Original line number Diff line number Diff line Loading @@ -154,6 +154,8 @@ import android.content.pm.ActivityInfo.ScreenOrientation; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.ColorSpace; import android.graphics.GraphicBuffer; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -3821,7 +3823,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp final ActivityRecord activity = mImeLayeringTarget.mActivityRecord; final SurfaceControl imeSurface = mWmService.mSurfaceControlFactory.apply(null) .setName("IME-snapshot-surface") .setBufferSize(buffer.getWidth(), buffer.getHeight()) .setBLASTLayer() .setFormat(buffer.getFormat()) .setParent(activity.getSurfaceControl()) .setCallsite("DisplayContent.attachAndShowImeScreenshotOnTarget") Loading @@ -3829,10 +3831,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // Make IME snapshot as trusted overlay InputMonitor.setTrustedOverlayInputInfo(imeSurface, t, getDisplayId(), "IME-snapshot-surface"); Surface surface = mWmService.mSurfaceFactory.get(); surface.copyFrom(imeSurface); surface.attachAndQueueBufferWithColorSpace(buffer, null); surface.release(); GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(buffer); t.setBuffer(imeSurface, graphicBuffer); t.setColorSpace(mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB)); t.setRelativeLayer(imeSurface, activity.getSurfaceControl(), 1); t.setPosition(imeSurface, mInputMethodWindow.getDisplayFrame().left, mInputMethodWindow.getDisplayFrame().top); Loading
services/core/java/com/android/server/wm/TaskScreenshotAnimatable.java +6 −6 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package com.android.server.wm; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS; import android.graphics.GraphicBuffer; import android.hardware.HardwareBuffer; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; Loading Loading @@ -51,14 +51,14 @@ class TaskScreenshotAnimatable implements SurfaceAnimator.Animatable { task, mWidth, mHeight); mSurfaceControl = surfaceControlFactory.apply(new SurfaceSession()) .setName("RecentTaskScreenshotSurface") .setBufferSize(mWidth, mHeight) .setBLASTLayer() .setCallsite("TaskScreenshotAnimatable") .build(); if (buffer != null) { final Surface surface = new Surface(); surface.copyFrom(mSurfaceControl); surface.attachAndQueueBufferWithColorSpace(buffer, screenshotBuffer.getColorSpace()); surface.release(); GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(buffer); getPendingTransaction().setBuffer(mSurfaceControl, graphicBuffer); getPendingTransaction().setColorSpace(mSurfaceControl, screenshotBuffer.getColorSpace()); final float scale = 1.0f * mTask.getBounds().width() / mWidth; getPendingTransaction().setMatrix(mSurfaceControl, scale, 0, 0, scale); } Loading
services/core/java/com/android/server/wm/WindowContainerThumbnail.java +10 −28 Original line number Diff line number Diff line Loading @@ -28,12 +28,13 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION; import android.graphics.ColorSpace; import android.graphics.GraphicBuffer; import android.graphics.PixelFormat; import android.graphics.Point; import android.hardware.HardwareBuffer; import android.os.Process; import android.util.proto.ProtoOutputStream; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Builder; import android.view.SurfaceControl.Transaction; Loading @@ -43,8 +44,6 @@ import com.android.internal.protolog.common.ProtoLog; import com.android.server.wm.SurfaceAnimator.Animatable; import com.android.server.wm.SurfaceAnimator.AnimationType; import java.util.function.Supplier; /** * Represents a surface that is displayed over a subclass of {@link WindowContainer} */ Loading @@ -57,30 +56,20 @@ class WindowContainerThumbnail implements Animatable { private final SurfaceAnimator mSurfaceAnimator; private final int mWidth; private final int mHeight; private final boolean mRelative; WindowContainerThumbnail(Supplier<Surface> surfaceFactory, Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader) { this(surfaceFactory, t, container, thumbnailHeader, false /* relative */); } /** * @param t Transaction to create the thumbnail in. * @param container The sub-class of {@link WindowContainer} to associate this thumbnail with. * @param thumbnailHeader A thumbnail or placeholder for thumbnail to initialize with. * @param relative Whether this thumbnail will be a child of the container (and thus positioned * relative to it) or not. */ WindowContainerThumbnail(Supplier<Surface> surfaceFactory, Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader, boolean relative) { this(t, container, thumbnailHeader, relative, surfaceFactory.get(), null); WindowContainerThumbnail(Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader) { this(t, container, thumbnailHeader, null /* animator */); } WindowContainerThumbnail(Transaction t, WindowContainer container, HardwareBuffer thumbnailHeader, boolean relative, Surface drawSurface, SurfaceAnimator animator) { HardwareBuffer thumbnailHeader, SurfaceAnimator animator) { mWindowContainer = container; mRelative = relative; if (animator != null) { mSurfaceAnimator = animator; } else { Loading @@ -99,7 +88,7 @@ class WindowContainerThumbnail implements Animatable { // this to the task. mSurfaceControl = mWindowContainer.makeChildSurface(mWindowContainer.getTopChild()) .setName("thumbnail anim: " + mWindowContainer.toString()) .setBufferSize(mWidth, mHeight) .setBLASTLayer() .setFormat(PixelFormat.TRANSLUCENT) .setMetadata(METADATA_WINDOW_TYPE, mWindowContainer.getWindowingMode()) .setMetadata(METADATA_OWNER_UID, Process.myUid()) Loading @@ -108,18 +97,14 @@ class WindowContainerThumbnail implements Animatable { ProtoLog.i(WM_SHOW_TRANSACTIONS, " THUMBNAIL %s: CREATE", mSurfaceControl); // Transfer the thumbnail to the surface drawSurface.copyFrom(mSurfaceControl); drawSurface.attachAndQueueBufferWithColorSpace(thumbnailHeader, null); drawSurface.release(); GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(thumbnailHeader); t.setBuffer(mSurfaceControl, graphicBuffer); t.setColorSpace(mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB)); t.show(mSurfaceControl); // We parent the thumbnail to the container, and just place it on top of anything else in // the container. t.setLayer(mSurfaceControl, Integer.MAX_VALUE); if (relative) { t.reparent(mSurfaceControl, mWindowContainer.getSurfaceControl()); } } void startAnimation(Transaction t, Animation anim) { Loading Loading @@ -194,9 +179,6 @@ class WindowContainerThumbnail implements Animatable { @Override public void onAnimationLeashCreated(Transaction t, SurfaceControl leash) { t.setLayer(leash, Integer.MAX_VALUE); if (mRelative) { t.reparent(leash, mWindowContainer.getSurfaceControl()); } } @Override Loading
services/tests/wmtests/src/com/android/server/wm/WindowContainerThumbnailTest.java +3 −4 Original line number Diff line number Diff line Loading @@ -18,14 +18,13 @@ package com.android.server.wm; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; import static org.mockito.ArgumentMatchers.any; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import android.hardware.HardwareBuffer; import android.platform.test.annotations.Presubmit; import android.view.Surface; import androidx.test.filters.FlakyTest; import androidx.test.filters.SmallTest; Loading @@ -51,8 +50,8 @@ public class WindowContainerThumbnailTest extends WindowTestsBase { when(mockAr.getPendingTransaction()).thenReturn(new StubTransaction()); when(mockAr.makeChildSurface(any())).thenReturn(new MockSurfaceControlBuilder()); when(mockAr.makeSurface()).thenReturn(new MockSurfaceControlBuilder()); return new WindowContainerThumbnail(new StubTransaction(), mockAr, buffer, false, mock(Surface.class), mock(SurfaceAnimator.class)); return new WindowContainerThumbnail(new StubTransaction(), mockAr, buffer, mock(SurfaceAnimator.class)); } @Test Loading