Loading services/core/java/com/android/server/display/DisplayDevice.java +8 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,14 @@ abstract class DisplayDevice { return false; } /** * Returns whether content should be automatically mirrored on the display when no content is * currently being shown. */ boolean shouldAutoMirror() { return false; } /** * Sets the display layer stack while in a transaction. */ Loading services/core/java/com/android/server/display/LogicalDisplay.java +16 −0 Original line number Diff line number Diff line Loading @@ -998,6 +998,22 @@ final class LogicalDisplay { return true; } // The display that should always show system decorations can always host tasks. // See DisplayDeviceInfo#FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS. final boolean shouldAlwaysShowSysDecors = (mPrimaryDisplayDevice.getDisplayDeviceInfoLocked().flags & DisplayDeviceInfo.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0; if (shouldAlwaysShowSysDecors) { return true; } // The display that should auto mirror can always host tasks. // TODO(b/426331944): Change the behavior of VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR and returns // false for this if (mPrimaryDisplayDevice.shouldAutoMirror()) { return true; } return canHostTasks; } Loading services/core/java/com/android/server/display/VirtualDisplayAdapter.java +9 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUST import android.annotation.Nullable; import android.content.Context; import android.graphics.Point; import android.hardware.display.DisplayManager; import android.hardware.display.IBrightnessListener; import android.hardware.display.IVirtualDisplayCallback; import android.hardware.display.VirtualDisplayConfig; Loading Loading @@ -547,6 +548,14 @@ public class VirtualDisplayAdapter extends DisplayAdapter { return mProjection != null; } /** * See {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR}. */ @Override boolean shouldAutoMirror() { return (mFlags & VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0; } public void setSurfaceLocked(Surface surface) { if (!mStopped && mSurface != surface) { if (mDisplayState == Display.STATE_ON Loading services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -692,4 +692,32 @@ public class LogicalDisplayTest { mLogicalDisplay.setCanHostTasksLocked(false); assertTrue(mLogicalDisplay.canHostTasksLocked()); } @Test public void testSetCanHostTasks_nonDefaultShouldAlwaysShowSysDecors() { mDisplayDeviceInfo.flags = DisplayDeviceInfo.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS; mLogicalDisplay = new LogicalDisplay(Display.DEFAULT_DISPLAY + 1, LAYER_STACK, mDisplayDevice); mLogicalDisplay.setCanHostTasksLocked(true); assertTrue(mLogicalDisplay.canHostTasksLocked()); mLogicalDisplay.setCanHostTasksLocked(false); assertTrue(mLogicalDisplay.canHostTasksLocked()); } @Test public void testSetCanHostTasks_nonDefaultNeverBlank() { mDisplayDeviceInfo.type = Display.TYPE_VIRTUAL; when(mDisplayDevice.shouldAutoMirror()).thenReturn(true); mLogicalDisplay = new LogicalDisplay(Display.DEFAULT_DISPLAY + 1, LAYER_STACK, mDisplayDevice); mLogicalDisplay.updateLocked(mDeviceRepo, mSyntheticModeManager); mLogicalDisplay.setCanHostTasksLocked(true); assertTrue(mLogicalDisplay.canHostTasksLocked()); mLogicalDisplay.setCanHostTasksLocked(false); assertTrue(mLogicalDisplay.canHostTasksLocked()); } } Loading
services/core/java/com/android/server/display/DisplayDevice.java +8 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,14 @@ abstract class DisplayDevice { return false; } /** * Returns whether content should be automatically mirrored on the display when no content is * currently being shown. */ boolean shouldAutoMirror() { return false; } /** * Sets the display layer stack while in a transaction. */ Loading
services/core/java/com/android/server/display/LogicalDisplay.java +16 −0 Original line number Diff line number Diff line Loading @@ -998,6 +998,22 @@ final class LogicalDisplay { return true; } // The display that should always show system decorations can always host tasks. // See DisplayDeviceInfo#FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS. final boolean shouldAlwaysShowSysDecors = (mPrimaryDisplayDevice.getDisplayDeviceInfoLocked().flags & DisplayDeviceInfo.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0; if (shouldAlwaysShowSysDecors) { return true; } // The display that should auto mirror can always host tasks. // TODO(b/426331944): Change the behavior of VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR and returns // false for this if (mPrimaryDisplayDevice.shouldAutoMirror()) { return true; } return canHostTasks; } Loading
services/core/java/com/android/server/display/VirtualDisplayAdapter.java +9 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUST import android.annotation.Nullable; import android.content.Context; import android.graphics.Point; import android.hardware.display.DisplayManager; import android.hardware.display.IBrightnessListener; import android.hardware.display.IVirtualDisplayCallback; import android.hardware.display.VirtualDisplayConfig; Loading Loading @@ -547,6 +548,14 @@ public class VirtualDisplayAdapter extends DisplayAdapter { return mProjection != null; } /** * See {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR}. */ @Override boolean shouldAutoMirror() { return (mFlags & VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0; } public void setSurfaceLocked(Surface surface) { if (!mStopped && mSurface != surface) { if (mDisplayState == Display.STATE_ON Loading
services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -692,4 +692,32 @@ public class LogicalDisplayTest { mLogicalDisplay.setCanHostTasksLocked(false); assertTrue(mLogicalDisplay.canHostTasksLocked()); } @Test public void testSetCanHostTasks_nonDefaultShouldAlwaysShowSysDecors() { mDisplayDeviceInfo.flags = DisplayDeviceInfo.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS; mLogicalDisplay = new LogicalDisplay(Display.DEFAULT_DISPLAY + 1, LAYER_STACK, mDisplayDevice); mLogicalDisplay.setCanHostTasksLocked(true); assertTrue(mLogicalDisplay.canHostTasksLocked()); mLogicalDisplay.setCanHostTasksLocked(false); assertTrue(mLogicalDisplay.canHostTasksLocked()); } @Test public void testSetCanHostTasks_nonDefaultNeverBlank() { mDisplayDeviceInfo.type = Display.TYPE_VIRTUAL; when(mDisplayDevice.shouldAutoMirror()).thenReturn(true); mLogicalDisplay = new LogicalDisplay(Display.DEFAULT_DISPLAY + 1, LAYER_STACK, mDisplayDevice); mLogicalDisplay.updateLocked(mDeviceRepo, mSyntheticModeManager); mLogicalDisplay.setCanHostTasksLocked(true); assertTrue(mLogicalDisplay.canHostTasksLocked()); mLogicalDisplay.setCanHostTasksLocked(false); assertTrue(mLogicalDisplay.canHostTasksLocked()); } }