Move APEX handling to a library

Make a library for APEX handling using the microdroid_manager logic as
the basis. Other components are going to need to be able to extract the
keys from APEXs so make the logic reusable and available to host tools.

Test: atest microdroid_manager_test
Test: atest libapexutil_rust.test
Change-Id: I36abf21b59b67046b1464bf47f7be40186926410
diff --git a/libs/apexutil/Android.bp b/libs/apexutil/Android.bp
new file mode 100644
index 0000000..a1a1ca6
--- /dev/null
+++ b/libs/apexutil/Android.bp
@@ -0,0 +1,40 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_defaults {
+    name: "libapexutil_rust.defaults",
+    crate_name: "apexutil",
+    host_supported: true,
+    srcs: ["src/lib.rs"],
+    prefer_rlib: true,
+    edition: "2018",
+    rustlibs: [
+        "libavb_bindgen",
+        "liblog_rust",
+        "libthiserror",
+        "libzip",
+    ],
+}
+
+rust_library {
+    name: "libapexutil_rust",
+    defaults: ["libapexutil_rust.defaults"],
+}
+
+rust_test {
+    name: "libapexutil_rust.test",
+    defaults: ["libapexutil_rust.defaults"],
+    test_suites: ["general-tests"],
+    data: ["tests/data/*"],
+    target: {
+        host: {
+            // TODO(b/204562227): remove once the build does this automatically
+            data_libs: [
+                "libc++",
+                "libcrypto",
+                "libz",
+            ],
+        },
+    },
+}