diff options
| author | 2023-09-08 18:08:46 +0000 | |
|---|---|---|
| committer | 2023-09-08 18:08:46 +0000 | |
| commit | d8606ef3ffe63071bed7d3a063be5317064f69c5 (patch) | |
| tree | aabbca359881c5fc0b62d749830006ae8d60e074 /libs | |
| parent | 8efc78d40ae2aee672ddea78561c8d1cf9881e3f (diff) | |
| parent | 2bce819db77c091ba7a4c7df307e7f003d807f98 (diff) | |
Merge "Protect AHardwareBuffer API calls with __builtin_available" into main am: 2bce819db7
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2730939
Change-Id: I827423ff44b97d145eed8ec87abcfeffd164f295
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/nativewindow/include/android/hardware_buffer_aidl.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libs/nativewindow/include/android/hardware_buffer_aidl.h b/libs/nativewindow/include/android/hardware_buffer_aidl.h index e269f0dddf..3f77c78096 100644 --- a/libs/nativewindow/include/android/hardware_buffer_aidl.h +++ b/libs/nativewindow/include/android/hardware_buffer_aidl.h @@ -95,14 +95,22 @@ public: binder_status_t readFromParcel(const AParcel* _Nonnull parcel) { reset(); - return AHardwareBuffer_readFromParcel(parcel, &mBuffer); + if (__builtin_available(android __ANDROID_API_U__, *)) { + return AHardwareBuffer_readFromParcel(parcel, &mBuffer); + } else { + return STATUS_FAILED_TRANSACTION; + } } binder_status_t writeToParcel(AParcel* _Nonnull parcel) const { if (!mBuffer) { return STATUS_BAD_VALUE; } - return AHardwareBuffer_writeToParcel(mBuffer, parcel); + if (__builtin_available(android __ANDROID_API_U__, *)) { + return AHardwareBuffer_writeToParcel(mBuffer, parcel); + } else { + return STATUS_FAILED_TRANSACTION; + } } /** @@ -150,9 +158,13 @@ public: if (!mBuffer) { return "<HardwareBuffer: Invalid>"; } - uint64_t id = 0; - AHardwareBuffer_getId(mBuffer, &id); - return "<HardwareBuffer " + std::to_string(id) + ">"; + if (__builtin_available(android __ANDROID_API_S__, *)) { + uint64_t id = 0; + AHardwareBuffer_getId(mBuffer, &id); + return "<HardwareBuffer " + std::to_string(id) + ">"; + } else { + return "<HardwareBuffer (unknown)>"; + } } private: |