Skip to content

Commit 8e3e8ff

Browse files
authored
ndk/hardware_buffer: Add API-31 getId() function to HardwareBuffer (#428)
This is the only new/missing function in our `HardwareBuffer` wrapper, except the `AParcel` functions that cannot be bound until that type is mapped.
1 parent 83b3b3a commit 8e3e8ff

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

ndk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- looper: Add `remove_fd()` to unregister events/callbacks for a file descriptor. (#416)
2525
- **Breaking:** Use `BorrowedFd` and `OwnedFd` to clarify possible ownership transitions. (#417)
2626
- **Breaking:** Upgrade to [`ndk-sys 0.5.0`](../ndk-sys/CHANGELOG.md#050-beta0-2023-08-15). (#420)
27+
- hardware_buffer: Add `id()` to retrieve a system-wide unique identifier for a `HardwareBuffer`. (#428)
2728

2829
# 0.7.0 (2022-07-24)
2930

ndk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ api-level-27 = ["api-level-26"]
2727
api-level-28 = ["api-level-27"]
2828
api-level-29 = ["api-level-28"]
2929
api-level-30 = ["api-level-29"]
30+
api-level-31 = ["api-level-30"]
3031

3132
test = ["ffi/test", "jni", "all"]
3233

ndk/src/hardware_buffer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ impl HardwareBuffer {
233233
res == 1
234234
}
235235

236+
/// Get the system-wide unique id for this [`HardwareBuffer`].
237+
#[cfg(feature = "api-level-31")]
238+
#[doc(alias = "AHardwareBuffer_getId")]
239+
pub fn id(&self) -> Result<u64> {
240+
construct(|res| unsafe { ffi::AHardwareBuffer_getId(self.as_ptr(), res) })
241+
}
242+
236243
/// Lock the [`HardwareBuffer`] for direct CPU access.
237244
///
238245
/// This function can lock the buffer for either reading or writing. It may block if the

0 commit comments

Comments
 (0)