[ANDROID] Add Android.bp and preupload configuration

Build rules for the CBOR certificates using boringssl including tests
and fuzzers. The tests are host supported GTest targets so are used
during presbumit automatically.

Bug: 187673309
Test: mmm external/open-dice
Change-Id: I2bc26bc0a455a1039a2dcc010cd72373861744e1
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..649a706
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,72 @@
+package {
+    default_applicable_licenses: ["external_open_dice_license"],
+}
+
+license {
+    name: "external_open_dice_license",
+    visibility: [":__subpackages__"],
+    license_kinds: ["SPDX-license-identifier-Apache-2.0"],
+    license_text: ["LICENSE"],
+}
+
+cc_library_headers {
+    name: "libopen_dice_headers",
+    host_supported: true,
+    export_include_dirs: ["include"],
+}
+
+cc_library_static {
+    name: "libopen_dice_cbor",
+    host_supported: true,
+    srcs: [
+        "src/boringssl_hash_kdf_sign_ops.c",
+        "src/cbor_cert_op.c",
+        "src/cbor_writer.c",
+        "src/dice.c",
+        "src/utils.c",
+    ],
+    header_libs: ["libopen_dice_headers"],
+    export_header_lib_headers: ["libopen_dice_headers"],
+    shared_libs: ["libcrypto"],
+}
+
+cc_test {
+    name: "libopen_dice_test",
+    host_supported: true,
+    cflags: ["-DDICE_USE_GTEST"],
+    srcs: [
+        "src/dice_test.cc",
+        "src/dice.c",
+        "src/utils.c",
+    ],
+    header_libs: ["libopen_dice_headers"],
+    shared_libs: ["libcrypto"],
+}
+
+cc_test {
+    name: "libopen_dice_cbor_writer_test",
+    host_supported: true,
+    cflags: ["-DDICE_USE_GTEST"],
+    srcs: ["src/cbor_writer_test.cc"],
+    static_libs: ["libopen_dice_cbor"],
+}
+
+// TODO: cbor_cert_op_test after resolving COSE dependency
+
+cc_fuzz {
+    name: "libopen_dice_cbor_writer_fuzzer",
+    host_supported: true,
+    srcs: ["src/cbor_writer_fuzzer.cc"],
+    static_libs: ["libopen_dice_cbor"],
+}
+
+cc_fuzz {
+    name: "libopen_dice_cbor_fuzzer",
+    host_supported: true,
+    srcs: [
+        "src/fuzz_utils.cc",
+        "src/cbor_cert_op_fuzzer.cc",
+    ],
+    static_libs: ["libopen_dice_cbor"],
+    shared_libs: ["libcrypto"],
+}
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..0f3c468
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,6 @@
+[Builtin Hooks]
+android_test_mapping_format = true
+bpfmt = true
+
+[Hook Scripts]
+aosp_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "."