diff options
-rw-r--r-- | cmds/screencap/screencap.cpp | 1 | ||||
-rw-r--r-- | core/java/android/view/SurfaceControl.java | 134 | ||||
-rw-r--r-- | core/jni/android_view_SurfaceControl.cpp | 238 | ||||
-rw-r--r-- | libs/hwui/tests/common/TestContext.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/tests/common/TestContext.h | 4 | ||||
-rw-r--r-- | libs/input/MouseCursorController.h | 1 | ||||
-rw-r--r-- | libs/input/PointerController.h | 1 | ||||
-rw-r--r-- | libs/input/PointerControllerContext.h | 1 | ||||
-rw-r--r-- | native/android/surface_control.cpp | 12 | ||||
-rw-r--r-- | services/core/java/com/android/server/display/ColorFade.java | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/display/DisplayDeviceInfo.java | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/display/LocalDisplayAdapter.java | 180 | ||||
-rw-r--r-- | services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java | 134 |
13 files changed, 375 insertions, 343 deletions
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index 5c08704a6623..d4da5e554591 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -34,7 +34,6 @@ #include <gui/SurfaceComposerClient.h> #include <gui/SyncScreenCaptureListener.h> -#include <ui/DisplayInfo.h> #include <ui/GraphicTypes.h> #include <ui/PixelFormat.h> diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 66b9617714a6..7d049d09a677 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -68,6 +68,7 @@ import java.lang.ref.WeakReference; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; +import java.util.Arrays; import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -161,25 +162,21 @@ public final class SurfaceControl implements Parcelable { int L, int T, int R, int B); private static native void nativeSetDisplaySize(long transactionObj, IBinder displayToken, int width, int height); - private static native DisplayInfo nativeGetDisplayInfo(IBinder displayToken); - private static native DisplayMode[] nativeGetDisplayModes( - IBinder displayToken); + private static native StaticDisplayInfo nativeGetStaticDisplayInfo(IBinder displayToken); + private static native DynamicDisplayInfo nativeGetDynamicDisplayInfo(IBinder displayToken); private static native DisplayedContentSamplingAttributes nativeGetDisplayedContentSamplingAttributes(IBinder displayToken); private static native boolean nativeSetDisplayedContentSamplingEnabled(IBinder displayToken, boolean enable, int componentMask, int maxFrames); private static native DisplayedContentSample nativeGetDisplayedContentSample( IBinder displayToken, long numFrames, long timestamp); - private static native int nativeGetActiveDisplayMode(IBinder displayToken); private static native boolean nativeSetDesiredDisplayModeSpecs(IBinder displayToken, DesiredDisplayModeSpecs desiredDisplayModeSpecs); private static native DesiredDisplayModeSpecs nativeGetDesiredDisplayModeSpecs(IBinder displayToken); - private static native int[] nativeGetDisplayColorModes(IBinder displayToken); private static native DisplayPrimaries nativeGetDisplayNativePrimaries( IBinder displayToken); private static native int[] nativeGetCompositionDataspaces(); - private static native int nativeGetActiveColorMode(IBinder displayToken); private static native boolean nativeSetActiveColorMode(IBinder displayToken, int colorMode); private static native void nativeSetAutoLowLatencyMode(IBinder displayToken, boolean on); @@ -191,8 +188,6 @@ public final class SurfaceControl implements Parcelable { private static native void nativeReparent(long transactionObj, long nativeObject, long newParentNativeObject); - private static native Display.HdrCapabilities nativeGetHdrCapabilities(IBinder displayToken); - private static native boolean nativeGetAutoLowLatencyModeSupport(IBinder displayToken); private static native boolean nativeGetGameContentTypeSupport(IBinder displayToken); @@ -1707,7 +1702,7 @@ public final class SurfaceControl implements Parcelable { * * @hide */ - public static final class DisplayInfo { + public static final class StaticDisplayInfo { public boolean isInternal; public float density; public boolean secure; @@ -1715,7 +1710,7 @@ public final class SurfaceControl implements Parcelable { @Override public String toString() { - return "DisplayInfo{isInternal=" + isInternal + return "StaticDisplayInfo{isInternal=" + isInternal + ", density=" + density + ", secure=" + secure + ", deviceProductInfo=" + deviceProductInfo + "}"; @@ -1725,7 +1720,7 @@ public final class SurfaceControl implements Parcelable { public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - DisplayInfo that = (DisplayInfo) o; + StaticDisplayInfo that = (StaticDisplayInfo) o; return isInternal == that.isInternal && density == that.density && secure == that.secure @@ -1739,6 +1734,49 @@ public final class SurfaceControl implements Parcelable { } /** + * Dynamic information about physical display. + * + * @hide + */ + public static final class DynamicDisplayInfo { + public DisplayMode[] supportedDisplayModes; + public int activeDisplayModeId; + + public int[] supportedColorModes; + public int activeColorMode; + + public Display.HdrCapabilities hdrCapabilities; + + @Override + public String toString() { + return "DynamicDisplayInfo{" + + "supportedDisplayModes=" + Arrays.toString(supportedDisplayModes) + + ", activeDisplayModeId=" + activeDisplayModeId + + ", supportedColorModes=" + Arrays.toString(supportedColorModes) + + ", activeColorMode=" + activeColorMode + + ", hdrCapabilities=" + hdrCapabilities + "}"; + } + + @Override + public boolean equals(@Nullable Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DynamicDisplayInfo that = (DynamicDisplayInfo) o; + return Arrays.equals(supportedDisplayModes, that.supportedDisplayModes) + && activeDisplayModeId == that.activeDisplayModeId + && Arrays.equals(supportedColorModes, that.supportedColorModes) + && activeColorMode == that.activeColorMode + && Objects.equals(hdrCapabilities, that.hdrCapabilities); + } + + @Override + public int hashCode() { + return Objects.hash(supportedDisplayModes, activeDisplayModeId, activeDisplayModeId, + activeColorMode, hdrCapabilities); + } + } + + /** * Configuration supported by physical display. * * @hide @@ -1749,6 +1787,7 @@ public final class SurfaceControl implements Parcelable { */ public static final int INVALID_DISPLAY_MODE_ID = -1; + public int id; public int width; public int height; public float xDpi; @@ -1768,7 +1807,8 @@ public final class SurfaceControl implements Parcelable { @Override public String toString() { - return "DisplayConfig{width=" + width + return "DisplayMode{id=" + id + + ", width=" + width + ", height=" + height + ", xDpi=" + xDpi + ", yDpi=" + yDpi @@ -1777,46 +1817,58 @@ public final class SurfaceControl implements Parcelable { + ", presentationDeadlineNanos=" + presentationDeadlineNanos + ", group=" + group + "}"; } - } - /** - * @hide - */ - public static void setDisplayPowerMode(IBinder displayToken, int mode) { - if (displayToken == null) { - throw new IllegalArgumentException("displayToken must not be null"); + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DisplayMode that = (DisplayMode) o; + return id == that.id + && width == that.width + && height == that.height + && Float.compare(that.xDpi, xDpi) == 0 + && Float.compare(that.yDpi, yDpi) == 0 + && Float.compare(that.refreshRate, refreshRate) == 0 + && appVsyncOffsetNanos == that.appVsyncOffsetNanos + && presentationDeadlineNanos == that.presentationDeadlineNanos + && group == that.group; + } + + @Override + public int hashCode() { + return Objects.hash(id, width, height, xDpi, yDpi, refreshRate, appVsyncOffsetNanos, + presentationDeadlineNanos, group); } - nativeSetDisplayPowerMode(displayToken, mode); } /** * @hide */ - public static SurfaceControl.DisplayInfo getDisplayInfo(IBinder displayToken) { + public static void setDisplayPowerMode(IBinder displayToken, int mode) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } - return nativeGetDisplayInfo(displayToken); + nativeSetDisplayPowerMode(displayToken, mode); } /** * @hide */ - public static DisplayMode[] getDisplayModes(IBinder displayToken) { + public static StaticDisplayInfo getStaticDisplayInfo(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } - return nativeGetDisplayModes(displayToken); + return nativeGetStaticDisplayInfo(displayToken); } /** * @hide */ - public static int getActiveDisplayMode(IBinder displayToken) { + public static DynamicDisplayInfo getDynamicDisplayInfo(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } - return nativeGetActiveDisplayMode(displayToken); + return nativeGetDynamicDisplayInfo(displayToken); } /** @@ -1978,16 +2030,6 @@ public final class SurfaceControl implements Parcelable { } /** - * @hide - */ - public static int[] getDisplayColorModes(IBinder displayToken) { - if (displayToken == null) { - throw new IllegalArgumentException("displayToken must not be null"); - } - return nativeGetDisplayColorModes(displayToken); - } - - /** * Color coordinates in CIE1931 XYZ color space * * @hide @@ -2057,16 +2099,6 @@ public final class SurfaceControl implements Parcelable { /** * @hide */ - public static int getActiveColorMode(IBinder displayToken) { - if (displayToken == null) { - throw new IllegalArgumentException("displayToken must not be null"); - } - return nativeGetActiveColorMode(displayToken); - } - - /** - * @hide - */ public static boolean setActiveColorMode(IBinder displayToken, int colorMode) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); @@ -2169,16 +2201,6 @@ public final class SurfaceControl implements Parcelable { /** * @hide */ - public static Display.HdrCapabilities getHdrCapabilities(IBinder displayToken) { - if (displayToken == null) { - throw new IllegalArgumentException("displayToken must not be null"); - } - return nativeGetHdrCapabilities(displayToken); - } - - /** - * @hide - */ public static boolean getAutoLowLatencyModeSupport(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 961d4cb23679..094ca1843eea 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -45,14 +45,15 @@ #include <ui/BlurRegion.h> #include <ui/ConfigStoreTypes.h> #include <ui/DeviceProductInfo.h> -#include <ui/DisplayInfo.h> #include <ui/DisplayMode.h> #include <ui/DisplayedFrameStats.h> +#include <ui/DynamicDisplayInfo.h> #include <ui/FrameStats.h> #include <ui/GraphicTypes.h> #include <ui/HdrCapabilities.h> #include <ui/Rect.h> #include <ui/Region.h> +#include <ui/StaticDisplayInfo.h> #include <utils/LightRefBase.h> #include <utils/Log.h> @@ -87,11 +88,22 @@ static struct { jfieldID density; jfieldID secure; jfieldID deviceProductInfo; -} gDisplayInfoClassInfo; +} gStaticDisplayInfoClassInfo; static struct { jclass clazz; jmethodID ctor; + jfieldID supportedDisplayModes; + jfieldID activeDisplayModeId; + jfieldID supportedColorModes; + jfieldID activeColorMode; + jfieldID hdrCapabilities; +} gDynamicDisplayInfoClassInfo; + +static struct { + jclass clazz; + jmethodID ctor; + jfieldID id; jfieldID width; jfieldID height; jfieldID xDpi; @@ -1020,51 +1032,100 @@ static jobject convertDeviceProductInfoToJavaObject( connectionToSinkType); } -static jobject nativeGetDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) { - DisplayInfo info; +static jobject nativeGetStaticDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) { + ui::StaticDisplayInfo info; if (const auto token = ibinderForJavaObject(env, tokenObj); - !token || SurfaceComposerClient::getDisplayInfo(token, &info) != NO_ERROR) { + !token || SurfaceComposerClient::getStaticDisplayInfo(token, &info) != NO_ERROR) { return nullptr; } - jobject object = env->NewObject(gDisplayInfoClassInfo.clazz, gDisplayInfoClassInfo.ctor); - env->SetBooleanField(object, gDisplayInfoClassInfo.isInternal, - info.connectionType == DisplayConnectionType::Internal); - env->SetFloatField(object, gDisplayInfoClassInfo.density, info.density); - env->SetBooleanField(object, gDisplayInfoClassInfo.secure, info.secure); - env->SetObjectField(object, gDisplayInfoClassInfo.deviceProductInfo, + jobject object = + env->NewObject(gStaticDisplayInfoClassInfo.clazz, gStaticDisplayInfoClassInfo.ctor); + env->SetBooleanField(object, gStaticDisplayInfoClassInfo.isInternal, + info.connectionType == ui::DisplayConnectionType::Internal); + env->SetFloatField(object, gStaticDisplayInfoClassInfo.density, info.density); + env->SetBooleanField(object, gStaticDisplayInfoClassInfo.secure, info.secure); + env->SetObjectField(object, gStaticDisplayInfoClassInfo.deviceProductInfo, convertDeviceProductInfoToJavaObject(env, info.deviceProductInfo)); return object; } -static jobjectArray nativeGetDisplayModes(JNIEnv* env, jclass clazz, jobject tokenObj) { - Vector<ui::DisplayMode> modes; - if (const auto token = ibinderForJavaObject(env, tokenObj); !token || - SurfaceComposerClient::getDisplayModes(token, &modes) != NO_ERROR || modes.isEmpty()) { +static jobject convertDisplayModeToJavaObject(JNIEnv* env, const ui::DisplayMode& config) { + jobject object = env->NewObject(gDisplayModeClassInfo.clazz, gDisplayModeClassInfo.ctor); + env->SetIntField(object, gDisplayModeClassInfo.id, config.id); + env->SetIntField(object, gDisplayModeClassInfo.width, config.resolution.getWidth()); + env->SetIntField(object, gDisplayModeClassInfo.height, config.resolution.getHeight()); + env->SetFloatField(object, gDisplayModeClassInfo.xDpi, config.xDpi); + env->SetFloatField(object, gDisplayModeClassInfo.yDpi, config.yDpi); + + env->SetFloatField(object, gDisplayModeClassInfo.refreshRate, config.refreshRate); + env->SetLongField(object, gDisplayModeClassInfo.appVsyncOffsetNanos, config.appVsyncOffset); + env->SetLongField(object, gDisplayModeClassInfo.presentationDeadlineNanos, + config.presentationDeadline); + env->SetIntField(object, gDisplayModeClassInfo.group, config.group); + return object; +} + +jobject convertDeviceProductInfoToJavaObject(JNIEnv* env, const HdrCapabilities& capabilities) { + const auto& types = capabilities.getSupportedHdrTypes(); + std::vector<int32_t> intTypes; + for (auto type : types) { + intTypes.push_back(static_cast<int32_t>(type)); + } + auto typesArray = env->NewIntArray(types.size()); + env->SetIntArrayRegion(typesArray, 0, intTypes.size(), intTypes.data()); + + return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor, + typesArray, capabilities.getDesiredMaxLuminance(), + capabilities.getDesiredMaxAverageLuminance(), + capabilities.getDesiredMinLuminance()); +} + +static jobject nativeGetDynamicDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) { + ui::DynamicDisplayInfo info; + if (const auto token = ibinderForJavaObject(env, tokenObj); + !token || SurfaceComposerClient::getDynamicDisplayInfo(token, &info) != NO_ERROR) { return nullptr; } - jobjectArray modesArray = - env->NewObjectArray(modes.size(), gDisplayModeClassInfo.clazz, nullptr); + jobject object = + env->NewObject(gDynamicDisplayInfoClassInfo.clazz, gDynamicDisplayInfoClassInfo.ctor); + if (object == NULL) { + jniThrowException(env, "java/lang/OutOfMemoryError", NULL); + return NULL; + } - for (size_t c = 0; c < modes.size(); ++c) { - const ui::DisplayMode& mode = modes[c]; - jobject object = env->NewObject(gDisplayModeClassInfo.clazz, gDisplayModeClassInfo.ctor); - env->SetIntField(object, gDisplayModeClassInfo.width, mode.resolution.getWidth()); - env->SetIntField(object, gDisplayModeClassInfo.height, mode.resolution.getHeight()); - env->SetFloatField(object, gDisplayModeClassInfo.xDpi, mode.xDpi); - env->SetFloatField(object, gDisplayModeClassInfo.yDpi, mode.yDpi); + const auto numModes = info.supportedDisplayModes.size(); + jobjectArray modesArray = env->NewObjectArray(numModes, gDisplayModeClassInfo.clazz, nullptr); + for (size_t i = 0; i < numModes; i++) { + const ui::DisplayMode& mode = info.supportedDisplayModes[i]; + jobject displayModeObj = convertDisplayModeToJavaObject(env, mode); + env->SetObjectArrayElement(modesArray, static_cast<jsize>(i), displayModeObj); + env->DeleteLocalRef(displayModeObj); + } + env->SetObjectField(object, gDynamicDisplayInfoClassInfo.supportedDisplayModes, modesArray); + env->SetIntField(object, gDynamicDisplayInfoClassInfo.activeDisplayModeId, + info.activeDisplayModeId); - env->SetFloatField(object, gDisplayModeClassInfo.refreshRate, mode.refreshRate); - env->SetLongField(object, gDisplayModeClassInfo.appVsyncOffsetNanos, mode.appVsyncOffset); - env->SetLongField(object, gDisplayModeClassInfo.presentationDeadlineNanos, - mode.presentationDeadline); - env->SetIntField(object, gDisplayModeClassInfo.group, mode.group); - env->SetObjectArrayElement(modesArray, static_cast<jsize>(c), object); - env->DeleteLocalRef(object); + jintArray colorModesArray = env->NewIntArray(info.supportedColorModes.size()); + if (colorModesArray == NULL) { + jniThrowException(env, "java/lang/OutOfMemoryError", NULL); + return NULL; } + jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0); + for (size_t i = 0; i < info.supportedColorModes.size(); i++) { + colorModesArrayValues[i] = static_cast<jint>(info.supportedColorModes[i]); + } + env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0); + env->SetObjectField(object, gDynamicDisplayInfoClassInfo.supportedColorModes, colorModesArray); + + env->SetIntField(object, gDynamicDisplayInfoClassInfo.activeColorMode, + static_cast<jint>(info.activeColorMode)); - return modesArray; + env->SetObjectField(object, gDynamicDisplayInfoClassInfo.hdrCapabilities, + convertDeviceProductInfoToJavaObject(env, info.hdrCapabilities)); + + return object; } static jboolean nativeSetDesiredDisplayModeSpecs(JNIEnv* env, jclass clazz, jobject tokenObj, @@ -1072,9 +1133,8 @@ static jboolean nativeSetDesiredDisplayModeSpecs(JNIEnv* env, jclass clazz, jobj sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == nullptr) return JNI_FALSE; - size_t defaultMode = - static_cast<size_t>(env->GetIntField(DesiredDisplayModeSpecs, - gDesiredDisplayModeSpecsClassInfo.defaultMode)); + ui::DisplayModeId defaultMode = env->GetIntField(DesiredDisplayModeSpecs, + gDesiredDisplayModeSpecsClassInfo.defaultMode); jboolean allowGroupSwitching = env->GetBooleanField(DesiredDisplayModeSpecs, gDesiredDisplayModeSpecsClassInfo.allowGroupSwitching); @@ -1104,7 +1164,7 @@ static jobject nativeGetDesiredDisplayModeSpecs(JNIEnv* env, jclass clazz, jobje sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == nullptr) return nullptr; - size_t defaultMode; + ui::DisplayModeId defaultMode; bool allowGroupSwitching; float primaryRefreshRateMin; float primaryRefreshRateMax; @@ -1124,34 +1184,6 @@ static jobject nativeGetDesiredDisplayModeSpecs(JNIEnv* env, jclass clazz, jobje appRequestRefreshRateMax); } -static jint nativeGetActiveDisplayMode(JNIEnv* env, jclass clazz, jobject tokenObj) { - sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); - if (token == NULL) return -1; - return static_cast<jint>(SurfaceComposerClient::getActiveDisplayModeId(token)); -} - -static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) { - sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); - if (token == NULL) return NULL; - Vector<ui::ColorMode> colorModes; - if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR || - colorModes.isEmpty()) { - return NULL; - } - - jintArray colorModesArray = env->NewIntArray(colorModes.size()); - if (colorModesArray == NULL) { - jniThrowException(env, "java/lang/OutOfMemoryError", NULL); - return NULL; - } - jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0); - for (size_t i = 0; i < colorModes.size(); i++) { - colorModesArrayValues[i] = static_cast<jint>(colorModes[i]); - } - env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0); - return colorModesArray; -} - static jobject nativeGetDisplayNativePrimaries(JNIEnv* env, jclass, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return NULL; @@ -1212,12 +1244,6 @@ static jobject nativeGetDisplayNativePrimaries(JNIEnv* env, jclass, jobject toke return jprimaries; } -static jint nativeGetActiveColorMode(JNIEnv* env, jclass, jobject tokenObj) { - sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); - if (token == NULL) return -1; - return static_cast<jint>(SurfaceComposerClient::getActiveColorMode(token)); -} - static jintArray nativeGetCompositionDataspaces(JNIEnv* env, jclass) { ui::Dataspace defaultDataspace, wcgDataspace; ui::PixelFormat defaultPixelFormat, wcgPixelFormat; @@ -1423,26 +1449,6 @@ static void nativeReparent(JNIEnv* env, jclass clazz, jlong transactionObj, transaction->reparent(ctrl, newParent); } -static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) { - sp<IBinder> token(ibinderForJavaObject(env, tokenObject)); - if (token == NULL) return NULL; - - HdrCapabilities capabilities; - SurfaceComposerClient::getHdrCapabilities(token, &capabilities); - - const auto& types = capabilities.getSupportedHdrTypes(); - std::vector<int32_t> intTypes; - for (auto type : types) { - intTypes.push_back(static_cast<int32_t>(type)); - } - auto typesArray = env->NewIntArray(types.size()); - env->SetIntArrayRegion(typesArray, 0, intTypes.size(), intTypes.data()); - - return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor, - typesArray, capabilities.getDesiredMaxLuminance(), - capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance()); -} - static jboolean nativeGetAutoLowLatencyModeSupport(JNIEnv* env, jclass clazz, jobject tokenObject) { sp<IBinder> token(ibinderForJavaObject(env, tokenObject)); if (token == NULL) return NULL; @@ -1787,24 +1793,21 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetDisplayProjection }, {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", (void*)nativeSetDisplaySize }, - {"nativeGetDisplayInfo", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayInfo;", - (void*)nativeGetDisplayInfo }, - {"nativeGetDisplayModes", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$DisplayMode;", - (void*)nativeGetDisplayModes }, - {"nativeGetActiveDisplayMode", "(Landroid/os/IBinder;)I", - (void*)nativeGetActiveDisplayMode }, + {"nativeGetStaticDisplayInfo", + "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$StaticDisplayInfo;", + (void*)nativeGetStaticDisplayInfo }, + {"nativeGetDynamicDisplayInfo", + "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DynamicDisplayInfo;", + (void*)nativeGetDynamicDisplayInfo }, {"nativeSetDesiredDisplayModeSpecs", "(Landroid/os/IBinder;Landroid/view/SurfaceControl$DesiredDisplayModeSpecs;)Z", (void*)nativeSetDesiredDisplayModeSpecs }, {"nativeGetDesiredDisplayModeSpecs", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DesiredDisplayModeSpecs;", (void*)nativeGetDesiredDisplayModeSpecs }, - {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", - (void*)nativeGetDisplayColorModes}, - {"nativeGetDisplayNativePrimaries", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayPrimaries;", + {"nativeGetDisplayNativePrimaries", + "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayPrimaries;", (void*)nativeGetDisplayNativePrimaries }, - {"nativeGetActiveColorMode", "(Landroid/os/IBinder;)I", - (void*)nativeGetActiveColorMode}, {"nativeSetActiveColorMode", "(Landroid/os/IBinder;I)Z", (void*)nativeSetActiveColorMode}, {"nativeGetAutoLowLatencyModeSupport", "(Landroid/os/IBinder;)Z", @@ -1817,8 +1820,6 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetGameContentType }, {"nativeGetCompositionDataspaces", "()[I", (void*)nativeGetCompositionDataspaces}, - {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;", - (void*)nativeGetHdrCapabilities }, {"nativeClearContentFrameStats", "(J)Z", (void*)nativeClearContentFrameStats }, {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z", @@ -1897,19 +1898,36 @@ int register_android_view_SurfaceControl(JNIEnv* env) gIntegerClassInfo.clazz = MakeGlobalRefOrDie(env, integerClass); gIntegerClassInfo.ctor = GetMethodIDOrDie(env, gIntegerClassInfo.clazz, "<init>", "(I)V"); - jclass infoClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayInfo"); - gDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, infoClazz); - gDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, infoClazz, "<init>", "()V"); - gDisplayInfoClassInfo.isInternal = GetFieldIDOrDie(env, infoClazz, "isInternal", "Z"); - gDisplayInfoClassInfo.density = GetFieldIDOrDie(env, infoClazz, "density", "F"); - gDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, infoClazz, "secure", "Z"); - gDisplayInfoClassInfo.deviceProductInfo = + jclass infoClazz = FindClassOrDie(env, "android/view/SurfaceControl$StaticDisplayInfo"); + gStaticDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, infoClazz); + gStaticDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, infoClazz, "<init>", "()V"); + gStaticDisplayInfoClassInfo.isInternal = GetFieldIDOrDie(env, infoClazz, "isInternal", "Z"); + gStaticDisplayInfoClassInfo.density = GetFieldIDOrDie(env, infoClazz, "density", "F"); + gStaticDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, infoClazz, "secure", "Z"); + gStaticDisplayInfoClassInfo.deviceProductInfo = GetFieldIDOrDie(env, infoClazz, "deviceProductInfo", "Landroid/hardware/display/DeviceProductInfo;"); + jclass dynamicInfoClazz = FindClassOrDie(env, "android/view/SurfaceControl$DynamicDisplayInfo"); + gDynamicDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, dynamicInfoClazz); + gDynamicDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, dynamicInfoClazz, "<init>", "()V"); + gDynamicDisplayInfoClassInfo.supportedDisplayModes = + GetFieldIDOrDie(env, dynamicInfoClazz, "supportedDisplayModes", + "[Landroid/view/SurfaceControl$DisplayMode;"); + gDynamicDisplayInfoClassInfo.activeDisplayModeId = + GetFieldIDOrDie(env, dynamicInfoClazz, "activeDisplayModeId", "I"); + gDynamicDisplayInfoClassInfo.supportedColorModes = + GetFieldIDOrDie(env, dynamicInfoClazz, "supportedColorModes", "[I"); + gDynamicDisplayInfoClassInfo.activeColorMode = + GetFieldIDOrDie(env, dynamicInfoClazz, "activeColorMode", "I"); + gDynamicDisplayInfoClassInfo.hdrCapabilities = + GetFieldIDOrDie(env, dynamicInfoClazz, "hdrCapabilities", + "Landroid/view/Display$HdrCapabilities;"); + jclass modeClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayMode"); gDisplayModeClassInfo.clazz = MakeGlobalRefOrDie(env, modeClazz); gDisplayModeClassInfo.ctor = GetMethodIDOrDie(env, modeClazz, "<init>", "()V"); + gDisplayModeClassInfo.id = GetFieldIDOrDie(env, modeClazz, "id", "I"); gDisplayModeClassInfo.width = GetFieldIDOrDie(env, modeClazz, "width", "I"); gDisplayModeClassInfo.height = GetFieldIDOrDie(env, modeClazz, "height", "I"); gDisplayModeClassInfo.xDpi = GetFieldIDOrDie(env, modeClazz, "xDpi", "F"); diff --git a/libs/hwui/tests/common/TestContext.cpp b/libs/hwui/tests/common/TestContext.cpp index 6a9a98d6743b..898c64bd4159 100644 --- a/libs/hwui/tests/common/TestContext.cpp +++ b/libs/hwui/tests/common/TestContext.cpp @@ -22,16 +22,16 @@ namespace android { namespace uirenderer { namespace test { -const DisplayInfo& getDisplayInfo() { - static DisplayInfo info = [] { - DisplayInfo info; +const ui::StaticDisplayInfo& getDisplayInfo() { + static ui::StaticDisplayInfo info = [] { + ui::StaticDisplayInfo info; #if HWUI_NULL_GPU info.density = 2.f; #else const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken(); LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__); - const status_t status = SurfaceComposerClient::getDisplayInfo(token, &info); + const status_t status = SurfaceComposerClient::getStaticDisplayInfo(token, &info); LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get display info", __FUNCTION__); #endif return info; diff --git a/libs/hwui/tests/common/TestContext.h b/libs/hwui/tests/common/TestContext.h index 7d2f6d8ea731..9d00366daffe 100644 --- a/libs/hwui/tests/common/TestContext.h +++ b/libs/hwui/tests/common/TestContext.h @@ -23,8 +23,8 @@ #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceControl.h> -#include <ui/DisplayInfo.h> #include <ui/DisplayMode.h> +#include <ui/StaticDisplayInfo.h> #include <utils/Looper.h> #include <atomic> @@ -36,7 +36,7 @@ namespace android { namespace uirenderer { namespace test { -const DisplayInfo& getDisplayInfo(); +const ui::StaticDisplayInfo& getDisplayInfo(); const ui::DisplayMode& getActiveDisplayMode(); inline const ui::Size& getActiveDisplayResolution() { diff --git a/libs/input/MouseCursorController.h b/libs/input/MouseCursorController.h index e6dfc4c6f99a..c0ab58bd2e7e 100644 --- a/libs/input/MouseCursorController.h +++ b/libs/input/MouseCursorController.h @@ -20,7 +20,6 @@ #include <gui/DisplayEventReceiver.h> #include <input/DisplayViewport.h> #include <input/Input.h> -#include <ui/DisplayInfo.h> #include <utils/BitSet.h> #include <utils/Looper.h> #include <utils/RefBase.h> diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h index 827fcf1e1bc1..97567bab202b 100644 --- a/libs/input/PointerController.h +++ b/libs/input/PointerController.h @@ -21,7 +21,6 @@ #include <gui/DisplayEventReceiver.h> #include <input/DisplayViewport.h> #include <input/Input.h> -#include <ui/DisplayInfo.h> #include <utils/BitSet.h> #include <utils/Looper.h> #include <utils/RefBase.h> diff --git a/libs/input/PointerControllerContext.h b/libs/input/PointerControllerContext.h index 98073fea323e..26a65a47471d 100644 --- a/libs/input/PointerControllerContext.h +++ b/libs/input/PointerControllerContext.h @@ -21,7 +21,6 @@ #include <gui/DisplayEventReceiver.h> #include <input/DisplayViewport.h> #include <input/Input.h> -#include <ui/DisplayInfo.h> #include <utils/BitSet.h> #include <utils/Looper.h> #include <utils/RefBase.h> diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp index e51add276647..e8cf63f64572 100644 --- a/native/android/surface_control.cpp +++ b/native/android/surface_control.cpp @@ -27,14 +27,13 @@ #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceControl.h> -#include <ui/HdrCapabilities.h> +#include <ui/DynamicDisplayInfo.h> #include <utils/Timers.h> using namespace android::hardware::configstore; using namespace android::hardware::configstore::V1_0; using namespace android; -using android::hardware::configstore::V1_0::ISurfaceFlingerConfigs; using Transaction = SurfaceComposerClient::Transaction; @@ -72,14 +71,13 @@ static bool getHdrSupport(const sp<SurfaceControl>& surfaceControl) { return false; } - HdrCapabilities hdrCapabilities; - status_t err = client->getHdrCapabilities(display, &hdrCapabilities); - if (err) { + ui::DynamicDisplayInfo info; + if (status_t err = client->getDynamicDisplayInfo(display, &info); err != NO_ERROR) { ALOGE("unable to get hdr capabilities"); - return false; + return err; } - return !hdrCapabilities.getSupportedHdrTypes().empty(); + return !info.hdrCapabilities.getSupportedHdrTypes().empty(); } static bool isDataSpaceValid(const sp<SurfaceControl>& surfaceControl, ADataSpace dataSpace) { diff --git a/services/core/java/com/android/server/display/ColorFade.java b/services/core/java/com/android/server/display/ColorFade.java index 5e1df27167c2..198ea3d3f66a 100644 --- a/services/core/java/com/android/server/display/ColorFade.java +++ b/services/core/java/com/android/server/display/ColorFade.java @@ -165,7 +165,7 @@ final class ColorFade { "Failed to take screenshot because internal display is disconnected"); return false; } - boolean isWideColor = SurfaceControl.getActiveColorMode(token) + boolean isWideColor = SurfaceControl.getDynamicDisplayInfo(token).activeColorMode == Display.COLOR_MODE_DISPLAY_P3; // Set mPrepared here so if initialization fails, resources can be cleaned up. diff --git a/services/core/java/com/android/server/display/DisplayDeviceInfo.java b/services/core/java/com/android/server/display/DisplayDeviceInfo.java index 501533d535d3..40cee66a6791 100644 --- a/services/core/java/com/android/server/display/DisplayDeviceInfo.java +++ b/services/core/java/com/android/server/display/DisplayDeviceInfo.java @@ -466,7 +466,7 @@ final class DisplayDeviceInfo { sb.append(", supportedModes ").append(Arrays.toString(supportedModes)); sb.append(", colorMode ").append(colorMode); sb.append(", supportedColorModes ").append(Arrays.toString(supportedColorModes)); - sb.append(", HdrCapabilities ").append(hdrCapabilities); + sb.append(", hdrCapabilities ").append(hdrCapabilities); sb.append(", allmSupported ").append(allmSupported); sb.append(", gameContentTypeSupported ").append(gameContentTypeSupported); sb.append(", density ").append(densityDpi); diff --git a/services/core/java/com/android/server/display/LocalDisplayAdapter.java b/services/core/java/com/android/server/display/LocalDisplayAdapter.java index 3b66236c9f0f..7ce4f066b058 100644 --- a/services/core/java/com/android/server/display/LocalDisplayAdapter.java +++ b/services/core/java/com/android/server/display/LocalDisplayAdapter.java @@ -100,50 +100,48 @@ final class LocalDisplayAdapter extends DisplayAdapter { private void tryConnectDisplayLocked(long physicalDisplayId) { final IBinder displayToken = SurfaceControl.getPhysicalDisplayToken(physicalDisplayId); if (displayToken != null) { - SurfaceControl.DisplayInfo info = SurfaceControl.getDisplayInfo(displayToken); - if (info == null) { - Slog.w(TAG, "No valid info found for display device " + physicalDisplayId); + SurfaceControl.StaticDisplayInfo staticInfo = + SurfaceControl.getStaticDisplayInfo(displayToken); + if (staticInfo == null) { + Slog.w(TAG, "No valid static info found for display device " + physicalDisplayId); return; } - SurfaceControl.DisplayMode[] displayModes = - SurfaceControl.getDisplayModes(displayToken); - if (displayModes == null) { + SurfaceControl.DynamicDisplayInfo dynamicInfo = + SurfaceControl.getDynamicDisplayInfo(displayToken); + if (dynamicInfo == null) { + Slog.w(TAG, "No valid dynamic info found for display device " + physicalDisplayId); + return; + } + if (dynamicInfo.supportedDisplayModes == null) { // There are no valid modes for this device, so we can't use it Slog.w(TAG, "No valid modes found for display device " + physicalDisplayId); return; } - int activeDisplayMode = SurfaceControl.getActiveDisplayMode(displayToken); - if (activeDisplayMode < 0) { + if (dynamicInfo.activeDisplayModeId < 0) { // There is no active mode, and for now we don't have the // policy to set one. - Slog.w(TAG, "No active mode found for display device " + physicalDisplayId); + Slog.w(TAG, "No valid active mode found for display device " + physicalDisplayId); return; } - int activeColorMode = SurfaceControl.getActiveColorMode(displayToken); - if (activeColorMode < 0) { + if (dynamicInfo.activeColorMode < 0) { // We failed to get the active color mode. We don't bail out here since on the next // configuration pass we'll go ahead and set it to whatever it was set to last (or // COLOR_MODE_NATIVE if this is the first configuration). - Slog.w(TAG, "Unable to get active color mode for display device " + - physicalDisplayId); - activeColorMode = Display.COLOR_MODE_INVALID; + Slog.w(TAG, "No valid active color mode for display device " + physicalDisplayId); + dynamicInfo.activeColorMode = Display.COLOR_MODE_INVALID; } - SurfaceControl.DesiredDisplayModeSpecs modeSpecsSpecs = + SurfaceControl.DesiredDisplayModeSpecs modeSpecs = SurfaceControl.getDesiredDisplayModeSpecs(displayToken); - int[] colorModes = SurfaceControl.getDisplayColorModes(displayToken); - Display.HdrCapabilities hdrCapabilities = - SurfaceControl.getHdrCapabilities(displayToken); LocalDisplayDevice device = mDevices.get(physicalDisplayId); if (device == null) { // Display was added. final boolean isDefaultDisplay = mDevices.size() == 0; - device = new LocalDisplayDevice(displayToken, physicalDisplayId, info, displayModes, - activeDisplayMode, modeSpecsSpecs, colorModes, activeColorMode, - hdrCapabilities, isDefaultDisplay); + device = new LocalDisplayDevice(displayToken, physicalDisplayId, staticInfo, + dynamicInfo, modeSpecs, isDefaultDisplay); mDevices.put(physicalDisplayId, device); sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED); - } else if (device.updateDisplayPropertiesLocked(info, displayModes, activeDisplayMode, - modeSpecsSpecs, colorModes, activeColorMode, hdrCapabilities)) { + } else if (device.updateDisplayPropertiesLocked(staticInfo, dynamicInfo, + modeSpecs)) { sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED); } } else { @@ -195,7 +193,6 @@ final class LocalDisplayAdapter extends DisplayAdapter { private DisplayModeDirector.DesiredDisplayModeSpecs mDisplayModeSpecs = new DisplayModeDirector.DesiredDisplayModeSpecs(); private boolean mDisplayModeSpecsInvalid; - private int mActiveDisplayModeId; private int mActiveColorMode; private Display.HdrCapabilities mHdrCapabilities; private boolean mAllmSupported; @@ -204,8 +201,11 @@ final class LocalDisplayAdapter extends DisplayAdapter { private boolean mGameContentTypeRequested; private boolean mSidekickActive; private SidekickInternal mSidekickInternal; - private SurfaceControl.DisplayInfo mDisplayInfo; - private SurfaceControl.DisplayMode[] mDisplayModes; + private SurfaceControl.StaticDisplayInfo mStaticDisplayInfo; + // The supported display modes according in SurfaceFlinger + private SurfaceControl.DisplayMode[] mSfDisplayModes; + // The active display mode in SurfaceFlinger + private SurfaceControl.DisplayMode mActiveSfDisplayMode; private Spline mSystemBrightnessToNits; private Spline mNitsToHalBrightness; private DisplayDeviceConfig mDisplayDeviceConfig; @@ -214,15 +214,13 @@ final class LocalDisplayAdapter extends DisplayAdapter { new DisplayEventReceiver.FrameRateOverride[0]; LocalDisplayDevice(IBinder displayToken, long physicalDisplayId, - SurfaceControl.DisplayInfo info, SurfaceControl.DisplayMode[] displayModes, - int activeDisplayModeId, SurfaceControl.DesiredDisplayModeSpecs modeSpecs, - int[] colorModes, int activeColorMode, Display.HdrCapabilities hdrCapabilities, - boolean isDefaultDisplay) { + SurfaceControl.StaticDisplayInfo staticDisplayInfo, + SurfaceControl.DynamicDisplayInfo dynamicInfo, + SurfaceControl.DesiredDisplayModeSpecs modeSpecs, boolean isDefaultDisplay) { super(LocalDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + physicalDisplayId); mPhysicalDisplayId = physicalDisplayId; mIsDefaultDisplay = isDefaultDisplay; - updateDisplayPropertiesLocked(info, displayModes, activeDisplayModeId, modeSpecs, - colorModes, activeColorMode, hdrCapabilities); + updateDisplayPropertiesLocked(staticDisplayInfo, dynamicInfo, modeSpecs); mSidekickInternal = LocalServices.getService(SidekickInternal.class); mBacklightAdapter = new BacklightAdapter(displayToken, isDefaultDisplay); mAllmSupported = SurfaceControl.getAutoLowLatencyModeSupport(displayToken); @@ -241,15 +239,15 @@ final class LocalDisplayAdapter extends DisplayAdapter { /** * Returns true if there is a change. **/ - public boolean updateDisplayPropertiesLocked(SurfaceControl.DisplayInfo info, - SurfaceControl.DisplayMode[] displayModes, - int activeDisplayModeId, SurfaceControl.DesiredDisplayModeSpecs modeSpecs, - int[] colorModes, int activeColorMode, Display.HdrCapabilities hdrCapabilities) { + public boolean updateDisplayPropertiesLocked(SurfaceControl.StaticDisplayInfo staticInfo, + SurfaceControl.DynamicDisplayInfo dynamicInfo, + SurfaceControl.DesiredDisplayModeSpecs modeSpecs) { boolean changed = updateDisplayModesLocked( - displayModes, activeDisplayModeId, modeSpecs); - changed |= updateDisplayInfo(info); - changed |= updateColorModesLocked(colorModes, activeColorMode); - changed |= updateHdrCapabilitiesLocked(hdrCapabilities); + dynamicInfo.supportedDisplayModes, dynamicInfo.activeDisplayModeId, modeSpecs); + changed |= updateStaticInfo(staticInfo); + changed |= updateColorModesLocked(dynamicInfo.supportedColorModes, + dynamicInfo.activeColorMode); + changed |= updateHdrCapabilitiesLocked(dynamicInfo.hdrCapabilities); if (changed) { mHavePendingChanges = true; @@ -260,8 +258,9 @@ final class LocalDisplayAdapter extends DisplayAdapter { public boolean updateDisplayModesLocked( SurfaceControl.DisplayMode[] displayModes, int activeDisplayModeId, SurfaceControl.DesiredDisplayModeSpecs modeSpecs) { - mDisplayModes = Arrays.copyOf(displayModes, displayModes.length); - mActiveDisplayModeId = activeDisplayModeId; + mSfDisplayModes = Arrays.copyOf(displayModes, displayModes.length); + mActiveSfDisplayMode = getModeById(displayModes, activeDisplayModeId); + // Build an updated list of all existing modes. ArrayList<DisplayModeRecord> records = new ArrayList<>(); boolean modesAdded = false; @@ -282,7 +281,7 @@ final class LocalDisplayAdapter extends DisplayAdapter { // First, check to see if we've already added a matching mode. Since not all // configuration options are exposed via Display.Mode, it's possible that we have - // multiple DisplayModess that would generate the same Display.Mode. + // multiple DisplayModes that would generate the same Display.Mode. boolean existingMode = false; for (DisplayModeRecord record : records) { if (record.hasMatchingMode(mode) @@ -312,9 +311,8 @@ final class LocalDisplayAdapter extends DisplayAdapter { // Get the currently active mode DisplayModeRecord activeRecord = null; - for (int i = 0; i < records.size(); i++) { - DisplayModeRecord record = records.get(i); - if (record.hasMatchingMode(displayModes[activeDisplayModeId])) { + for (DisplayModeRecord record : records) { + if (record.hasMatchingMode(mActiveSfDisplayMode)) { activeRecord = record; break; } @@ -370,17 +368,17 @@ final class LocalDisplayAdapter extends DisplayAdapter { // For a new display, we need to initialize the default mode ID. if (mDefaultModeId == NO_DISPLAY_MODE_ID) { mDefaultModeId = activeRecord.mMode.getModeId(); - mDefaultModeGroup = displayModes[activeDisplayModeId].group; + mDefaultModeGroup = mActiveSfDisplayMode.group; } else if (modesAdded && activeModeChanged) { Slog.d(TAG, "New display modes are added and the active mode has changed, " + "use active mode as default mode."); mDefaultModeId = activeRecord.mMode.getModeId(); - mDefaultModeGroup = displayModes[activeDisplayModeId].group; + mDefaultModeGroup = mActiveSfDisplayMode.group; } else if (findDisplayModeIdLocked(mDefaultModeId, mDefaultModeGroup) < 0) { Slog.w(TAG, "Default display mode no longer available, using currently" + " active mode as default."); mDefaultModeId = activeRecord.mMode.getModeId(); - mDefaultModeGroup = displayModes[activeDisplayModeId].group; + mDefaultModeGroup = mActiveSfDisplayMode.group; } // Determine whether the display mode specs' base mode is still there. @@ -454,11 +452,11 @@ final class LocalDisplayAdapter extends DisplayAdapter { mSystemBrightnessToNits = sysToNits; } - private boolean updateDisplayInfo(SurfaceControl.DisplayInfo info) { - if (Objects.equals(mDisplayInfo, info)) { + private boolean updateStaticInfo(SurfaceControl.StaticDisplayInfo info) { + if (Objects.equals(mStaticDisplayInfo, info)) { return false; } - mDisplayInfo = info; + mStaticDisplayInfo = info; return true; } @@ -520,6 +518,17 @@ final class LocalDisplayAdapter extends DisplayAdapter { return true; } + private SurfaceControl.DisplayMode getModeById(SurfaceControl.DisplayMode[] supportedModes, + int modeId) { + for (SurfaceControl.DisplayMode mode : supportedModes) { + if (mode.id == modeId) { + return mode; + } + } + Slog.e(TAG, "Can't find display mode with id " + modeId); + return null; + } + private DisplayModeRecord findDisplayModeRecord(SurfaceControl.DisplayMode mode, List<Float> alternativeRefreshRates) { for (int i = 0; i < mSupportedModes.size(); i++) { @@ -556,10 +565,9 @@ final class LocalDisplayAdapter extends DisplayAdapter { @Override public DisplayDeviceInfo getDisplayDeviceInfoLocked() { if (mInfo == null) { - SurfaceControl.DisplayMode mode = mDisplayModes[mActiveDisplayModeId]; mInfo = new DisplayDeviceInfo(); - mInfo.width = mode.width; - mInfo.height = mode.height; + mInfo.width = mActiveSfDisplayMode.width; + mInfo.height = mActiveSfDisplayMode.height; mInfo.modeId = mActiveModeId; mInfo.defaultModeId = mDefaultModeId; mInfo.supportedModes = getDisplayModes(mSupportedModes); @@ -572,21 +580,21 @@ final class LocalDisplayAdapter extends DisplayAdapter { mInfo.supportedColorModes[i] = mSupportedColorModes.get(i); } mInfo.hdrCapabilities = mHdrCapabilities; - mInfo.appVsyncOffsetNanos = mode.appVsyncOffsetNanos; - mInfo.presentationDeadlineNanos = mode.presentationDeadlineNanos; + mInfo.appVsyncOffsetNanos = mActiveSfDisplayMode.appVsyncOffsetNanos; + mInfo.presentationDeadlineNanos = mActiveSfDisplayMode.presentationDeadlineNanos; mInfo.state = mState; mInfo.uniqueId = getUniqueId(); final DisplayAddress.Physical physicalAddress = DisplayAddress.fromPhysicalDisplayId(mPhysicalDisplayId); mInfo.address = physicalAddress; - mInfo.densityDpi = (int) (mDisplayInfo.density * 160 + 0.5f); - mInfo.xDpi = mode.xDpi; - mInfo.yDpi = mode.yDpi; - mInfo.deviceProductInfo = mDisplayInfo.deviceProductInfo; + mInfo.densityDpi = (int) (mStaticDisplayInfo.density * 160 + 0.5f); + mInfo.xDpi = mActiveSfDisplayMode.xDpi; + mInfo.yDpi = mActiveSfDisplayMode.yDpi; + mInfo.deviceProductInfo = mStaticDisplayInfo.deviceProductInfo; // Assume that all built-in displays that have secure output (eg. HDCP) also // support compositing from gralloc protected buffers. - if (mDisplayInfo.secure) { + if (mStaticDisplayInfo.secure) { mInfo.flags = DisplayDeviceInfo.FLAG_SECURE | DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS; } @@ -620,7 +628,7 @@ final class LocalDisplayAdapter extends DisplayAdapter { } } - if (mDisplayInfo.isInternal) { + if (mStaticDisplayInfo.isInternal) { mInfo.type = Display.TYPE_INTERNAL; mInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL; mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT; @@ -878,9 +886,10 @@ final class LocalDisplayAdapter extends DisplayAdapter { // Do not lock when calling these SurfaceControl methods because they are sync // operations that may block for a while when setting display power mode. SurfaceControl.setDesiredDisplayModeSpecs(displayToken, modeSpecs); - final int activeMode = SurfaceControl.getActiveDisplayMode(displayToken); + final int sfActiveModeId = + SurfaceControl.getDynamicDisplayInfo(displayToken).activeDisplayModeId; synchronized (getSyncRoot()) { - if (updateActiveModeLocked(activeMode)) { + if (updateActiveModeLocked(sfActiveModeId)) { updateDeviceInfoLocked(); } } @@ -891,8 +900,8 @@ final class LocalDisplayAdapter extends DisplayAdapter { updateDeviceInfoLocked(); } - public void onActiveDisplayModeChangedLocked(int modeId) { - if (updateActiveModeLocked(modeId)) { + public void onActiveDisplayModeChangedLocked(int sfModeId) { + if (updateActiveModeLocked(sfModeId)) { updateDeviceInfoLocked(); } } @@ -904,15 +913,15 @@ final class LocalDisplayAdapter extends DisplayAdapter { } } - public boolean updateActiveModeLocked(int activeModeId) { - if (mActiveDisplayModeId == activeModeId) { + public boolean updateActiveModeLocked(int activeSfModeId) { + if (mActiveSfDisplayMode.id == activeSfModeId) { return false; } - mActiveDisplayModeId = activeModeId; - mActiveModeId = findMatchingModeIdLocked(activeModeId); + mActiveSfDisplayMode = getModeById(mSfDisplayModes, activeSfModeId); + mActiveModeId = findMatchingModeIdLocked(activeSfModeId); if (mActiveModeId == NO_DISPLAY_MODE_ID) { Slog.w(TAG, "In unknown mode after setting allowed modes" - + ", activeModeId=" + mActiveDisplayModeId); + + ", activeModeId=" + activeSfModeId); } return true; } @@ -992,7 +1001,6 @@ final class LocalDisplayAdapter extends DisplayAdapter { pw.println("mPhysicalDisplayId=" + mPhysicalDisplayId); pw.println("mDisplayModeSpecs={" + mDisplayModeSpecs + "}"); pw.println("mDisplayModeSpecsInvalid=" + mDisplayModeSpecsInvalid); - pw.println("mActiveDisplayModeId=" + mActiveDisplayModeId); pw.println("mActiveModeId=" + mActiveModeId); pw.println("mActiveColorMode=" + mActiveColorMode); pw.println("mDefaultModeId=" + mDefaultModeId); @@ -1003,11 +1011,12 @@ final class LocalDisplayAdapter extends DisplayAdapter { pw.println("mAllmRequested=" + mAllmRequested); pw.println("mGameContentTypeSupported=" + mGameContentTypeSupported); pw.println("mGameContentTypeRequested=" + mGameContentTypeRequested); - pw.println("mDisplayInfo=" + mDisplayInfo); - pw.println("mDisplayModes="); - for (int i = 0; i < mDisplayModes.length; i++) { - pw.println(" " + mDisplayModes[i]); + pw.println("mStaticDisplayInfo=" + mStaticDisplayInfo); + pw.println("mSfDisplayModes="); + for (int i = 0; i < mSfDisplayModes.length; i++) { + pw.println(" " + mSfDisplayModes[i]); } + pw.println("mActiveSfDisplayMode=" + mActiveSfDisplayMode); pw.println("mSupportedModes="); for (int i = 0; i < mSupportedModes.size(); i++) { pw.println(" " + mSupportedModes.valueAt(i)); @@ -1020,17 +1029,16 @@ final class LocalDisplayAdapter extends DisplayAdapter { int matchingModeId = SurfaceControl.DisplayMode.INVALID_DISPLAY_MODE_ID; DisplayModeRecord record = mSupportedModes.get(modeId); if (record != null) { - for (int i = 0; i < mDisplayModes.length; i++) { - SurfaceControl.DisplayMode mode = mDisplayModes[i]; + for (SurfaceControl.DisplayMode mode : mSfDisplayModes) { if (record.hasMatchingMode(mode)) { if (matchingModeId == SurfaceControl.DisplayMode.INVALID_DISPLAY_MODE_ID) { - matchingModeId = i; + matchingModeId = mode.id; } // Prefer to return a mode that matches the modeGroup if (mode.group == modeGroup) { - return i; + return mode.id; } } } @@ -1038,12 +1046,12 @@ final class LocalDisplayAdapter extends DisplayAdapter { return matchingModeId; } - private int findMatchingModeIdLocked(int modeId) { - if (modeId < 0 || modeId >= mDisplayModes.length) { - Slog.e(TAG, "Invalid display config index " + modeId); + private int findMatchingModeIdLocked(int sfModeId) { + SurfaceControl.DisplayMode mode = getModeById(mSfDisplayModes, sfModeId); + if (mode == null) { + Slog.e(TAG, "Invalid display mode ID " + sfModeId); return NO_DISPLAY_MODE_ID; } - SurfaceControl.DisplayMode mode = mDisplayModes[modeId]; for (int i = 0; i < mSupportedModes.size(); i++) { DisplayModeRecord record = mSupportedModes.valueAt(i); if (record.hasMatchingMode(mode)) { @@ -1229,8 +1237,6 @@ final class LocalDisplayAdapter extends DisplayAdapter { /** * @param displayToken Token for display associated with this backlight. * @param isDefaultDisplay {@code true} if it is the default display. - * @param forceSurfaceControl {@code true} if brightness should always be - * set via SurfaceControl API. */ BacklightAdapter(IBinder displayToken, boolean isDefaultDisplay) { mDisplayToken = displayToken; diff --git a/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java b/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java index ca534927bd66..7f8784dc2599 100644 --- a/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java @@ -223,7 +223,7 @@ public class LocalDisplayAdapterTest { for (int i = 0; i < wrappedModes.length; i++) { modes[i] = wrappedModes[i].mode; } - display.modes = modes; + display.dynamicInfo.supportedDisplayModes = modes; setUpDisplay(display); mInjector.getTransmitter().sendHotplug(display, /* connected */ true); waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); @@ -252,53 +252,53 @@ public class LocalDisplayAdapterTest { testAlternativeRefreshRatesCommon(display, new DisplayModeWrapper[] { new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 60f, 0), new float[]{24f, 50f}), + createFakeDisplayMode(0, 1920, 1080, 60f, 0), new float[]{24f, 50f}), new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 50f, 0), new float[]{24f, 60f}), + createFakeDisplayMode(1, 1920, 1080, 50f, 0), new float[]{24f, 60f}), new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 24f, 0), new float[]{50f, 60f}), + createFakeDisplayMode(2, 1920, 1080, 24f, 0), new float[]{50f, 60f}), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 60f, 0), new float[]{24f, 50f}), + createFakeDisplayMode(3, 3840, 2160, 60f, 0), new float[]{24f, 50f}), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 50f, 0), new float[]{24f, 60f}), + createFakeDisplayMode(4, 3840, 2160, 50f, 0), new float[]{24f, 60f}), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 24f, 0), new float[]{50f, 60f}), + createFakeDisplayMode(5, 3840, 2160, 24f, 0), new float[]{50f, 60f}), }); testAlternativeRefreshRatesCommon(display, new DisplayModeWrapper[] { new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 60f, 0), new float[]{50f}), + createFakeDisplayMode(0, 1920, 1080, 60f, 0), new float[]{50f}), new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 50f, 0), new float[]{60f}), + createFakeDisplayMode(1, 1920, 1080, 50f, 0), new float[]{60f}), new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 24f, 1), new float[0]), + createFakeDisplayMode(2, 1920, 1080, 24f, 1), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 60f, 2), new float[0]), + createFakeDisplayMode(3, 3840, 2160, 60f, 2), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 50f, 3), new float[]{24f}), + createFakeDisplayMode(4, 3840, 2160, 50f, 3), new float[]{24f}), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 24f, 3), new float[]{50f}), + createFakeDisplayMode(5, 3840, 2160, 24f, 3), new float[]{50f}), }); testAlternativeRefreshRatesCommon(display, new DisplayModeWrapper[] { new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 60f, 0), new float[0]), + createFakeDisplayMode(0, 1920, 1080, 60f, 0), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 50f, 1), new float[0]), + createFakeDisplayMode(1, 1920, 1080, 50f, 1), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(1920, 1080, 24f, 2), new float[0]), + createFakeDisplayMode(2, 1920, 1080, 24f, 2), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 60f, 3), new float[0]), + createFakeDisplayMode(3, 3840, 2160, 60f, 3), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 50f, 4), new float[0]), + createFakeDisplayMode(4, 3840, 2160, 50f, 4), new float[0]), new DisplayModeWrapper( - createFakeDisplayMode(3840, 2160, 24f, 5), new float[0]), + createFakeDisplayMode(5, 3840, 2160, 24f, 5), new float[0]), }); } @Test public void testAfterDisplayChange_DisplayModesAreUpdated() throws Exception { - SurfaceControl.DisplayMode displayMode = createFakeDisplayMode(1920, 1080, 60f); + SurfaceControl.DisplayMode displayMode = createFakeDisplayMode(0, 1920, 1080, 60f); SurfaceControl.DisplayMode[] modes = new SurfaceControl.DisplayMode[]{displayMode}; FakeDisplay display = new FakeDisplay(PORT_A, modes, 0); @@ -325,18 +325,14 @@ public class LocalDisplayAdapterTest { displayMode.refreshRate)).isTrue(); // Change the display - SurfaceControl.DisplayMode addedDisplayInfo = createFakeDisplayMode(3840, 2160, - 60f); + SurfaceControl.DisplayMode addedDisplayInfo = createFakeDisplayMode(1, 3840, 2160, 60f); modes = new SurfaceControl.DisplayMode[]{displayMode, addedDisplayInfo}; - display.modes = modes; - display.activeMode = 1; + display.dynamicInfo.supportedDisplayModes = modes; + display.dynamicInfo.activeDisplayModeId = 1; setUpDisplay(display); mInjector.getTransmitter().sendHotplug(display, /* connected */ true); waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); - assertThat(SurfaceControl.getActiveDisplayMode(display.token)).isEqualTo(1); - assertThat(SurfaceControl.getDisplayModes(display.token).length).isEqualTo(2); - assertThat(mListener.addedDisplays.size()).isEqualTo(1); assertThat(mListener.changedDisplays.size()).isEqualTo(1); @@ -360,8 +356,8 @@ public class LocalDisplayAdapterTest { @Test public void testAfterDisplayChange_ActiveModeIsUpdated() throws Exception { SurfaceControl.DisplayMode[] modes = new SurfaceControl.DisplayMode[]{ - createFakeDisplayMode(1920, 1080, 60f), - createFakeDisplayMode(1920, 1080, 50f) + createFakeDisplayMode(0, 1920, 1080, 60f), + createFakeDisplayMode(1, 1920, 1080, 50f) }; FakeDisplay display = new FakeDisplay(PORT_A, modes, /* activeMode */ 0); setUpDisplay(display); @@ -379,13 +375,11 @@ public class LocalDisplayAdapterTest { assertThat(activeMode.matches(1920, 1080, 60f)).isTrue(); // Change the display - display.activeMode = 1; + display.dynamicInfo.activeDisplayModeId = 1; setUpDisplay(display); mInjector.getTransmitter().sendHotplug(display, /* connected */ true); waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); - assertThat(SurfaceControl.getActiveDisplayMode(display.token)).isEqualTo(1); - assertThat(mListener.addedDisplays.size()).isEqualTo(1); assertThat(mListener.changedDisplays.size()).isEqualTo(1); @@ -402,7 +396,7 @@ public class LocalDisplayAdapterTest { FakeDisplay display = new FakeDisplay(PORT_A); Display.HdrCapabilities initialHdrCapabilities = new Display.HdrCapabilities(new int[0], 1000, 1000, 0); - display.hdrCapabilities = initialHdrCapabilities; + display.dynamicInfo.hdrCapabilities = initialHdrCapabilities; setUpDisplay(display); updateAvailableDisplays(); mAdapter.registerLocked(); @@ -419,7 +413,7 @@ public class LocalDisplayAdapterTest { // Change the display Display.HdrCapabilities changedHdrCapabilities = new Display.HdrCapabilities( new int[Display.HdrCapabilities.HDR_TYPE_HDR10_PLUS], 1000, 1000, 0); - display.hdrCapabilities = changedHdrCapabilities; + display.dynamicInfo.hdrCapabilities = changedHdrCapabilities; setUpDisplay(display); mInjector.getTransmitter().sendHotplug(display, /* connected */ true); waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); @@ -438,7 +432,7 @@ public class LocalDisplayAdapterTest { public void testAfterDisplayChange_ColorModesAreUpdated() throws Exception { FakeDisplay display = new FakeDisplay(PORT_A); final int[] initialColorModes = new int[]{Display.COLOR_MODE_BT709}; - display.colorModes = initialColorModes; + display.dynamicInfo.supportedColorModes = initialColorModes; setUpDisplay(display); updateAvailableDisplays(); mAdapter.registerLocked(); @@ -455,7 +449,7 @@ public class LocalDisplayAdapterTest { // Change the display final int[] changedColorModes = new int[]{Display.COLOR_MODE_DEFAULT}; - display.colorModes = changedColorModes; + display.dynamicInfo.supportedColorModes = changedColorModes; setUpDisplay(display); mInjector.getTransmitter().sendHotplug(display, /* connected */ true); waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); @@ -474,8 +468,8 @@ public class LocalDisplayAdapterTest { @Test public void testDisplayChange_withStaleDesiredDisplayModeSpecs() throws Exception { SurfaceControl.DisplayMode[] modes = new SurfaceControl.DisplayMode[]{ - createFakeDisplayMode(1920, 1080, 60f), - createFakeDisplayMode(1920, 1080, 50f) + createFakeDisplayMode(0, 1920, 1080, 60f), + createFakeDisplayMode(1, 1920, 1080, 50f) }; final int activeMode = 0; FakeDisplay display = new FakeDisplay(PORT_A, modes, activeMode); @@ -487,11 +481,11 @@ public class LocalDisplayAdapterTest { waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); // Change the display - display.modes = new SurfaceControl.DisplayMode[]{ - createFakeDisplayMode(1920, 1080, 60f) + display.dynamicInfo.supportedDisplayModes = new SurfaceControl.DisplayMode[]{ + createFakeDisplayMode(2, 1920, 1080, 60f) }; - // SurfaceFlinger can return a stale defaultMode. Make sure this doesn't - // trigger ArrayOutOfBoundsException. + display.dynamicInfo.activeDisplayModeId = 2; + // SurfaceFlinger can return a stale defaultMode. Make sure this doesn't crash. display.desiredDisplayModeSpecs.defaultMode = 1; setUpDisplay(display); @@ -588,12 +582,15 @@ public class LocalDisplayAdapterTest { private static class FakeDisplay { public final DisplayAddress.Physical address; public final IBinder token = new Binder(); - public final SurfaceControl.DisplayInfo info; - public SurfaceControl.DisplayMode[] modes; - public int activeMode; - public int[] colorModes = new int[]{ Display.COLOR_MODE_DEFAULT }; - public Display.HdrCapabilities hdrCapabilities = new Display.HdrCapabilities(new int[0], - 1000, 1000, 0); + public final SurfaceControl.StaticDisplayInfo info; + public SurfaceControl.DynamicDisplayInfo dynamicInfo = + new SurfaceControl.DynamicDisplayInfo(); + { + dynamicInfo.supportedColorModes = new int[]{ Display.COLOR_MODE_DEFAULT }; + dynamicInfo.hdrCapabilities = new Display.HdrCapabilities(new int[0], + 1000, 1000, 0); + } + public SurfaceControl.DesiredDisplayModeSpecs desiredDisplayModeSpecs = new SurfaceControl.DesiredDisplayModeSpecs(/* defaultMode */ 0, /* allowGroupSwitching */ false, @@ -603,19 +600,19 @@ public class LocalDisplayAdapterTest { /* appRefreshRateMax */60.f); private FakeDisplay(int port) { - this.address = createDisplayAddress(port); - this.info = createFakeDisplayInfo(); - this.modes = new SurfaceControl.DisplayMode[]{ - createFakeDisplayMode(800, 600, 60f) + address = createDisplayAddress(port); + info = createFakeDisplayInfo(); + dynamicInfo.supportedDisplayModes = new SurfaceControl.DisplayMode[]{ + createFakeDisplayMode(0, 800, 600, 60f) }; - this.activeMode = 0; + dynamicInfo.activeDisplayModeId = 0; } private FakeDisplay(int port, SurfaceControl.DisplayMode[] modes, int activeMode) { - this.address = createDisplayAddress(port); - this.info = createFakeDisplayInfo(); - this.modes = modes; - this.activeMode = activeMode; + address = createDisplayAddress(port); + info = createFakeDisplayInfo(); + dynamicInfo.supportedDisplayModes = modes; + dynamicInfo.activeDisplayModeId = activeMode; } } @@ -623,15 +620,9 @@ public class LocalDisplayAdapterTest { mAddresses.add(display.address); doReturn(display.token).when(() -> SurfaceControl.getPhysicalDisplayToken(display.address.getPhysicalDisplayId())); - doReturn(display.info).when(() -> SurfaceControl.getDisplayInfo(display.token)); - doReturn(display.modes).when( - () -> SurfaceControl.getDisplayModes(display.token)); - doReturn(display.activeMode).when(() -> SurfaceControl.getActiveDisplayMode(display.token)); - doReturn(0).when(() -> SurfaceControl.getActiveColorMode(display.token)); - doReturn(display.colorModes).when( - () -> SurfaceControl.getDisplayColorModes(display.token)); - doReturn(display.hdrCapabilities).when( - () -> SurfaceControl.getHdrCapabilities(display.token)); + doReturn(display.info).when(() -> SurfaceControl.getStaticDisplayInfo(display.token)); + doReturn(display.dynamicInfo).when( + () -> SurfaceControl.getDynamicDisplayInfo(display.token)); doReturn(display.desiredDisplayModeSpecs) .when(() -> SurfaceControl.getDesiredDisplayModeSpecs(display.token)); } @@ -650,20 +641,21 @@ public class LocalDisplayAdapterTest { return DisplayAddress.fromPortAndModel(port, DISPLAY_MODEL); } - private static SurfaceControl.DisplayInfo createFakeDisplayInfo() { - final SurfaceControl.DisplayInfo info = new SurfaceControl.DisplayInfo(); + private static SurfaceControl.StaticDisplayInfo createFakeDisplayInfo() { + final SurfaceControl.StaticDisplayInfo info = new SurfaceControl.StaticDisplayInfo(); info.density = 100; return info; } - private static SurfaceControl.DisplayMode createFakeDisplayMode(int width, int height, + private static SurfaceControl.DisplayMode createFakeDisplayMode(int id, int width, int height, float refreshRate) { - return createFakeDisplayMode(width, height, refreshRate, 0); + return createFakeDisplayMode(id, width, height, refreshRate, 0); } - private static SurfaceControl.DisplayMode createFakeDisplayMode(int width, int height, + private static SurfaceControl.DisplayMode createFakeDisplayMode(int id, int width, int height, float refreshRate, int group) { final SurfaceControl.DisplayMode mode = new SurfaceControl.DisplayMode(); + mode.id = id; mode.width = width; mode.height = height; mode.refreshRate = refreshRate; |