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

Commit 0eb37e5f authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge changes I22d45015,I9aa4b894 into main

* changes:
  Desktop: Use new WM API to check for Desktop-host eligibility.
  Don't allow app handle/header on displays not in topology.
parents 4722d128 8b6aefdc
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS;
import static android.view.WindowLayoutParamsProto.X;
import static android.view.WindowLayoutParamsProto.Y;

import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT;

import android.Manifest.permission;
import android.annotation.CallbackExecutor;
import android.annotation.FlaggedApi;
@@ -1872,6 +1874,19 @@ public interface WindowManager extends ViewManager {
        return false;
    }

    /**
     * Indicates that the display is eligible for the desktop mode from WindowManager's perspective.
     *
     * @param displayId The id of the display.
     * @return {@code true} if the display is eligible for the desktop mode from WindowManager's
     * perspective.
     * @hide
     */
    @FlaggedApi(FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT)
    default boolean isEligibleForDesktopMode(int displayId) {
        return false;
    }

    /**
     * Sets the policy for how the display should show IME.
     *
+10 −0
Original line number Diff line number Diff line
@@ -338,6 +338,16 @@ public class WindowManagerImpl implements WindowManager {
        return false;
    }

    @Override
    public boolean isEligibleForDesktopMode(int displayId) {
        try {
            return WindowManagerGlobal.getWindowManagerService()
                    .isEligibleForDesktopMode(displayId);
        } catch (RemoteException e) {
        }
        return false;
    }

    @Override
    public void setDisplayImePolicy(int displayId, @DisplayImePolicy int imePolicy) {
        try {
+1 −1
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ public class DesktopModeStatus {
                || display.getType() == Display.TYPE_OVERLAY)
                && enableDisplayContentModeManagement()) {
            final WindowManager wm = context.getSystemService(WindowManager.class);
            return wm != null && wm.shouldShowSystemDecors(display.getDisplayId());
            return wm != null && wm.isEligibleForDesktopMode(display.getDisplayId());
        }

        return false;
+8 −0
Original line number Diff line number Diff line
@@ -111,6 +111,14 @@ public class DisplayController {
        return mDisplayManager.getDisplay(displayId);
    }

    /**
     * Returns true if the display with the given displayId is part of the topology.
     */
    public boolean isDisplayInTopology(int displayId) {
        return mDisplayTopology != null
                && mDisplayTopology.findDisplay(displayId, mDisplayTopology.getRoot()) != null;
    }

    /**
     * Gets the DisplayLayout associated with a display.
     */
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.windowdecor.common
import android.app.ActivityManager
import android.app.WindowConfiguration
import android.content.Context
import android.view.Display
import android.view.WindowManager
import android.window.DesktopExperienceFlags.ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY
import com.android.wm.shell.common.DisplayController
@@ -99,6 +100,11 @@ class AppHandleAndHeaderVisibilityHelper (
        val display = displayController.getDisplay(displayId)
        if (display == null) return false

        if (display.type != Display.TYPE_INTERNAL
            && !displayController.isDisplayInTopology(displayId)) {
            return false
        }

        if (DesktopModeStatus.isDesktopModeSupportedOnDisplay(context, display)) {
            return true
        }
Loading