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

Commit 7ff7089e authored by Andy Wickham's avatar Andy Wickham Committed by Android Build Coastguard Worker
Browse files

Add displayId to WindowManagerPolicy#isScreenOn().

This allows certain flows to continue to work even if the default
display is off. For example, when taking an Assist screenshot for
Contextual Search, DisplayContent checks if the screen is on. This
previously only checked the default display, but now instead checks
the display where the search is invoked.

Fix: 441675960
Test: Connect phone to external display, wait for primary display to
time out, invoke Contextual Search on the external display.
Test: atest DisplayPolicyTests WindowManagerServiceTests
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:d658f0f0c78d94b367f3056a84af1b3c95c4a21e
Merged-In: I21ae35333551e170127be546d1cc8ca09bad4448
Change-Id: I21ae35333551e170127be546d1cc8ca09bad4448
parent 1efe5fd7
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -386,6 +386,7 @@ public class ContextualSearchManagerService extends SystemService {
            }
            }
        }
        }
        final int displayId = getDisplayIdFromConfig(config);
        final int displayId = getDisplayIdFromConfig(config);
        if (DEBUG) Log.d(TAG, "Taking contextual search screenshot for displayId=" + displayId);
        final ScreenshotHardwareBuffer shb =
        final ScreenshotHardwareBuffer shb =
                mWmInternal.takeContextualSearchScreenshot(csUid, displayId);
                mWmInternal.takeContextualSearchScreenshot(csUid, displayId);
        final Bitmap bm = shb != null ? shb.asBitmap() : null;
        final Bitmap bm = shb != null ? shb.asBitmap() : null;
+11 −2
Original line number Original line Diff line number Diff line
@@ -5788,8 +5788,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }
    }


    @Override
    @Override
    public boolean isScreenOn() {
    public boolean isScreenOn(int displayId) {
        return mDefaultDisplayPolicy.isScreenOnEarly();
        final DisplayPolicy policy = getDisplayPolicy(displayId);
        return policy != null && policy.isScreenOnEarly();
    }

    @Nullable
    private DisplayPolicy getDisplayPolicy(int displayId) {
        if (displayId == DEFAULT_DISPLAY) {
            return mDefaultDisplayPolicy;
        }
        return mWindowManagerInternal.getDisplayPolicy(displayId);
    }
    }


    @Override
    @Override
+11 −1
Original line number Original line Diff line number Diff line
@@ -906,8 +906,18 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {


    /**
    /**
     * Return whether the default display is on and not blocked by a black surface.
     * Return whether the default display is on and not blocked by a black surface.
     *
     * @deprecated Use {@link #isScreenOn(int)} instead, to better support multi-display.
     */
    @Deprecated
    default boolean isScreenOn() {
        return isScreenOn(Display.DEFAULT_DISPLAY);
    }

    /**
     * Return whether the specified display is on and not blocked by a black surface.
     */
     */
    public boolean isScreenOn();
    boolean isScreenOn(int displayId);


    /**
    /**
     * @param ignoreScreenOn {@code true} if screen state should be ignored.
     * @param ignoreScreenOn {@code true} if screen state should be ignored.
+3 −2
Original line number Original line Diff line number Diff line
@@ -5304,9 +5304,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
     */
    LayerCaptureArgs getLayerCaptureArgs(@Nullable ToBooleanFunction<WindowState> predicate,
    LayerCaptureArgs getLayerCaptureArgs(@Nullable ToBooleanFunction<WindowState> predicate,
            boolean useWindowingLayerAsScreenshotRoot) {
            boolean useWindowingLayerAsScreenshotRoot) {
        if (!mWmService.mPolicy.isScreenOn()) {
        if (!mWmService.mPolicy.isScreenOn(mDisplayId)) {
            if (DEBUG_SCREENSHOT) {
            if (DEBUG_SCREENSHOT) {
                Slog.i(TAG_WM, "Attempted to take screenshot while display was off.");
                Slog.i(TAG_WM, "Attempted to take screenshot while display " + mDisplayId
                        + " was off.");
            }
            }
            return null;
            return null;
        }
        }
+10 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@ import android.window.ScreenCaptureInternal.ScreenshotHardwareBuffer;
import com.android.internal.policy.KeyInterceptionInfo;
import com.android.internal.policy.KeyInterceptionInfo;
import com.android.server.input.InputManagerService;
import com.android.server.input.InputManagerService;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.wm.DisplayPolicy;
import com.android.server.wm.SensitiveContentPackages.PackageInfo;
import com.android.server.wm.SensitiveContentPackages.PackageInfo;


import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
@@ -872,6 +873,15 @@ public abstract class WindowManagerInternal {
     */
     */
    public abstract Context getDisplayUiContext(int displayId);
    public abstract Context getDisplayUiContext(int displayId);


    /**
     * Returns the display policy for a given display.
     *
     * @param displayId The display id.
     * @return The display policy, or null if display not found.
     */
    @Nullable
    public abstract DisplayPolicy getDisplayPolicy(int displayId);

    /**
    /**
     * Sets the rotation of a non-default display.
     * Sets the rotation of a non-default display.
     *
     *
Loading