Keystore 2.0: Add AID_USER_OFFSET to utils.rs

Add AID_USER_OFFSET and function to extract the Android user id from a
UID to utils.rs

Test: None
Change-Id: Ifbadeda7bbdce971627df2b2d0f1eaf8ae415068
diff --git a/keystore2/src/utils.rs b/keystore2/src/utils.rs
index c168486..7a6d6d7 100644
--- a/keystore2/src/utils.rs
+++ b/keystore2/src/utils.rs
@@ -153,3 +153,12 @@
     // defined to be an error that can never happen (i.e. the result is always ok).
     i64::try_from(current_time.tv_sec).unwrap()
 }
+
+/// AID offset for uid space partitioning.
+/// TODO: Replace with bindgen generated from libcutils. b/175619259
+pub const AID_USER_OFFSET: u32 = 100000;
+
+/// Extracts the android user from the given uid.
+pub fn uid_to_android_user(uid: u32) -> u32 {
+    uid / AID_USER_OFFSET
+}