diff options
| author | 2017-04-12 15:20:33 -0700 | |
|---|---|---|
| committer | 2017-04-17 18:11:02 +0000 | |
| commit | 728d81f67326ad0c2f468d1da560936b5ffb90a0 (patch) | |
| tree | fb86154046835ee94181934beeccc8c2dbd0484b | |
| parent | feada91060fe356a86a9a4e16e3c8c8f60c69389 (diff) | |
Clean up ImageReader when VrMode is disabled.
Adjusts some of the startImageReader code as well.
Bug: 34281731
Test: Start a VR App and ensure the virtual display is functional.
Start it a second time and ensure the virtual display is functional.
Previously, any session after the first did not have a functional
virtual display.
Change-Id: Ifbf9fb9466f550ae3e9b30a1d7cf4d2f0a32578b
| -rw-r--r-- | services/core/java/com/android/server/vr/CompatibilityDisplay.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/vr/CompatibilityDisplay.java b/services/core/java/com/android/server/vr/CompatibilityDisplay.java index ee615fd6fde4..c6e52cdac2e1 100644 --- a/services/core/java/com/android/server/vr/CompatibilityDisplay.java +++ b/services/core/java/com/android/server/vr/CompatibilityDisplay.java @@ -107,7 +107,6 @@ class CompatibilityDisplay { // TODO: STOPSHIP Remove createVirtualDisplay conditional before launching. if (createVirtualDisplay) { startVirtualDisplay(); - startImageReader(); } } else { // Stop virtual display to test exit condition @@ -208,6 +207,8 @@ class CompatibilityDisplay { if (mVirtualDisplay != null) { mActivityManagerInternal.setVrCompatibilityDisplayId( mVirtualDisplay.getDisplay().getDisplayId()); + // Now create the ImageReader to supply a Surface to the new virtual display. + startImageReader(); } else { Log.w(TAG, "Virtual display id is null after createVirtualDisplay"); mActivityManagerInternal.setVrCompatibilityDisplayId(INVALID_DISPLAY); @@ -241,6 +242,7 @@ class CompatibilityDisplay { mVirtualDisplay.release(); mVirtualDisplay = null; } + stopImageReader(); } } } @@ -286,4 +288,14 @@ class CompatibilityDisplay { setSurfaceLocked(mImageReader.getSurface()); } } + + /** + * Cleans up the ImageReader. + */ + private void stopImageReader() { + if (mImageReader != null) { + mImageReader.close(); + mImageReader = null; + } + } } |