Add safety comments.
These will soon be required by a lint.
Bug: 290018030
Test: m libkeystore2_apc_compat-rust
Change-Id: Ic7e4e62e52d3361af9a275443bf097282a84f034
diff --git a/keystore2/apc_compat/apc_compat.rs b/keystore2/apc_compat/apc_compat.rs
index 480f14d..e97ac59 100644
--- a/keystore2/apc_compat/apc_compat.rs
+++ b/keystore2/apc_compat/apc_compat.rs
@@ -53,7 +53,10 @@
/// ```
pub struct ApcHal(ApcCompatServiceHandle);
+// SAFETY: This is a wrapper around `ApcCompatSession`, which can be used from any thread.
unsafe impl Send for ApcHal {}
+// SAFETY: `ApcCompatSession` can be called simultaneously from different threads because AIDL and
+// HIDL are thread-safe.
unsafe impl Sync for ApcHal {}
impl Drop for ApcHal {
@@ -120,6 +123,7 @@
// `closeUserConfirmationService` when dropped.
let handle = unsafe { tryGetUserConfirmationService() };
match handle {
+ // SAFETY: This is just a constant.
h if h == unsafe { INVALID_SERVICE_HANDLE } => None,
h => Some(Self(h)),
}