Snap for 8564071 from 5c282b36b2b28e1ab58755b8e4c1b8dfc49e579a to mainline-conscrypt-release

Change-Id: I5f75c8ad11dfb52a7ea69e078d6d4c6f4c7421af
diff --git a/Android.bp b/Android.bp
index 5c43223..051dcae 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,29 +1,47 @@
 // This file is generated by cargo2android.py --config cargo2android.json.
 // Do not modify this file as changes will be overridden on upgrade.
 
+package {
+    default_applicable_licenses: ["external_rust_crates_base64_license"],
+}
 
-
-rust_library {
-    name: "libbase64_rust",
-    stem: "libbase64",
-    host_supported: true,
-    crate_name: "base64",
-    srcs: ["src/lib.rs"],
-    edition: "2018",
-    features: [
-        "default",
-        "std",
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+//
+// large-scale-change included anything that looked like it might be a license
+// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
+//
+// Please consider removing redundant or irrelevant files from 'license_text:'.
+// See: http://go/android-license-faq
+license {
+    name: "external_rust_crates_base64_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-MIT",
     ],
-    apex_available: [
-        "//apex_available:platform",
-        "com.android.resolv",
+    license_text: [
+        "LICENSE-APACHE",
+        "LICENSE-MIT",
     ],
-    min_sdk_version: "29",
 }
 
 rust_defaults {
-    name: "base64_defaults_base64",
+    name: "base64_test_defaults",
     crate_name: "base64",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.13.0",
     test_suites: ["general-tests"],
     auto_gen_config: true,
     edition: "2018",
@@ -39,9 +57,10 @@
     ],
 }
 
-rust_test_host {
-    name: "base64_host_test_tests_decode",
-    defaults: ["base64_defaults_base64"],
+rust_test {
+    name: "base64_test_tests_decode",
+    defaults: ["base64_test_defaults"],
+    host_supported: true,
     srcs: ["tests/decode.rs"],
     test_options: {
         unit_test: true,
@@ -49,38 +68,31 @@
 }
 
 rust_test {
-    name: "base64_device_test_tests_decode",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/decode.rs"],
-}
-
-rust_test_host {
-    name: "base64_host_test_tests_encode",
-    defaults: ["base64_defaults_base64"],
+    name: "base64_test_tests_encode",
+    defaults: ["base64_test_defaults"],
+    host_supported: true,
     srcs: ["tests/encode.rs"],
     test_options: {
         unit_test: true,
     },
 }
 
-rust_test {
-    name: "base64_device_test_tests_encode",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/encode.rs"],
+rust_library {
+    name: "libbase64_rust",
+    stem: "libbase64",
+    host_supported: true,
+    crate_name: "base64",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.13.0",
+    srcs: ["src/lib.rs"],
+    edition: "2018",
+    features: [
+        "default",
+        "std",
+    ],
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.resolv",
+    ],
+    min_sdk_version: "29",
 }
-
-rust_test_host {
-    name: "base64_host_test_tests_helpers",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/helpers.rs"],
-    test_options: {
-        unit_test: true,
-    },
-}
-
-rust_test {
-    name: "base64_device_test_tests_helpers",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/helpers.rs"],
-}
-
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 768046f..de2964d 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,14 +1,48 @@
 // Generated by update_crate_tests.py for tests that depend on this crate.
 {
+  "imports": [
+    {
+      "path": "external/rust/crates/webpki"
+    }
+  ],
   "presubmit": [
     {
-      "name": "base64_device_test_tests_decode"
+      "name": "base64_test_tests_decode"
     },
     {
-      "name": "base64_device_test_tests_encode"
+      "name": "base64_test_tests_encode"
     },
     {
-      "name": "base64_device_test_tests_helpers"
+      "name": "doh_unit_test"
+    },
+    {
+      "name": "libapkverify.integration_test"
+    },
+    {
+      "name": "libapkverify.test"
+    },
+    {
+      "name": "microdroid_manager_test"
+    }
+  ],
+  "presubmit-rust": [
+    {
+      "name": "base64_test_tests_decode"
+    },
+    {
+      "name": "base64_test_tests_encode"
+    },
+    {
+      "name": "doh_unit_test"
+    },
+    {
+      "name": "libapkverify.integration_test"
+    },
+    {
+      "name": "libapkverify.test"
+    },
+    {
+      "name": "microdroid_manager_test"
     }
   ]
 }
diff --git a/cargo2android.json b/cargo2android.json
index 6d85f2f..d2d1ca1 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -1,10 +1,14 @@
 {
-    "add-toplevel-block": "cargo2android_tests.bp",
-    "apex-available": [
-      "//apex_available:platform",
-      "com.android.resolv"
-    ],
-    "min_sdk_version": "29",
-    "device": true,
-    "run": true
-  }
\ No newline at end of file
+  "apex-available": [
+    "//apex_available:platform",
+    "com.android.resolv"
+  ],
+  "device": true,
+  "min-sdk-version": "29",
+  "run": true,
+  "test-blocklist": [
+    "src/lib.rs",
+    "tests/tests.rs"
+  ],
+  "tests": true
+}
\ No newline at end of file
diff --git a/cargo2android_tests.bp b/cargo2android_tests.bp
deleted file mode 100644
index 1213c14..0000000
--- a/cargo2android_tests.bp
+++ /dev/null
@@ -1,62 +0,0 @@
-rust_defaults {
-    name: "base64_defaults_base64",
-    crate_name: "base64",
-    test_suites: ["general-tests"],
-    auto_gen_config: true,
-    edition: "2018",
-    features: [
-        "default",
-        "std",
-    ],
-    rustlibs: [
-        "libbase64_rust",
-        "libcriterion",
-        "librand",
-        "libstructopt",
-    ],
-}
-
-rust_test_host {
-    name: "base64_host_test_tests_decode",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/decode.rs"],
-    test_options: {
-        unit_test: true,
-    },
-}
-
-rust_test {
-    name: "base64_device_test_tests_decode",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/decode.rs"],
-}
-
-rust_test_host {
-    name: "base64_host_test_tests_encode",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/encode.rs"],
-    test_options: {
-        unit_test: true,
-    },
-}
-
-rust_test {
-    name: "base64_device_test_tests_encode",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/encode.rs"],
-}
-
-rust_test_host {
-    name: "base64_host_test_tests_helpers",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/helpers.rs"],
-    test_options: {
-        unit_test: true,
-    },
-}
-
-rust_test {
-    name: "base64_device_test_tests_helpers",
-    defaults: ["base64_defaults_base64"],
-    srcs: ["tests/helpers.rs"],
-}
diff --git a/patches/encoder.patch b/patches/encoder.patch
new file mode 100644
index 0000000..ac1cd73
--- /dev/null
+++ b/patches/encoder.patch
@@ -0,0 +1,13 @@
+diff --git a/src/write/encoder.rs b/src/write/encoder.rs
+index 8a48f43..4bb57eb 100644
+--- a/src/write/encoder.rs
++++ b/src/write/encoder.rs
+@@ -223,7 +223,7 @@ impl<W: Write> Write for EncoderWriter<W> {
+     /// Under non-error circumstances, this returns `Ok` with the value being the number of bytes
+     /// of `input` consumed. The value may be `0`, which interacts poorly with `write_all`, which
+     /// interprets `Ok(0)` as an error, despite it being allowed by the contract of `write`. See
+-    /// https://github.com/rust-lang/rust/issues/56889 for more on that.
++    /// <https://github.com/rust-lang/rust/issues/56889> for more on that.
+     ///
+     /// If the previous call to `write` provided more (encoded) data than the delegate writer could
+     /// accept in a single call to its `write`, the remaining data is buffered. As long as buffered
diff --git a/src/write/encoder.rs b/src/write/encoder.rs
index 8a48f43..4bb57eb 100644
--- a/src/write/encoder.rs
+++ b/src/write/encoder.rs
@@ -223,7 +223,7 @@
     /// Under non-error circumstances, this returns `Ok` with the value being the number of bytes
     /// of `input` consumed. The value may be `0`, which interacts poorly with `write_all`, which
     /// interprets `Ok(0)` as an error, despite it being allowed by the contract of `write`. See
-    /// https://github.com/rust-lang/rust/issues/56889 for more on that.
+    /// <https://github.com/rust-lang/rust/issues/56889> for more on that.
     ///
     /// If the previous call to `write` provided more (encoded) data than the delegate writer could
     /// accept in a single call to its `write`, the remaining data is buffered. As long as buffered