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

Commit 46ede929 authored by Oleg Blinnikov's avatar Oleg Blinnikov Committed by Android (Google) Code Review
Browse files

Merge "Content Recorder check mirror confirmation" into main

parents f613f7fe 63fe08d3
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -460,6 +460,16 @@ public abstract class DisplayManagerInternal {
     */
    public abstract void stylusGestureStarted(long eventTime);

    /**
     * Called by {@link com.android.server.wm.ContentRecorder} to verify whether
     * the display is allowed to mirror primary display's content.
     * @param displayId the id of the display where we mirror to.
     * @return true if the mirroring dialog is confirmed (display is enabled), or
     * {@link com.android.server.display.ExternalDisplayPolicy#ENABLE_ON_CONNECT}
     * system property is enabled.
     */
    public abstract boolean isDisplayReadyForMirroring(int displayId);

    /**
     * Describes the requested power state of the display.
     *
+5 −0
Original line number Diff line number Diff line
@@ -5666,6 +5666,11 @@ public final class DisplayManagerService extends SystemService {
                displayPowerController.stylusGestureStarted(eventTime);
            }
        }

        @Override
        public boolean isDisplayReadyForMirroring(int displayId) {
            return mExternalDisplayPolicy.isDisplayReadyForMirroring(displayId);
        }
    }

    class DesiredDisplayModeSpecsObserver
+48 −0
Original line number Diff line number Diff line
@@ -375,6 +375,54 @@ class ExternalDisplayPolicy {
        }
    }

    boolean isDisplayReadyForMirroring(int displayId) {
        if (!mFlags.isWaitingConfirmationBeforeMirroringEnabled()) {
            if (DEBUG) {
                Slog.d(TAG, "isDisplayReadyForMirroring: mirroring CONFIRMED - "
                        + " flag 'waiting for confirmation before mirroring' is disabled");
            }
            return true;
        }

        synchronized (mSyncRoot) {
            if (!mIsBootCompleted) {
                if (DEBUG) {
                    Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
                            + "boot is in progress");
                }
                return false;
            }

            var logicalDisplay = mLogicalDisplayMapper.getDisplayLocked(displayId);
            if (logicalDisplay == null) {
                if (DEBUG) {
                    Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
                            + "logicalDisplay is null");
                }
                return false;
            }

            if (!isExternalDisplayLocked(logicalDisplay)) {
                if (DEBUG) {
                    Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
                            + "logicalDisplay" + logicalDisplay.getDisplayIdLocked()
                            + " type is " + logicalDisplay.getDisplayInfoLocked().type);
                }
                return false;
            }

            if (!logicalDisplay.isEnabledLocked()) {
                if (DEBUG) {
                    Slog.d(TAG, "isDisplayReadyForMirroring: mirroring is not confirmed - "
                            + "logicalDisplay is disabled");
                }
                return false;
            }
        }

        return true;
    }

    private final class SkinThermalStatusObserver extends IThermalEventListener.Stub {
        @Override
        public void notifyThrottling(@NonNull final Temperature temp) {
+14 −0
Original line number Diff line number Diff line
@@ -217,6 +217,11 @@ public class DisplayManagerFlags {
            Flags::enableUserRefreshRateForExternalDisplay
    );

    private final FlagState mEnableWaitingConfirmationBeforeMirroring = new FlagState(
            Flags.FLAG_ENABLE_WAITING_CONFIRMATION_BEFORE_MIRRORING,
            Flags::enableWaitingConfirmationBeforeMirroring
    );

    private final FlagState mEnableBatteryStatsForAllDisplays = new FlagState(
            Flags.FLAG_ENABLE_BATTERY_STATS_FOR_ALL_DISPLAYS,
            Flags::enableBatteryStatsForAllDisplays
@@ -444,6 +449,14 @@ public class DisplayManagerFlags {
        return mIdleScreenConfigInSubscribingLightSensor.isEnabled();
    }

    /**
      * @return {@code true} if mirroring won't be enabled until boot completes and the user enables
      * the display.
      */
    public boolean isWaitingConfirmationBeforeMirroringEnabled() {
        return mEnableWaitingConfirmationBeforeMirroring.isEnabled();
    }

    /**
      * @return {@code true} if battery stats is enabled for all displays, not just the primary
      * display.
@@ -511,6 +524,7 @@ public class DisplayManagerFlags {
        pw.println(" " + mVirtualDisplayLimit);
        pw.println(" " + mNormalBrightnessForDozeParameter);
        pw.println(" " + mIdleScreenConfigInSubscribingLightSensor);
        pw.println(" " + mEnableWaitingConfirmationBeforeMirroring);
        pw.println(" " + mEnableBatteryStatsForAllDisplays);
        pw.println(" " + mBlockAutobrightnessChangesOnStylusUsage);
        pw.println(" " + mIsUserRefreshRateForExternalDisplayEnabled);
+11 −0
Original line number Diff line number Diff line
@@ -366,6 +366,17 @@ flag {
    }
}

flag {
    name: "enable_waiting_confirmation_before_mirroring"
    namespace: "display_manager"
    description: "Allow ContentRecorder checking whether user confirmed mirroring after boot"
    bug: "361698995"
    is_fixed_read_only: true
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_battery_stats_for_all_displays"
    namespace: "display_manager"
Loading