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

Commit 891aed2a authored by Chilun's avatar Chilun
Browse files

Prohibit showing system decorations on untrusted virtual displays

Enable "Force destop mode" will enable system decorations on all
virtual displays and system will put launchers on untrusted virtual
displays.

This is to prohibit showing system decorations on untrusted virtual
displays for "Force desktop mode".

Change-Id: Ibcda42291ed51157172fdbb192f46f16bef91162
Bug: 130264203
Test: atest MultiDisplaySystemDecorationTests
parent 81894407
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -4916,11 +4916,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    boolean supportsSystemDecorations() {
        return (mWmService.mDisplayWindowSettings.shouldShowSystemDecorsLocked(this)
                || (mDisplay.getFlags() & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0
                || mWmService.mForceDesktopModeOnExternalDisplays)
                || (mWmService.mForceDesktopModeOnExternalDisplays && !isUntrustedVirtualDisplay()))
                // VR virtual display will be used to run and render 2D app within a VR experience.
                && mDisplayId != mWmService.mVr2dDisplayId;
    }

    /**
     * @return {@code true} if the display is non-system created virtual display.
     */
    boolean isUntrustedVirtualDisplay() {
        return mDisplay.getType() == Display.TYPE_VIRTUAL
                && mDisplay.getOwnerUid() != Process.SYSTEM_UID;
    }

    /**
     * Re-parent the DisplayContent's top surfaces, {@link #mWindowingLayer} and
     * {@link #mOverlayLayer} to the specified surfaceControl.
+2 −13
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.TYPE_VIRTUAL;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
@@ -164,7 +163,6 @@ import android.os.PowerManager;
import android.os.PowerManager.ServiceType;
import android.os.PowerManagerInternal;
import android.os.PowerSaveState;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
@@ -6873,21 +6871,13 @@ public class WindowManagerService extends IWindowManager.Stub
                        + "not exist: " + displayId);
                return false;
            }
            final Display display = displayContent.getDisplay();
            if (isUntrustedVirtualDisplay(display)) {
            if (displayContent.isUntrustedVirtualDisplay()) {
                return false;
            }
            return displayContent.supportsSystemDecorations();
        }
    }

    /**
     * @return {@code true} if the display is non-system created virtual display.
     */
    private static boolean isUntrustedVirtualDisplay(Display display) {
        return display.getType() == TYPE_VIRTUAL && display.getOwnerUid() != Process.SYSTEM_UID;
    }

    @Override
    public void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
        if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "setShouldShowSystemDecors()")) {
@@ -6921,8 +6911,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        + displayId);
                return false;
            }
            final Display display = displayContent.getDisplay();
            if (isUntrustedVirtualDisplay(display)) {
            if (displayContent.isUntrustedVirtualDisplay()) {
                return false;
            }
            return mDisplayWindowSettings.shouldShowImeLocked(displayContent)