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

Commit 63fe08d3 authored by Oleg Blinnikov's avatar Oleg Blinnikov
Browse files

Content Recorder check mirror confirmation

In case DisplayManager boots longer than
WindowManager, the ContentRecorder may start
recording the content of the primary display
before the boot completes and without user
confirmation.

This is a privacy problem, so we need to wait
until user had a chance to confirm the mirroring.
This is happening after boot completes and the
display is enabled. This is because if user
not confirmed the mirroring, this can be
either during boot, or after boot when the display
is disabled. This is because the way for the user to
re-enable the display is either via confirmation
dialog or via settings, both ensures the
concious action by the user to enable mirroring.

Change-Id: I605d6d5cce8ecdf5d32a79d7e945fce0b59a29c9
Test: atest ExternalDisplayPolicyTest ContentRecorderTests
Bug: 361698995
Flag: com.android.server.display.feature.flags.enable_waiting_confirmation_before_mirroring
parent f21cc714
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
@@ -208,6 +208,11 @@ public class DisplayManagerFlags {
            Flags::blockAutobrightnessChangesOnStylusUsage
    );

    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
@@ -431,6 +436,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.
@@ -489,6 +502,7 @@ public class DisplayManagerFlags {
        pw.println(" " + mNewHdrBrightnessModifier);
        pw.println(" " + mNormalBrightnessForDozeParameter);
        pw.println(" " + mIdleScreenConfigInSubscribingLightSensor);
        pw.println(" " + mEnableWaitingConfirmationBeforeMirroring);
        pw.println(" " + mEnableBatteryStatsForAllDisplays);
        pw.println(" " + mBlockAutobrightnessChangesOnStylusUsage);
    }
+11 −0
Original line number Diff line number Diff line
@@ -358,6 +358,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