mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
graphics: clarify importBuffer and passthrough HALs
A buffer handle recieved from a HAL is by definition raw and needs to be imported. But because of passthrough HALs, such a raw handle may have been imported already. Explicitly specify that an implementation must accept such a raw handle. Bug: 37540361 Test: boots on angler, ryu and marlin Change-Id: I5ecf526e59b27cc4a8f7f5d5ec27477da0946ece
This commit is contained in:
@@ -103,7 +103,7 @@ b3aac6c3817f039964fcd62268274b3039e17bd7d0d5b40b4d1d1c7b19a1f866 android.hardwar
|
||||
b19d00eb8a8b3b0034a0321f22e8f32162bf4c2aebbce6da22c025f56e459ea2 android.hardware.graphics.composer@2.1::IComposerCallback
|
||||
e992684e690dfe67a8cbeab5005bfa3fa9c2bf3d4b0b75657fb1f0c2d5dd2bae android.hardware.graphics.composer@2.1::IComposerClient
|
||||
1c98c2f5154345312ec054871792a2982ec5f3e2bc2abfb61a10c0b517978e20 android.hardware.graphics.composer@2.1::types
|
||||
04fbe91f2a860d463fa6287fbcfa05a8cc4f17848cabcd2aa9eef0f2aa1fedc0 android.hardware.graphics.mapper@2.0::IMapper
|
||||
a695898589e1ef15b2b2510f11edd6aafac9918d9cf8d74b4b6143b309dee542 android.hardware.graphics.mapper@2.0::IMapper
|
||||
28507d385a3dd224bf3c32f1bfd9f96092c4701b9c1cc66caa578fc3efc97877 android.hardware.graphics.mapper@2.0::types
|
||||
91e2ba3805c923f01fc1231ec9ff838942aee3346f2d7614ecc0caeadbe57ed4 android.hardware.health@1.0::IHealth
|
||||
1275aa2e8732909101b26aec49ed2285489e89d97b8610a8908b7868e35a3cc5 android.hardware.health@1.0::types
|
||||
|
||||
@@ -85,10 +85,11 @@ interface IMapper {
|
||||
* Imports a raw buffer handle to create an imported buffer handle for use
|
||||
* with the rest of the mapper or with other in-process libraries.
|
||||
*
|
||||
* A buffer handle is considered raw when it is cloned or when it is
|
||||
* received from another HAL or another process. A raw buffer handle must
|
||||
* not be used to access the underlying graphics buffer. It must be
|
||||
* imported to create an imported handle first.
|
||||
* A buffer handle is considered raw when it is cloned (e.g., with
|
||||
* native_handle_clone) from another buffer handle locally, or when it is
|
||||
* received from another HAL server/client or another process. A raw
|
||||
* buffer handle must not be used to access the underlying graphics
|
||||
* buffer. It must be imported to create an imported handle first.
|
||||
*
|
||||
* This function must at least validate the raw handle before creating the
|
||||
* imported handle. It must also support importing the same raw handle
|
||||
@@ -96,6 +97,12 @@ interface IMapper {
|
||||
* must be considered valid everywhere in the process, including in
|
||||
* another instance of the mapper.
|
||||
*
|
||||
* Because of passthrough HALs, a raw buffer handle received from a HAL
|
||||
* may actually have been imported in the process. importBuffer must treat
|
||||
* such a handle as if it is raw and must not return BAD_BUFFER. The
|
||||
* returned handle is independent from the input handle as usual, and
|
||||
* freeBuffer must be called on it when it is no longer needed.
|
||||
*
|
||||
* @param rawHandle is the raw buffer handle to import.
|
||||
* @return error is NONE upon success. Otherwise,
|
||||
* BAD_BUFFER when the raw handle is invalid.
|
||||
|
||||
@@ -125,11 +125,8 @@ Return<void> GrallocMapper::createDescriptor(
|
||||
|
||||
Return<void> GrallocMapper::importBuffer(const hidl_handle& rawHandle,
|
||||
importBuffer_cb hidl_cb) {
|
||||
// importing an already imported handle rather than a raw handle
|
||||
if (gRegisteredHandles->get(rawHandle.getNativeHandle())) {
|
||||
hidl_cb(Error::BAD_BUFFER, nullptr);
|
||||
return Void();
|
||||
}
|
||||
// because of passthrough HALs, we must not generate an error when
|
||||
// rawHandle has been imported
|
||||
|
||||
if (!rawHandle.getNativeHandle()) {
|
||||
hidl_cb(Error::BAD_BUFFER, nullptr);
|
||||
|
||||
@@ -216,18 +216,6 @@ TEST_F(GraphicsMapperHidlTest, ImportBufferNegative) {
|
||||
<< "importBuffer with invalid handle did not fail with BAD_BUFFER";
|
||||
});
|
||||
native_handle_delete(invalidHandle);
|
||||
|
||||
const native_handle_t* importedHandle;
|
||||
ASSERT_NO_FATAL_FAILURE(importedHandle =
|
||||
mGralloc->allocate(mDummyDescriptorInfo, true));
|
||||
mGralloc->getMapper()->importBuffer(
|
||||
importedHandle, [&](const auto& tmpError, const auto&) {
|
||||
EXPECT_EQ(Error::BAD_BUFFER, tmpError)
|
||||
<< "importBuffer with an "
|
||||
"already imported handle did "
|
||||
"not fail with BAD_BUFFER";
|
||||
});
|
||||
mGralloc->freeBuffer(importedHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user