Do not crash on invalid dataspace
Prior logic caused device to crash when setting the dataspace for a layer to hdr on a non-hdr device. Update to log the failure and perform a no-op to match framework APIs. Bug: 140029823 Test: build, boot, CtsViewTestCases:android.view.cts.ASurfaceControlTest Change-Id: I9baf88a6d787e043b440ad4c2ebeb4c7a1fd90a2
This commit is contained in:
@@ -100,7 +100,11 @@ static bool isDataSpaceValid(const sp<SurfaceControl>& surfaceControl, ADataSpac
|
||||
return getWideColorSupport(surfaceControl);
|
||||
// These data space need HDR support.
|
||||
case HAL_DATASPACE_BT2020_PQ:
|
||||
return getHdrSupport(surfaceControl);
|
||||
if (!getHdrSupport(surfaceControl)) {
|
||||
ALOGE("Invalid dataspace - device does not support hdr");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -458,10 +462,11 @@ void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* aSurfaceTransac
|
||||
CHECK_NOT_NULL(aSurfaceControl);
|
||||
|
||||
sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);
|
||||
LOG_ALWAYS_FATAL_IF(!isDataSpaceValid(surfaceControl, aDataSpace), "invalid dataspace");
|
||||
|
||||
if (!isDataSpaceValid(surfaceControl, aDataSpace)) {
|
||||
ALOGE("Failed to set buffer dataspace - invalid dataspace");
|
||||
return;
|
||||
}
|
||||
Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
|
||||
|
||||
transaction->setDataspace(surfaceControl, static_cast<ui::Dataspace>(aDataSpace));
|
||||
}
|
||||
|
||||
@@ -527,7 +532,10 @@ void ASurfaceTransaction_setColor(ASurfaceTransaction* aSurfaceTransaction,
|
||||
CHECK_NOT_NULL(aSurfaceControl);
|
||||
|
||||
sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl);
|
||||
LOG_ALWAYS_FATAL_IF(!isDataSpaceValid(surfaceControl, dataspace), "invalid dataspace");
|
||||
if (!isDataSpaceValid(surfaceControl, dataspace)) {
|
||||
ALOGE("Failed to set buffer dataspace - invalid dataspace");
|
||||
return;
|
||||
}
|
||||
Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction);
|
||||
|
||||
half3 color;
|
||||
|
||||
Reference in New Issue
Block a user