Tracking changes to renaming DisplayConfig to DisplayMode
Bug: 159590486
Test: presubmit
Change-Id: I64e57fe4d73c22bbbe0a1767cadf8648259e9beb
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index a7396fa..be82b22 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -43,7 +43,7 @@
#include <android-base/properties.h>
-#include <ui/DisplayConfig.h>
+#include <ui/DisplayMode.h>
#include <ui/PixelFormat.h>
#include <ui/Rect.h>
#include <ui/Region.h>
@@ -65,6 +65,8 @@
namespace android {
+using ui::DisplayMode;
+
static const char OEM_BOOTANIMATION_FILE[] = "/oem/media/bootanimation.zip";
static const char PRODUCT_BOOTANIMATION_DARK_FILE[] = "/product/media/bootanimation-dark.zip";
static const char PRODUCT_BOOTANIMATION_FILE[] = "/product/media/bootanimation.zip";
@@ -345,14 +347,14 @@
continue;
}
- DisplayConfig displayConfig;
- const status_t error = SurfaceComposerClient::getActiveDisplayConfig(
- mBootAnimation->mDisplayToken, &displayConfig);
+ DisplayMode displayMode;
+ const status_t error = SurfaceComposerClient::getActiveDisplayMode(
+ mBootAnimation->mDisplayToken, &displayMode);
if (error != NO_ERROR) {
- SLOGE("Can't get active display configuration.");
+ SLOGE("Can't get active display mode.");
}
- mBootAnimation->resizeSurface(displayConfig.resolution.getWidth(),
- displayConfig.resolution.getHeight());
+ mBootAnimation->resizeSurface(displayMode.resolution.getWidth(),
+ displayMode.resolution.getHeight());
}
}
} while (numEvents > 0);
@@ -401,15 +403,15 @@
if (mDisplayToken == nullptr)
return NAME_NOT_FOUND;
- DisplayConfig displayConfig;
+ DisplayMode displayMode;
const status_t error =
- SurfaceComposerClient::getActiveDisplayConfig(mDisplayToken, &displayConfig);
+ SurfaceComposerClient::getActiveDisplayMode(mDisplayToken, &displayMode);
if (error != NO_ERROR)
return error;
mMaxWidth = android::base::GetIntProperty("ro.surface_flinger.max_graphics_width", 0);
mMaxHeight = android::base::GetIntProperty("ro.surface_flinger.max_graphics_height", 0);
- ui::Size resolution = displayConfig.resolution;
+ ui::Size resolution = displayMode.resolution;
resolution = limitSurfaceSize(resolution.width, resolution.height);
// create the native surface
sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
diff --git a/core/java/android/view/DisplayEventReceiver.java b/core/java/android/view/DisplayEventReceiver.java
index 5d4a4e5..e6cd252 100644
--- a/core/java/android/view/DisplayEventReceiver.java
+++ b/core/java/android/view/DisplayEventReceiver.java
@@ -58,11 +58,11 @@
public static final int VSYNC_SOURCE_SURFACE_FLINGER = 1;
/**
- * Specifies to generate config changed events from Surface Flinger.
+ * Specifies to generate mode changed events from Surface Flinger.
* <p>
* Needs to be kept in sync with frameworks/native/include/gui/ISurfaceComposer.h
*/
- public static final int EVENT_REGISTRATION_CONFIG_CHANGED_FLAG = 0x1;
+ public static final int EVENT_REGISTRATION_MODE_CHANGED_FLAG = 0x1;
/**
* Specifies to generate frame rate override events from Surface Flinger.
@@ -197,14 +197,14 @@
}
/**
- * Called when a display config changed event is received.
+ * Called when a display mode changed event is received.
*
* @param timestampNanos The timestamp of the event, in the {@link System#nanoTime()}
* timebase.
* @param physicalDisplayId Stable display ID that uniquely describes a (display, port) pair.
- * @param configId The new config Id
+ * @param modeId The new mode Id
*/
- public void onConfigChanged(long timestampNanos, long physicalDisplayId, int configId) {
+ public void onModeChanged(long timestampNanos, long physicalDisplayId, int modeId) {
}
/**
@@ -273,8 +273,8 @@
// Called from native code.
@SuppressWarnings("unused")
- private void dispatchConfigChanged(long timestampNanos, long physicalDisplayId, int configId) {
- onConfigChanged(timestampNanos, physicalDisplayId, configId);
+ private void dispatchModeChanged(long timestampNanos, long physicalDisplayId, int modeId) {
+ onModeChanged(timestampNanos, physicalDisplayId, modeId);
}
// Called from native code.
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index efa33f7..f9036d7 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -161,8 +161,8 @@
int L, int T, int R, int B);
private static native void nativeSetDisplaySize(long transactionObj, IBinder displayToken,
int width, int height);
- private static native SurfaceControl.DisplayInfo nativeGetDisplayInfo(IBinder displayToken);
- private static native SurfaceControl.DisplayConfig[] nativeGetDisplayConfigs(
+ private static native DisplayInfo nativeGetDisplayInfo(IBinder displayToken);
+ private static native DisplayMode[] nativeGetDisplayModes(
IBinder displayToken);
private static native DisplayedContentSamplingAttributes
nativeGetDisplayedContentSamplingAttributes(IBinder displayToken);
@@ -170,13 +170,13 @@
boolean enable, int componentMask, int maxFrames);
private static native DisplayedContentSample nativeGetDisplayedContentSample(
IBinder displayToken, long numFrames, long timestamp);
- private static native int nativeGetActiveConfig(IBinder displayToken);
- private static native boolean nativeSetDesiredDisplayConfigSpecs(IBinder displayToken,
- SurfaceControl.DesiredDisplayConfigSpecs desiredDisplayConfigSpecs);
- private static native SurfaceControl.DesiredDisplayConfigSpecs
- nativeGetDesiredDisplayConfigSpecs(IBinder displayToken);
+ 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 SurfaceControl.DisplayPrimaries nativeGetDisplayNativePrimaries(
+ private static native DisplayPrimaries nativeGetDisplayNativePrimaries(
IBinder displayToken);
private static native int[] nativeGetCompositionDataspaces();
private static native int nativeGetActiveColorMode(IBinder displayToken);
@@ -1745,11 +1745,11 @@
*
* @hide
*/
- public static final class DisplayConfig {
+ public static final class DisplayMode {
/**
* Invalid display config id.
*/
- public static final int INVALID_DISPLAY_CONFIG_ID = -1;
+ public static final int INVALID_DISPLAY_MODE_ID = -1;
public int width;
public int height;
@@ -1766,7 +1766,7 @@
* configs within the same group can be done seamlessly in most cases.
* @see: android.hardware.graphics.composer@2.4::IComposerClient::Attribute::CONFIG_GROUP
*/
- public int configGroup;
+ public int group;
@Override
public String toString() {
@@ -1777,7 +1777,7 @@
+ ", refreshRate=" + refreshRate
+ ", appVsyncOffsetNanos=" + appVsyncOffsetNanos
+ ", presentationDeadlineNanos=" + presentationDeadlineNanos
- + ", configGroup=" + configGroup + "}";
+ + ", group=" + group + "}";
}
}
@@ -1804,21 +1804,21 @@
/**
* @hide
*/
- public static SurfaceControl.DisplayConfig[] getDisplayConfigs(IBinder displayToken) {
+ public static DisplayMode[] getDisplayModes(IBinder displayToken) {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
}
- return nativeGetDisplayConfigs(displayToken);
+ return nativeGetDisplayModes(displayToken);
}
/**
* @hide
*/
- public static int getActiveConfig(IBinder displayToken) {
+ public static int getActiveDisplayMode(IBinder displayToken) {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
}
- return nativeGetActiveConfig(displayToken);
+ return nativeGetActiveDisplayMode(displayToken);
}
/**
@@ -1865,8 +1865,8 @@
*
* @hide
*/
- public static final class DesiredDisplayConfigSpecs {
- public int defaultConfig;
+ public static final class DesiredDisplayModeSpecs {
+ public int defaultMode;
/**
* The primary refresh rate range represents display manager's general guidance on the
* display configs surface flinger will consider when switching refresh rates. Unless
@@ -1891,16 +1891,16 @@
*/
public boolean allowGroupSwitching;
- public DesiredDisplayConfigSpecs() {}
+ public DesiredDisplayModeSpecs() {}
- public DesiredDisplayConfigSpecs(DesiredDisplayConfigSpecs other) {
+ public DesiredDisplayModeSpecs(DesiredDisplayModeSpecs other) {
copyFrom(other);
}
- public DesiredDisplayConfigSpecs(int defaultConfig, boolean allowGroupSwitching,
+ public DesiredDisplayModeSpecs(int defaultMode, boolean allowGroupSwitching,
float primaryRefreshRateMin, float primaryRefreshRateMax,
float appRequestRefreshRateMin, float appRequestRefreshRateMax) {
- this.defaultConfig = defaultConfig;
+ this.defaultMode = defaultMode;
this.allowGroupSwitching = allowGroupSwitching;
this.primaryRefreshRateMin = primaryRefreshRateMin;
this.primaryRefreshRateMax = primaryRefreshRateMax;
@@ -1910,14 +1910,14 @@
@Override
public boolean equals(@Nullable Object o) {
- return o instanceof DesiredDisplayConfigSpecs && equals((DesiredDisplayConfigSpecs) o);
+ return o instanceof DesiredDisplayModeSpecs && equals((DesiredDisplayModeSpecs) o);
}
/**
* Tests for equality.
*/
- public boolean equals(DesiredDisplayConfigSpecs other) {
- return other != null && defaultConfig == other.defaultConfig
+ public boolean equals(DesiredDisplayModeSpecs other) {
+ return other != null && defaultMode == other.defaultMode
&& primaryRefreshRateMin == other.primaryRefreshRateMin
&& primaryRefreshRateMax == other.primaryRefreshRateMax
&& appRequestRefreshRateMin == other.appRequestRefreshRateMin
@@ -1932,8 +1932,8 @@
/**
* Copies the supplied object's values to this object.
*/
- public void copyFrom(DesiredDisplayConfigSpecs other) {
- defaultConfig = other.defaultConfig;
+ public void copyFrom(DesiredDisplayModeSpecs other) {
+ defaultMode = other.defaultMode;
primaryRefreshRateMin = other.primaryRefreshRateMin;
primaryRefreshRateMax = other.primaryRefreshRateMax;
appRequestRefreshRateMin = other.appRequestRefreshRateMin;
@@ -1944,7 +1944,7 @@
public String toString() {
return String.format("defaultConfig=%d primaryRefreshRateRange=[%.0f %.0f]"
+ " appRequestRefreshRateRange=[%.0f %.0f]",
- defaultConfig, primaryRefreshRateMin, primaryRefreshRateMax,
+ defaultMode, primaryRefreshRateMin, primaryRefreshRateMax,
appRequestRefreshRateMin, appRequestRefreshRateMax);
}
}
@@ -1952,25 +1952,31 @@
/**
* @hide
*/
- public static boolean setDesiredDisplayConfigSpecs(IBinder displayToken,
- SurfaceControl.DesiredDisplayConfigSpecs desiredDisplayConfigSpecs) {
+ public static boolean setDesiredDisplayModeSpecs(IBinder displayToken,
+ DesiredDisplayModeSpecs desiredDisplayModeSpecs) {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
}
+ if (desiredDisplayModeSpecs == null) {
+ throw new IllegalArgumentException("desiredDisplayModeSpecs must not be null");
+ }
+ if (desiredDisplayModeSpecs.defaultMode < 0) {
+ throw new IllegalArgumentException("defaultMode must be non-negative");
+ }
- return nativeSetDesiredDisplayConfigSpecs(displayToken, desiredDisplayConfigSpecs);
+ return nativeSetDesiredDisplayModeSpecs(displayToken, desiredDisplayModeSpecs);
}
/**
* @hide
*/
- public static SurfaceControl.DesiredDisplayConfigSpecs getDesiredDisplayConfigSpecs(
+ public static DesiredDisplayModeSpecs getDesiredDisplayModeSpecs(
IBinder displayToken) {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
}
- return nativeGetDesiredDisplayConfigSpecs(displayToken);
+ return nativeGetDesiredDisplayModeSpecs(displayToken);
}
/**
@@ -2041,7 +2047,7 @@
/**
* @hide
*/
- public static SurfaceControl.DisplayPrimaries getDisplayNativePrimaries(
+ public static DisplayPrimaries getDisplayNativePrimaries(
IBinder displayToken) {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp
index 6337680..8977b97 100644
--- a/core/jni/android_view_DisplayEventReceiver.cpp
+++ b/core/jni/android_view_DisplayEventReceiver.cpp
@@ -40,7 +40,7 @@
jmethodID dispatchVsync;
jmethodID dispatchHotplug;
- jmethodID dispatchConfigChanged;
+ jmethodID dispatchModeChanged;
jmethodID dispatchFrameRateOverrides;
struct {
@@ -69,8 +69,8 @@
void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count,
VsyncEventData vsyncEventData) override;
void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) override;
- void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId,
- int32_t configId, nsecs_t vsyncPeriod) override;
+ void dispatchModeChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t modeId,
+ nsecs_t vsyncPeriod) override;
void dispatchFrameRateOverrides(nsecs_t timestamp, PhysicalDisplayId displayId,
std::vector<FrameRateOverride> overrides) override;
void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) override {}
@@ -129,20 +129,19 @@
mMessageQueue->raiseAndClearException(env, "dispatchHotplug");
}
-void NativeDisplayEventReceiver::dispatchConfigChanged(
- nsecs_t timestamp, PhysicalDisplayId displayId, int32_t configId, nsecs_t) {
- JNIEnv* env = AndroidRuntime::getJNIEnv();
+void NativeDisplayEventReceiver::dispatchModeChanged(nsecs_t timestamp, PhysicalDisplayId displayId,
+ int32_t modeId, nsecs_t) {
+ JNIEnv* env = AndroidRuntime::getJNIEnv();
- ScopedLocalRef<jobject> receiverObj(env,
- jniGetReferent(env, mReceiverWeakGlobal));
- if (receiverObj.get()) {
- ALOGV("receiver %p ~ Invoking config changed handler.", this);
- env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchConfigChanged,
- timestamp, displayId.value, configId);
- ALOGV("receiver %p ~ Returned from config changed handler.", this);
- }
+ ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal));
+ if (receiverObj.get()) {
+ ALOGV("receiver %p ~ Invoking mode changed handler.", this);
+ env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchModeChanged,
+ timestamp, displayId.value, modeId);
+ ALOGV("receiver %p ~ Returned from mode changed handler.", this);
+ }
- mMessageQueue->raiseAndClearException(env, "dispatchConfigChanged");
+ mMessageQueue->raiseAndClearException(env, "dispatchModeChanged");
}
void NativeDisplayEventReceiver::dispatchFrameRateOverrides(
@@ -173,7 +172,7 @@
ALOGV("receiver %p ~ Returned from FrameRateOverride handler.", this);
}
- mMessageQueue->raiseAndClearException(env, "dispatchConfigChanged");
+ mMessageQueue->raiseAndClearException(env, "dispatchModeChanged");
}
static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak, jobject messageQueueObj,
@@ -243,8 +242,9 @@
"(JJIJJ)V");
gDisplayEventReceiverClassInfo.dispatchHotplug = GetMethodIDOrDie(env,
gDisplayEventReceiverClassInfo.clazz, "dispatchHotplug", "(JJZ)V");
- gDisplayEventReceiverClassInfo.dispatchConfigChanged = GetMethodIDOrDie(env,
- gDisplayEventReceiverClassInfo.clazz, "dispatchConfigChanged", "(JJI)V");
+ gDisplayEventReceiverClassInfo.dispatchModeChanged =
+ GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz, "dispatchModeChanged",
+ "(JJI)V");
gDisplayEventReceiverClassInfo.dispatchFrameRateOverrides =
GetMethodIDOrDie(env, gDisplayEventReceiverClassInfo.clazz,
"dispatchFrameRateOverrides",
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 05fcaec..886f29c 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -44,8 +44,8 @@
#include <ui/BlurRegion.h>
#include <ui/ConfigStoreTypes.h>
#include <ui/DeviceProductInfo.h>
-#include <ui/DisplayConfig.h>
#include <ui/DisplayInfo.h>
+#include <ui/DisplayMode.h>
#include <ui/DisplayedFrameStats.h>
#include <ui/FrameStats.h>
#include <ui/GraphicTypes.h>
@@ -98,8 +98,8 @@
jfieldID refreshRate;
jfieldID appVsyncOffsetNanos;
jfieldID presentationDeadlineNanos;
- jfieldID configGroup;
-} gDisplayConfigClassInfo;
+ jfieldID group;
+} gDisplayModeClassInfo;
static struct {
jfieldID bottom;
@@ -202,13 +202,13 @@
static struct {
jclass clazz;
jmethodID ctor;
- jfieldID defaultConfig;
+ jfieldID defaultMode;
jfieldID allowGroupSwitching;
jfieldID primaryRefreshRateMin;
jfieldID primaryRefreshRateMax;
jfieldID appRequestRefreshRateMin;
jfieldID appRequestRefreshRateMax;
-} gDesiredDisplayConfigSpecsClassInfo;
+} gDesiredDisplayModeSpecsClassInfo;
static struct {
jclass clazz;
@@ -1028,101 +1028,97 @@
return object;
}
-static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) {
- Vector<DisplayConfig> configs;
+static jobjectArray nativeGetDisplayModes(JNIEnv* env, jclass clazz, jobject tokenObj) {
+ Vector<ui::DisplayMode> modes;
if (const auto token = ibinderForJavaObject(env, tokenObj); !token ||
- SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR ||
- configs.isEmpty()) {
+ SurfaceComposerClient::getDisplayModes(token, &modes) != NO_ERROR || modes.isEmpty()) {
return nullptr;
}
- jobjectArray configArray =
- env->NewObjectArray(configs.size(), gDisplayConfigClassInfo.clazz, nullptr);
+ jobjectArray modesArray =
+ env->NewObjectArray(modes.size(), gDisplayModeClassInfo.clazz, nullptr);
- for (size_t c = 0; c < configs.size(); ++c) {
- const DisplayConfig& config = configs[c];
- jobject object =
- env->NewObject(gDisplayConfigClassInfo.clazz, gDisplayConfigClassInfo.ctor);
- env->SetIntField(object, gDisplayConfigClassInfo.width, config.resolution.getWidth());
- env->SetIntField(object, gDisplayConfigClassInfo.height, config.resolution.getHeight());
- env->SetFloatField(object, gDisplayConfigClassInfo.xDpi, config.xDpi);
- env->SetFloatField(object, gDisplayConfigClassInfo.yDpi, config.yDpi);
+ 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);
- env->SetFloatField(object, gDisplayConfigClassInfo.refreshRate, config.refreshRate);
- env->SetLongField(object, gDisplayConfigClassInfo.appVsyncOffsetNanos,
- config.appVsyncOffset);
- env->SetLongField(object, gDisplayConfigClassInfo.presentationDeadlineNanos,
- config.presentationDeadline);
- env->SetIntField(object, gDisplayConfigClassInfo.configGroup, config.configGroup);
- env->SetObjectArrayElement(configArray, static_cast<jsize>(c), object);
+ 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);
}
- return configArray;
+ return modesArray;
}
-static jboolean nativeSetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, jobject tokenObj,
- jobject desiredDisplayConfigSpecs) {
+static jboolean nativeSetDesiredDisplayModeSpecs(JNIEnv* env, jclass clazz, jobject tokenObj,
+ jobject DesiredDisplayModeSpecs) {
sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
if (token == nullptr) return JNI_FALSE;
- jint defaultConfig = env->GetIntField(desiredDisplayConfigSpecs,
- gDesiredDisplayConfigSpecsClassInfo.defaultConfig);
+ size_t defaultMode =
+ static_cast<size_t>(env->GetIntField(DesiredDisplayModeSpecs,
+ gDesiredDisplayModeSpecsClassInfo.defaultMode));
jboolean allowGroupSwitching =
- env->GetBooleanField(desiredDisplayConfigSpecs,
- gDesiredDisplayConfigSpecsClassInfo.allowGroupSwitching);
+ env->GetBooleanField(DesiredDisplayModeSpecs,
+ gDesiredDisplayModeSpecsClassInfo.allowGroupSwitching);
jfloat primaryRefreshRateMin =
- env->GetFloatField(desiredDisplayConfigSpecs,
- gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMin);
+ env->GetFloatField(DesiredDisplayModeSpecs,
+ gDesiredDisplayModeSpecsClassInfo.primaryRefreshRateMin);
jfloat primaryRefreshRateMax =
- env->GetFloatField(desiredDisplayConfigSpecs,
- gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMax);
+ env->GetFloatField(DesiredDisplayModeSpecs,
+ gDesiredDisplayModeSpecsClassInfo.primaryRefreshRateMax);
jfloat appRequestRefreshRateMin =
- env->GetFloatField(desiredDisplayConfigSpecs,
- gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMin);
+ env->GetFloatField(DesiredDisplayModeSpecs,
+ gDesiredDisplayModeSpecsClassInfo.appRequestRefreshRateMin);
jfloat appRequestRefreshRateMax =
- env->GetFloatField(desiredDisplayConfigSpecs,
- gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMax);
+ env->GetFloatField(DesiredDisplayModeSpecs,
+ gDesiredDisplayModeSpecsClassInfo.appRequestRefreshRateMax);
- size_t result = SurfaceComposerClient::setDesiredDisplayConfigSpecs(token, defaultConfig,
- allowGroupSwitching,
- primaryRefreshRateMin,
- primaryRefreshRateMax,
- appRequestRefreshRateMin,
- appRequestRefreshRateMax);
+ size_t result = SurfaceComposerClient::setDesiredDisplayModeSpecs(token, defaultMode,
+ allowGroupSwitching,
+ primaryRefreshRateMin,
+ primaryRefreshRateMax,
+ appRequestRefreshRateMin,
+ appRequestRefreshRateMax);
return result == NO_ERROR ? JNI_TRUE : JNI_FALSE;
}
-static jobject nativeGetDesiredDisplayConfigSpecs(JNIEnv* env, jclass clazz, jobject tokenObj) {
+static jobject nativeGetDesiredDisplayModeSpecs(JNIEnv* env, jclass clazz, jobject tokenObj) {
sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
if (token == nullptr) return nullptr;
- int32_t defaultConfig;
+ size_t defaultMode;
bool allowGroupSwitching;
float primaryRefreshRateMin;
float primaryRefreshRateMax;
float appRequestRefreshRateMin;
float appRequestRefreshRateMax;
- if (SurfaceComposerClient::getDesiredDisplayConfigSpecs(token, &defaultConfig,
- &allowGroupSwitching,
- &primaryRefreshRateMin,
- &primaryRefreshRateMax,
- &appRequestRefreshRateMin,
- &appRequestRefreshRateMax) !=
- NO_ERROR) {
+ if (SurfaceComposerClient::getDesiredDisplayModeSpecs(token, &defaultMode, &allowGroupSwitching,
+ &primaryRefreshRateMin,
+ &primaryRefreshRateMax,
+ &appRequestRefreshRateMin,
+ &appRequestRefreshRateMax) != NO_ERROR) {
return nullptr;
}
- return env->NewObject(gDesiredDisplayConfigSpecsClassInfo.clazz,
- gDesiredDisplayConfigSpecsClassInfo.ctor, defaultConfig,
- allowGroupSwitching, primaryRefreshRateMin, primaryRefreshRateMax,
- appRequestRefreshRateMin, appRequestRefreshRateMax);
+ return env->NewObject(gDesiredDisplayModeSpecsClassInfo.clazz,
+ gDesiredDisplayModeSpecsClassInfo.ctor, defaultMode, allowGroupSwitching,
+ primaryRefreshRateMin, primaryRefreshRateMax, appRequestRefreshRateMin,
+ appRequestRefreshRateMax);
}
-static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) {
+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::getActiveConfig(token));
+ return static_cast<jint>(SurfaceComposerClient::getActiveDisplayModeId(token));
}
static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) {
@@ -1794,16 +1790,16 @@
(void*)nativeSetDisplaySize },
{"nativeGetDisplayInfo", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayInfo;",
(void*)nativeGetDisplayInfo },
- {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$DisplayConfig;",
- (void*)nativeGetDisplayConfigs },
- {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I",
- (void*)nativeGetActiveConfig },
- {"nativeSetDesiredDisplayConfigSpecs",
- "(Landroid/os/IBinder;Landroid/view/SurfaceControl$DesiredDisplayConfigSpecs;)Z",
- (void*)nativeSetDesiredDisplayConfigSpecs },
- {"nativeGetDesiredDisplayConfigSpecs",
- "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DesiredDisplayConfigSpecs;",
- (void*)nativeGetDesiredDisplayConfigSpecs },
+ {"nativeGetDisplayModes", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$DisplayMode;",
+ (void*)nativeGetDisplayModes },
+ {"nativeGetActiveDisplayMode", "(Landroid/os/IBinder;)I",
+ (void*)nativeGetActiveDisplayMode },
+ {"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;",
@@ -1914,19 +1910,19 @@
GetFieldIDOrDie(env, infoClazz, "deviceProductInfo",
"Landroid/hardware/display/DeviceProductInfo;");
- jclass configClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayConfig");
- gDisplayConfigClassInfo.clazz = MakeGlobalRefOrDie(env, configClazz);
- gDisplayConfigClassInfo.ctor = GetMethodIDOrDie(env, configClazz, "<init>", "()V");
- gDisplayConfigClassInfo.width = GetFieldIDOrDie(env, configClazz, "width", "I");
- gDisplayConfigClassInfo.height = GetFieldIDOrDie(env, configClazz, "height", "I");
- gDisplayConfigClassInfo.xDpi = GetFieldIDOrDie(env, configClazz, "xDpi", "F");
- gDisplayConfigClassInfo.yDpi = GetFieldIDOrDie(env, configClazz, "yDpi", "F");
- gDisplayConfigClassInfo.refreshRate = GetFieldIDOrDie(env, configClazz, "refreshRate", "F");
- gDisplayConfigClassInfo.appVsyncOffsetNanos =
- GetFieldIDOrDie(env, configClazz, "appVsyncOffsetNanos", "J");
- gDisplayConfigClassInfo.presentationDeadlineNanos =
- GetFieldIDOrDie(env, configClazz, "presentationDeadlineNanos", "J");
- gDisplayConfigClassInfo.configGroup = GetFieldIDOrDie(env, configClazz, "configGroup", "I");
+ jclass modeClazz = FindClassOrDie(env, "android/view/SurfaceControl$DisplayMode");
+ gDisplayModeClassInfo.clazz = MakeGlobalRefOrDie(env, modeClazz);
+ gDisplayModeClassInfo.ctor = GetMethodIDOrDie(env, modeClazz, "<init>", "()V");
+ gDisplayModeClassInfo.width = GetFieldIDOrDie(env, modeClazz, "width", "I");
+ gDisplayModeClassInfo.height = GetFieldIDOrDie(env, modeClazz, "height", "I");
+ gDisplayModeClassInfo.xDpi = GetFieldIDOrDie(env, modeClazz, "xDpi", "F");
+ gDisplayModeClassInfo.yDpi = GetFieldIDOrDie(env, modeClazz, "yDpi", "F");
+ gDisplayModeClassInfo.refreshRate = GetFieldIDOrDie(env, modeClazz, "refreshRate", "F");
+ gDisplayModeClassInfo.appVsyncOffsetNanos =
+ GetFieldIDOrDie(env, modeClazz, "appVsyncOffsetNanos", "J");
+ gDisplayModeClassInfo.presentationDeadlineNanos =
+ GetFieldIDOrDie(env, modeClazz, "presentationDeadlineNanos", "J");
+ gDisplayModeClassInfo.group = GetFieldIDOrDie(env, modeClazz, "group", "I");
jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I");
@@ -2017,24 +2013,23 @@
gDisplayPrimariesClassInfo.white = GetFieldIDOrDie(env, displayPrimariesClazz, "white",
"Landroid/view/SurfaceControl$CieXyz;");
- jclass desiredDisplayConfigSpecsClazz =
- FindClassOrDie(env, "android/view/SurfaceControl$DesiredDisplayConfigSpecs");
- gDesiredDisplayConfigSpecsClassInfo.clazz =
- MakeGlobalRefOrDie(env, desiredDisplayConfigSpecsClazz);
- gDesiredDisplayConfigSpecsClassInfo.ctor =
- GetMethodIDOrDie(env, gDesiredDisplayConfigSpecsClassInfo.clazz, "<init>", "(IZFFFF)V");
- gDesiredDisplayConfigSpecsClassInfo.defaultConfig =
- GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "defaultConfig", "I");
- gDesiredDisplayConfigSpecsClassInfo.allowGroupSwitching =
- GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "allowGroupSwitching", "Z");
- gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMin =
- GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "primaryRefreshRateMin", "F");
- gDesiredDisplayConfigSpecsClassInfo.primaryRefreshRateMax =
- GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "primaryRefreshRateMax", "F");
- gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMin =
- GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "appRequestRefreshRateMin", "F");
- gDesiredDisplayConfigSpecsClassInfo.appRequestRefreshRateMax =
- GetFieldIDOrDie(env, desiredDisplayConfigSpecsClazz, "appRequestRefreshRateMax", "F");
+ jclass DesiredDisplayModeSpecsClazz =
+ FindClassOrDie(env, "android/view/SurfaceControl$DesiredDisplayModeSpecs");
+ gDesiredDisplayModeSpecsClassInfo.clazz = MakeGlobalRefOrDie(env, DesiredDisplayModeSpecsClazz);
+ gDesiredDisplayModeSpecsClassInfo.ctor =
+ GetMethodIDOrDie(env, gDesiredDisplayModeSpecsClassInfo.clazz, "<init>", "(IZFFFF)V");
+ gDesiredDisplayModeSpecsClassInfo.defaultMode =
+ GetFieldIDOrDie(env, DesiredDisplayModeSpecsClazz, "defaultMode", "I");
+ gDesiredDisplayModeSpecsClassInfo.allowGroupSwitching =
+ GetFieldIDOrDie(env, DesiredDisplayModeSpecsClazz, "allowGroupSwitching", "Z");
+ gDesiredDisplayModeSpecsClassInfo.primaryRefreshRateMin =
+ GetFieldIDOrDie(env, DesiredDisplayModeSpecsClazz, "primaryRefreshRateMin", "F");
+ gDesiredDisplayModeSpecsClassInfo.primaryRefreshRateMax =
+ GetFieldIDOrDie(env, DesiredDisplayModeSpecsClazz, "primaryRefreshRateMax", "F");
+ gDesiredDisplayModeSpecsClassInfo.appRequestRefreshRateMin =
+ GetFieldIDOrDie(env, DesiredDisplayModeSpecsClazz, "appRequestRefreshRateMin", "F");
+ gDesiredDisplayModeSpecsClassInfo.appRequestRefreshRateMax =
+ GetFieldIDOrDie(env, DesiredDisplayModeSpecsClazz, "appRequestRefreshRateMax", "F");
jclass captureArgsClazz = FindClassOrDie(env, "android/view/SurfaceControl$CaptureArgs");
gCaptureArgsClassInfo.pixelFormat = GetFieldIDOrDie(env, captureArgsClazz, "mPixelFormat", "I");
diff --git a/libs/hwui/tests/common/TestContext.cpp b/libs/hwui/tests/common/TestContext.cpp
index 06f158f..6a9a98d 100644
--- a/libs/hwui/tests/common/TestContext.cpp
+++ b/libs/hwui/tests/common/TestContext.cpp
@@ -40,9 +40,9 @@
return info;
}
-const DisplayConfig& getActiveDisplayConfig() {
- static DisplayConfig config = [] {
- DisplayConfig config;
+const ui::DisplayMode& getActiveDisplayMode() {
+ static ui::DisplayMode config = [] {
+ ui::DisplayMode config;
#if HWUI_NULL_GPU
config.resolution = ui::Size(1080, 1920);
config.xDpi = config.yDpi = 320.f;
@@ -51,7 +51,7 @@
const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken();
LOG_ALWAYS_FATAL_IF(!token, "%s: No internal display", __FUNCTION__);
- const status_t status = SurfaceComposerClient::getActiveDisplayConfig(token, &config);
+ const status_t status = SurfaceComposerClient::getActiveDisplayMode(token, &config);
LOG_ALWAYS_FATAL_IF(status, "%s: Failed to get active display config", __FUNCTION__);
#endif
return config;
diff --git a/libs/hwui/tests/common/TestContext.h b/libs/hwui/tests/common/TestContext.h
index a012ecb..7d2f6d8 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/DisplayConfig.h>
#include <ui/DisplayInfo.h>
+#include <ui/DisplayMode.h>
#include <utils/Looper.h>
#include <atomic>
@@ -37,10 +37,10 @@
namespace test {
const DisplayInfo& getDisplayInfo();
-const DisplayConfig& getActiveDisplayConfig();
+const ui::DisplayMode& getActiveDisplayMode();
inline const ui::Size& getActiveDisplayResolution() {
- return getActiveDisplayConfig().resolution;
+ return getActiveDisplayMode().resolution;
}
class TestContext {
diff --git a/services/core/java/com/android/server/display/LocalDisplayAdapter.java b/services/core/java/com/android/server/display/LocalDisplayAdapter.java
index 7e6a137..73ebb2e 100644
--- a/services/core/java/com/android/server/display/LocalDisplayAdapter.java
+++ b/services/core/java/com/android/server/display/LocalDisplayAdapter.java
@@ -105,17 +105,18 @@
Slog.w(TAG, "No valid info found for display device " + physicalDisplayId);
return;
}
- SurfaceControl.DisplayConfig[] configs = SurfaceControl.getDisplayConfigs(displayToken);
- if (configs == null) {
- // There are no valid configs for this device, so we can't use it
- Slog.w(TAG, "No valid configs found for display device " + physicalDisplayId);
+ SurfaceControl.DisplayMode[] displayModes =
+ SurfaceControl.getDisplayModes(displayToken);
+ if (displayModes == 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 activeConfig = SurfaceControl.getActiveConfig(displayToken);
- if (activeConfig < 0) {
- // There is no active config, and for now we don't have the
+ int activeDisplayMode = SurfaceControl.getActiveDisplayMode(displayToken);
+ if (activeDisplayMode < 0) {
+ // There is no active mode, and for now we don't have the
// policy to set one.
- Slog.w(TAG, "No active config found for display device " + physicalDisplayId);
+ Slog.w(TAG, "No active mode found for display device " + physicalDisplayId);
return;
}
int activeColorMode = SurfaceControl.getActiveColorMode(displayToken);
@@ -127,8 +128,8 @@
physicalDisplayId);
activeColorMode = Display.COLOR_MODE_INVALID;
}
- SurfaceControl.DesiredDisplayConfigSpecs configSpecs =
- SurfaceControl.getDesiredDisplayConfigSpecs(displayToken);
+ SurfaceControl.DesiredDisplayModeSpecs modeSpecsSpecs =
+ SurfaceControl.getDesiredDisplayModeSpecs(displayToken);
int[] colorModes = SurfaceControl.getDisplayColorModes(displayToken);
Display.HdrCapabilities hdrCapabilities =
SurfaceControl.getHdrCapabilities(displayToken);
@@ -136,13 +137,13 @@
if (device == null) {
// Display was added.
final boolean isDefaultDisplay = mDevices.size() == 0;
- device = new LocalDisplayDevice(displayToken, physicalDisplayId, info,
- configs, activeConfig, configSpecs, colorModes, activeColorMode,
+ device = new LocalDisplayDevice(displayToken, physicalDisplayId, info, displayModes,
+ activeDisplayMode, modeSpecsSpecs, colorModes, activeColorMode,
hdrCapabilities, isDefaultDisplay);
mDevices.put(physicalDisplayId, device);
sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED);
- } else if (device.updateDisplayPropertiesLocked(info, configs, activeConfig,
- configSpecs, colorModes, activeColorMode, hdrCapabilities)) {
+ } else if (device.updateDisplayPropertiesLocked(info, displayModes, activeDisplayMode,
+ modeSpecsSpecs, colorModes, activeColorMode, hdrCapabilities)) {
sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
}
} else {
@@ -189,12 +190,12 @@
// This is only set in the runnable returned from requestDisplayStateLocked.
private float mBrightnessState = PowerManager.BRIGHTNESS_INVALID_FLOAT;
private int mDefaultModeId;
- private int mDefaultConfigGroup;
+ private int mDefaultModeGroup;
private int mActiveModeId;
private DisplayModeDirector.DesiredDisplayModeSpecs mDisplayModeSpecs =
new DisplayModeDirector.DesiredDisplayModeSpecs();
private boolean mDisplayModeSpecsInvalid;
- private int mActiveConfigId;
+ private int mActiveDisplayModeId;
private int mActiveColorMode;
private Display.HdrCapabilities mHdrCapabilities;
private boolean mAllmSupported;
@@ -204,7 +205,7 @@
private boolean mSidekickActive;
private SidekickInternal mSidekickInternal;
private SurfaceControl.DisplayInfo mDisplayInfo;
- private SurfaceControl.DisplayConfig[] mDisplayConfigs;
+ private SurfaceControl.DisplayMode[] mDisplayModes;
private Spline mSystemBrightnessToNits;
private Spline mNitsToHalBrightness;
private DisplayDeviceConfig mDisplayDeviceConfig;
@@ -213,15 +214,15 @@
new DisplayEventReceiver.FrameRateOverride[0];
LocalDisplayDevice(IBinder displayToken, long physicalDisplayId,
- SurfaceControl.DisplayInfo info, SurfaceControl.DisplayConfig[] configs,
- int activeConfigId, SurfaceControl.DesiredDisplayConfigSpecs configSpecs,
+ SurfaceControl.DisplayInfo info, SurfaceControl.DisplayMode[] displayModes,
+ int activeDisplayModeId, SurfaceControl.DesiredDisplayModeSpecs modeSpecs,
int[] colorModes, int activeColorMode, Display.HdrCapabilities hdrCapabilities,
boolean isDefaultDisplay) {
super(LocalDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + physicalDisplayId);
mPhysicalDisplayId = physicalDisplayId;
mIsDefaultDisplay = isDefaultDisplay;
- updateDisplayPropertiesLocked(info, configs, activeConfigId, configSpecs, colorModes,
- activeColorMode, hdrCapabilities);
+ updateDisplayPropertiesLocked(info, displayModes, activeDisplayModeId, modeSpecs,
+ colorModes, activeColorMode, hdrCapabilities);
mSidekickInternal = LocalServices.getService(SidekickInternal.class);
mBacklightAdapter = new BacklightAdapter(displayToken, isDefaultDisplay);
mAllmSupported = SurfaceControl.getAutoLowLatencyModeSupport(displayToken);
@@ -241,10 +242,11 @@
* Returns true if there is a change.
**/
public boolean updateDisplayPropertiesLocked(SurfaceControl.DisplayInfo info,
- SurfaceControl.DisplayConfig[] configs,
- int activeConfigId, SurfaceControl.DesiredDisplayConfigSpecs configSpecs,
+ SurfaceControl.DisplayMode[] displayModes,
+ int activeDisplayModeId, SurfaceControl.DesiredDisplayModeSpecs modeSpecs,
int[] colorModes, int activeColorMode, Display.HdrCapabilities hdrCapabilities) {
- boolean changed = updateDisplayConfigsLocked(configs, activeConfigId, configSpecs);
+ boolean changed = updateDisplayModesLocked(
+ displayModes, activeDisplayModeId, modeSpecs);
changed |= updateDisplayInfo(info);
changed |= updateColorModesLocked(colorModes, activeColorMode);
changed |= updateHdrCapabilitiesLocked(hdrCapabilities);
@@ -255,35 +257,35 @@
return changed;
}
- public boolean updateDisplayConfigsLocked(
- SurfaceControl.DisplayConfig[] configs, int activeConfigId,
- SurfaceControl.DesiredDisplayConfigSpecs configSpecs) {
- mDisplayConfigs = Arrays.copyOf(configs, configs.length);
- mActiveConfigId = activeConfigId;
+ public boolean updateDisplayModesLocked(
+ SurfaceControl.DisplayMode[] displayModes, int activeDisplayModeId,
+ SurfaceControl.DesiredDisplayModeSpecs modeSpecs) {
+ mDisplayModes = Arrays.copyOf(displayModes, displayModes.length);
+ mActiveDisplayModeId = activeDisplayModeId;
// Build an updated list of all existing modes.
ArrayList<DisplayModeRecord> records = new ArrayList<>();
boolean modesAdded = false;
- for (int i = 0; i < configs.length; i++) {
- SurfaceControl.DisplayConfig config = configs[i];
+ for (int i = 0; i < displayModes.length; i++) {
+ SurfaceControl.DisplayMode mode = displayModes[i];
List<Float> alternativeRefreshRates = new ArrayList<>();
- for (int j = 0; j < configs.length; j++) {
- SurfaceControl.DisplayConfig other = configs[j];
- boolean isAlternative = j != i && other.width == config.width
- && other.height == config.height
- && other.refreshRate != config.refreshRate
- && other.configGroup == config.configGroup;
+ for (int j = 0; j < displayModes.length; j++) {
+ SurfaceControl.DisplayMode other = displayModes[j];
+ boolean isAlternative = j != i && other.width == mode.width
+ && other.height == mode.height
+ && other.refreshRate != mode.refreshRate
+ && other.group == mode.group;
if (isAlternative) {
- alternativeRefreshRates.add(configs[j].refreshRate);
+ alternativeRefreshRates.add(displayModes[j].refreshRate);
}
}
Collections.sort(alternativeRefreshRates);
// 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 DisplayConfigs that would generate the same Display.Mode.
+ // multiple DisplayModess that would generate the same Display.Mode.
boolean existingMode = false;
for (DisplayModeRecord record : records) {
- if (record.hasMatchingMode(config)
+ if (record.hasMatchingMode(mode)
&& refreshRatesEquals(alternativeRefreshRates,
record.mMode.getAlternativeRefreshRates())) {
existingMode = true;
@@ -296,13 +298,13 @@
// If we haven't already added a mode for this configuration to the new set of
// supported modes then check to see if we have one in the prior set of supported
// modes to reuse.
- DisplayModeRecord record = findDisplayModeRecord(config, alternativeRefreshRates);
+ DisplayModeRecord record = findDisplayModeRecord(mode, alternativeRefreshRates);
if (record == null) {
float[] alternativeRates = new float[alternativeRefreshRates.size()];
for (int j = 0; j < alternativeRates.length; j++) {
alternativeRates[j] = alternativeRefreshRates.get(j);
}
- record = new DisplayModeRecord(config, alternativeRates);
+ record = new DisplayModeRecord(mode, alternativeRates);
modesAdded = true;
}
records.add(record);
@@ -312,7 +314,7 @@
DisplayModeRecord activeRecord = null;
for (int i = 0; i < records.size(); i++) {
DisplayModeRecord record = records.get(i);
- if (record.hasMatchingMode(configs[activeConfigId])) {
+ if (record.hasMatchingMode(displayModes[activeDisplayModeId])) {
activeRecord = record;
break;
}
@@ -334,20 +336,20 @@
// Check whether surface flinger spontaneously changed display config specs out from
// under us. If so, schedule a traversal to reapply our display config specs.
if (mDisplayModeSpecs.baseModeId != NO_DISPLAY_MODE_ID) {
- int activeBaseMode = findMatchingModeIdLocked(configSpecs.defaultConfig);
- // If we can't map the defaultConfig index to a mode, then the physical display
- // configs must have changed, and the code below for handling changes to the
- // list of available modes will take care of updating display config specs.
+ int activeBaseMode = findMatchingModeIdLocked(modeSpecs.defaultMode);
+ // If we can't map the defaultMode index to a mode, then the physical display
+ // modes must have changed, and the code below for handling changes to the
+ // list of available modes will take care of updating display mode specs.
if (activeBaseMode != NO_DISPLAY_MODE_ID) {
if (mDisplayModeSpecs.baseModeId != activeBaseMode
|| mDisplayModeSpecs.primaryRefreshRateRange.min
- != configSpecs.primaryRefreshRateMin
+ != modeSpecs.primaryRefreshRateMin
|| mDisplayModeSpecs.primaryRefreshRateRange.max
- != configSpecs.primaryRefreshRateMax
+ != modeSpecs.primaryRefreshRateMax
|| mDisplayModeSpecs.appRequestRefreshRateRange.min
- != configSpecs.appRequestRefreshRateMin
+ != modeSpecs.appRequestRefreshRateMin
|| mDisplayModeSpecs.appRequestRefreshRateRange.max
- != configSpecs.appRequestRefreshRateMax) {
+ != modeSpecs.appRequestRefreshRateMax) {
mDisplayModeSpecsInvalid = true;
sendTraversalRequestLocked();
}
@@ -368,17 +370,17 @@
// For a new display, we need to initialize the default mode ID.
if (mDefaultModeId == NO_DISPLAY_MODE_ID) {
mDefaultModeId = activeRecord.mMode.getModeId();
- mDefaultConfigGroup = configs[activeConfigId].configGroup;
+ mDefaultModeGroup = displayModes[activeDisplayModeId].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();
- mDefaultConfigGroup = configs[activeConfigId].configGroup;
- } else if (findDisplayConfigIdLocked(mDefaultModeId, mDefaultConfigGroup) < 0) {
+ mDefaultModeGroup = displayModes[activeDisplayModeId].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();
- mDefaultConfigGroup = configs[activeConfigId].configGroup;
+ mDefaultModeGroup = displayModes[activeDisplayModeId].group;
}
// Determine whether the display mode specs' base mode is still there.
@@ -518,11 +520,11 @@
return true;
}
- private DisplayModeRecord findDisplayModeRecord(SurfaceControl.DisplayConfig config,
+ private DisplayModeRecord findDisplayModeRecord(SurfaceControl.DisplayMode mode,
List<Float> alternativeRefreshRates) {
for (int i = 0; i < mSupportedModes.size(); i++) {
DisplayModeRecord record = mSupportedModes.valueAt(i);
- if (record.hasMatchingMode(config)
+ if (record.hasMatchingMode(mode)
&& refreshRatesEquals(alternativeRefreshRates,
record.mMode.getAlternativeRefreshRates())) {
return record;
@@ -554,10 +556,10 @@
@Override
public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
if (mInfo == null) {
- SurfaceControl.DisplayConfig config = mDisplayConfigs[mActiveConfigId];
+ SurfaceControl.DisplayMode mode = mDisplayModes[mActiveDisplayModeId];
mInfo = new DisplayDeviceInfo();
- mInfo.width = config.width;
- mInfo.height = config.height;
+ mInfo.width = mode.width;
+ mInfo.height = mode.height;
mInfo.modeId = mActiveModeId;
mInfo.defaultModeId = mDefaultModeId;
mInfo.supportedModes = getDisplayModes(mSupportedModes);
@@ -570,16 +572,16 @@
mInfo.supportedColorModes[i] = mSupportedColorModes.get(i);
}
mInfo.hdrCapabilities = mHdrCapabilities;
- mInfo.appVsyncOffsetNanos = config.appVsyncOffsetNanos;
- mInfo.presentationDeadlineNanos = config.presentationDeadlineNanos;
+ mInfo.appVsyncOffsetNanos = mode.appVsyncOffsetNanos;
+ mInfo.presentationDeadlineNanos = mode.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 = config.xDpi;
- mInfo.yDpi = config.yDpi;
+ mInfo.xDpi = mode.xDpi;
+ mInfo.yDpi = mode.yDpi;
mInfo.deviceProductInfo = mDisplayInfo.deviceProductInfo;
// Assume that all built-in displays that have secure output (eg. HDCP) also
@@ -835,16 +837,16 @@
return;
}
- // Find the config Id based on the desired mode specs. In case there is more than one
- // config matching the mode spec, prefer the one that is in the default config group.
- // For now the default config group is taken from the active config when we got the
+ // Find the mode Id based on the desired mode specs. In case there is more than one
+ // mode matching the mode spec, prefer the one that is in the default mode group.
+ // For now the default config mode is taken from the active mode when we got the
// hotplug event for the display. In the future we might want to change the default
- // config based on vendor requirements.
- // Note: We prefer the default config group over the current one as this is the config
+ // mode based on vendor requirements.
+ // Note: We prefer the default mode group over the current one as this is the mode
// group the vendor prefers.
- int baseConfigId = findDisplayConfigIdLocked(displayModeSpecs.baseModeId,
- mDefaultConfigGroup);
- if (baseConfigId < 0) {
+ int baseModeId = findDisplayModeIdLocked(displayModeSpecs.baseModeId,
+ mDefaultModeGroup);
+ if (baseModeId < 0) {
// When a display is hotplugged, it's possible for a mode to be removed that was
// previously valid. Because of the way display changes are propagated through the
// framework, and the caching of the display mode specs in LogicalDisplay, it's
@@ -862,7 +864,7 @@
getHandler().sendMessage(PooledLambda.obtainMessage(
LocalDisplayDevice::setDesiredDisplayModeSpecsAsync, this,
getDisplayTokenLocked(),
- new SurfaceControl.DesiredDisplayConfigSpecs(baseConfigId,
+ new SurfaceControl.DesiredDisplayModeSpecs(baseModeId,
mDisplayModeSpecs.allowGroupSwitching,
mDisplayModeSpecs.primaryRefreshRateRange.min,
mDisplayModeSpecs.primaryRefreshRateRange.max,
@@ -872,13 +874,13 @@
}
private void setDesiredDisplayModeSpecsAsync(IBinder displayToken,
- SurfaceControl.DesiredDisplayConfigSpecs configSpecs) {
+ SurfaceControl.DesiredDisplayModeSpecs modeSpecs) {
// 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.setDesiredDisplayConfigSpecs(displayToken, configSpecs);
- final int activePhysIndex = SurfaceControl.getActiveConfig(displayToken);
+ SurfaceControl.setDesiredDisplayModeSpecs(displayToken, modeSpecs);
+ final int activeMode = SurfaceControl.getActiveDisplayMode(displayToken);
synchronized (getSyncRoot()) {
- if (updateActiveModeLocked(activePhysIndex)) {
+ if (updateActiveModeLocked(activeMode)) {
updateDeviceInfoLocked();
}
}
@@ -889,8 +891,8 @@
updateDeviceInfoLocked();
}
- public void onActiveDisplayConfigChangedLocked(int configId) {
- if (updateActiveModeLocked(configId)) {
+ public void onActiveDisplayModeChangedLocked(int modeId) {
+ if (updateActiveModeLocked(modeId)) {
updateDeviceInfoLocked();
}
}
@@ -902,15 +904,15 @@
}
}
- public boolean updateActiveModeLocked(int activeConfigId) {
- if (mActiveConfigId == activeConfigId) {
+ public boolean updateActiveModeLocked(int activeModeId) {
+ if (mActiveDisplayModeId == activeModeId) {
return false;
}
- mActiveConfigId = activeConfigId;
- mActiveModeId = findMatchingModeIdLocked(activeConfigId);
+ mActiveDisplayModeId = activeModeId;
+ mActiveModeId = findMatchingModeIdLocked(activeModeId);
if (mActiveModeId == NO_DISPLAY_MODE_ID) {
- Slog.w(TAG, "In unknown mode after setting allowed configs"
- + ", activeConfigId=" + mActiveConfigId);
+ Slog.w(TAG, "In unknown mode after setting allowed modes"
+ + ", activeModeId=" + mActiveDisplayModeId);
}
return true;
}
@@ -990,7 +992,7 @@
pw.println("mPhysicalDisplayId=" + mPhysicalDisplayId);
pw.println("mDisplayModeSpecs={" + mDisplayModeSpecs + "}");
pw.println("mDisplayModeSpecsInvalid=" + mDisplayModeSpecsInvalid);
- pw.println("mActiveConfigId=" + mActiveConfigId);
+ pw.println("mActiveDisplayModeId=" + mActiveDisplayModeId);
pw.println("mActiveModeId=" + mActiveModeId);
pw.println("mActiveColorMode=" + mActiveColorMode);
pw.println("mDefaultModeId=" + mDefaultModeId);
@@ -1002,9 +1004,9 @@
pw.println("mGameContentTypeSupported=" + mGameContentTypeSupported);
pw.println("mGameContentTypeRequested=" + mGameContentTypeRequested);
pw.println("mDisplayInfo=" + mDisplayInfo);
- pw.println("mDisplayConfigs=");
- for (int i = 0; i < mDisplayConfigs.length; i++) {
- pw.println(" " + mDisplayConfigs[i]);
+ pw.println("mDisplayModes=");
+ for (int i = 0; i < mDisplayModes.length; i++) {
+ pw.println(" " + mDisplayModes[i]);
}
pw.println("mSupportedModes=");
for (int i = 0; i < mSupportedModes.size(); i++) {
@@ -1014,37 +1016,37 @@
pw.println("mDisplayDeviceConfig=" + mDisplayDeviceConfig);
}
- private int findDisplayConfigIdLocked(int modeId, int configGroup) {
- int matchingConfigId = SurfaceControl.DisplayConfig.INVALID_DISPLAY_CONFIG_ID;
+ private int findDisplayModeIdLocked(int modeId, int modeGroup) {
+ int matchingModeId = SurfaceControl.DisplayMode.INVALID_DISPLAY_MODE_ID;
DisplayModeRecord record = mSupportedModes.get(modeId);
if (record != null) {
- for (int i = 0; i < mDisplayConfigs.length; i++) {
- SurfaceControl.DisplayConfig config = mDisplayConfigs[i];
- if (record.hasMatchingMode(config)) {
- if (matchingConfigId
- == SurfaceControl.DisplayConfig.INVALID_DISPLAY_CONFIG_ID) {
- matchingConfigId = i;
+ for (int i = 0; i < mDisplayModes.length; i++) {
+ SurfaceControl.DisplayMode mode = mDisplayModes[i];
+ if (record.hasMatchingMode(mode)) {
+ if (matchingModeId
+ == SurfaceControl.DisplayMode.INVALID_DISPLAY_MODE_ID) {
+ matchingModeId = i;
}
- // Prefer to return a config that matches the configGroup
- if (config.configGroup == configGroup) {
+ // Prefer to return a mode that matches the modeGroup
+ if (mode.group == modeGroup) {
return i;
}
}
}
}
- return matchingConfigId;
+ return matchingModeId;
}
- private int findMatchingModeIdLocked(int configId) {
- if (configId < 0 || configId >= mDisplayConfigs.length) {
- Slog.e(TAG, "Invalid display config index " + configId);
+ private int findMatchingModeIdLocked(int modeId) {
+ if (modeId < 0 || modeId >= mDisplayModes.length) {
+ Slog.e(TAG, "Invalid display config index " + modeId);
return NO_DISPLAY_MODE_ID;
}
- SurfaceControl.DisplayConfig config = mDisplayConfigs[configId];
+ SurfaceControl.DisplayMode mode = mDisplayModes[modeId];
for (int i = 0; i < mSupportedModes.size(); i++) {
DisplayModeRecord record = mSupportedModes.valueAt(i);
- if (record.hasMatchingMode(config)) {
+ if (record.hasMatchingMode(mode)) {
return record.mMode.getModeId();
}
}
@@ -1091,30 +1093,29 @@
}
/**
- * Keeps track of a display configuration.
+ * Keeps track of a display mode.
*/
private static final class DisplayModeRecord {
public final Display.Mode mMode;
- DisplayModeRecord(SurfaceControl.DisplayConfig config,
+ DisplayModeRecord(SurfaceControl.DisplayMode mode,
float[] alternativeRefreshRates) {
- mMode = createMode(config.width, config.height, config.refreshRate,
+ mMode = createMode(mode.width, mode.height, mode.refreshRate,
alternativeRefreshRates);
}
/**
- * Returns whether the mode generated by the given DisplayConfig matches the mode
+ * Returns whether the mode generated by the given DisplayModes matches the mode
* contained by the record modulo mode ID.
*
- * Note that this doesn't necessarily mean that the DisplayConfigs are identical, just
+ * Note that this doesn't necessarily mean that the DisplayModes are identical, just
* that they generate identical modes.
*/
- public boolean hasMatchingMode(SurfaceControl.DisplayConfig config) {
- int modeRefreshRate = Float.floatToIntBits(mMode.getRefreshRate());
- int configRefreshRate = Float.floatToIntBits(config.refreshRate);
- return mMode.getPhysicalWidth() == config.width
- && mMode.getPhysicalHeight() == config.height
- && modeRefreshRate == configRefreshRate;
+ public boolean hasMatchingMode(SurfaceControl.DisplayMode mode) {
+ return mMode.getPhysicalWidth() == mode.width
+ && mMode.getPhysicalHeight() == mode.height
+ && Float.floatToIntBits(mMode.getRefreshRate())
+ == Float.floatToIntBits(mode.refreshRate);
}
public String toString() {
@@ -1131,7 +1132,7 @@
public interface DisplayEventListener {
void onHotplug(long timestampNanos, long physicalDisplayId, boolean connected);
- void onConfigChanged(long timestampNanos, long physicalDisplayId, int configId);
+ void onModeChanged(long timestampNanos, long physicalDisplayId, int modeId);
void onFrameRateOverridesChanged(long timestampNanos, long physicalDisplayId,
DisplayEventReceiver.FrameRateOverride[] overrides);
@@ -1141,7 +1142,7 @@
private final DisplayEventListener mListener;
ProxyDisplayEventReceiver(Looper looper, DisplayEventListener listener) {
super(looper, VSYNC_SOURCE_APP,
- EVENT_REGISTRATION_CONFIG_CHANGED_FLAG
+ EVENT_REGISTRATION_MODE_CHANGED_FLAG
| EVENT_REGISTRATION_FRAME_RATE_OVERRIDE_FLAG);
mListener = listener;
}
@@ -1152,8 +1153,8 @@
}
@Override
- public void onConfigChanged(long timestampNanos, long physicalDisplayId, int configId) {
- mListener.onConfigChanged(timestampNanos, physicalDisplayId, configId);
+ public void onModeChanged(long timestampNanos, long physicalDisplayId, int modeId) {
+ mListener.onModeChanged(timestampNanos, physicalDisplayId, modeId);
}
@Override
@@ -1176,23 +1177,23 @@
}
@Override
- public void onConfigChanged(long timestampNanos, long physicalDisplayId, int configId) {
+ public void onModeChanged(long timestampNanos, long physicalDisplayId, int modeId) {
if (DEBUG) {
- Slog.d(TAG, "onConfigChanged("
+ Slog.d(TAG, "onModeChanged("
+ "timestampNanos=" + timestampNanos
+ ", physicalDisplayId=" + physicalDisplayId
- + ", configId=" + configId + ")");
+ + ", modeId=" + modeId + ")");
}
synchronized (getSyncRoot()) {
LocalDisplayDevice device = mDevices.get(physicalDisplayId);
if (device == null) {
if (DEBUG) {
- Slog.d(TAG, "Received config change for unhandled physical display: "
+ Slog.d(TAG, "Received mode change for unhandled physical display: "
+ "physicalDisplayId=" + physicalDisplayId);
}
return;
}
- device.onActiveDisplayConfigChangedLocked(configId);
+ device.onActiveDisplayModeChangedLocked(modeId);
}
}
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 af4130d..ca53492 100644
--- a/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java
@@ -200,12 +200,12 @@
}
private static class DisplayModeWrapper {
- public SurfaceControl.DisplayConfig config;
+ public SurfaceControl.DisplayMode mode;
public float[] expectedAlternativeRefreshRates;
- DisplayModeWrapper(SurfaceControl.DisplayConfig config,
+ DisplayModeWrapper(SurfaceControl.DisplayMode mode,
float[] expectedAlternativeRefreshRates) {
- this.config = config;
+ this.mode = mode;
this.expectedAlternativeRefreshRates = expectedAlternativeRefreshRates;
}
}
@@ -215,14 +215,15 @@
* <code>expectedAlternativeRefreshRates</code> are present for each of the
* <code>modes</code>.
*/
- private void testAlternativeRefreshRatesCommon(FakeDisplay display, DisplayModeWrapper[] modes)
+ private void testAlternativeRefreshRatesCommon(FakeDisplay display,
+ DisplayModeWrapper[] wrappedModes)
throws InterruptedException {
// Update the display.
- SurfaceControl.DisplayConfig[] configs = new SurfaceControl.DisplayConfig[modes.length];
- for (int i = 0; i < modes.length; i++) {
- configs[i] = modes[i].config;
+ SurfaceControl.DisplayMode[] modes = new SurfaceControl.DisplayMode[wrappedModes.length];
+ for (int i = 0; i < wrappedModes.length; i++) {
+ modes[i] = wrappedModes[i].mode;
}
- display.configs = configs;
+ display.modes = modes;
setUpDisplay(display);
mInjector.getTransmitter().sendHotplug(display, /* connected */ true);
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
@@ -233,11 +234,11 @@
mListener.changedDisplays.get(mListener.changedDisplays.size() - 1);
displayDevice.applyPendingDisplayDeviceInfoChangesLocked();
Display.Mode[] supportedModes = displayDevice.getDisplayDeviceInfoLocked().supportedModes;
- assertThat(supportedModes.length).isEqualTo(configs.length);
+ assertThat(supportedModes.length).isEqualTo(modes.length);
- for (int i = 0; i < modes.length; i++) {
- assertModeIsSupported(supportedModes, configs[i],
- modes[i].expectedAlternativeRefreshRates);
+ for (int i = 0; i < wrappedModes.length; i++) {
+ assertModeIsSupported(supportedModes, modes[i],
+ wrappedModes[i].expectedAlternativeRefreshRates);
}
}
@@ -251,56 +252,56 @@
testAlternativeRefreshRatesCommon(display, new DisplayModeWrapper[] {
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 60f, 0), new float[]{24f, 50f}),
+ createFakeDisplayMode(1920, 1080, 60f, 0), new float[]{24f, 50f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 50f, 0), new float[]{24f, 60f}),
+ createFakeDisplayMode(1920, 1080, 50f, 0), new float[]{24f, 60f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 24f, 0), new float[]{50f, 60f}),
+ createFakeDisplayMode(1920, 1080, 24f, 0), new float[]{50f, 60f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 60f, 0), new float[]{24f, 50f}),
+ createFakeDisplayMode(3840, 2160, 60f, 0), new float[]{24f, 50f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 50f, 0), new float[]{24f, 60f}),
+ createFakeDisplayMode(3840, 2160, 50f, 0), new float[]{24f, 60f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 24f, 0), new float[]{50f, 60f}),
+ createFakeDisplayMode(3840, 2160, 24f, 0), new float[]{50f, 60f}),
});
testAlternativeRefreshRatesCommon(display, new DisplayModeWrapper[] {
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 60f, 0), new float[]{50f}),
+ createFakeDisplayMode(1920, 1080, 60f, 0), new float[]{50f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 50f, 0), new float[]{60f}),
+ createFakeDisplayMode(1920, 1080, 50f, 0), new float[]{60f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 24f, 1), new float[0]),
+ createFakeDisplayMode(1920, 1080, 24f, 1), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 60f, 2), new float[0]),
+ createFakeDisplayMode(3840, 2160, 60f, 2), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 50f, 3), new float[]{24f}),
+ createFakeDisplayMode(3840, 2160, 50f, 3), new float[]{24f}),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 24f, 3), new float[]{50f}),
+ createFakeDisplayMode(3840, 2160, 24f, 3), new float[]{50f}),
});
testAlternativeRefreshRatesCommon(display, new DisplayModeWrapper[] {
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 60f, 0), new float[0]),
+ createFakeDisplayMode(1920, 1080, 60f, 0), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 50f, 1), new float[0]),
+ createFakeDisplayMode(1920, 1080, 50f, 1), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(1920, 1080, 24f, 2), new float[0]),
+ createFakeDisplayMode(1920, 1080, 24f, 2), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 60f, 3), new float[0]),
+ createFakeDisplayMode(3840, 2160, 60f, 3), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 50f, 4), new float[0]),
+ createFakeDisplayMode(3840, 2160, 50f, 4), new float[0]),
new DisplayModeWrapper(
- createFakeDisplayConfig(3840, 2160, 24f, 5), new float[0]),
+ createFakeDisplayMode(3840, 2160, 24f, 5), new float[0]),
});
}
@Test
public void testAfterDisplayChange_DisplayModesAreUpdated() throws Exception {
- SurfaceControl.DisplayConfig displayConfig = createFakeDisplayConfig(1920, 1080, 60f);
- SurfaceControl.DisplayConfig[] configs =
- new SurfaceControl.DisplayConfig[]{displayConfig};
- FakeDisplay display = new FakeDisplay(PORT_A, configs, 0);
+ SurfaceControl.DisplayMode displayMode = createFakeDisplayMode(1920, 1080, 60f);
+ SurfaceControl.DisplayMode[] modes =
+ new SurfaceControl.DisplayMode[]{displayMode};
+ FakeDisplay display = new FakeDisplay(PORT_A, modes, 0);
setUpDisplay(display);
updateAvailableDisplays();
mAdapter.registerLocked();
@@ -312,29 +313,29 @@
DisplayDeviceInfo displayDeviceInfo = mListener.addedDisplays.get(
0).getDisplayDeviceInfoLocked();
- assertThat(displayDeviceInfo.supportedModes.length).isEqualTo(configs.length);
- assertModeIsSupported(displayDeviceInfo.supportedModes, displayConfig);
+ assertThat(displayDeviceInfo.supportedModes.length).isEqualTo(modes.length);
+ assertModeIsSupported(displayDeviceInfo.supportedModes, displayMode);
Display.Mode defaultMode = getModeById(displayDeviceInfo, displayDeviceInfo.defaultModeId);
- assertThat(defaultMode.matches(displayConfig.width, displayConfig.height,
- displayConfig.refreshRate)).isTrue();
+ assertThat(defaultMode.matches(displayMode.width, displayMode.height,
+ displayMode.refreshRate)).isTrue();
Display.Mode activeMode = getModeById(displayDeviceInfo, displayDeviceInfo.modeId);
- assertThat(activeMode.matches(displayConfig.width, displayConfig.height,
- displayConfig.refreshRate)).isTrue();
+ assertThat(activeMode.matches(displayMode.width, displayMode.height,
+ displayMode.refreshRate)).isTrue();
// Change the display
- SurfaceControl.DisplayConfig addedDisplayInfo = createFakeDisplayConfig(3840, 2160,
+ SurfaceControl.DisplayMode addedDisplayInfo = createFakeDisplayMode(3840, 2160,
60f);
- configs = new SurfaceControl.DisplayConfig[]{displayConfig, addedDisplayInfo};
- display.configs = configs;
- display.activeConfig = 1;
+ modes = new SurfaceControl.DisplayMode[]{displayMode, addedDisplayInfo};
+ display.modes = modes;
+ display.activeMode = 1;
setUpDisplay(display);
mInjector.getTransmitter().sendHotplug(display, /* connected */ true);
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
- assertThat(SurfaceControl.getActiveConfig(display.token)).isEqualTo(1);
- assertThat(SurfaceControl.getDisplayConfigs(display.token).length).isEqualTo(2);
+ 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);
@@ -343,8 +344,8 @@
displayDevice.applyPendingDisplayDeviceInfoChangesLocked();
displayDeviceInfo = displayDevice.getDisplayDeviceInfoLocked();
- assertThat(displayDeviceInfo.supportedModes.length).isEqualTo(configs.length);
- assertModeIsSupported(displayDeviceInfo.supportedModes, displayConfig);
+ assertThat(displayDeviceInfo.supportedModes.length).isEqualTo(modes.length);
+ assertModeIsSupported(displayDeviceInfo.supportedModes, displayMode);
assertModeIsSupported(displayDeviceInfo.supportedModes, addedDisplayInfo);
activeMode = getModeById(displayDeviceInfo, displayDeviceInfo.modeId);
@@ -358,11 +359,11 @@
@Test
public void testAfterDisplayChange_ActiveModeIsUpdated() throws Exception {
- SurfaceControl.DisplayConfig[] configs = new SurfaceControl.DisplayConfig[]{
- createFakeDisplayConfig(1920, 1080, 60f),
- createFakeDisplayConfig(1920, 1080, 50f)
+ SurfaceControl.DisplayMode[] modes = new SurfaceControl.DisplayMode[]{
+ createFakeDisplayMode(1920, 1080, 60f),
+ createFakeDisplayMode(1920, 1080, 50f)
};
- FakeDisplay display = new FakeDisplay(PORT_A, configs, /* activeConfig */ 0);
+ FakeDisplay display = new FakeDisplay(PORT_A, modes, /* activeMode */ 0);
setUpDisplay(display);
updateAvailableDisplays();
mAdapter.registerLocked();
@@ -378,12 +379,12 @@
assertThat(activeMode.matches(1920, 1080, 60f)).isTrue();
// Change the display
- display.activeConfig = 1;
+ display.activeMode = 1;
setUpDisplay(display);
mInjector.getTransmitter().sendHotplug(display, /* connected */ true);
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
- assertThat(SurfaceControl.getActiveConfig(display.token)).isEqualTo(1);
+ assertThat(SurfaceControl.getActiveDisplayMode(display.token)).isEqualTo(1);
assertThat(mListener.addedDisplays.size()).isEqualTo(1);
assertThat(mListener.changedDisplays.size()).isEqualTo(1);
@@ -471,14 +472,14 @@
}
@Test
- public void testDisplayChange_withStaleDesiredDisplayConfigSpecs() throws Exception {
- SurfaceControl.DisplayConfig[] configs = new SurfaceControl.DisplayConfig[]{
- createFakeDisplayConfig(1920, 1080, 60f),
- createFakeDisplayConfig(1920, 1080, 50f)
+ public void testDisplayChange_withStaleDesiredDisplayModeSpecs() throws Exception {
+ SurfaceControl.DisplayMode[] modes = new SurfaceControl.DisplayMode[]{
+ createFakeDisplayMode(1920, 1080, 60f),
+ createFakeDisplayMode(1920, 1080, 50f)
};
- final int activeConfig = 0;
- FakeDisplay display = new FakeDisplay(PORT_A, configs, activeConfig);
- display.desiredDisplayConfigSpecs.defaultConfig = 1;
+ final int activeMode = 0;
+ FakeDisplay display = new FakeDisplay(PORT_A, modes, activeMode);
+ display.desiredDisplayModeSpecs.defaultMode = 1;
setUpDisplay(display);
updateAvailableDisplays();
@@ -486,12 +487,12 @@
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
// Change the display
- display.configs = new SurfaceControl.DisplayConfig[]{
- createFakeDisplayConfig(1920, 1080, 60f)
+ display.modes = new SurfaceControl.DisplayMode[]{
+ createFakeDisplayMode(1920, 1080, 60f)
};
- // SurfaceFlinger can return a stale defaultConfig. Make sure this doesn't
+ // SurfaceFlinger can return a stale defaultMode. Make sure this doesn't
// trigger ArrayOutOfBoundsException.
- display.desiredDisplayConfigSpecs.defaultConfig = 1;
+ display.desiredDisplayModeSpecs.defaultMode = 1;
setUpDisplay(display);
updateAvailableDisplays();
@@ -562,13 +563,13 @@
}
private void assertModeIsSupported(Display.Mode[] supportedModes,
- SurfaceControl.DisplayConfig mode) {
+ SurfaceControl.DisplayMode mode) {
assertThat(Arrays.stream(supportedModes).anyMatch(
x -> x.matches(mode.width, mode.height, mode.refreshRate))).isTrue();
}
private void assertModeIsSupported(Display.Mode[] supportedModes,
- SurfaceControl.DisplayConfig mode, float[] alternativeRefreshRates) {
+ SurfaceControl.DisplayMode mode, float[] alternativeRefreshRates) {
float[] sortedAlternativeRates =
Arrays.copyOf(alternativeRefreshRates, alternativeRefreshRates.length);
Arrays.sort(sortedAlternativeRates);
@@ -588,13 +589,13 @@
public final DisplayAddress.Physical address;
public final IBinder token = new Binder();
public final SurfaceControl.DisplayInfo info;
- public SurfaceControl.DisplayConfig[] configs;
- public int activeConfig;
+ 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 SurfaceControl.DesiredDisplayConfigSpecs desiredDisplayConfigSpecs =
- new SurfaceControl.DesiredDisplayConfigSpecs(/* defaultConfig */ 0,
+ public SurfaceControl.DesiredDisplayModeSpecs desiredDisplayModeSpecs =
+ new SurfaceControl.DesiredDisplayModeSpecs(/* defaultMode */ 0,
/* allowGroupSwitching */ false,
/* primaryRefreshRateMin */ 60.f,
/* primaryRefreshRateMax */ 60.f,
@@ -604,17 +605,17 @@
private FakeDisplay(int port) {
this.address = createDisplayAddress(port);
this.info = createFakeDisplayInfo();
- this.configs = new SurfaceControl.DisplayConfig[]{
- createFakeDisplayConfig(800, 600, 60f)
+ this.modes = new SurfaceControl.DisplayMode[]{
+ createFakeDisplayMode(800, 600, 60f)
};
- this.activeConfig = 0;
+ this.activeMode = 0;
}
- private FakeDisplay(int port, SurfaceControl.DisplayConfig[] configs, int activeConfig) {
+ private FakeDisplay(int port, SurfaceControl.DisplayMode[] modes, int activeMode) {
this.address = createDisplayAddress(port);
this.info = createFakeDisplayInfo();
- this.configs = configs;
- this.activeConfig = activeConfig;
+ this.modes = modes;
+ this.activeMode = activeMode;
}
}
@@ -623,16 +624,16 @@
doReturn(display.token).when(() ->
SurfaceControl.getPhysicalDisplayToken(display.address.getPhysicalDisplayId()));
doReturn(display.info).when(() -> SurfaceControl.getDisplayInfo(display.token));
- doReturn(display.configs).when(
- () -> SurfaceControl.getDisplayConfigs(display.token));
- doReturn(display.activeConfig).when(() -> SurfaceControl.getActiveConfig(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.desiredDisplayConfigSpecs)
- .when(() -> SurfaceControl.getDesiredDisplayConfigSpecs(display.token));
+ doReturn(display.desiredDisplayModeSpecs)
+ .when(() -> SurfaceControl.getDesiredDisplayModeSpecs(display.token));
}
private void updateAvailableDisplays() {
@@ -655,21 +656,21 @@
return info;
}
- private static SurfaceControl.DisplayConfig createFakeDisplayConfig(int width, int height,
+ private static SurfaceControl.DisplayMode createFakeDisplayMode(int width, int height,
float refreshRate) {
- return createFakeDisplayConfig(width, height, refreshRate, 0);
+ return createFakeDisplayMode(width, height, refreshRate, 0);
}
- private static SurfaceControl.DisplayConfig createFakeDisplayConfig(int width, int height,
- float refreshRate, int configGroup) {
- final SurfaceControl.DisplayConfig config = new SurfaceControl.DisplayConfig();
- config.width = width;
- config.height = height;
- config.refreshRate = refreshRate;
- config.xDpi = 100;
- config.yDpi = 100;
- config.configGroup = configGroup;
- return config;
+ private static SurfaceControl.DisplayMode createFakeDisplayMode(int width, int height,
+ float refreshRate, int group) {
+ final SurfaceControl.DisplayMode mode = new SurfaceControl.DisplayMode();
+ mode.width = width;
+ mode.height = height;
+ mode.refreshRate = refreshRate;
+ mode.xDpi = 100;
+ mode.yDpi = 100;
+ mode.group = group;
+ return mode;
}
private static void waitForHandlerToComplete(Handler handler, long waitTimeMs)