Merge remote-tracking branch 'aosp/upstream-main' into master

This merge is necessary to update crosvm to the latest version

Bug: 163867676
Test: locally
Change-Id: Ia0681ee12911ac60f44b04008c5a0590032733a3
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..4cb9810
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,52 @@
+//
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+    default_applicable_licenses: ["external_adhd_license"],
+}
+
+// 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_adhd_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-LGPL",
+    ],
+    license_text: [
+        "LICENSE.SUPERFASTHASH",
+        "LICENSE.UTLIST",
+        "LICENSE.WEBKIT",
+        "NOTICE",
+    ],
+}
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..6d8601b
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+  license_type: RESTRICTED
+}
diff --git a/MODULE_LICENSE_BSD b/MODULE_LICENSE_BSD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_BSD
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..a7f0a02
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,76 @@
+Paul Hsieh OLD BSD license
+
+Copyright (c) 2010, Paul Hsieh
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice, this
+  list of conditions and the following disclaimer in the documentation and/or
+  other materials provided with the distribution.
+* Neither my name, Paul Hsieh, nor the names of any other contributors to the
+  code use may not be used to endorse or promote products derived from this
+  software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/*
+Copyright (c) 2007-2011, Troy D. Hanson   http://uthash.sourceforge.net
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff --git a/OWNERS.android b/OWNERS.android
new file mode 100644
index 0000000..47d8383
--- /dev/null
+++ b/OWNERS.android
@@ -0,0 +1,4 @@
+adelva@google.com
+jemoreira@google.com
+jeffv@google.com
+ivanlozano@google.com
diff --git a/audio_streams/Android.bp b/audio_streams/Android.bp
index 47b5be6..2909b54 100644
--- a/audio_streams/Android.bp
+++ b/audio_streams/Android.bp
@@ -1,7 +1,61 @@
-rust_library_rlib {
+// This file is generated by cargo2android.py --run --device --test --global_defaults=crosvm_defaults --dependencies.
+
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_adhd_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-BSD
+    default_applicable_licenses: ["external_adhd_license"],
+}
+
+rust_defaults {
+    name: "audio_streams_defaults",
+    defaults: ["crosvm_defaults"],
+    crate_name: "audio_streams",
+    srcs: ["src/audio_streams.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2018",
+    rustlibs: [
+        "libsync_rust",
+        "libsys_util",
+    ],
+}
+
+rust_test_host {
+    name: "audio_streams_host_test_src_audio_streams",
+    defaults: ["audio_streams_defaults"],
+}
+
+rust_test {
+    name: "audio_streams_device_test_src_audio_streams",
+    defaults: ["audio_streams_defaults"],
+}
+
+rust_library {
     name: "libaudio_streams",
+    defaults: ["crosvm_defaults"],
     host_supported: true,
     crate_name: "audio_streams",
-    edition: "2018",
     srcs: ["src/audio_streams.rs"],
+    edition: "2018",
+    rustlibs: [
+        "libsync_rust",
+        "libsys_util",
+    ],
 }
+
+// dependent_library ["feature_list"]
+//   ../../crosvm/assertions/src/lib.rs
+//   ../../crosvm/data_model/src/lib.rs
+//   ../../crosvm/sync/src/lib.rs
+//   ../../crosvm/sys_util/poll_token_derive/poll_token_derive.rs
+//   ../../crosvm/sys_util/src/lib.rs
+//   ../../crosvm/syscall_defines/src/lib.rs
+//   ../../crosvm/tempfile/src/lib.rs
+//   libc-0.2.76 "default,std"
+//   proc-macro2-1.0.19 "default,proc-macro"
+//   quote-1.0.7 "default,proc-macro"
+//   syn-1.0.39 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+//   unicode-xid-0.2.1 "default"
diff --git a/audio_streams/Cargo.toml b/audio_streams/Cargo.toml
index 032cd90..dd169c7 100644
--- a/audio_streams/Cargo.toml
+++ b/audio_streams/Cargo.toml
@@ -8,5 +8,5 @@
 path = "src/audio_streams.rs"
 
 [dependencies]
-sync = { path = "../../../platform/crosvm/sync" } # provided by ebuild
-sys_util = { path = "../../../platform/crosvm/sys_util" } # provided by ebuild
+sync = { path = "../../crosvm/sync" } # provided by ebuild
+sys_util = { path = "../../crosvm/sys_util" } # provided by ebuild
diff --git a/cras/client/cras-sys/Android.bp b/cras/client/cras-sys/Android.bp
index 46b5fb2..d6482b2 100644
--- a/cras/client/cras-sys/Android.bp
+++ b/cras/client/cras-sys/Android.bp
@@ -1,8 +1,62 @@
-rust_library_rlib {
+// This file is generated by cargo2android.py --run --device --test --global_defaults=crosvm_defaults --dependencies.
+
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_adhd_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-BSD
+    default_applicable_licenses: ["external_adhd_license"],
+}
+
+rust_defaults {
+    name: "cras-sys_defaults",
+    defaults: ["crosvm_defaults"],
+    crate_name: "cras_sys",
+    srcs: ["src/lib.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2015",
+    rustlibs: [
+        "libaudio_streams",
+        "libdata_model",
+    ],
+}
+
+rust_test_host {
+    name: "cras-sys_host_test_src_lib",
+    defaults: ["cras-sys_defaults"],
+}
+
+rust_test {
+    name: "cras-sys_device_test_src_lib",
+    defaults: ["cras-sys_defaults"],
+}
+
+rust_library {
     name: "libcras_sys",
+    defaults: ["crosvm_defaults"],
     host_supported: true,
     crate_name: "cras_sys",
-    edition: "2015",
-    rlibs: ["libdata_model"],
     srcs: ["src/lib.rs"],
+    edition: "2015",
+    rustlibs: [
+        "libaudio_streams",
+        "libdata_model",
+    ],
 }
+
+// dependent_library ["feature_list"]
+//   ../../../../crosvm/assertions/src/lib.rs
+//   ../../../../crosvm/data_model/src/lib.rs
+//   ../../../../crosvm/sync/src/lib.rs
+//   ../../../../crosvm/sys_util/poll_token_derive/poll_token_derive.rs
+//   ../../../../crosvm/sys_util/src/lib.rs
+//   ../../../../crosvm/syscall_defines/src/lib.rs
+//   ../../../../crosvm/tempfile/src/lib.rs
+//   ../../../audio_streams/src/audio_streams.rs
+//   libc-0.2.76 "default,std"
+//   proc-macro2-1.0.19 "default,proc-macro"
+//   quote-1.0.7 "default,proc-macro"
+//   syn-1.0.39 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+//   unicode-xid-0.2.1 "default"
diff --git a/cras/client/cras-sys/Cargo.toml b/cras/client/cras-sys/Cargo.toml
index 956234e..1ac1857 100644
--- a/cras/client/cras-sys/Cargo.toml
+++ b/cras/client/cras-sys/Cargo.toml
@@ -5,4 +5,4 @@
 
 [dependencies]
 audio_streams = { path = "../../../audio_streams" } # provided by ebuild
-data_model = { path = "../../../../../platform/crosvm/data_model" } # provided by ebuild
+data_model = { path = "../../../../crosvm/data_model" } # provided by ebuild
diff --git a/cras/client/cras_tests/Cargo.toml b/cras/client/cras_tests/Cargo.toml
index 22cfc5c..108fe6c 100644
--- a/cras/client/cras_tests/Cargo.toml
+++ b/cras/client/cras_tests/Cargo.toml
@@ -9,7 +9,7 @@
 getopts = "0.2.18"
 hound = "3.4.0"
 libcras = { path = "../libcras" } # provided by ebuild
-sys_util = { path = "../../../../../platform/crosvm/sys_util" } # provided by ebuild
+sys_util = { path = "../../../../crosvm/sys_util" } # provided by ebuild
 
 [profile.release]
 lto = true
diff --git a/cras/client/libcras/Android.bp b/cras/client/libcras/Android.bp
index e81f068..aecb27a 100644
--- a/cras/client/libcras/Android.bp
+++ b/cras/client/libcras/Android.bp
@@ -1,14 +1,69 @@
-rust_library_rlib {
-    name: "liblibcras",
-    host_supported: true,
+// This file is generated by cargo2android.py --run --device --test --global_defaults=crosvm_defaults --dependencies.
+
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_adhd_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-BSD
+    default_applicable_licenses: ["external_adhd_license"],
+}
+
+rust_defaults {
+    name: "libcras_defaults",
+    defaults: ["crosvm_defaults"],
     crate_name: "libcras",
-    edition: "2018",
     srcs: ["src/libcras.rs"],
-    rlibs: [
-        "libc_rust",
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2018",
+    rustlibs: [
         "libaudio_streams",
         "libcras_sys",
         "libdata_model",
+        "liblibc",
         "libsys_util",
     ],
 }
+
+rust_test_host {
+    name: "libcras_host_test_src_libcras",
+    defaults: ["libcras_defaults"],
+}
+
+rust_test {
+    name: "libcras_device_test_src_libcras",
+    defaults: ["libcras_defaults"],
+}
+
+rust_library {
+    name: "liblibcras",
+    defaults: ["crosvm_defaults"],
+    host_supported: true,
+    crate_name: "libcras",
+    srcs: ["src/libcras.rs"],
+    edition: "2018",
+    rustlibs: [
+        "libaudio_streams",
+        "libcras_sys",
+        "libdata_model",
+        "liblibc",
+        "libsys_util",
+    ],
+}
+
+// dependent_library ["feature_list"]
+//   ../../../../crosvm/assertions/src/lib.rs
+//   ../../../../crosvm/data_model/src/lib.rs
+//   ../../../../crosvm/sync/src/lib.rs
+//   ../../../../crosvm/sys_util/poll_token_derive/poll_token_derive.rs
+//   ../../../../crosvm/sys_util/src/lib.rs
+//   ../../../../crosvm/syscall_defines/src/lib.rs
+//   ../../../../crosvm/tempfile/src/lib.rs
+//   ../../../audio_streams/src/audio_streams.rs
+//   ../cras-sys/src/lib.rs
+//   libc-0.2.76 "default,std"
+//   proc-macro2-1.0.19 "default,proc-macro"
+//   quote-1.0.7 "default,proc-macro"
+//   syn-1.0.39 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+//   unicode-xid-0.2.1 "default"
diff --git a/cras/client/libcras/Cargo.toml b/cras/client/libcras/Cargo.toml
index cc2a3e1..b52a261 100644
--- a/cras/client/libcras/Cargo.toml
+++ b/cras/client/libcras/Cargo.toml
@@ -11,5 +11,5 @@
 audio_streams = { path = "../../../audio_streams" } # provided by ebuild
 libc = "*"
 cras-sys = { path = "../cras-sys" } # provided by ebuild
-data_model = { path = "../../../../../platform/crosvm/data_model" } # provided by ebuild
-sys_util = { path = "../../../../../platform/crosvm/sys_util" } # provided by ebuild
+data_model = { path = "../../../../crosvm/data_model" } # provided by ebuild
+sys_util = { path = "../../../../crosvm/sys_util" } # provided by ebuild
diff --git a/cras/src/Android.bp b/cras/src/Android.bp
index 070e6ca..17b9919 100644
--- a/cras/src/Android.bp
+++ b/cras/src/Android.bp
@@ -1,3 +1,13 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "external_adhd_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-BSD
+    //   SPDX-license-identifier-LGPL
+    default_applicable_licenses: ["external_adhd_license"],
+}
+
 cc_library_static {
     name: "libcras",