Loading core/java/android/view/Display.java +8 −0 Original line number Diff line number Diff line Loading @@ -374,6 +374,14 @@ public final class Display { */ public static final int FLAG_REAR = 1 << 13; /** * Display flag: Indicates that the orientation of this display is not fixed and is coupled to * the orientation of its content. * * @hide */ public static final int FLAG_ROTATES_WITH_CONTENT = 1 << 14; /** * Display flag: Indicates that the contents of the display should not be scaled * to fit the physical screen dimensions. Used for development only to emulate Loading services/core/java/com/android/server/display/LogicalDisplay.java +3 −0 Original line number Diff line number Diff line Loading @@ -441,6 +441,9 @@ final class LogicalDisplay { if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_ALWAYS_UNLOCKED) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_ALWAYS_UNLOCKED; } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_ROTATES_WITH_CONTENT; } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_TOUCH_FEEDBACK_DISABLED) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_TOUCH_FEEDBACK_DISABLED; } Loading services/core/java/com/android/server/wm/DisplayContent.java +7 −0 Original line number Diff line number Diff line Loading @@ -6498,6 +6498,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return (mDisplayInfo.flags & Display.FLAG_ALWAYS_UNLOCKED) != 0; } /** * @return whether the physical display has a fixed orientation and cannot be rotated. */ boolean isDisplayOrientationFixed() { return (mDisplayInfo.flags & Display.FLAG_ROTATES_WITH_CONTENT) == 0; } /** * @return whether AOD is showing on this display */ Loading services/core/java/com/android/server/wm/DisplayRotation.java +2 −1 Original line number Diff line number Diff line Loading @@ -434,7 +434,8 @@ public class DisplayRotation { final boolean isTv = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK); mDefaultFixedToUserRotation = (isCar || isTv || mService.mIsPc || mDisplayContent.forceDesktopMode()) (isCar || isTv || mService.mIsPc || mDisplayContent.forceDesktopMode() || mDisplayContent.isDisplayOrientationFixed()) // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true // $ adb shell wm size reset Loading services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,41 @@ public class DisplayManagerServiceTest { assertTrue((ddi.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0); } @Test public void testCreateVirtualRotatesWithContent() throws RemoteException { DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector); registerDefaultDisplays(displayManager); // This is effectively the DisplayManager service published to ServiceManager. DisplayManagerService.BinderService bs = displayManager.new BinderService(); String uniqueId = "uniqueId --- Rotates with Content Test"; int width = 600; int height = 800; int dpi = 320; int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT; when(mMockAppToken.asBinder()).thenReturn(mMockAppToken); final VirtualDisplayConfig.Builder builder = new VirtualDisplayConfig.Builder( VIRTUAL_DISPLAY_NAME, width, height, dpi); builder.setFlags(flags); builder.setUniqueId(uniqueId); int displayId = bs.createVirtualDisplay(builder.build(), /* callback= */ mMockAppToken, /* projection= */ null, PACKAGE_NAME); verify(mMockProjectionService, never()).setContentRecordingSession(any(), nullable(IMediaProjection.class)); displayManager.performTraversalInternal(mock(SurfaceControl.Transaction.class)); // flush the handler displayManager.getDisplayHandler().runWithScissors(() -> {}, /* now= */ 0); DisplayDeviceInfo ddi = displayManager.getDisplayDeviceInfoInternal(displayId); assertNotNull(ddi); assertTrue((ddi.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0); } @Test public void testCreateVirtualDisplayOwnFocus() throws RemoteException { DisplayManagerService displayManager = Loading Loading
core/java/android/view/Display.java +8 −0 Original line number Diff line number Diff line Loading @@ -374,6 +374,14 @@ public final class Display { */ public static final int FLAG_REAR = 1 << 13; /** * Display flag: Indicates that the orientation of this display is not fixed and is coupled to * the orientation of its content. * * @hide */ public static final int FLAG_ROTATES_WITH_CONTENT = 1 << 14; /** * Display flag: Indicates that the contents of the display should not be scaled * to fit the physical screen dimensions. Used for development only to emulate Loading
services/core/java/com/android/server/display/LogicalDisplay.java +3 −0 Original line number Diff line number Diff line Loading @@ -441,6 +441,9 @@ final class LogicalDisplay { if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_ALWAYS_UNLOCKED) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_ALWAYS_UNLOCKED; } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_ROTATES_WITH_CONTENT; } if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_TOUCH_FEEDBACK_DISABLED) != 0) { mBaseDisplayInfo.flags |= Display.FLAG_TOUCH_FEEDBACK_DISABLED; } Loading
services/core/java/com/android/server/wm/DisplayContent.java +7 −0 Original line number Diff line number Diff line Loading @@ -6498,6 +6498,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return (mDisplayInfo.flags & Display.FLAG_ALWAYS_UNLOCKED) != 0; } /** * @return whether the physical display has a fixed orientation and cannot be rotated. */ boolean isDisplayOrientationFixed() { return (mDisplayInfo.flags & Display.FLAG_ROTATES_WITH_CONTENT) == 0; } /** * @return whether AOD is showing on this display */ Loading
services/core/java/com/android/server/wm/DisplayRotation.java +2 −1 Original line number Diff line number Diff line Loading @@ -434,7 +434,8 @@ public class DisplayRotation { final boolean isTv = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK); mDefaultFixedToUserRotation = (isCar || isTv || mService.mIsPc || mDisplayContent.forceDesktopMode()) (isCar || isTv || mService.mIsPc || mDisplayContent.forceDesktopMode() || mDisplayContent.isDisplayOrientationFixed()) // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true // $ adb shell wm size reset Loading
services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,41 @@ public class DisplayManagerServiceTest { assertTrue((ddi.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0); } @Test public void testCreateVirtualRotatesWithContent() throws RemoteException { DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector); registerDefaultDisplays(displayManager); // This is effectively the DisplayManager service published to ServiceManager. DisplayManagerService.BinderService bs = displayManager.new BinderService(); String uniqueId = "uniqueId --- Rotates with Content Test"; int width = 600; int height = 800; int dpi = 320; int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT; when(mMockAppToken.asBinder()).thenReturn(mMockAppToken); final VirtualDisplayConfig.Builder builder = new VirtualDisplayConfig.Builder( VIRTUAL_DISPLAY_NAME, width, height, dpi); builder.setFlags(flags); builder.setUniqueId(uniqueId); int displayId = bs.createVirtualDisplay(builder.build(), /* callback= */ mMockAppToken, /* projection= */ null, PACKAGE_NAME); verify(mMockProjectionService, never()).setContentRecordingSession(any(), nullable(IMediaProjection.class)); displayManager.performTraversalInternal(mock(SurfaceControl.Transaction.class)); // flush the handler displayManager.getDisplayHandler().runWithScissors(() -> {}, /* now= */ 0); DisplayDeviceInfo ddi = displayManager.getDisplayDeviceInfoInternal(displayId); assertNotNull(ddi); assertTrue((ddi.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0); } @Test public void testCreateVirtualDisplayOwnFocus() throws RemoteException { DisplayManagerService displayManager = Loading