Update native getDisplayDecorationSupport API
I27f119f927b23052c5fd8f068cbca75338fe7b91 adds new HAL APIs which
provide more detailed info regarding DISPLAY_DECORATION support. Call
the new API and plumb it up to SurfaceComposerClient.
Remove reference to old DisplayCapability.DISPLAY_DECORATION.
Bug: 216644902
Test: manual
Change-Id: I961051c0a660b596039ac04b546040764ee20d34
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index e17b2c8..13c3dfd 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -339,6 +339,7 @@
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.common@1.2",
+ "android.hardware.graphics.common-V3-ndk",
"android.hidl.token@1.0-utils",
"libbase",
"libcutils",
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index fb9ed22..75c5e26 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -42,6 +42,8 @@
// ---------------------------------------------------------------------------
+using namespace aidl::android::hardware::graphics;
+
namespace android {
using gui::IDisplayEventConnection;
@@ -1201,8 +1203,9 @@
return NO_ERROR;
}
- status_t getDisplayDecorationSupport(const sp<IBinder>& displayToken,
- bool* outSupport) const override {
+ status_t getDisplayDecorationSupport(
+ const sp<IBinder>& displayToken,
+ std::optional<common::DisplayDecorationSupport>* outSupport) const override {
Parcel data, reply;
status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
if (error != NO_ERROR) {
@@ -1225,7 +1228,26 @@
ALOGE("getDisplayDecorationSupport: failed to read support: %d", error);
return error;
}
- *outSupport = support;
+
+ if (support) {
+ int32_t format, alphaInterpretation;
+ error = reply.readInt32(&format);
+ if (error != NO_ERROR) {
+ ALOGE("getDisplayDecorationSupport: failed to read format: %d", error);
+ return error;
+ }
+ error = reply.readInt32(&alphaInterpretation);
+ if (error != NO_ERROR) {
+ ALOGE("getDisplayDecorationSupport: failed to read alphaInterpretation: %d", error);
+ return error;
+ }
+ outSupport->emplace();
+ outSupport->value().format = static_cast<common::PixelFormat>(format);
+ outSupport->value().alphaInterpretation =
+ static_cast<common::AlphaInterpretation>(alphaInterpretation);
+ } else {
+ outSupport->reset();
+ }
return NO_ERROR;
}
@@ -2164,14 +2186,18 @@
case GET_DISPLAY_DECORATION_SUPPORT: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
sp<IBinder> displayToken;
- status_t error = data.readNullableStrongBinder(&displayToken);
+ SAFE_PARCEL(data.readNullableStrongBinder, &displayToken);
+ std::optional<common::DisplayDecorationSupport> support;
+ auto error = getDisplayDecorationSupport(displayToken, &support);
if (error != NO_ERROR) {
- ALOGE("getDisplayDecorationSupport: failed to read display token: %d", error);
+ ALOGE("getDisplayDecorationSupport failed with error %d", error);
return error;
}
- bool support = false;
- error = getDisplayDecorationSupport(displayToken, &support);
- reply->writeBool(support);
+ reply->writeBool(support.has_value());
+ if (support) {
+ reply->writeInt32(static_cast<int32_t>(support.value().format));
+ reply->writeInt32(static_cast<int32_t>(support.value().alphaInterpretation));
+ }
return error;
}
case SET_FRAME_RATE: {
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 91b2fb1..ea73c6d 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -52,6 +52,7 @@
namespace android {
+using aidl::android::hardware::graphics::common::DisplayDecorationSupport;
using gui::FocusRequest;
using gui::IRegionSamplingListener;
using gui::WindowInfo;
@@ -2239,8 +2240,9 @@
lightRadius);
}
-bool SurfaceComposerClient::getDisplayDecorationSupport(const sp<IBinder>& displayToken) {
- bool support = false;
+std::optional<DisplayDecorationSupport> SurfaceComposerClient::getDisplayDecorationSupport(
+ const sp<IBinder>& displayToken) {
+ std::optional<DisplayDecorationSupport> support;
ComposerService::getComposerService()->getDisplayDecorationSupport(displayToken, &support);
return support;
}
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 90b2a0e..0a59f52 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -52,6 +52,8 @@
#include <unordered_set>
#include <vector>
+#include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
+
namespace android {
struct client_cache_t;
@@ -533,15 +535,17 @@
* displayToken
* The token of the display.
* outSupport
- * An output parameter for whether the display supports
+ * An output parameter for whether/how the display supports
* DISPLAY_DECORATION layers.
*
* Returns NO_ERROR upon success. Otherwise,
* NAME_NOT_FOUND if the display is invalid, or
* BAD_VALUE if the output parameter is invalid.
*/
- virtual status_t getDisplayDecorationSupport(const sp<IBinder>& displayToken,
- bool* outSupport) const = 0;
+ virtual status_t getDisplayDecorationSupport(
+ const sp<IBinder>& displayToken,
+ std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
+ outSupport) const = 0;
/*
* Sets the intended frame rate for a surface. See ANativeWindow_setFrameRate() for more info.
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 61eeab3..4bafa89 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -47,6 +47,8 @@
#include <gui/WindowInfosListenerReporter.h>
#include <math/vec3.h>
+#include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
+
namespace android {
class HdrCapabilities;
@@ -285,14 +287,16 @@
float lightPosY, float lightPosZ, float lightRadius);
/*
- * Returns whether a display supports DISPLAY_DECORATION layers.
+ * Returns whether and how a display supports DISPLAY_DECORATION layers.
*
* displayToken
* The token of the display.
*
- * Returns whether a display supports DISPLAY_DECORATION layers.
+ * Returns how a display supports DISPLAY_DECORATION layers, or nullopt if
+ * it does not.
*/
- static bool getDisplayDecorationSupport(const sp<IBinder>& displayToken);
+ static std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>
+ getDisplayDecorationSupport(const sp<IBinder>& displayToken);
// ------------------------------------------------------------------------
// surface creation / destruction
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 120ed48..6056280 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -47,6 +47,7 @@
// retrieve wide-color and hdr settings from configstore
using namespace android::hardware::configstore;
using namespace android::hardware::configstore::V1_0;
+using aidl::android::hardware::graphics::common::DisplayDecorationSupport;
using gui::IDisplayEventConnection;
using gui::IRegionSamplingListener;
using ui::ColorMode;
@@ -889,8 +890,9 @@
return NO_ERROR;
}
- status_t getDisplayDecorationSupport(const sp<IBinder>& /*displayToken*/,
- bool* /*outSupport*/) const override {
+ status_t getDisplayDecorationSupport(
+ const sp<IBinder>& /*displayToken*/,
+ std::optional<DisplayDecorationSupport>* /*outSupport*/) const override {
return NO_ERROR;
}