Merge "libjpegrecoverymap: XMP updates."
diff --git a/include/android/surface_control.h b/include/android/surface_control.h
index f76e73d..79c59f2 100644
--- a/include/android/surface_control.h
+++ b/include/android/surface_control.h
@@ -521,6 +521,45 @@
__INTRODUCED_IN(29);
/**
+ * Sets the desired extended range brightness for the layer. This only applies for layers whose
+ * dataspace has RANGE_EXTENDED set on it.
+ *
+ * @param surface_control The layer whose extended range brightness is being specified
+ * @param currentBufferRatio The current hdr/sdr ratio of the current buffer as represented as
+ * peakHdrBrightnessInNits / targetSdrWhitePointInNits. For example if the
+ * buffer was rendered with a target SDR whitepoint of 100nits and a max
+ * display brightness of 200nits, this should be set to 2.0f.
+ *
+ * Default value is 1.0f.
+ *
+ * Transfer functions that encode their own brightness ranges, such as
+ * HLG or PQ, should also set this to 1.0f and instead communicate
+ * extended content brightness information via metadata such as CTA861_3
+ * or SMPTE2086.
+ *
+ * Must be finite && >= 1.0f
+ *
+ * @param desiredRatio The desired hdr/sdr ratio as represented as peakHdrBrightnessInNits /
+ * targetSdrWhitePointInNits. This can be used to communicate the max desired
+ * brightness range. This is similar to the "max luminance" value in other
+ * HDR metadata formats, but represented as a ratio of the target SDR whitepoint
+ * to the max display brightness. The system may not be able to, or may choose
+ * not to, deliver the requested range.
+ *
+ * If unspecified, the system will attempt to provide the best range it can
+ * for the given ambient conditions & device state. However, voluntarily
+ * reducing the requested range can help improve battery life as well as can
+ * improve quality by ensuring greater bit depth is allocated to the luminance
+ * range in use.
+ *
+ * Must be finite && >= 1.0f
+ */
+void ASurfaceTransaction_setExtendedRangeBrightness(ASurfaceTransaction* transaction,
+ ASurfaceControl* surface_control,
+ float currentBufferRatio,
+ float desiredRatio) __INTRODUCED_IN(__ANDROID_API_U__);
+
+/**
* Same as ASurfaceTransaction_setFrameRateWithChangeStrategy(transaction, surface_control,
* frameRate, compatibility, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS).
*
diff --git a/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp b/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
index 3ebbed6..42d226b 100644
--- a/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
+++ b/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
@@ -57,6 +57,15 @@
// could not be started.
[[nodiscard]] ARpcServer* ARpcServer_newUnixDomainBootstrap(AIBinder* service, int bootstrapFd);
+// Starts an RPC server on a given IP address+port and a given IBinder object.
+// Returns an opaque handle to the running server instance, or null if the server
+// could not be started.
+// Does not take ownership of `service`.
+// Returns an opaque handle to the running service instance, or null if the server
+// could not be started.
+[[nodiscard]] ARpcServer* ARpcServer_newInet(AIBinder* service, const char* address,
+ unsigned int port);
+
// Sets the list of supported file descriptor transport modes of this RPC server.
void ARpcServer_setSupportedFileDescriptorTransportModes(
ARpcServer* handle,
@@ -98,6 +107,10 @@
AIBinder* ARpcSession_setupUnixDomainBootstrapClient(ARpcSession* session,
int bootstrapFd);
+// Connects to an RPC server over an INET socket at a given IP address on a given port.
+// Returns the root Binder object of the server.
+AIBinder* ARpcSession_setupInet(ARpcSession* session, const char* address, unsigned int port);
+
// Connects to an RPC server with preconnected file descriptors.
//
// requestFd should connect to the server and return a valid file descriptor, or
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp
index e7943dd..daff8c1 100644
--- a/libs/binder/libbinder_rpc_unstable.cpp
+++ b/libs/binder/libbinder_rpc_unstable.cpp
@@ -145,6 +145,17 @@
return createObjectHandle<ARpcServer>(server);
}
+ARpcServer* ARpcServer_newInet(AIBinder* service, const char* address, unsigned int port) {
+ auto server = RpcServer::make();
+ if (status_t status = server->setupInetServer(address, port, nullptr); status != OK) {
+ LOG(ERROR) << "Failed to set up inet RPC server with address " << address << " and port "
+ << port << " error: " << statusToString(status).c_str();
+ return nullptr;
+ }
+ server->setRootObject(AIBinder_toPlatformBinder(service));
+ return createObjectHandle<ARpcServer>(server);
+}
+
void ARpcServer_setSupportedFileDescriptorTransportModes(
ARpcServer* handle, const ARpcSession_FileDescriptorTransportMode modes[],
size_t modes_len) {
@@ -222,6 +233,16 @@
return AIBinder_fromPlatformBinder(session->getRootObject());
}
+AIBinder* ARpcSession_setupInet(ARpcSession* handle, const char* address, unsigned int port) {
+ auto session = handleToStrongPointer<RpcSession>(handle);
+ if (status_t status = session->setupInetClient(address, port); status != OK) {
+ LOG(ERROR) << "Failed to set up inet RPC client with address " << address << " and port "
+ << port << " error: " << statusToString(status).c_str();
+ return nullptr;
+ }
+ return AIBinder_fromPlatformBinder(session->getRootObject());
+}
+
AIBinder* ARpcSession_setupPreconnectedClient(ARpcSession* handle, int (*requestFd)(void* param),
void* param) {
auto session = handleToStrongPointer<RpcSession>(handle);
diff --git a/libs/binder/libbinder_rpc_unstable.map.txt b/libs/binder/libbinder_rpc_unstable.map.txt
index 1bc2416..63679c2 100644
--- a/libs/binder/libbinder_rpc_unstable.map.txt
+++ b/libs/binder/libbinder_rpc_unstable.map.txt
@@ -2,6 +2,7 @@
global:
ARpcServer_free;
ARpcServer_join;
+ ARpcServer_newInet;
ARpcServer_newInitUnixDomain;
ARpcServer_newVsock;
ARpcServer_shutdown;
diff --git a/libs/binder/rust/rpcbinder/src/server.rs b/libs/binder/rust/rpcbinder/src/server.rs
index 761b306..c87876a 100644
--- a/libs/binder/rust/rpcbinder/src/server.rs
+++ b/libs/binder/rust/rpcbinder/src/server.rs
@@ -102,6 +102,29 @@
}
}
+ /// Creates a binder RPC server, serving the supplied binder service implementation on the given
+ /// IP address and port.
+ pub fn new_inet(mut service: SpIBinder, address: &str, port: u32) -> Result<RpcServer, Error> {
+ let address = match CString::new(address) {
+ Ok(s) => s,
+ Err(e) => {
+ log::error!("Cannot convert {} to CString. Error: {:?}", address, e);
+ return Err(Error::from(ErrorKind::InvalidInput));
+ }
+ };
+ let service = service.as_native_mut();
+
+ // SAFETY: Service ownership is transferring to the server and won't be valid afterward.
+ // Plus the binder objects are threadsafe.
+ unsafe {
+ Self::checked_from_ptr(binder_rpc_unstable_bindgen::ARpcServer_newInet(
+ service,
+ address.as_ptr(),
+ port,
+ ))
+ }
+ }
+
unsafe fn checked_from_ptr(ptr: *mut ARpcServer) -> Result<RpcServer, Error> {
if ptr.is_null() {
return Err(Error::new(ErrorKind::Other, "Failed to start server"));
diff --git a/libs/binder/rust/rpcbinder/src/session.rs b/libs/binder/rust/rpcbinder/src/session.rs
index 62fedb1..0b517cf 100644
--- a/libs/binder/rust/rpcbinder/src/session.rs
+++ b/libs/binder/rust/rpcbinder/src/session.rs
@@ -144,6 +144,32 @@
Self::get_interface(service)
}
+ /// Connects to an RPC Binder server over inet socket at the given address and port.
+ pub fn setup_inet_client<T: FromIBinder + ?Sized>(
+ &self,
+ address: &str,
+ port: u32,
+ ) -> Result<Strong<T>, StatusCode> {
+ let address = match CString::new(address) {
+ Ok(s) => s,
+ Err(e) => {
+ log::error!("Cannot convert {} to CString. Error: {:?}", address, e);
+ return Err(StatusCode::BAD_VALUE);
+ }
+ };
+
+ // SAFETY: AIBinder returned by ARpcSession_setupInet has correct reference
+ // count, and the ownership can safely be taken by new_spibinder.
+ let service = unsafe {
+ new_spibinder(binder_rpc_unstable_bindgen::ARpcSession_setupInet(
+ self.as_ptr(),
+ address.as_ptr(),
+ port,
+ ))
+ };
+ Self::get_interface(service)
+ }
+
/// Connects to an RPC Binder server, using the given callback to get (and
/// take ownership of) file descriptors already connected to it.
pub fn setup_preconnected_client<T: FromIBinder + ?Sized>(
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 4596c8a..c508917 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -2657,9 +2657,11 @@
}
status_t SurfaceComposerClient::setHdrConversionStrategy(
- gui::HdrConversionStrategy hdrConversionStrategy) {
- binder::Status status = ComposerServiceAIDL::getComposerService()->setHdrConversionStrategy(
- hdrConversionStrategy);
+ gui::HdrConversionStrategy hdrConversionStrategy, ui::Hdr* outPreferredHdrOutputType) {
+ int hdrType;
+ binder::Status status = ComposerServiceAIDL::getComposerService()
+ ->setHdrConversionStrategy(hdrConversionStrategy, &hdrType);
+ *outPreferredHdrOutputType = static_cast<ui::Hdr>(hdrType);
return statusTFromBinderStatus(status);
}
diff --git a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
index 9812142..aa58e2e 100644
--- a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
+++ b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
@@ -191,10 +191,12 @@
/**
* Sets the HDR conversion strategy of the device.
+ * Returns the preferred HDR output type of the device, in case when HdrConversionStrategy has
+ * autoAllowedHdrTypes set. Returns Hdr::INVALID in other cases.
*
* Requires the ACCESS_SURFACE_FLINGER permission.
*/
- void setHdrConversionStrategy(in HdrConversionStrategy hdrConversionStrategy);
+ int setHdrConversionStrategy(in HdrConversionStrategy hdrConversionStrategy);
/**
* Gets whether HDR output conversion operations are supported on the device.
diff --git a/libs/gui/fuzzer/libgui_fuzzer_utils.h b/libs/gui/fuzzer/libgui_fuzzer_utils.h
index f01c2a9..8c003d8 100644
--- a/libs/gui/fuzzer/libgui_fuzzer_utils.h
+++ b/libs/gui/fuzzer/libgui_fuzzer_utils.h
@@ -93,8 +93,8 @@
MOCK_METHOD(binder::Status, getBootDisplayModeSupport, (bool*), (override));
MOCK_METHOD(binder::Status, getHdrConversionCapabilities,
(std::vector<gui::HdrConversionCapability>*), (override));
- MOCK_METHOD(binder::Status, setHdrConversionStrategy, (const gui::HdrConversionStrategy&),
- (override));
+ MOCK_METHOD(binder::Status, setHdrConversionStrategy,
+ (const gui::HdrConversionStrategy&, int32_t*), (override));
MOCK_METHOD(binder::Status, getHdrOutputConversionSupport, (bool*), (override));
MOCK_METHOD(binder::Status, setAutoLowLatencyMode, (const sp<IBinder>&, bool), (override));
MOCK_METHOD(binder::Status, setGameContentType, (const sp<IBinder>&, bool), (override));
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index fcf8d64..44e78ec 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -192,8 +192,10 @@
// Gets the HDR conversion capabilities of the device
static status_t getHdrConversionCapabilities(std::vector<gui::HdrConversionCapability>*);
- // Sets the HDR conversion strategy for the device
- static status_t setHdrConversionStrategy(gui::HdrConversionStrategy hdrConversionStrategy);
+ // Sets the HDR conversion strategy for the device. in case when HdrConversionStrategy has
+ // autoAllowedHdrTypes set. Returns Hdr::INVALID in other cases.
+ static status_t setHdrConversionStrategy(gui::HdrConversionStrategy hdrConversionStrategy,
+ ui::Hdr* outPreferredHdrOutputType);
// Returns whether HDR conversion is supported by the device.
static status_t getHdrOutputConversionSupport(bool* isSupported);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index babc197..fccc408 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -827,7 +827,8 @@
}
binder::Status setHdrConversionStrategy(
- const gui::HdrConversionStrategy& /*hdrConversionStrategy*/) override {
+ const gui::HdrConversionStrategy& /*hdrConversionStrategy*/,
+ int32_t* /*outPreferredHdrOutputType*/) override {
return binder::Status::ok();
}
diff --git a/libs/jpegrecoverymap/jpegr.cpp b/libs/jpegrecoverymap/jpegr.cpp
index bd8874e..08be4be 100644
--- a/libs/jpegrecoverymap/jpegr.cpp
+++ b/libs/jpegrecoverymap/jpegr.cpp
@@ -27,7 +27,9 @@
#include <image_io/base/data_segment_data_source.h>
#include <utils/Log.h>
#include "SkColorSpace.h"
+#include "SkData.h"
#include "SkICC.h"
+#include "SkRefCnt.h"
#include <map>
#include <memory>
diff --git a/services/inputflinger/TEST_MAPPING b/services/inputflinger/TEST_MAPPING
index 2a3dba7..495334e 100644
--- a/services/inputflinger/TEST_MAPPING
+++ b/services/inputflinger/TEST_MAPPING
@@ -46,8 +46,11 @@
"include-filter": "android.view.cts.MotionEventTest",
"include-filter": "android.view.cts.PointerCaptureTest",
"include-filter": "android.view.cts.TooltipTest",
+ "include-filter": "android.view.cts.TouchDelegateTest",
"include-filter": "android.view.cts.VelocityTrackerTest",
- "include-filter": "android.view.cts.VerifyInputEventTest"
+ "include-filter": "android.view.cts.VerifyInputEventTest",
+ "include-filter": "android.view.cts.ViewTest",
+ "include-filter": "android.view.cts.ViewUnbufferedTest"
}
]
},
@@ -55,7 +58,8 @@
"name": "CtsWidgetTestCases",
"options": [
{
- "include-filter": "android.widget.cts.NumberPickerTest"
+ "include-filter": "android.widget.cts.NumberPickerTest",
+ "include-filter": "android.widget.cts.SeekBarTest"
}
]
},
@@ -138,8 +142,11 @@
"include-filter": "android.view.cts.MotionEventTest",
"include-filter": "android.view.cts.PointerCaptureTest",
"include-filter": "android.view.cts.TooltipTest",
+ "include-filter": "android.view.cts.TouchDelegateTest",
"include-filter": "android.view.cts.VelocityTrackerTest",
- "include-filter": "android.view.cts.VerifyInputEventTest"
+ "include-filter": "android.view.cts.VerifyInputEventTest",
+ "include-filter": "android.view.cts.ViewTest",
+ "include-filter": "android.view.cts.ViewUnbufferedTest"
}
]
},
@@ -147,7 +154,8 @@
"name": "CtsWidgetTestCases",
"options": [
{
- "include-filter": "android.widget.cts.NumberPickerTest"
+ "include-filter": "android.widget.cts.NumberPickerTest",
+ "include-filter": "android.widget.cts.SeekBarTest"
}
]
},
diff --git a/services/sensorservice/aidl/DirectReportChannel.cpp b/services/sensorservice/aidl/DirectReportChannel.cpp
index cab53c1..9ef4ca8 100644
--- a/services/sensorservice/aidl/DirectReportChannel.cpp
+++ b/services/sensorservice/aidl/DirectReportChannel.cpp
@@ -32,7 +32,7 @@
int32_t sensorHandle, ::aidl::android::hardware::sensors::ISensors::RateLevel rate,
int32_t* _aidl_return) {
int token = mManager.configureDirectChannel(mId, sensorHandle, static_cast<int>(rate));
- if (token <= 0) {
+ if (token < 0) {
return ndk::ScopedAStatus::fromServiceSpecificError(token);
}
*_aidl_return = token;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h
index 4777f13..a8322d8 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h
@@ -97,6 +97,8 @@
std::optional<std::chrono::steady_clock::time_point> scheduledFrameTime;
std::vector<BorderRenderInfo> borderInfoList;
+
+ bool hasTrustedPresentationListener = false;
};
} // namespace android::compositionengine
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
index 5bb2497..32684fc 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
@@ -212,6 +212,8 @@
float currentSdrHdrRatio = 1.f;
float desiredSdrHdrRatio = 1.f;
+ bool isInternalDisplayOverlay = false;
+
virtual ~LayerFECompositionState();
// Debugging
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
index 52ebd9e..a3d8639 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
@@ -153,6 +153,10 @@
Region aboveOpaqueLayers;
// The region of the output which should be considered dirty
Region dirtyRegion;
+ // The region of the output which is covered by layers, excluding display overlays. This
+ // only has a value if there's something needing it, like when a TrustedPresentationListener
+ // is set
+ std::optional<Region> aboveCoveredLayersExcludingOverlays;
};
virtual ~Output();
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h
index b86782f..7b0af3a 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h
@@ -63,9 +63,15 @@
// The portion of the layer that is not obscured and is also opaque
Region visibleNonTransparentRegion;
- // The portion of the layer that is obscured by opaque layers on top
+ // The portion of the layer that is obscured by all layers on top. This includes transparent and
+ // opaque.
Region coveredRegion;
+ // The portion of the layer that is obscured by all layers on top excluding display overlays.
+ // This only has a value if there's something needing it, like when a
+ // TrustedPresentationListener is set.
+ std::optional<Region> coveredRegionExcludingDisplayOverlays;
+
// The visibleRegion transformed to output space
Region outputSpaceVisibleRegion;
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 403385e..7d94316 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -31,6 +31,7 @@
#include <ftl/future.h>
#include <gui/TraceUtils.h>
+#include <optional>
#include <thread>
#include "renderengine/ExternalTexture.h"
@@ -480,6 +481,9 @@
// Process the layers to determine visibility and coverage
compositionengine::Output::CoverageState coverage{layerFESet};
+ coverage.aboveCoveredLayersExcludingOverlays = refreshArgs.hasTrustedPresentationListener
+ ? std::make_optional<Region>()
+ : std::nullopt;
collectVisibleLayers(refreshArgs, coverage);
// Compute the resulting coverage for this output, and store it for later
@@ -534,6 +538,9 @@
return;
}
+ bool computeAboveCoveredExcludingOverlays =
+ coverage.aboveCoveredLayersExcludingOverlays && !layerFEState->isInternalDisplayOverlay;
+
/*
* opaqueRegion: area of a surface that is fully opaque.
*/
@@ -575,6 +582,11 @@
*/
Region shadowRegion;
+ /**
+ * covered region above excluding internal display overlay layers
+ */
+ std::optional<Region> coveredRegionExcludingDisplayOverlays = std::nullopt;
+
const ui::Transform& tr = layerFEState->geomLayerTransform;
// Get the visible region
@@ -647,6 +659,12 @@
// Update accumAboveCoveredLayers for next (lower) layer
coverage.aboveCoveredLayers.orSelf(visibleRegion);
+ if (CC_UNLIKELY(computeAboveCoveredExcludingOverlays)) {
+ coveredRegionExcludingDisplayOverlays =
+ coverage.aboveCoveredLayersExcludingOverlays->intersect(visibleRegion);
+ coverage.aboveCoveredLayersExcludingOverlays->orSelf(visibleRegion);
+ }
+
// subtract the opaque region covered by the layers above us
visibleRegion.subtractSelf(coverage.aboveOpaqueLayers);
@@ -733,6 +751,10 @@
? outputState.transform.transform(
transparentRegion.intersect(outputState.layerStackSpace.getContent()))
: Region();
+ if (CC_UNLIKELY(computeAboveCoveredExcludingOverlays)) {
+ outputLayerState.coveredRegionExcludingDisplayOverlays =
+ std::move(coveredRegionExcludingDisplayOverlays);
+ }
}
void Output::setReleasedLayers(const compositionengine::CompositionRefreshArgs&) {
diff --git a/services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h b/services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h
index 933f616..8555fd6 100644
--- a/services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h
+++ b/services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h
@@ -115,8 +115,9 @@
MOCK_CONST_METHOD0(
getHdrConversionCapabilities,
std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>());
- MOCK_METHOD1(setHdrConversionStrategy,
- status_t(aidl::android::hardware::graphics::common::HdrConversionStrategy));
+ MOCK_METHOD2(setHdrConversionStrategy,
+ status_t(aidl::android::hardware::graphics::common::HdrConversionStrategy,
+ aidl::android::hardware::graphics::common::Hdr*));
MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
MOCK_METHOD(status_t, getSupportedContentTypes,
(PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override));
diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp
index ba9aed8..4194a7e 100644
--- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp
+++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp
@@ -1417,8 +1417,10 @@
return Error::NONE;
}
-Error AidlComposer::setHdrConversionStrategy(AidlHdrConversionStrategy hdrConversionStrategy) {
- const auto status = mAidlComposerClient->setHdrConversionStrategy(hdrConversionStrategy);
+Error AidlComposer::setHdrConversionStrategy(AidlHdrConversionStrategy hdrConversionStrategy,
+ Hdr* outPreferredHdrOutputType) {
+ const auto status = mAidlComposerClient->setHdrConversionStrategy(hdrConversionStrategy,
+ outPreferredHdrOutputType);
if (!status.isOk()) {
ALOGE("setHdrConversionStrategy failed %s", status.getDescription().c_str());
return static_cast<Error>(status.getServiceSpecificError());
diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h
index a5ddf74..d163ff2 100644
--- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h
+++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h
@@ -238,7 +238,7 @@
void onHotplugConnect(Display) override;
void onHotplugDisconnect(Display) override;
Error getHdrConversionCapabilities(std::vector<HdrConversionCapability>*) override;
- Error setHdrConversionStrategy(HdrConversionStrategy) override;
+ Error setHdrConversionStrategy(HdrConversionStrategy, Hdr*) override;
private:
// Many public functions above simply write a command into the command
diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.h b/services/surfaceflinger/DisplayHardware/ComposerHal.h
index 82b677e..9b9b7fd 100644
--- a/services/surfaceflinger/DisplayHardware/ComposerHal.h
+++ b/services/surfaceflinger/DisplayHardware/ComposerHal.h
@@ -293,7 +293,7 @@
virtual Error getHdrConversionCapabilities(
std::vector<::aidl::android::hardware::graphics::common::HdrConversionCapability>*) = 0;
virtual Error setHdrConversionStrategy(
- ::aidl::android::hardware::graphics::common::HdrConversionStrategy) = 0;
+ ::aidl::android::hardware::graphics::common::HdrConversionStrategy, Hdr*) = 0;
};
} // namespace Hwc2
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 6d94079..470bf76 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -796,10 +796,14 @@
return mHdrConversionCapabilities;
}
-status_t HWComposer::setHdrConversionStrategy(HdrConversionStrategy hdrConversionStrategy) {
- const auto error = mComposer->setHdrConversionStrategy(hdrConversionStrategy);
+status_t HWComposer::setHdrConversionStrategy(
+ HdrConversionStrategy hdrConversionStrategy,
+ aidl::android::hardware::graphics::common::Hdr* outPreferredHdrOutputType) {
+ const auto error =
+ mComposer->setHdrConversionStrategy(hdrConversionStrategy, outPreferredHdrOutputType);
if (error != hal::Error::NONE) {
ALOGE("Error in setting HDR conversion strategy %s", to_string(error).c_str());
+ return INVALID_OPERATION;
}
return NO_ERROR;
}
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index acebfb2..95568eb 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -44,6 +44,7 @@
#include "Hal.h"
#include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
+#include <aidl/android/hardware/graphics/common/Hdr.h>
#include <aidl/android/hardware/graphics/common/HdrConversionCapability.h>
#include <aidl/android/hardware/graphics/common/HdrConversionStrategy.h>
#include <aidl/android/hardware/graphics/composer3/Capability.h>
@@ -294,7 +295,8 @@
virtual std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>
getHdrConversionCapabilities() const = 0;
virtual status_t setHdrConversionStrategy(
- aidl::android::hardware::graphics::common::HdrConversionStrategy) = 0;
+ aidl::android::hardware::graphics::common::HdrConversionStrategy,
+ aidl::android::hardware::graphics::common::Hdr*) = 0;
};
static inline bool operator==(const android::HWComposer::DeviceRequestedChanges& lhs,
@@ -449,7 +451,8 @@
std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>
getHdrConversionCapabilities() const override;
status_t setHdrConversionStrategy(
- aidl::android::hardware::graphics::common::HdrConversionStrategy) override;
+ aidl::android::hardware::graphics::common::HdrConversionStrategy,
+ aidl::android::hardware::graphics::common::Hdr*) override;
// for debugging ----------------------------------------------------------
void dump(std::string& out) const override;
diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp
index 6fdb2d7..9bc62b6 100644
--- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp
+++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp
@@ -1354,7 +1354,7 @@
return Error::UNSUPPORTED;
}
-Error HidlComposer::setHdrConversionStrategy(HdrConversionStrategy) {
+Error HidlComposer::setHdrConversionStrategy(HdrConversionStrategy, Hdr*) {
return Error::UNSUPPORTED;
}
diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h
index 8280af2..2bab1fe 100644
--- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h
+++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h
@@ -346,8 +346,8 @@
Error getHdrConversionCapabilities(
std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>*)
override;
- Error setHdrConversionStrategy(
- aidl::android::hardware::graphics::common::HdrConversionStrategy) override;
+ Error setHdrConversionStrategy(aidl::android::hardware::graphics::common::HdrConversionStrategy,
+ Hdr*) override;
private:
class CommandWriter : public CommandWriterBase {
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 704f336..084d9b9 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -393,14 +393,22 @@
if (!leaveState) {
const auto outputLayer = findOutputLayerForDisplay(display);
- if (outputLayer != nullptr && snapshot != nullptr) {
- mLastComputedTrustedPresentationState =
- computeTrustedPresentationState(snapshot->geomLayerBounds,
- snapshot->sourceBounds(),
- outputLayer->getState().coveredRegion,
- snapshot->transformedBounds, snapshot->alpha,
- snapshot->geomLayerTransform,
- mTrustedPresentationThresholds);
+ if (outputLayer != nullptr) {
+ if (outputLayer->getState().coveredRegionExcludingDisplayOverlays) {
+ Region coveredRegion =
+ *outputLayer->getState().coveredRegionExcludingDisplayOverlays;
+ mLastComputedTrustedPresentationState =
+ computeTrustedPresentationState(snapshot->geomLayerBounds,
+ snapshot->sourceBounds(), coveredRegion,
+ snapshot->transformedBounds,
+ snapshot->alpha,
+ snapshot->geomLayerTransform,
+ mTrustedPresentationThresholds);
+ } else {
+ ALOGE("CoveredRegionExcludingDisplayOverlays was not set for %s. Don't compute "
+ "TrustedPresentationState",
+ getDebugName());
+ }
}
}
const bool newState = mLastComputedTrustedPresentationState;
@@ -457,10 +465,15 @@
float boundsOverSourceH = bounds.getHeight() / (float)sourceBounds.getHeight();
fractionRendered *= boundsOverSourceW * boundsOverSourceH;
- Rect coveredBounds = coveredRegion.bounds();
- fractionRendered *= (1 -
- ((coveredBounds.width() / (float)screenBounds.getWidth()) *
- coveredBounds.height() / (float)screenBounds.getHeight()));
+ Region tJunctionFreeRegion = Region::createTJunctionFreeRegion(coveredRegion);
+ // Compute the size of all the rects since they may be disconnected.
+ float coveredSize = 0;
+ for (auto rect = tJunctionFreeRegion.begin(); rect < tJunctionFreeRegion.end(); rect++) {
+ float size = rect->width() * rect->height();
+ coveredSize += size;
+ }
+
+ fractionRendered *= (1 - (coveredSize / (screenBounds.getWidth() * screenBounds.getHeight())));
if (fractionRendered < thresholds.minFractionRendered) {
return false;
@@ -3993,6 +4006,7 @@
snapshot->bufferSize = getBufferSize(mDrawingState);
snapshot->externalTexture = mBufferInfo.mBuffer;
snapshot->hasReadyFrame = hasReadyFrame();
+ snapshot->isInternalDisplayOverlay = isInternalDisplayOverlay();
preparePerFrameCompositionState();
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index b42576f..174749a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1580,7 +1580,8 @@
}
status_t SurfaceFlinger::setHdrConversionStrategy(
- const gui::HdrConversionStrategy& hdrConversionStrategy) {
+ const gui::HdrConversionStrategy& hdrConversionStrategy,
+ int32_t* outPreferredHdrOutputType) {
bool hdrOutputConversionSupport;
getHdrOutputConversionSupport(&hdrOutputConversionSupport);
if (hdrOutputConversionSupport == false) {
@@ -1592,11 +1593,16 @@
aidl::android::hardware::graphics::common::HdrConversionStrategy;
using GuiHdrConversionStrategyTag = gui::HdrConversionStrategy::Tag;
AidlHdrConversionStrategy aidlConversionStrategy;
+ status_t status;
+ aidl::android::hardware::graphics::common::Hdr aidlPreferredHdrOutputType;
switch (hdrConversionStrategy.getTag()) {
case GuiHdrConversionStrategyTag::passthrough: {
aidlConversionStrategy.set<AidlHdrConversionStrategy::Tag::passthrough>(
hdrConversionStrategy.get<GuiHdrConversionStrategyTag::passthrough>());
- return getHwComposer().setHdrConversionStrategy(aidlConversionStrategy);
+ status = getHwComposer().setHdrConversionStrategy(aidlConversionStrategy,
+ &aidlPreferredHdrOutputType);
+ *outPreferredHdrOutputType = static_cast<int32_t>(aidlPreferredHdrOutputType);
+ return status;
}
case GuiHdrConversionStrategyTag::autoAllowedHdrTypes: {
auto autoHdrTypes =
@@ -1609,7 +1615,10 @@
}
aidlConversionStrategy.set<AidlHdrConversionStrategy::Tag::autoAllowedHdrTypes>(
aidlAutoHdrTypes);
- return getHwComposer().setHdrConversionStrategy(aidlConversionStrategy);
+ status = getHwComposer().setHdrConversionStrategy(aidlConversionStrategy,
+ &aidlPreferredHdrOutputType);
+ *outPreferredHdrOutputType = static_cast<int32_t>(aidlPreferredHdrOutputType);
+ return status;
}
case GuiHdrConversionStrategyTag::forceHdrConversion: {
auto forceHdrConversion =
@@ -1618,7 +1627,10 @@
aidlConversionStrategy.set<AidlHdrConversionStrategy::Tag::forceHdrConversion>(
static_cast<aidl::android::hardware::graphics::common::Hdr>(
forceHdrConversion));
- return getHwComposer().setHdrConversionStrategy(aidlConversionStrategy);
+ status = getHwComposer().setHdrConversionStrategy(aidlConversionStrategy,
+ &aidlPreferredHdrOutputType);
+ *outPreferredHdrOutputType = static_cast<int32_t>(aidlPreferredHdrOutputType);
+ return status;
}
}
});
@@ -2517,6 +2529,7 @@
refreshArgs.previousPresentFence = mPreviousPresentFences[0].fenceTime;
refreshArgs.scheduledFrameTime = mScheduler->getScheduledFrameTime();
refreshArgs.expectedPresentTime = mExpectedPresentTime.ns();
+ refreshArgs.hasTrustedPresentationListener = mNumTrustedPresentationListeners > 0;
// Store the present time just before calling to the composition engine so we could notify
// the scheduler.
@@ -3131,24 +3144,11 @@
const auto [kernelIdleTimerController, idleTimerTimeoutMs] =
getKernelIdleTimerProperties(compositionDisplay->getId());
- const auto enableFrameRateOverride = [&] {
- using Config = scheduler::RefreshRateSelector::Config;
- if (!sysprop::enable_frame_rate_override(true)) {
- return Config::FrameRateOverride::Disabled;
- }
-
- if (sysprop::frame_rate_override_for_native_rates(false)) {
- return Config::FrameRateOverride::AppOverrideNativeRefreshRates;
- }
-
- if (!sysprop::frame_rate_override_global(true)) {
- return Config::FrameRateOverride::AppOverride;
- }
-
- return Config::FrameRateOverride::Enabled;
- }();
-
- scheduler::RefreshRateSelector::Config config =
+ using Config = scheduler::RefreshRateSelector::Config;
+ const auto enableFrameRateOverride = sysprop::enable_frame_rate_override(true)
+ ? Config::FrameRateOverride::Enabled
+ : Config::FrameRateOverride::Disabled;
+ Config config =
{.enableFrameRateOverride = enableFrameRateOverride,
.frameRateMultipleThreshold =
base::GetIntProperty("debug.sf.frame_rate_multiple_threshold", 0),
@@ -8163,10 +8163,12 @@
}
binder::Status SurfaceComposerAIDL::setHdrConversionStrategy(
- const gui::HdrConversionStrategy& hdrConversionStrategy) {
+ const gui::HdrConversionStrategy& hdrConversionStrategy,
+ int32_t* outPreferredHdrOutputType) {
status_t status = checkAccessPermission();
if (status == OK) {
- status = mFlinger->setHdrConversionStrategy(hdrConversionStrategy);
+ status = mFlinger->setHdrConversionStrategy(hdrConversionStrategy,
+ outPreferredHdrOutputType);
}
return binderStatusFromStatusT(status);
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index aded52a..6489398 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -558,7 +558,8 @@
status_t clearBootDisplayMode(const sp<IBinder>& displayToken);
status_t getHdrConversionCapabilities(
std::vector<gui::HdrConversionCapability>* hdrConversionCapaabilities) const;
- status_t setHdrConversionStrategy(const gui::HdrConversionStrategy& hdrConversionStrategy);
+ status_t setHdrConversionStrategy(const gui::HdrConversionStrategy& hdrConversionStrategy,
+ int32_t*);
status_t getHdrOutputConversionSupport(bool* outSupport) const;
void setAutoLowLatencyMode(const sp<IBinder>& displayToken, bool on);
void setGameContentType(const sp<IBinder>& displayToken, bool on);
@@ -1461,8 +1462,8 @@
binder::Status getOverlaySupport(gui::OverlayProperties* outProperties) override;
binder::Status getHdrConversionCapabilities(
std::vector<gui::HdrConversionCapability>*) override;
- binder::Status setHdrConversionStrategy(
- const gui::HdrConversionStrategy& hdrConversionStrategy) override;
+ binder::Status setHdrConversionStrategy(const gui::HdrConversionStrategy& hdrConversionStrategy,
+ int32_t*) override;
binder::Status getHdrOutputConversionSupport(bool* outSupport) override;
binder::Status setAutoLowLatencyMode(const sp<IBinder>& display, bool on) override;
binder::Status setGameContentType(const sp<IBinder>& display, bool on) override;
diff --git a/services/surfaceflinger/SurfaceFlingerProperties.cpp b/services/surfaceflinger/SurfaceFlingerProperties.cpp
index 5b73030..20fa091 100644
--- a/services/surfaceflinger/SurfaceFlingerProperties.cpp
+++ b/services/surfaceflinger/SurfaceFlingerProperties.cpp
@@ -367,14 +367,6 @@
return SurfaceFlingerProperties::enable_frame_rate_override().value_or(defaultValue);
}
-bool frame_rate_override_for_native_rates(bool defaultValue) {
- return SurfaceFlingerProperties::frame_rate_override_for_native_rates().value_or(defaultValue);
-}
-
-bool frame_rate_override_global(bool defaultValue) {
- return SurfaceFlingerProperties::frame_rate_override_global().value_or(defaultValue);
-}
-
bool enable_layer_caching(bool defaultValue) {
return SurfaceFlingerProperties::enable_layer_caching().value_or(defaultValue);
}
diff --git a/services/surfaceflinger/SurfaceFlingerProperties.h b/services/surfaceflinger/SurfaceFlingerProperties.h
index 09629cf..080feee 100644
--- a/services/surfaceflinger/SurfaceFlingerProperties.h
+++ b/services/surfaceflinger/SurfaceFlingerProperties.h
@@ -96,10 +96,6 @@
bool enable_frame_rate_override(bool defaultValue);
-bool frame_rate_override_for_native_rates(bool defaultValue);
-
-bool frame_rate_override_global(bool defaultValue);
-
bool enable_layer_caching(bool defaultValue);
bool enable_sdr_dimming(bool defaultValue);
diff --git a/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop b/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
index 8540c3d..bcbe21a 100644
--- a/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
+++ b/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop
@@ -445,28 +445,6 @@
prop_name: "ro.surface_flinger.enable_frame_rate_override"
}
-# Limits the frame rate override feature (enable_frame_rate_override) to override the refresh rate
-# to native display refresh rates only. Before introducing this flag, native display refresh rates
-# was the default behaviour. With this flag we can control which behaviour we want explicitly.
-# This flag is introduced as a fail-safe mechanism and planned to be defaulted to false.
-prop {
- api_name: "frame_rate_override_for_native_rates"
- type: Boolean
- scope: Public
- access: Readonly
- prop_name: "ro.surface_flinger.frame_rate_override_for_native_rates"
-}
-
-# Enables the frame rate override feature (enable_frame_rate_override) to
-# override the frame rate globally instead of only for individual apps.
-prop {
- api_name: "frame_rate_override_global"
- type: Boolean
- scope: Public
- access: Readonly
- prop_name: "ro.surface_flinger.frame_rate_override_global"
-}
-
# Enables Layer Caching
prop {
api_name: "enable_layer_caching"
diff --git a/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-current.txt b/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-current.txt
index 9338133..348a462 100644
--- a/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-current.txt
+++ b/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-current.txt
@@ -61,14 +61,6 @@
prop_name: "ro.surface_flinger.force_hwc_copy_for_virtual_displays"
}
prop {
- api_name: "frame_rate_override_for_native_rates"
- prop_name: "ro.surface_flinger.frame_rate_override_for_native_rates"
- }
- prop {
- api_name: "frame_rate_override_global"
- prop_name: "ro.surface_flinger.frame_rate_override_global"
- }
- prop {
api_name: "has_HDR_display"
prop_name: "ro.surface_flinger.has_HDR_display"
}
diff --git a/services/surfaceflinger/tests/LayerTrustedPresentationListener_test.cpp b/services/surfaceflinger/tests/LayerTrustedPresentationListener_test.cpp
index a843fd1..2be8d3b 100644
--- a/services/surfaceflinger/tests/LayerTrustedPresentationListener_test.cpp
+++ b/services/surfaceflinger/tests/LayerTrustedPresentationListener_test.cpp
@@ -238,4 +238,50 @@
EXPECT_TRUE(pch.awaitCallback());
}
+TEST_F(LayerTrustedPresentationListenerTest, obscuring_with_display_overlay) {
+ auto otherLayer = makeLayer();
+ t.show(otherLayer)
+ .setPosition(otherLayer, 100, 100)
+ .setLayer(otherLayer, INT32_MAX)
+ .setFlags(otherLayer, layer_state_t::eLayerSkipScreenshot,
+ layer_state_t::eLayerSkipScreenshot)
+ .setLayer(mainLayer, INT32_MAX - 1)
+ .show(mainLayer)
+ .setPosition(mainLayer, 100, 100)
+ .setTrustedPresentationCallback(
+ mainLayer,
+ [&](void* context, bool state) {
+ PresentationCallbackHelper* helper = (PresentationCallbackHelper*)context;
+ helper->callbackArrived(state);
+ },
+ thresholds, &pch, mCallback)
+ .apply();
+ EXPECT_TRUE(pch.awaitCallback());
+}
+
+TEST_F(LayerTrustedPresentationListenerTest, obscuring_with_non_overlapping_bounds) {
+ thresholds.minFractionRendered = 0.5;
+ auto otherLayer1 = makeLayer();
+ auto otherLayer2 = makeLayer();
+ t.show(otherLayer1)
+ .show(otherLayer2)
+ .setPosition(otherLayer1, 100, 25)
+ .setLayer(otherLayer1, INT32_MAX)
+ .setPosition(otherLayer2, 100, 175)
+ .setLayer(otherLayer2, INT32_MAX)
+ .setLayer(mainLayer, INT32_MAX - 1)
+ .show(mainLayer)
+ .setPosition(mainLayer, 100, 100)
+ .setTrustedPresentationCallback(
+ mainLayer,
+ [&](void* context, bool state) {
+ PresentationCallbackHelper* helper = (PresentationCallbackHelper*)context;
+ helper->callbackArrived(state);
+ },
+ thresholds, &pch, mCallback)
+ .apply();
+
+ EXPECT_TRUE(pch.awaitCallback());
+}
+
} // namespace android
diff --git a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h
index 5e29fe7..f28b8d8 100644
--- a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h
+++ b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h
@@ -148,8 +148,9 @@
MOCK_METHOD1(getHdrConversionCapabilities,
Error(std::vector<
aidl::android::hardware::graphics::common::HdrConversionCapability>*));
- MOCK_METHOD1(setHdrConversionStrategy,
- Error(aidl::android::hardware::graphics::common::HdrConversionStrategy));
+ MOCK_METHOD2(setHdrConversionStrategy,
+ Error(aidl::android::hardware::graphics::common::HdrConversionStrategy,
+ aidl::android::hardware::graphics::common::Hdr*));
MOCK_METHOD2(getSupportedContentTypes,
V2_4::Error(Display, std::vector<IComposerClient::ContentType>*));
MOCK_METHOD2(setContentType, V2_4::Error(Display, IComposerClient::ContentType));