Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23cbd0ec authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Do not consider "desktop" displays as fixed orientation

The current logic breaks public trusted virtual displays not
created with VDM, even if FLAG_ROTATES_WITH_CONTENT is
explicitly specified.

Additionally, isPublicSecondaryDisplayWithDesktopModeForceEnabled
should return "false" for virtual displays in general, because
the freeform windowing mode also breaks orientation requests from
activities running on these displays.

The new logic in isPublicSecondaryDisplayWithDesktopModeForceEnabled:
  - return false if FREEFORM is not supported on this display. This
    automatically includes all VDM displays because VDM doesn't
    support this windowing mode (for now)
  - return false for virtual displays without system decorations
    support (to allow virtual displays to explicitly opt-in - this API
    is hidden, and we can expose a different API in the future)

Fix: 407786865
Test: atest VirtualDisplayTest
Test: presubmit
Flag: EXEMPT bugfix

Change-Id: I42049d7f9b17eb365269fe8e25c7a64b289cd446
parent 40af2bbb
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -5735,8 +5735,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    /**
     * This is the development option to force enable desktop mode on all secondary public displays
     * that are not owned by a virtual device.
     * This is the development option to force enable desktop mode on all secondary public displays.
     * When this is enabled, it also force enable system decorations on those displays.
     *
     * If we need a per-display config to enable desktop mode for production, that config should
@@ -5746,9 +5745,16 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (!mWmService.mForceDesktopModeOnExternalDisplays || isDefaultDisplay || isPrivate()) {
            return false;
        }
        // Desktop mode is not supported on virtual devices.
        int deviceId = mRootWindowContainer.mTaskSupervisor.getDeviceIdForDisplayId(mDisplayId);
        return deviceId == Context.DEVICE_ID_DEFAULT;
        if (mDwpcHelper != null && !mDwpcHelper.isWindowingModeSupported(WINDOWING_MODE_FREEFORM)) {
            return false;
        }
        // Virtual displays need to explicitly opt in via the system decorations.
        if (mDisplay.getType() == Display.TYPE_VIRTUAL
                && !mWmService.mDisplayWindowSettings.shouldShowSystemDecorsLocked(this)
                && (mDisplay.getFlags() & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) == 0) {
            return false;
        }
        return true;
    }

    /**
+1 −3
Original line number Diff line number Diff line
@@ -429,9 +429,7 @@ public class DisplayRotation {
        final boolean isTv = mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_LEANBACK);
        mDefaultFixedToUserRotation =
                (isCar || isTv || mService.mIsPc
                        || mDisplayContent.isPublicSecondaryDisplayWithDesktopModeForceEnabled()
                        || !mDisplayContent.shouldRotateWithContent())
                (isCar || isTv || mService.mIsPc || !mDisplayContent.shouldRotateWithContent())
                // For debug purposes the next line turns this feature off with:
                // $ adb shell setprop config.override_forced_orient true
                // $ adb shell wm size reset
+3 −1
Original line number Diff line number Diff line
@@ -508,7 +508,9 @@ public class DisplayWindowSettingsTests extends WindowTestsBase {
    public void testShouldShowImeOnDisplayWithinForceDesktopMode() {
        try {
            // Presume display enabled force desktop mode from developer options.
            final DisplayContent dc = createMockSimulatedDisplay();
            final SettingsEntry settingsEntry = new SettingsEntry();
            settingsEntry.mShouldShowSystemDecors = true;
            final DisplayContent dc = createMockSimulatedDisplay(settingsEntry);
            mWm.setForceDesktopModeOnExternalDisplays(true);
            final WindowManagerInternal wmInternal = LocalServices.getService(
                    WindowManagerInternal.class);