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

Commit 619dfd59 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Use layer mirroring when screen recording via VD"

parents 66b5bad0 e64bae45
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -373,6 +373,15 @@ public abstract class DisplayManagerInternal {
     */
    public abstract Point getDisplaySurfaceDefaultSize(int displayId);

    /**
     * Get a new displayId which represents the display you want to mirror. If mirroring is not
     * enabled on the display, {@link Display#INVALID_DISPLAY} will be returned.
     *
     * @param displayId The id of the display.
     * @return The displayId that should be mirrored or INVALID_DISPLAY if mirroring is not enabled.
     */
    public abstract int getDisplayIdToMirror(int displayId);

    /**
     * Receives early interactivity changes from power manager.
     *
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public enum ProtoLogGroup implements IProtoLogGroup {
            Consts.TAG_WM),
    WM_DEBUG_WINDOW_INSETS(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
            Consts.TAG_WM),
    WM_DEBUG_CONTENT_RECORDING(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
    WM_DEBUG_CONTENT_RECORDING(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
            Consts.TAG_WM),
    WM_DEBUG_WALLPAPER(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false, Consts.TAG_WM),
    WM_DEBUG_BACK_PREVIEW(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, true,
+24 −0
Original line number Diff line number Diff line
@@ -13,12 +13,24 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-2123789565": {
      "message": "Found no matching mirror display for id=%d for DEFAULT_DISPLAY. Nothing to mirror.",
      "level": "WARN",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-2121056984": {
      "message": "%s",
      "level": "WARN",
      "group": "WM_DEBUG_LOCKTASK",
      "at": "com\/android\/server\/wm\/LockTaskController.java"
    },
    "-2113780196": {
      "message": "Successfully created a ContentRecordingSession for displayId=%d to mirror content from displayId=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-2111539867": {
      "message": "remove IME snapshot, caller=%s",
      "level": "INFO",
@@ -1303,6 +1315,12 @@
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-838378223": {
      "message": "Attempting to mirror self on %d",
      "level": "WARN",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-814760297": {
      "message": "Looking for task of %s in %s",
      "level": "DEBUG",
@@ -1411,6 +1429,12 @@
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "-729864558": {
      "message": "Attempting to mirror %d from %d but no DisplayContent associated. Changing to mirror default display.",
      "level": "WARN",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-729530161": {
      "message": "Moving to DESTROYED: %s (no app)",
      "level": "VERBOSE",
+4 −3
Original line number Diff line number Diff line
@@ -127,12 +127,13 @@ abstract class DisplayDevice {

    /**
     * Returns the default size of the surface associated with the display, or null if the surface
     * is not provided for layer mirroring by SurfaceFlinger.
     * Only used for mirroring started from MediaProjection.
     * is not provided for layer mirroring by SurfaceFlinger. For non virtual displays, this will
     * be the actual display device's size.
     */
    @Nullable
    public Point getDisplaySurfaceDefaultSizeLocked() {
        return null;
        DisplayDeviceInfo displayDeviceInfo = getDisplayDeviceInfoLocked();
        return new Point(displayDeviceInfo.width, displayDeviceInfo.height);
    }

    /**
+31 −26
Original line number Diff line number Diff line
@@ -2214,24 +2214,10 @@ public final class DisplayManagerService extends SystemService {

    private void configureDisplayLocked(SurfaceControl.Transaction t, DisplayDevice device) {
        final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;

        // Find the logical display that the display device is showing.
        // Certain displays only ever show their own content.
        LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(device);
        // Proceed with display-managed mirroring only if window manager will not be handling it.
        if (!ownContent && !device.isWindowManagerMirroringLocked()) {
            // Only mirror the display if content recording is not taking place in WM.
            if (display != null && !display.hasContentLocked()) {
                // If the display does not have any content of its own, then
                // automatically mirror the requested logical display contents if possible.
                display = mLogicalDisplayMapper.getDisplayLocked(
                        device.getDisplayIdToMirrorLocked());
            }
            if (display == null) {
                display = mLogicalDisplayMapper.getDisplayLocked(Display.DEFAULT_DISPLAY);
            }
        }

        // Apply the logical display configuration to the display device.
        if (display == null) {
@@ -2545,18 +2531,6 @@ public final class DisplayManagerService extends SystemService {
        }
    }

    @VisibleForTesting
    int getDisplayIdToMirrorInternal(int displayId) {
        synchronized (mSyncRoot) {
            final LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(displayId);
            if (display != null) {
                final DisplayDevice displayDevice = display.getPrimaryDisplayDeviceLocked();
                return displayDevice.getDisplayIdToMirrorLocked();
            }
            return Display.INVALID_DISPLAY;
        }
    }

    @VisibleForTesting
    Surface getVirtualDisplaySurfaceInternal(IBinder appToken) {
        synchronized (mSyncRoot) {
@@ -3853,6 +3827,37 @@ public final class DisplayManagerService extends SystemService {
                return null;
            }
        }

        @Override
        public int getDisplayIdToMirror(int displayId) {
            synchronized (mSyncRoot) {
                final LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(displayId);
                if (display == null) {
                    return Display.INVALID_DISPLAY;
                }

                final DisplayDevice displayDevice = display.getPrimaryDisplayDeviceLocked();
                final boolean ownContent = (displayDevice.getDisplayDeviceInfoLocked().flags
                        & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;
                // If the display has enabled mirroring, but specified that it will be managed by
                // WindowManager, return an invalid display id. This is to ensure we don't
                // accidentally select the display id to mirror based on DM logic and instead allow
                // the caller to specify what area to mirror.
                if (ownContent || displayDevice.isWindowManagerMirroringLocked()) {
                    return Display.INVALID_DISPLAY;
                }

                int displayIdToMirror = displayDevice.getDisplayIdToMirrorLocked();
                LogicalDisplay displayToMirror = mLogicalDisplayMapper.getDisplayLocked(
                        displayIdToMirror);
                // If the displayId for the requested mirror doesn't exist, fallback to mirroring
                // default display.
                if (displayToMirror == null) {
                    displayIdToMirror = Display.DEFAULT_DISPLAY;
                }
                return displayIdToMirror;
            }
        }
    }

    class DesiredDisplayModeSpecsObserver
Loading