Add liblibusb1_sys_platform variant and remove Android.bp tests
Added the liblibusb1_sys_platform variant that uses the library
libusb_platform, therefore enabling listening to libusb hotplug
events. This should be used only by programs running at OS-level.
Also removed the tests from Android.bp due to test_init_and_exit
and test_get_device_list failing because of missing required
permissions (SELinux).
Bug: 376046775
Test: m liblibusb1_sys, m liblibusb1_sys_platform,
- manually test librusb (depending on liblibusb1) on device
Change-Id: I753f88903d598517f44e67e42941fdb0c42bfc60
diff --git a/Android.bp b/Android.bp
index ce59553..8e9ee67 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,3 +1,6 @@
+// This file is generated by cargo_embargo.
+// Do not modify this file because the changes will be overridden on upgrade.
+
package {
default_applicable_licenses: ["external_rust_crates_libusb1-sys_license"],
default_team: "trendy_team_android_rust",
@@ -19,45 +22,31 @@
crate_root: "src/lib.rs",
edition: "2018",
rustlibs: ["liblibc"],
- shared_libs: ["libusb"],
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
vendor_available: true,
+ shared_libs: ["libusb"],
}
-rust_test {
- name: "libusb1-sys_test_src_lib",
+rust_library {
+ name: "liblibusb1_sys_platform",
host_supported: true,
crate_name: "libusb1_sys",
cargo_env_compat: true,
cargo_pkg_version: "0.7.0",
crate_root: "src/lib.rs",
- test_suites: ["general-tests"],
- auto_gen_config: true,
- test_options: {
- unit_test: true,
- },
edition: "2018",
rustlibs: ["liblibc"],
-}
-
-rust_test {
- name: "libusb1-sys_test_tests_test",
- host_supported: true,
- crate_name: "test",
- cargo_env_compat: true,
- cargo_pkg_version: "0.7.0",
- crate_root: "tests/test.rs",
- test_suites: ["general-tests"],
- auto_gen_config: true,
- test_options: {
- unit_test: true,
- },
- edition: "2018",
- rustlibs: [
- "liblibc",
- "liblibusb1_sys",
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
],
+ vendor_available: true,
+ // This library should be depended upon only by programs
+ // running on Android at OS level (e.g. Android platform
+ // services). The reason is that programs using "libusb_platform"
+ // must have permission to access netlink sockets.
+ shared_libs: ["libusb_platform"],
}
diff --git a/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..f7006a2
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,23 @@
+{
+ "run_cargo": false,
+ "product_available": false,
+ "variants": [
+ {
+ "package": {
+ "libusb1-sys": {
+ "add_module_block": "module_block.bp.fragment"
+ }
+ }
+ },
+ {
+ "module_name_overrides": {
+ "liblibusb1_sys": "liblibusb1_sys_platform"
+ },
+ "package": {
+ "libusb1-sys": {
+ "add_module_block": "module_block_platform.bp.fragment"
+ }
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/module_block.bp.fragment b/module_block.bp.fragment
new file mode 100644
index 0000000..1bc3ec1
--- /dev/null
+++ b/module_block.bp.fragment
@@ -0,0 +1 @@
+shared_libs: ["libusb"]
\ No newline at end of file
diff --git a/module_block_platform.bp.fragment b/module_block_platform.bp.fragment
new file mode 100644
index 0000000..101e331
--- /dev/null
+++ b/module_block_platform.bp.fragment
@@ -0,0 +1,5 @@
+// This library should be depended upon only by programs
+// running on Android at OS level (e.g. Android platform
+// services). The reason is that programs using "libusb_platform"
+// must have permission to access netlink sockets.
+shared_libs: ["libusb_platform"]
\ No newline at end of file