Loading core/java/android/view/Display.java +16 −0 Original line number Diff line number Diff line Loading @@ -2055,6 +2055,22 @@ public final class Display { } } /** * Returns whether the display is eligible for hosting tasks. * * For example, if the display is used for mirroring, this will return {@code false}. * * TODO (b/383666349): Rename this later once there is a better option. * * @hide */ public boolean canHostTasks() { synchronized (mLock) { updateDisplayInfoLocked(); return mIsValid && mDisplayInfo.canHostTasks; } } /** * Returns true if the specified UID has access to this display. * @hide Loading core/java/android/view/DisplayInfo.java +16 −1 Original line number Diff line number Diff line Loading @@ -408,6 +408,15 @@ public final class DisplayInfo implements Parcelable { @Nullable public String thermalBrightnessThrottlingDataId; /** * Indicates whether the display is eligible for hosting tasks. * * For example, if the display is used for mirroring, this will be {@code false}. * * @hide */ public boolean canHostTasks; public static final @android.annotation.NonNull Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() { @Override public DisplayInfo createFromParcel(Parcel source) { Loading Loading @@ -493,7 +502,8 @@ public final class DisplayInfo implements Parcelable { && BrightnessSynchronizer.floatEquals(hdrSdrRatio, other.hdrSdrRatio) && thermalRefreshRateThrottling.contentEquals(other.thermalRefreshRateThrottling) && Objects.equals( thermalBrightnessThrottlingDataId, other.thermalBrightnessThrottlingDataId); thermalBrightnessThrottlingDataId, other.thermalBrightnessThrottlingDataId) && canHostTasks == other.canHostTasks; } @Override Loading Loading @@ -561,6 +571,7 @@ public final class DisplayInfo implements Parcelable { hdrSdrRatio = other.hdrSdrRatio; thermalRefreshRateThrottling = other.thermalRefreshRateThrottling; thermalBrightnessThrottlingDataId = other.thermalBrightnessThrottlingDataId; canHostTasks = other.canHostTasks; } public void readFromParcel(Parcel source) { Loading Loading @@ -642,6 +653,7 @@ public final class DisplayInfo implements Parcelable { thermalRefreshRateThrottling = source.readSparseArray(null, SurfaceControl.RefreshRateRange.class); thermalBrightnessThrottlingDataId = source.readString8(); canHostTasks = source.readBoolean(); } @Override Loading Loading @@ -717,6 +729,7 @@ public final class DisplayInfo implements Parcelable { dest.writeFloat(hdrSdrRatio); dest.writeSparseArray(thermalRefreshRateThrottling); dest.writeString8(thermalBrightnessThrottlingDataId); dest.writeBoolean(canHostTasks); } @Override Loading Loading @@ -1020,6 +1033,8 @@ public final class DisplayInfo implements Parcelable { sb.append(thermalRefreshRateThrottling); sb.append(", thermalBrightnessThrottlingDataId "); sb.append(thermalBrightnessThrottlingDataId); sb.append(", canHostTasks "); sb.append(canHostTasks); sb.append("}"); return sb.toString(); } Loading services/core/java/com/android/server/display/DisplayDevice.java +8 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,14 @@ abstract class DisplayDevice { public void onOverlayChangedLocked() { } /** * Returns if the display should only mirror another display rather than showing other content * until it is destroyed. */ public boolean shouldOnlyMirror() { return false; } /** * Sets the display layer stack while in a transaction. */ Loading services/core/java/com/android/server/display/DisplayManagerService.java +23 −6 Original line number Diff line number Diff line Loading @@ -199,7 +199,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; /** * Manages attached displays. * <p> Loading Loading @@ -906,6 +905,16 @@ public final class DisplayManagerService extends SystemService { } } @VisibleForTesting ContentObserver getSettingsObserver() { return mSettingsObserver; } @VisibleForTesting boolean shouldMirrorBuiltInDisplay() { return mMirrorBuiltInDisplay; } DisplayNotificationManager getDisplayNotificationManager() { return mDisplayNotificationManager; } Loading Loading @@ -1230,11 +1239,6 @@ public final class DisplayManagerService extends SystemService { } private void updateMirrorBuiltInDisplaySettingLocked() { if (!mFlags.isDisplayContentModeManagementEnabled()) { Slog.e(TAG, "MirrorBuiltInDisplay setting shouldn't be updated when the flag is off."); return; } synchronized (mSyncRoot) { ContentResolver resolver = mContext.getContentResolver(); final boolean mirrorBuiltInDisplay = Settings.Secure.getIntForUser(resolver, Loading @@ -1243,6 +1247,9 @@ public final class DisplayManagerService extends SystemService { return; } mMirrorBuiltInDisplay = mirrorBuiltInDisplay; if (mFlags.isDisplayContentModeManagementEnabled()) { mLogicalDisplayMapper.forEachLocked(this::updateCanHostTasksIfNeededLocked); } } } Loading Loading @@ -2308,6 +2315,10 @@ public final class DisplayManagerService extends SystemService { mDisplayBrightnesses.append(displayId, new BrightnessPair(brightnessDefault, brightnessDefault)); if (mFlags.isDisplayContentModeManagementEnabled()) { updateCanHostTasksIfNeededLocked(display); } DisplayManagerGlobal.invalidateLocalDisplayInfoCaches(); } Loading Loading @@ -2630,6 +2641,12 @@ public final class DisplayManagerService extends SystemService { } } private void updateCanHostTasksIfNeededLocked(LogicalDisplay display) { if (display.setCanHostTasksLocked(!mMirrorBuiltInDisplay)) { sendDisplayEventIfEnabledLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); } } private void recordTopInsetLocked(@Nullable LogicalDisplay d) { // We must only persist the inset after boot has completed, otherwise we will end up // overwriting the persisted value before the masking flag has been loaded from the Loading services/core/java/com/android/server/display/ExternalDisplayPolicy.java +4 −2 Original line number Diff line number Diff line Loading @@ -217,8 +217,10 @@ class ExternalDisplayPolicy { mExternalDisplayStatsService.onDisplayConnected(logicalDisplay); if ((Build.IS_ENG || Build.IS_USERDEBUG) && SystemProperties.getBoolean(ENABLE_ON_CONNECT, false)) { if (((Build.IS_ENG || Build.IS_USERDEBUG) && SystemProperties.getBoolean(ENABLE_ON_CONNECT, false)) || (mFlags.isDisplayContentModeManagementEnabled() && logicalDisplay.canHostTasksLocked())) { Slog.w(TAG, "External display is enabled by default, bypassing user consent."); mInjector.sendExternalDisplayEventLocked(logicalDisplay, EVENT_DISPLAY_CONNECTED); return; Loading Loading
core/java/android/view/Display.java +16 −0 Original line number Diff line number Diff line Loading @@ -2055,6 +2055,22 @@ public final class Display { } } /** * Returns whether the display is eligible for hosting tasks. * * For example, if the display is used for mirroring, this will return {@code false}. * * TODO (b/383666349): Rename this later once there is a better option. * * @hide */ public boolean canHostTasks() { synchronized (mLock) { updateDisplayInfoLocked(); return mIsValid && mDisplayInfo.canHostTasks; } } /** * Returns true if the specified UID has access to this display. * @hide Loading
core/java/android/view/DisplayInfo.java +16 −1 Original line number Diff line number Diff line Loading @@ -408,6 +408,15 @@ public final class DisplayInfo implements Parcelable { @Nullable public String thermalBrightnessThrottlingDataId; /** * Indicates whether the display is eligible for hosting tasks. * * For example, if the display is used for mirroring, this will be {@code false}. * * @hide */ public boolean canHostTasks; public static final @android.annotation.NonNull Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() { @Override public DisplayInfo createFromParcel(Parcel source) { Loading Loading @@ -493,7 +502,8 @@ public final class DisplayInfo implements Parcelable { && BrightnessSynchronizer.floatEquals(hdrSdrRatio, other.hdrSdrRatio) && thermalRefreshRateThrottling.contentEquals(other.thermalRefreshRateThrottling) && Objects.equals( thermalBrightnessThrottlingDataId, other.thermalBrightnessThrottlingDataId); thermalBrightnessThrottlingDataId, other.thermalBrightnessThrottlingDataId) && canHostTasks == other.canHostTasks; } @Override Loading Loading @@ -561,6 +571,7 @@ public final class DisplayInfo implements Parcelable { hdrSdrRatio = other.hdrSdrRatio; thermalRefreshRateThrottling = other.thermalRefreshRateThrottling; thermalBrightnessThrottlingDataId = other.thermalBrightnessThrottlingDataId; canHostTasks = other.canHostTasks; } public void readFromParcel(Parcel source) { Loading Loading @@ -642,6 +653,7 @@ public final class DisplayInfo implements Parcelable { thermalRefreshRateThrottling = source.readSparseArray(null, SurfaceControl.RefreshRateRange.class); thermalBrightnessThrottlingDataId = source.readString8(); canHostTasks = source.readBoolean(); } @Override Loading Loading @@ -717,6 +729,7 @@ public final class DisplayInfo implements Parcelable { dest.writeFloat(hdrSdrRatio); dest.writeSparseArray(thermalRefreshRateThrottling); dest.writeString8(thermalBrightnessThrottlingDataId); dest.writeBoolean(canHostTasks); } @Override Loading Loading @@ -1020,6 +1033,8 @@ public final class DisplayInfo implements Parcelable { sb.append(thermalRefreshRateThrottling); sb.append(", thermalBrightnessThrottlingDataId "); sb.append(thermalBrightnessThrottlingDataId); sb.append(", canHostTasks "); sb.append(canHostTasks); sb.append("}"); return sb.toString(); } Loading
services/core/java/com/android/server/display/DisplayDevice.java +8 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,14 @@ abstract class DisplayDevice { public void onOverlayChangedLocked() { } /** * Returns if the display should only mirror another display rather than showing other content * until it is destroyed. */ public boolean shouldOnlyMirror() { return false; } /** * Sets the display layer stack while in a transaction. */ Loading
services/core/java/com/android/server/display/DisplayManagerService.java +23 −6 Original line number Diff line number Diff line Loading @@ -199,7 +199,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; /** * Manages attached displays. * <p> Loading Loading @@ -906,6 +905,16 @@ public final class DisplayManagerService extends SystemService { } } @VisibleForTesting ContentObserver getSettingsObserver() { return mSettingsObserver; } @VisibleForTesting boolean shouldMirrorBuiltInDisplay() { return mMirrorBuiltInDisplay; } DisplayNotificationManager getDisplayNotificationManager() { return mDisplayNotificationManager; } Loading Loading @@ -1230,11 +1239,6 @@ public final class DisplayManagerService extends SystemService { } private void updateMirrorBuiltInDisplaySettingLocked() { if (!mFlags.isDisplayContentModeManagementEnabled()) { Slog.e(TAG, "MirrorBuiltInDisplay setting shouldn't be updated when the flag is off."); return; } synchronized (mSyncRoot) { ContentResolver resolver = mContext.getContentResolver(); final boolean mirrorBuiltInDisplay = Settings.Secure.getIntForUser(resolver, Loading @@ -1243,6 +1247,9 @@ public final class DisplayManagerService extends SystemService { return; } mMirrorBuiltInDisplay = mirrorBuiltInDisplay; if (mFlags.isDisplayContentModeManagementEnabled()) { mLogicalDisplayMapper.forEachLocked(this::updateCanHostTasksIfNeededLocked); } } } Loading Loading @@ -2308,6 +2315,10 @@ public final class DisplayManagerService extends SystemService { mDisplayBrightnesses.append(displayId, new BrightnessPair(brightnessDefault, brightnessDefault)); if (mFlags.isDisplayContentModeManagementEnabled()) { updateCanHostTasksIfNeededLocked(display); } DisplayManagerGlobal.invalidateLocalDisplayInfoCaches(); } Loading Loading @@ -2630,6 +2641,12 @@ public final class DisplayManagerService extends SystemService { } } private void updateCanHostTasksIfNeededLocked(LogicalDisplay display) { if (display.setCanHostTasksLocked(!mMirrorBuiltInDisplay)) { sendDisplayEventIfEnabledLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); } } private void recordTopInsetLocked(@Nullable LogicalDisplay d) { // We must only persist the inset after boot has completed, otherwise we will end up // overwriting the persisted value before the masking flag has been loaded from the Loading
services/core/java/com/android/server/display/ExternalDisplayPolicy.java +4 −2 Original line number Diff line number Diff line Loading @@ -217,8 +217,10 @@ class ExternalDisplayPolicy { mExternalDisplayStatsService.onDisplayConnected(logicalDisplay); if ((Build.IS_ENG || Build.IS_USERDEBUG) && SystemProperties.getBoolean(ENABLE_ON_CONNECT, false)) { if (((Build.IS_ENG || Build.IS_USERDEBUG) && SystemProperties.getBoolean(ENABLE_ON_CONNECT, false)) || (mFlags.isDisplayContentModeManagementEnabled() && logicalDisplay.canHostTasksLocked())) { Slog.w(TAG, "External display is enabled by default, bypassing user consent."); mInjector.sendExternalDisplayEventLocked(logicalDisplay, EVENT_DISPLAY_CONNECTED); return; Loading