From d44449df803d86233a74bb895a99c1f2cd2650b5 Mon Sep 17 00:00:00 2001 From: chaviw Date: Wed, 2 Jan 2019 16:33:12 -0800 Subject: Forward setVisibility call to SurfaceView for ActivityView. SurfaceView setVisibility handles removing the surface already. By forwarding the visiblity call from AV to the SV, SV will destroy the surface. It will callback into AV through SurfaceCallback.surfaceDestroyed. In the callback, AV removes the surface for the display, causing the virtual display to turn off. When the virtual display is turned off, the activities on that display will get stopped. Test: ActivityViewVisibilityActivity Change-Id: Iea8b57d7871b8c87457f2ae19485a610d0d74c38 --- core/java/android/app/ActivityView.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index 680fed80d029..b86ba58d8c69 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -37,6 +37,7 @@ import android.view.SurfaceControl; import android.view.SurfaceHolder; import android.view.SurfaceSession; import android.view.SurfaceView; +import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManagerGlobal; @@ -345,6 +346,12 @@ public class ActivityView extends ViewGroup { } } + @Override + protected void onVisibilityChanged(View changedView, int visibility) { + super.onVisibilityChanged(changedView, visibility); + mSurfaceView.setVisibility(visibility); + } + private void initVirtualDisplay(SurfaceSession surfaceSession) { if (mVirtualDisplay != null) { throw new IllegalStateException("Trying to initialize for the second time."); -- cgit v1.2.3-59-g8ed1b