summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rupesh Bansal <brup@google.com> 2024-10-29 23:50:57 +0000
committer Rupesh Bansal <brup@google.com> 2024-11-06 11:29:58 +0000
commitee890b38c66c7e32c7c0fa2994c75b4a0a70b539 (patch)
tree22fc64ed556fc97b879836063d651991d67d5a87
parent49abbf0d1894ed54680484bfc09b32af9fc9d156 (diff)
Added API to register DisplayListener with EventMask
This change does a bunch of things 1. Introduces a new IntDef PrivateEventFlag for clients to subscribe to hidden properties 2. Introduces InternalEventFlag, which unifies both public and private event flags to a single mapping 3. Adds a new hidden API registerDisplayListener which takes in both public and private event masks. Bug: 372700957 Test: atest com.android.server.display Flag: EXEMPT Refactoring Change-Id: I79e85fb1c82aab8da53a2379e79e13a3fc034489
-rw-r--r--core/java/android/hardware/display/DisplayManager.java59
-rw-r--r--core/java/android/hardware/display/DisplayManagerGlobal.java158
-rw-r--r--core/java/android/view/Display.java5
-rw-r--r--core/java/android/view/ViewRootImpl.java7
-rw-r--r--core/java/com/android/internal/display/BrightnessSynchronizer.java4
-rw-r--r--core/java/com/android/internal/jank/DisplayResolutionTracker.java5
-rw-r--r--core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java3
-rw-r--r--core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java35
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/data/repository/ScreenBrightnessDisplayManagerRepositoryTest.kt8
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/brightness/data/repository/ScreenBrightnessRepository.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/DisplayTrackerImpl.kt27
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/settings/DisplayTrackerImplTest.kt13
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java62
-rw-r--r--services/core/java/com/android/server/display/mode/DisplayModeDirector.java17
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/BrightnessSynchronizerTest.java3
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java14
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java63
19 files changed, 329 insertions, 174 deletions
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
index a81bcbcce9c9..a452226c81ac 100644
--- a/core/java/android/hardware/display/DisplayManager.java
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -575,14 +575,22 @@ public final class DisplayManager {
EVENT_FLAG_DISPLAY_ADDED,
EVENT_FLAG_DISPLAY_CHANGED,
EVENT_FLAG_DISPLAY_REMOVED,
- EVENT_FLAG_DISPLAY_BRIGHTNESS,
- EVENT_FLAG_HDR_SDR_RATIO_CHANGED,
- EVENT_FLAG_DISPLAY_CONNECTION_CHANGED,
})
@Retention(RetentionPolicy.SOURCE)
public @interface EventFlag {}
/**
+ * @hide
+ */
+ @LongDef(flag = true, prefix = {"PRIVATE_EVENT_FLAG_"}, value = {
+ PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS,
+ PRIVATE_EVENT_FLAG_HDR_SDR_RATIO_CHANGED,
+ PRIVATE_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface PrivateEventFlag {}
+
+ /**
* Event type for when a new display is added.
*
* @see #registerDisplayListener(DisplayListener, Handler, long)
@@ -618,7 +626,7 @@ public final class DisplayManager {
*
* @hide
*/
- public static final long EVENT_FLAG_DISPLAY_BRIGHTNESS = 1L << 3;
+ public static final long PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS = 1L << 0;
/**
* Event flag to register for a display's hdr/sdr ratio changes. This notification is sent
@@ -631,14 +639,16 @@ public final class DisplayManager {
*
* @hide
*/
- public static final long EVENT_FLAG_HDR_SDR_RATIO_CHANGED = 1L << 4;
+ public static final long PRIVATE_EVENT_FLAG_HDR_SDR_RATIO_CHANGED = 1L << 1;
/**
* Event flag to register for a display's connection changed.
*
+ * @see #registerDisplayListener(DisplayListener, Handler, long)
* @hide
*/
- public static final long EVENT_FLAG_DISPLAY_CONNECTION_CHANGED = 1L << 5;
+ public static final long PRIVATE_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED = 1L << 2;
+
/** @hide */
public DisplayManager(Context context) {
@@ -774,20 +784,49 @@ public final class DisplayManager {
* @param listener The listener to register.
* @param handler The handler on which the listener should be invoked, or null
* if the listener should be invoked on the calling thread's looper.
- * @param eventFlagsMask A bitmask of the event types for which this listener is subscribed.
+ * @param eventFlags A bitmask of the event types for which this listener is subscribed.
+ *
+ * @see #EVENT_FLAG_DISPLAY_ADDED
+ * @see #EVENT_FLAG_DISPLAY_CHANGED
+ * @see #EVENT_FLAG_DISPLAY_REMOVED
+ * @see #registerDisplayListener(DisplayListener, Handler)
+ * @see #unregisterDisplayListener
+ *
+ * @hide
+ */
+ public void registerDisplayListener(@NonNull DisplayListener listener,
+ @Nullable Handler handler, @EventFlag long eventFlags) {
+ mGlobal.registerDisplayListener(listener, handler,
+ mGlobal.mapFlagsToInternalEventFlag(eventFlags, 0),
+ ActivityThread.currentPackageName());
+ }
+
+ /**
+ * Registers a display listener to receive notifications about given display event types.
+ *
+ * @param listener The listener to register.
+ * @param handler The handler on which the listener should be invoked, or null
+ * if the listener should be invoked on the calling thread's looper.
+ * @param eventFlags A bitmask of the event types for which this listener is subscribed.
+ * @param privateEventFlags A bitmask of the private event types for which this listener
+ * is subscribed.
*
* @see #EVENT_FLAG_DISPLAY_ADDED
* @see #EVENT_FLAG_DISPLAY_CHANGED
* @see #EVENT_FLAG_DISPLAY_REMOVED
- * @see #EVENT_FLAG_DISPLAY_BRIGHTNESS
+ * @see #PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS
+ * @see #PRIVATE_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED
+ * @see #PRIVATE_EVENT_FLAG_HDR_SDR_RATIO_CHANGED
* @see #registerDisplayListener(DisplayListener, Handler)
* @see #unregisterDisplayListener
*
* @hide
*/
public void registerDisplayListener(@NonNull DisplayListener listener,
- @Nullable Handler handler, @EventFlag long eventFlagsMask) {
- mGlobal.registerDisplayListener(listener, handler, eventFlagsMask,
+ @Nullable Handler handler, @EventFlag long eventFlags,
+ @PrivateEventFlag long privateEventFlags) {
+ mGlobal.registerDisplayListener(listener, handler,
+ mGlobal.mapFlagsToInternalEventFlag(eventFlags, privateEventFlags),
ActivityThread.currentPackageName());
}
diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java
index 3c6841cd8aeb..06720fd64c9d 100644
--- a/core/java/android/hardware/display/DisplayManagerGlobal.java
+++ b/core/java/android/hardware/display/DisplayManagerGlobal.java
@@ -24,6 +24,7 @@ import android.Manifest;
import android.annotation.FlaggedApi;
import android.annotation.FloatRange;
import android.annotation.IntDef;
+import android.annotation.LongDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -118,6 +119,24 @@ public final class DisplayManagerGlobal {
public static final int EVENT_DISPLAY_CONNECTED = 6;
public static final int EVENT_DISPLAY_DISCONNECTED = 7;
+ @LongDef(prefix = {"INTERNAL_EVENT_DISPLAY"}, flag = true, value = {
+ INTERNAL_EVENT_FLAG_DISPLAY_ADDED,
+ INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
+ INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
+ INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED,
+ INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED,
+ INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface InternalEventFlag {}
+
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_ADDED = 1L << 0;
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_CHANGED = 1L << 1;
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_REMOVED = 1L << 2;
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED = 1L << 3;
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED = 1L << 4;
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED = 1L << 5;
+
@UnsupportedAppUsage
private static DisplayManagerGlobal sInstance;
@@ -130,7 +149,7 @@ public final class DisplayManagerGlobal {
private final IDisplayManager mDm;
private DisplayManagerCallback mCallback;
- private @EventFlag long mRegisteredEventFlagsMask = 0;
+ private @InternalEventFlag long mRegisteredInternalEventFlag = 0;
private final CopyOnWriteArrayList<DisplayListenerDelegate> mDisplayListeners =
new CopyOnWriteArrayList<>();
@@ -346,11 +365,11 @@ public final class DisplayManagerGlobal {
* @param packageName of the calling package.
*/
public void registerDisplayListener(@NonNull DisplayListener listener,
- @Nullable Handler handler, @EventFlag long eventFlagsMask,
+ @Nullable Handler handler, @InternalEventFlag long internalEventFlagsMask,
String packageName) {
Looper looper = getLooperForHandler(handler);
Handler springBoard = new Handler(looper);
- registerDisplayListener(listener, new HandlerExecutor(springBoard), eventFlagsMask,
+ registerDisplayListener(listener, new HandlerExecutor(springBoard), internalEventFlagsMask,
packageName);
}
@@ -359,32 +378,34 @@ public final class DisplayManagerGlobal {
*
* @param listener The listener that will be called when display changes occur.
* @param executor Executor for the thread that will be receiving the callbacks. Cannot be null.
- * @param eventFlagsMask Flag of events to be listened to.
+ * @param internalEventFlagsMask Mask of events to be listened to.
* @param packageName of the calling package.
*/
public void registerDisplayListener(@NonNull DisplayListener listener,
- @NonNull Executor executor, @EventFlag long eventFlagsMask, String packageName) {
+ @NonNull Executor executor, @InternalEventFlag long internalEventFlagsMask,
+ String packageName) {
if (listener == null) {
throw new IllegalArgumentException("listener must not be null");
}
- if (eventFlagsMask == 0) {
+ if (internalEventFlagsMask == 0) {
throw new IllegalArgumentException("The set of events to listen to must not be empty.");
}
if (extraLogging()) {
Slog.i(TAG, "Registering Display Listener: "
- + Long.toBinaryString(eventFlagsMask) + ", packageName: " + packageName);
+ + Long.toBinaryString(internalEventFlagsMask)
+ + ", packageName: " + packageName);
}
synchronized (mLock) {
int index = findDisplayListenerLocked(listener);
if (index < 0) {
mDisplayListeners.add(new DisplayListenerDelegate(listener, executor,
- eventFlagsMask, packageName));
+ internalEventFlagsMask, packageName));
registerCallbackIfNeededLocked();
} else {
- mDisplayListeners.get(index).setEventFlagsMask(eventFlagsMask);
+ mDisplayListeners.get(index).setEventsMask(internalEventFlagsMask);
}
updateCallbackIfNeededLocked();
maybeLogAllDisplayListeners();
@@ -456,17 +477,17 @@ public final class DisplayManagerGlobal {
return -1;
}
- @EventFlag
- private int calculateEventFlagsMaskLocked() {
- int mask = 0;
+ @InternalEventFlag
+ private long calculateEventsMaskLocked() {
+ long mask = 0;
final int numListeners = mDisplayListeners.size();
for (int i = 0; i < numListeners; i++) {
- mask |= mDisplayListeners.get(i).mEventFlagsMask;
+ mask |= mDisplayListeners.get(i).mInternalEventFlagsMask;
}
if (mDispatchNativeCallbacks) {
- mask |= DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
+ mask |= INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
}
return mask;
}
@@ -479,14 +500,14 @@ public final class DisplayManagerGlobal {
}
private void updateCallbackIfNeededLocked() {
- int mask = calculateEventFlagsMaskLocked();
+ long mask = calculateEventsMaskLocked();
if (DEBUG) {
- Log.d(TAG, "Flag for listener: " + mask);
+ Log.d(TAG, "Mask for listener: " + mask);
}
- if (mask != mRegisteredEventFlagsMask) {
+ if (mask != mRegisteredInternalEventFlag) {
try {
mDm.registerCallbackWithEventMask(mCallback, mask);
- mRegisteredEventFlagsMask = mask;
+ mRegisteredInternalEventFlag = mask;
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
@@ -1268,8 +1289,8 @@ public final class DisplayManagerGlobal {
@Override
public void onDisplayEvent(int displayId, @DisplayEvent int event) {
if (DEBUG) {
- Log.d(TAG, "onDisplayEvent: displayId=" + displayId + ", event=" + eventToString(
- event));
+ Log.d(TAG, "onDisplayEvent: displayId=" + displayId + ", event="
+ + eventToString(event));
}
handleDisplayEvent(displayId, event, false /* forceUpdate */);
}
@@ -1277,7 +1298,7 @@ public final class DisplayManagerGlobal {
private static final class DisplayListenerDelegate {
public final DisplayListener mListener;
- public volatile long mEventFlagsMask;
+ public volatile long mInternalEventFlagsMask;
private final DisplayInfo mDisplayInfo = new DisplayInfo();
private final Executor mExecutor;
@@ -1285,10 +1306,10 @@ public final class DisplayManagerGlobal {
private final String mPackageName;
DisplayListenerDelegate(DisplayListener listener, @NonNull Executor executor,
- @EventFlag long eventFlag, String packageName) {
+ @InternalEventFlag long internalEventFlag, String packageName) {
mExecutor = executor;
mListener = listener;
- mEventFlagsMask = eventFlag;
+ mInternalEventFlagsMask = internalEventFlag;
mPackageName = packageName;
}
@@ -1310,16 +1331,16 @@ public final class DisplayManagerGlobal {
mGenerationId.incrementAndGet();
}
- void setEventFlagsMask(@EventFlag long newEventsFlag) {
- mEventFlagsMask = newEventsFlag;
+ void setEventsMask(@InternalEventFlag long newInternalEventFlagsMask) {
+ mInternalEventFlagsMask = newInternalEventFlagsMask;
}
- private void handleDisplayEventInner(int displayId, @DisplayEvent int eventFlagsMask,
+ private void handleDisplayEventInner(int displayId, @DisplayEvent int event,
@Nullable DisplayInfo info, boolean forceUpdate) {
if (extraLogging()) {
- Slog.i(TAG, "DLD(" + eventToString(eventFlagsMask)
+ Slog.i(TAG, "DLD(" + eventToString(event)
+ ", display=" + displayId
- + ", mEventsFlagMask=" + Long.toBinaryString(mEventFlagsMask)
+ + ", mEventsMask=" + Long.toBinaryString(mInternalEventFlagsMask)
+ ", mPackageName=" + mPackageName
+ ", displayInfo=" + info
+ ", listener=" + mListener.getClass() + ")");
@@ -1327,18 +1348,19 @@ public final class DisplayManagerGlobal {
if (DEBUG) {
Trace.beginSection(
TextUtils.trimToSize(
- "DLD(" + eventToString(eventFlagsMask)
+ "DLD(" + eventToString(event)
+ ", display=" + displayId
+ ", listener=" + mListener.getClass() + ")", 127));
}
- switch (eventFlagsMask) {
+ switch (event) {
case EVENT_DISPLAY_ADDED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_ADDED) != 0) {
+ if ((mInternalEventFlagsMask & INTERNAL_EVENT_FLAG_DISPLAY_ADDED) != 0) {
mListener.onDisplayAdded(displayId);
}
break;
case EVENT_DISPLAY_CHANGED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_CHANGED) != 0) {
+ if ((mInternalEventFlagsMask & INTERNAL_EVENT_FLAG_DISPLAY_CHANGED)
+ != 0) {
if (info != null && (forceUpdate || !info.equals(mDisplayInfo))) {
if (extraLogging()) {
Slog.i(TAG, "Sending onDisplayChanged: Display Changed. Info: "
@@ -1350,29 +1372,32 @@ public final class DisplayManagerGlobal {
}
break;
case EVENT_DISPLAY_BRIGHTNESS_CHANGED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS) != 0) {
+ if ((mInternalEventFlagsMask
+ & INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED) != 0) {
mListener.onDisplayChanged(displayId);
}
break;
case EVENT_DISPLAY_REMOVED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_REMOVED) != 0) {
+ if ((mInternalEventFlagsMask & INTERNAL_EVENT_FLAG_DISPLAY_REMOVED)
+ != 0) {
mListener.onDisplayRemoved(displayId);
}
break;
case EVENT_DISPLAY_HDR_SDR_RATIO_CHANGED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_HDR_SDR_RATIO_CHANGED) != 0) {
+ if ((mInternalEventFlagsMask
+ & INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED) != 0) {
mListener.onDisplayChanged(displayId);
}
break;
case EVENT_DISPLAY_CONNECTED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED)
- != 0) {
+ if ((mInternalEventFlagsMask
+ & INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
mListener.onDisplayConnected(displayId);
}
break;
case EVENT_DISPLAY_DISCONNECTED:
- if ((mEventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED)
- != 0) {
+ if ((mInternalEventFlagsMask
+ & INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
mListener.onDisplayDisconnected(displayId);
}
break;
@@ -1384,7 +1409,7 @@ public final class DisplayManagerGlobal {
@Override
public String toString() {
- return "mEventFlagsMask: {" + mEventFlagsMask + "}, for " + mListener.getClass();
+ return "flag: {" + mInternalEventFlagsMask + "}, for " + mListener.getClass();
}
}
@@ -1525,4 +1550,53 @@ public final class DisplayManagerGlobal {
private static boolean extraLogging() {
return sExtraDisplayListenerLogging;
}
+
+
+ /**
+ * Maps the supplied public and private event flags to a unified InternalEventFlag
+ * @param eventFlags A bitmask of the event types for which this listener is subscribed.
+ * @param privateEventFlags A bitmask of the private event types for which this listener
+ * is subscribed.
+ * @return returns the bitmask of both public and private event flags unified to
+ * InternalEventFlag
+ */
+ public @InternalEventFlag long mapFlagsToInternalEventFlag(@EventFlag long eventFlags,
+ @DisplayManager.PrivateEventFlag long privateEventFlags) {
+ return mapPrivateEventFlags(privateEventFlags) | mapPublicEventFlags(eventFlags);
+ }
+
+ private long mapPrivateEventFlags(@DisplayManager.PrivateEventFlag long privateEventFlags) {
+ long baseEventMask = 0;
+ if ((privateEventFlags & DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS) != 0) {
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED;
+ }
+
+ if ((privateEventFlags & DisplayManager.PRIVATE_EVENT_FLAG_HDR_SDR_RATIO_CHANGED) != 0) {
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED;
+ }
+
+ if ((privateEventFlags
+ & DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED;
+ }
+ return baseEventMask;
+ }
+
+ private long mapPublicEventFlags(@EventFlag long eventFlags) {
+ long baseEventMask = 0;
+ if ((eventFlags & DisplayManager.EVENT_FLAG_DISPLAY_ADDED) != 0) {
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_ADDED;
+ }
+
+ if ((eventFlags & DisplayManager.EVENT_FLAG_DISPLAY_CHANGED) != 0) {
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_CHANGED;
+ }
+
+ if ((eventFlags
+ & DisplayManager.EVENT_FLAG_DISPLAY_REMOVED) != 0) {
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
+ }
+
+ return baseEventMask;
+ }
}
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 910e644f7b6f..0241e9437950 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -1549,8 +1549,9 @@ public final class Display {
// Although we only care about the HDR/SDR ratio changing, that can also come in the
// form of the larger DISPLAY_CHANGED event
mGlobal.registerDisplayListener(toRegister, executor,
- DisplayManager.EVENT_FLAG_HDR_SDR_RATIO_CHANGED
- | DisplayManagerGlobal.EVENT_DISPLAY_CHANGED,
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED,
ActivityThread.currentPackageName());
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 3ce6870bf2ca..9a2aa0b8a682 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -185,7 +185,6 @@ import android.graphics.RenderNode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.hardware.SyncFence;
-import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.input.InputManagerGlobal;
@@ -1816,9 +1815,9 @@ public final class ViewRootImpl implements ViewParent,
.registerDisplayListener(
mDisplayListener,
mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED,
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
mBasePackageName);
if (forceInvertColor()) {
diff --git a/core/java/com/android/internal/display/BrightnessSynchronizer.java b/core/java/com/android/internal/display/BrightnessSynchronizer.java
index 21fbf9d03c71..a50dbb0223b7 100644
--- a/core/java/com/android/internal/display/BrightnessSynchronizer.java
+++ b/core/java/com/android/internal/display/BrightnessSynchronizer.java
@@ -600,8 +600,8 @@ public class BrightnessSynchronizer {
final ContentResolver cr = mContext.getContentResolver();
cr.registerContentObserver(BRIGHTNESS_URI, false,
createBrightnessContentObserver(handler), UserHandle.USER_ALL);
- mDisplayManager.registerDisplayListener(mListener, handler,
- DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS);
+ mDisplayManager.registerDisplayListener(mListener, handler, /* eventFlags */ 0,
+ DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS);
mIsObserving = true;
}
}
diff --git a/core/java/com/android/internal/jank/DisplayResolutionTracker.java b/core/java/com/android/internal/jank/DisplayResolutionTracker.java
index ca6c54dc0285..0c2fd4bbd7ae 100644
--- a/core/java/com/android/internal/jank/DisplayResolutionTracker.java
+++ b/core/java/com/android/internal/jank/DisplayResolutionTracker.java
@@ -147,8 +147,9 @@ public class DisplayResolutionTracker {
@Override
public void registerDisplayListener(DisplayManager.DisplayListener listener) {
manager.registerDisplayListener(listener, handler,
- DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED,
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
ActivityThread.currentPackageName());
}
diff --git a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java
index 31a4f16553a0..911b7ce22741 100644
--- a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java
+++ b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java
@@ -120,7 +120,8 @@ public class ClientTransactionListenerControllerTest {
doReturn(newDisplayInfo).when(mIDisplayManager).getDisplayInfo(123);
mDisplayManager.registerDisplayListener(mListener, mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_CHANGED, null /* packageName */);
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
+ null /* packageName */);
mController.onDisplayChanged(123);
mHandler.runWithScissors(() -> { }, 0);
diff --git a/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java b/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java
index 5a0dacb38865..9552c887443b 100644
--- a/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java
+++ b/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java
@@ -55,9 +55,10 @@ import org.mockito.MockitoAnnotations;
@RunWith(AndroidJUnit4.class)
public class DisplayManagerGlobalTest {
- private static final long ALL_DISPLAY_EVENTS = DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
+ private static final long ALL_DISPLAY_EVENTS =
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
@Mock
private IDisplayManager mDisplayManager;
@@ -127,19 +128,22 @@ public class DisplayManagerGlobalTest {
int displayId = 1;
mDisplayManagerGlobal.registerDisplayListener(mListener, mHandler,
- ALL_DISPLAY_EVENTS & ~DisplayManager.EVENT_FLAG_DISPLAY_ADDED, null);
+ ALL_DISPLAY_EVENTS
+ & ~DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED, null);
callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_ADDED);
waitForHandler();
Mockito.verifyZeroInteractions(mListener);
mDisplayManagerGlobal.registerDisplayListener(mListener, mHandler,
- ALL_DISPLAY_EVENTS & ~DisplayManager.EVENT_FLAG_DISPLAY_CHANGED, null);
+ ALL_DISPLAY_EVENTS
+ & ~DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED, null);
callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
waitForHandler();
Mockito.verifyZeroInteractions(mListener);
mDisplayManagerGlobal.registerDisplayListener(mListener, mHandler,
- ALL_DISPLAY_EVENTS & ~DisplayManager.EVENT_FLAG_DISPLAY_REMOVED, null);
+ ALL_DISPLAY_EVENTS
+ & ~DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED, null);
callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
waitForHandler();
Mockito.verifyZeroInteractions(mListener);
@@ -162,22 +166,25 @@ public class DisplayManagerGlobalTest {
public void testDisplayManagerGlobalRegistersWithDisplayManager_WhenThereAreListeners()
throws RemoteException {
mDisplayManagerGlobal.registerDisplayListener(mListener, mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS, null);
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED,
+ null);
InOrder inOrder = Mockito.inOrder(mDisplayManager);
inOrder.verify(mDisplayManager)
.registerCallbackWithEventMask(mCallbackCaptor.capture(),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED));
mDisplayManagerGlobal.registerNativeChoreographerForRefreshRateCallbacks();
inOrder.verify(mDisplayManager)
.registerCallbackWithEventMask(mCallbackCaptor.capture(),
- eq(ALL_DISPLAY_EVENTS | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(ALL_DISPLAY_EVENTS
+ | DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED));
mDisplayManagerGlobal.unregisterNativeChoreographerForRefreshRateCallbacks();
inOrder.verify(mDisplayManager)
.registerCallbackWithEventMask(mCallbackCaptor.capture(),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED));
mDisplayManagerGlobal.unregisterDisplayListener(mListener);
inOrder.verify(mDisplayManager)
@@ -196,10 +203,12 @@ public class DisplayManagerGlobalTest {
// One listener listens on add/remove, and the other one listens on change.
mDisplayManagerGlobal.registerDisplayListener(mListener, mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED, null /* packageName */);
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
+ null /* packageName */);
mDisplayManagerGlobal.registerDisplayListener(mListener2, mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_CHANGED, null /* packageName */);
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
+ null /* packageName */);
mDisplayManagerGlobal.handleDisplayChangeFromWindowManager(321);
waitForHandler();
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/data/repository/ScreenBrightnessDisplayManagerRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/data/repository/ScreenBrightnessDisplayManagerRepositoryTest.kt
index 09831059a4b3..f4cffc5d962a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/data/repository/ScreenBrightnessDisplayManagerRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/brightness/data/repository/ScreenBrightnessDisplayManagerRepositoryTest.kt
@@ -20,7 +20,7 @@ import android.hardware.display.BrightnessInfo
import android.hardware.display.BrightnessInfo.BRIGHTNESS_MAX_REASON_NONE
import android.hardware.display.BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF
import android.hardware.display.DisplayManager
-import android.hardware.display.DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
+import android.hardware.display.DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS
import android.view.Display
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -119,7 +119,8 @@ class ScreenBrightnessDisplayManagerRepositoryTest : SysuiTestCase() {
.registerDisplayListener(
capture(listenerCaptor),
eq(null),
- eq(EVENT_FLAG_DISPLAY_BRIGHTNESS),
+ eq(0),
+ eq(PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS),
)
val newBrightness = BrightnessInfo(0.6f, 0.3f, 0.9f)
@@ -157,7 +158,8 @@ class ScreenBrightnessDisplayManagerRepositoryTest : SysuiTestCase() {
.registerDisplayListener(
capture(listenerCaptor),
eq(null),
- eq(EVENT_FLAG_DISPLAY_BRIGHTNESS),
+ eq(0),
+ eq(PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS),
)
changeBrightnessInfoAndNotify(
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
index cd8b2e12a3d5..e6e5665e7694 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
@@ -540,7 +540,8 @@ class DisplayRepositoryTest : SysuiTestCase() {
.registerDisplayListener(
connectedDisplayListener.capture(),
eq(testHandler),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED),
+ eq(0),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED),
)
return flowValue
}
diff --git a/packages/SystemUI/src/com/android/systemui/brightness/data/repository/ScreenBrightnessRepository.kt b/packages/SystemUI/src/com/android/systemui/brightness/data/repository/ScreenBrightnessRepository.kt
index 06d391704870..3270c71057b6 100644
--- a/packages/SystemUI/src/com/android/systemui/brightness/data/repository/ScreenBrightnessRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/brightness/data/repository/ScreenBrightnessRepository.kt
@@ -19,6 +19,7 @@ package com.android.systemui.brightness.data.repository
import android.annotation.SuppressLint
import android.hardware.display.BrightnessInfo
import android.hardware.display.DisplayManager
+import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.brightness.shared.model.BrightnessLog
import com.android.systemui.brightness.shared.model.LinearBrightness
import com.android.systemui.brightness.shared.model.formatBrightness
@@ -46,7 +47,6 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
-import com.android.app.tracing.coroutines.launchTraced as launch
import kotlinx.coroutines.withContext
/**
@@ -90,10 +90,7 @@ constructor(
@Background private val backgroundContext: CoroutineContext,
) : ScreenBrightnessRepository {
- private val apiQueue =
- Channel<SetBrightnessMethod>(
- capacity = UNLIMITED,
- )
+ private val apiQueue = Channel<SetBrightnessMethod>(capacity = UNLIMITED)
init {
applicationScope.launch(context = backgroundContext) {
@@ -132,7 +129,8 @@ constructor(
displayManager.registerDisplayListener(
listener,
null,
- DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS,
+ /* eventFlags */ 0,
+ DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS,
)
awaitClose { displayManager.unregisterDisplayListener(listener) }
@@ -190,8 +188,10 @@ constructor(
private sealed interface SetBrightnessMethod {
val value: LinearBrightness
+
@JvmInline
value class Temporary(override val value: LinearBrightness) : SetBrightnessMethod
+
@JvmInline
value class Permanent(override val value: LinearBrightness) : SetBrightnessMethod
}
@@ -201,7 +201,7 @@ constructor(
LOG_BUFFER_BRIGHTNESS_CHANGE_TAG,
if (permanent) LogLevel.DEBUG else LogLevel.VERBOSE,
{ str1 = value.formatBrightness() },
- { "Change requested: $str1" }
+ { "Change requested: $str1" },
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt
index 034cb31dbc74..1fa829a675ec 100644
--- a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt
@@ -264,7 +264,8 @@ constructor(
displayManager.registerDisplayListener(
callback,
backgroundHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED,
+ /* eventFlags */ 0,
+ DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED,
)
awaitClose { displayManager.unregisterDisplayListener(callback) }
}
diff --git a/packages/SystemUI/src/com/android/systemui/settings/DisplayTrackerImpl.kt b/packages/SystemUI/src/com/android/systemui/settings/DisplayTrackerImpl.kt
index 2ef27a8df117..60ed2de5c532 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/DisplayTrackerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/settings/DisplayTrackerImpl.kt
@@ -17,7 +17,7 @@
package com.android.systemui.settings
import android.hardware.display.DisplayManager
-import android.hardware.display.DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
+import android.hardware.display.DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS
import android.os.Handler
import android.view.Display
import androidx.annotation.GuardedBy
@@ -32,7 +32,7 @@ import java.util.concurrent.Executor
class DisplayTrackerImpl
internal constructor(
val displayManager: DisplayManager,
- @Background val backgroundHandler: Handler
+ @Background val backgroundHandler: Handler,
) : DisplayTracker {
override val defaultDisplayId: Int = Display.DEFAULT_DISPLAY
override val allDisplays: Array<Display>
@@ -47,27 +47,21 @@ internal constructor(
val displayChangedListener: DisplayManager.DisplayListener =
object : DisplayManager.DisplayListener {
override fun onDisplayAdded(displayId: Int) {
- traceSection(
- "DisplayTrackerImpl.displayChangedDisplayListener#onDisplayAdded",
- ) {
+ traceSection("DisplayTrackerImpl.displayChangedDisplayListener#onDisplayAdded") {
val list = synchronized(displayCallbacks) { displayCallbacks.toList() }
onDisplayAdded(displayId, list)
}
}
override fun onDisplayRemoved(displayId: Int) {
- traceSection(
- "DisplayTrackerImpl.displayChangedDisplayListener#onDisplayRemoved",
- ) {
+ traceSection("DisplayTrackerImpl.displayChangedDisplayListener#onDisplayRemoved") {
val list = synchronized(displayCallbacks) { displayCallbacks.toList() }
onDisplayRemoved(displayId, list)
}
}
override fun onDisplayChanged(displayId: Int) {
- traceSection(
- "DisplayTrackerImpl.displayChangedDisplayListener#onDisplayChanged",
- ) {
+ traceSection("DisplayTrackerImpl.displayChangedDisplayListener#onDisplayChanged") {
val list = synchronized(displayCallbacks) { displayCallbacks.toList() }
onDisplayChanged(displayId, list)
}
@@ -83,7 +77,7 @@ internal constructor(
override fun onDisplayChanged(displayId: Int) {
traceSection(
- "DisplayTrackerImpl.displayBrightnessChangedDisplayListener#onDisplayChanged",
+ "DisplayTrackerImpl.displayBrightnessChangedDisplayListener#onDisplayChanged"
) {
val list = synchronized(brightnessCallbacks) { brightnessCallbacks.toList() }
onDisplayChanged(displayId, list)
@@ -102,14 +96,15 @@ internal constructor(
override fun addBrightnessChangeCallback(
callback: DisplayTracker.Callback,
- executor: Executor
+ executor: Executor,
) {
synchronized(brightnessCallbacks) {
if (brightnessCallbacks.isEmpty()) {
displayManager.registerDisplayListener(
displayBrightnessChangedListener,
backgroundHandler,
- EVENT_FLAG_DISPLAY_BRIGHTNESS
+ /* eventFlags */ 0,
+ PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS,
)
}
brightnessCallbacks.add(DisplayTrackerDataItem(WeakReference(callback), executor))
@@ -159,7 +154,7 @@ internal constructor(
private inline fun notifySubscribers(
crossinline action: DisplayTracker.Callback.() -> Unit,
- list: List<DisplayTrackerDataItem>
+ list: List<DisplayTrackerDataItem>,
) {
list.forEach {
if (it.callback.get() != null) {
@@ -170,7 +165,7 @@ internal constructor(
private data class DisplayTrackerDataItem(
val callback: WeakReference<DisplayTracker.Callback>,
- val executor: Executor
+ val executor: Executor,
) {
fun sameOrEmpty(other: DisplayTracker.Callback): Boolean {
return callback.get()?.equals(other) ?: true
diff --git a/packages/SystemUI/tests/src/com/android/systemui/settings/DisplayTrackerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/settings/DisplayTrackerImplTest.kt
index ae976a0ea703..9fb752a11f56 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/settings/DisplayTrackerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/settings/DisplayTrackerImplTest.kt
@@ -17,7 +17,7 @@
package com.android.systemui.settings
import android.hardware.display.DisplayManager
-import android.hardware.display.DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
+import android.hardware.display.DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS
import android.hardware.display.DisplayManagerGlobal
import android.os.Handler
import android.testing.AndroidTestingRunner
@@ -59,14 +59,14 @@ class DisplayTrackerImplTest : SysuiTestCase() {
DisplayManagerGlobal.getInstance(),
Display.DEFAULT_DISPLAY,
DisplayInfo(),
- DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS
+ DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS,
)
mSecondaryDisplay =
Display(
DisplayManagerGlobal.getInstance(),
Display.DEFAULT_DISPLAY + 1,
DisplayInfo(),
- DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS
+ DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS,
)
`when`(displayManager.displays).thenReturn(arrayOf(mDefaultDisplay, mSecondaryDisplay))
@@ -94,7 +94,12 @@ class DisplayTrackerImplTest : SysuiTestCase() {
fun registerBrightnessCallback_registersDisplayListener() {
tracker.addBrightnessChangeCallback(TestCallback(), executor)
verify(displayManager)
- .registerDisplayListener(any(), any(), eq(EVENT_FLAG_DISPLAY_BRIGHTNESS))
+ .registerDisplayListener(
+ any(),
+ any(),
+ eq(0L),
+ eq(PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS),
+ )
}
@Test
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index f5a75c7d1c38..0e77040187e1 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -25,7 +25,7 @@ import static android.Manifest.permission.MANAGE_DISPLAYS;
import static android.Manifest.permission.RESTRICT_DISPLAY_MODES;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_CACHED;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_GONE;
-import static android.hardware.display.DisplayManager.EventFlag;
+import static android.hardware.display.DisplayManagerGlobal.InternalEventFlag;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD;
@@ -1390,16 +1390,16 @@ public final class DisplayManagerService extends SystemService {
}
private void registerCallbackInternal(IDisplayManagerCallback callback, int callingPid,
- int callingUid, @EventFlag long eventFlagsMask) {
+ int callingUid, @InternalEventFlag long internalEventFlagsMask) {
synchronized (mSyncRoot) {
CallbackRecord record = mCallbacks.get(callingPid);
if (record != null) {
- record.updateEventFlagsMask(eventFlagsMask);
+ record.updateEventFlagsMask(internalEventFlagsMask);
return;
}
- record = new CallbackRecord(callingPid, callingUid, callback, eventFlagsMask);
+ record = new CallbackRecord(callingPid, callingUid, callback, internalEventFlagsMask);
try {
IBinder binder = callback.asBinder();
binder.linkToDeath(record, 0);
@@ -4009,7 +4009,7 @@ public final class DisplayManagerService extends SystemService {
public final int mPid;
public final int mUid;
private final IDisplayManagerCallback mCallback;
- private @DisplayManager.EventFlag AtomicLong mEventFlagsMask;
+ private @InternalEventFlag AtomicLong mInternalEventFlagsMask;
private final String mPackageName;
public boolean mWifiDisplayScanRequested;
@@ -4030,11 +4030,11 @@ public final class DisplayManagerService extends SystemService {
private boolean mFrozen;
CallbackRecord(int pid, int uid, @NonNull IDisplayManagerCallback callback,
- @EventFlag long eventFlagsMask) {
+ @InternalEventFlag long internalEventFlagsMask) {
mPid = pid;
mUid = uid;
mCallback = callback;
- mEventFlagsMask = new AtomicLong(eventFlagsMask);
+ mInternalEventFlagsMask = new AtomicLong(internalEventFlagsMask);
mCached = false;
mFrozen = false;
@@ -4056,8 +4056,8 @@ public final class DisplayManagerService extends SystemService {
mPackageName = packageNames == null ? null : packageNames[0];
}
- public void updateEventFlagsMask(@EventFlag long eventFlag) {
- mEventFlagsMask.set(eventFlag);
+ public void updateEventFlagsMask(@InternalEventFlag long internalEventFlag) {
+ mInternalEventFlagsMask.set(internalEventFlag);
}
/**
@@ -4121,13 +4121,13 @@ public final class DisplayManagerService extends SystemService {
if (!shouldSendEvent(event)) {
if (extraLogging(mPackageName)) {
Slog.i(TAG,
- "Not sending displayEvent: " + event + " due to flag:"
- + mEventFlagsMask);
+ "Not sending displayEvent: " + event + " due to mask:"
+ + mInternalEventFlagsMask);
}
if (Trace.isTagEnabled(Trace.TRACE_TAG_POWER)) {
Trace.instant(Trace.TRACE_TAG_POWER,
- "notifyDisplayEventAsync#notSendingEvent=" + event + ",mEventsFlag="
- + mEventFlagsMask);
+ "notifyDisplayEventAsync#notSendingEvent=" + event
+ + ",mInternalEventFlagsMask=" + mInternalEventFlagsMask);
}
// The client is not interested in this event, so do nothing.
return true;
@@ -4173,22 +4173,29 @@ public final class DisplayManagerService extends SystemService {
* Return true if the client is interested in this event.
*/
private boolean shouldSendEvent(@DisplayEvent int event) {
- final long flag = mEventFlagsMask.get();
+ final long mask = mInternalEventFlagsMask.get();
switch (event) {
case DisplayManagerGlobal.EVENT_DISPLAY_ADDED:
- return (flag & DisplayManager.EVENT_FLAG_DISPLAY_ADDED) != 0;
+ return (mask & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED) != 0;
case DisplayManagerGlobal.EVENT_DISPLAY_CHANGED:
- return (flag & DisplayManager.EVENT_FLAG_DISPLAY_CHANGED) != 0;
+ return (mask & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED) != 0;
case DisplayManagerGlobal.EVENT_DISPLAY_BRIGHTNESS_CHANGED:
- return (flag & DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS) != 0;
+ return (mask
+ & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED)
+ != 0;
case DisplayManagerGlobal.EVENT_DISPLAY_REMOVED:
- return (flag & DisplayManager.EVENT_FLAG_DISPLAY_REMOVED) != 0;
+ return (mask & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED) != 0;
case DisplayManagerGlobal.EVENT_DISPLAY_HDR_SDR_RATIO_CHANGED:
- return (flag & DisplayManager.EVENT_FLAG_HDR_SDR_RATIO_CHANGED) != 0;
+ return (mask
+ & DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED)
+ != 0;
case DisplayManagerGlobal.EVENT_DISPLAY_CONNECTED:
// fallthrough
case DisplayManagerGlobal.EVENT_DISPLAY_DISCONNECTED:
- return (flag & DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0;
+ return (mask
+ & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED)
+ != 0;
default:
// This should never happen.
Slog.e(TAG, "Unknown display event " + event);
@@ -4374,15 +4381,16 @@ public final class DisplayManagerService extends SystemService {
@Override // Binder call
public void registerCallback(IDisplayManagerCallback callback) {
- registerCallbackWithEventMask(callback, DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED);
+ registerCallbackWithEventMask(callback,
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED);
}
@Override // Binder call
@SuppressLint("AndroidFrameworkRequiresPermission") // Permission only required sometimes
public void registerCallbackWithEventMask(IDisplayManagerCallback callback,
- @EventFlag long eventFlagsMask) {
+ @InternalEventFlag long internalEventFlagsMask) {
if (callback == null) {
throw new IllegalArgumentException("listener must not be null");
}
@@ -4391,7 +4399,9 @@ public final class DisplayManagerService extends SystemService {
final int callingUid = Binder.getCallingUid();
if (mFlags.isConnectedDisplayManagementEnabled()) {
- if ((eventFlagsMask & DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
+ if ((internalEventFlagsMask
+ & DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
mContext.enforceCallingOrSelfPermission(MANAGE_DISPLAYS,
"Permission required to get signals about connection events.");
}
@@ -4399,7 +4409,7 @@ public final class DisplayManagerService extends SystemService {
final long token = Binder.clearCallingIdentity();
try {
- registerCallbackInternal(callback, callingPid, callingUid, eventFlagsMask);
+ registerCallbackInternal(callback, callingPid, callingUid, internalEventFlagsMask);
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
index 88562ab9ba2d..8423e1911764 100644
--- a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
+++ b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
@@ -2077,8 +2077,8 @@ public class DisplayModeDirector {
mDeviceConfigDisplaySettings.startListening();
mInjector.registerDisplayListener(this, mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS);
+ DisplayManager.EVENT_FLAG_DISPLAY_CHANGED,
+ DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS);
}
private void setLoggingEnabled(boolean loggingEnabled) {
@@ -2878,8 +2878,8 @@ public class DisplayModeDirector {
}
mDisplayManagerInternal = mInjector.getDisplayManagerInternal();
mInjector.registerDisplayListener(this, mHandler,
- DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED);
+ DisplayManager.EVENT_FLAG_DISPLAY_REMOVED,
+ DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS);
}
/**
@@ -3108,6 +3108,9 @@ public class DisplayModeDirector {
void registerDisplayListener(@NonNull DisplayManager.DisplayListener listener,
Handler handler, long flags);
+ void registerDisplayListener(@NonNull DisplayManager.DisplayListener listener,
+ Handler handler, long flags, long privateFlags);
+
Display getDisplay(int displayId);
Display[] getDisplays();
@@ -3175,6 +3178,12 @@ public class DisplayModeDirector {
}
@Override
+ public void registerDisplayListener(DisplayManager.DisplayListener listener,
+ Handler handler, long flags, long privateFlags) {
+ getDisplayManager().registerDisplayListener(listener, handler, flags, privateFlags);
+ }
+
+ @Override
public Display getDisplay(int displayId) {
return getDisplayManager().getDisplay(displayId);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/BrightnessSynchronizerTest.java b/services/tests/displayservicetests/src/com/android/server/display/BrightnessSynchronizerTest.java
index 06f1b27410ff..a8708f9f9e6e 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/BrightnessSynchronizerTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/BrightnessSynchronizerTest.java
@@ -223,7 +223,8 @@ public class BrightnessSynchronizerTest {
mIntRangeUserPerceptionEnabled);
mSynchronizer.startSynchronizing();
verify(mDisplayManagerMock).registerDisplayListener(mDisplayListenerCaptor.capture(),
- isA(Handler.class), eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ isA(Handler.class), eq(0L),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
mDisplayListener = mDisplayListenerCaptor.getValue();
verify(mContentResolverSpy).registerContentObserver(eq(BRIGHTNESS_URI), eq(false),
diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
index b917af4d796e..c741cae1c135 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
@@ -203,11 +203,13 @@ public class DisplayManagerServiceTest {
private static final String VIRTUAL_DISPLAY_NAME = "Test Virtual Display";
private static final String PACKAGE_NAME = "com.android.frameworks.displayservicetests";
- private static final long STANDARD_DISPLAY_EVENTS = DisplayManager.EVENT_FLAG_DISPLAY_ADDED
- | DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
+ private static final long STANDARD_DISPLAY_EVENTS =
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
private static final long STANDARD_AND_CONNECTION_DISPLAY_EVENTS =
- STANDARD_DISPLAY_EVENTS | DisplayManager.EVENT_FLAG_DISPLAY_CONNECTION_CHANGED;
+ STANDARD_DISPLAY_EVENTS
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED;
private static final String EVENT_DISPLAY_ADDED = "EVENT_DISPLAY_ADDED";
private static final String EVENT_DISPLAY_REMOVED = "EVENT_DISPLAY_REMOVED";
@@ -2379,7 +2381,7 @@ public class DisplayManagerServiceTest {
// register display listener callback
FakeDisplayManagerCallback callback = new FakeDisplayManagerCallback();
long allEventsExceptDisplayAdded = STANDARD_DISPLAY_EVENTS
- & ~DisplayManager.EVENT_FLAG_DISPLAY_ADDED;
+ & ~DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED;
displayManagerBinderService.registerCallbackWithEventMask(callback,
allEventsExceptDisplayAdded);
@@ -2450,7 +2452,7 @@ public class DisplayManagerServiceTest {
FakeDisplayManagerCallback callback = new FakeDisplayManagerCallback();
long allEventsExceptDisplayRemoved = STANDARD_DISPLAY_EVENTS
- & ~DisplayManager.EVENT_FLAG_DISPLAY_REMOVED;
+ & ~DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
displayManagerBinderService.registerCallbackWithEventMask(callback,
allEventsExceptDisplayRemoved);
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java
index 58f0ab4411bc..f3fc6d747d78 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java
@@ -1225,8 +1225,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
setBrightness(10, 10, displayListener);
@@ -1256,8 +1256,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
setBrightness(10, 10, displayListener);
@@ -1291,8 +1291,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
setBrightness(10, 10, displayListener);
@@ -1325,8 +1325,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
ArgumentCaptor<SensorEventListener> sensorListenerCaptor =
@@ -1404,8 +1404,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
ArgumentCaptor<SensorEventListener> sensorListenerCaptor =
@@ -1464,8 +1464,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
ArgumentCaptor<SensorEventListener> listenerCaptor =
@@ -1630,8 +1630,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
// Get the sensor listener so that we can give it new light sensor events
@@ -1730,8 +1730,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(displayListenerCaptor.capture(),
any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED
- | DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener displayListener = displayListenerCaptor.getValue();
// Get the sensor listener so that we can give it new light sensor events
@@ -2877,8 +2877,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor<DisplayListener> captor =
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(captor.capture(), any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_REMOVED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener listener = captor.getValue();
// Specify Limitation
@@ -3000,8 +3000,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor<DisplayListener> captor =
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(captor.capture(), any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_REMOVED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener listener = captor.getValue();
final int initialRefreshRate = 60;
@@ -3075,8 +3075,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor<DisplayListener> captor =
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(captor.capture(), any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_REMOVED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener listener = captor.getValue();
// Specify Limitation for different display
@@ -3115,8 +3115,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor<DisplayListener> captor =
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(captor.capture(), any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_REMOVED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener listener = captor.getValue();
// Specify Limitation
@@ -3200,8 +3200,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor<DisplayListener> captor = ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(captor.capture(), any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_REMOVED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener listener = captor.getValue();
// Specify Sunlight limitations
@@ -3239,8 +3239,8 @@ public class DisplayModeDirectorTest {
ArgumentCaptor<DisplayListener> captor =
ArgumentCaptor.forClass(DisplayListener.class);
verify(mInjector).registerDisplayListener(captor.capture(), any(Handler.class),
- eq(DisplayManager.EVENT_FLAG_DISPLAY_BRIGHTNESS
- | DisplayManager.EVENT_FLAG_DISPLAY_REMOVED));
+ eq(DisplayManager.EVENT_FLAG_DISPLAY_REMOVED),
+ eq(DisplayManager.PRIVATE_EVENT_FLAG_DISPLAY_BRIGHTNESS));
DisplayListener listener = captor.getValue();
// Specify Limitation for different display
@@ -3897,7 +3897,12 @@ public class DisplayModeDirectorTest {
public void registerDisplayListener(DisplayListener listener, Handler handler) {}
@Override
- public void registerDisplayListener(DisplayListener listener, Handler handler, long flag) {}
+ public void registerDisplayListener(DisplayListener listener, Handler handler,
+ long flags) {}
+
+ @Override
+ public void registerDisplayListener(DisplayListener listener, Handler handler, long flag,
+ long privateFlag) {}
@Override
public Display getDisplay(int displayId) {