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

Commit f1ac3135 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/29938225'] into 24Q4-release.

Change-Id: I7132fb9dc5afcd0e8e719f1160dda2365cb11205
parents a68a5b08 d0114a20
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.hardware.display;

import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.HdrCapabilities.HdrType;
import static android.view.Display.INVALID_DISPLAY;

import android.Manifest;
import android.annotation.FlaggedApi;
@@ -47,6 +48,7 @@ import android.os.Looper;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserManager;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -96,6 +98,8 @@ public final class DisplayManager {
    @GuardedBy("mLock")
    private final WeakDisplayCache mDisplayCache = new WeakDisplayCache();

    private int mDisplayIdToMirror = INVALID_DISPLAY;

    /**
     * Broadcast receiver that indicates when the Wifi display status changes.
     * <p>
@@ -1086,6 +1090,7 @@ public final class DisplayManager {
        if (surface != null) {
            builder.setSurface(surface);
        }
        builder.setDisplayIdToMirror(getDisplayIdToMirror());
        return createVirtualDisplay(builder.build(), handler, callback);
    }

@@ -1163,6 +1168,7 @@ public final class DisplayManager {
        if (surface != null) {
            builder.setSurface(surface);
        }
        builder.setDisplayIdToMirror(getDisplayIdToMirror());
        return createVirtualDisplay(projection, builder.build(), callback, handler);
    }

@@ -1708,6 +1714,16 @@ public final class DisplayManager {
        return mGlobal.getDefaultDozeBrightness(displayId);
    }

    private int getDisplayIdToMirror() {
        if (mDisplayIdToMirror == INVALID_DISPLAY) {
            final UserManager userManager = mContext.getSystemService(UserManager.class);
            mDisplayIdToMirror = userManager.isVisibleBackgroundUsersSupported()
                    ? userManager.getMainDisplayIdAssignedToUser()
                    : DEFAULT_DISPLAY;
        }
        return mDisplayIdToMirror;
    }

    /**
     * Listens for changes in available display devices.
     */