aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TEST_MAPPING3
-rw-r--r--build/hidl_interface.go108
-rw-r--r--build/properties.go19
-rw-r--r--hidl2aidl/test/Android.bp1
-rw-r--r--test/lazy_test/Android.bp24
-rw-r--r--test/lazy_test/hidl_lazy_test.cpp (renamed from test/lazy_test/main.cpp)36
-rw-r--r--test/lazy_test/hidl_lazy_test_server.cpp35
-rw-r--r--test/lazy_test/hidl_lazy_test_server.rc7
-rw-r--r--test/lazy_test/hidl_lazy_test_server.xml7
-rw-r--r--test/vendor/1.0/Android.bp11
10 files changed, 201 insertions, 50 deletions
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 9bf4ea30..16467e1f 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -14,6 +14,9 @@
},
{
"name": "libhidl-gen-utils_test"
+ },
+ {
+ "name": "hidl_lazy_test"
}
]
}
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index 03c32d2a..c4a84a6e 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -129,6 +129,9 @@ func (m *hidlInterfacesMetadataSingleton) GenerateAndroidBuildActions(ctx androi
var inheritanceHierarchyOutputs android.Paths
ctx.VisitDirectDeps(func(m android.Module) {
+ if !m.ExportedToMake() {
+ return
+ }
if t, ok := m.(*hidlGenRule); ok {
if t.properties.Language == "inheritance-hierarchy" {
inheritanceHierarchyOutputs = append(inheritanceHierarchyOutputs, t.genOutputs.Paths()...)
@@ -197,12 +200,13 @@ func (m *allHidlLintsSingleton) MakeVars(ctx android.MakeVarsContext) {
}
type hidlGenProperties struct {
- Language string
- FqName string
- Root string
- Interfaces []string
- Inputs []string
- Outputs []string
+ Language string
+ FqName string
+ Root string
+ Interfaces []string
+ Inputs []string
+ Outputs []string
+ Apex_available []string
}
type hidlGenRule struct {
@@ -468,6 +472,19 @@ type hidlInterfaceProperties struct {
// Whether this interface library should be installed on product partition.
// TODO(b/150902910): remove, since this should be an inherited property.
Product_specific *bool
+
+ // List of APEX modules this interface can be used in.
+ //
+ // WARNING: HIDL is not fully supported in APEX since VINTF currently doesn't
+ // read files from APEXes (b/130058564).
+ //
+ // "//apex_available:anyapex" is a pseudo APEX name that matches to any APEX.
+ // "//apex_available:platform" refers to non-APEX partitions like "system.img"
+ //
+ // Note, this only applies to C++ libs, Java libs, and Java constant libs. It
+ // does not apply to VTS targets/adapter targets/fuzzers since these components
+ // should not be shipped on device.
+ Apex_available []string
}
type hidlInterface struct {
@@ -640,6 +657,8 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
"libutils",
}),
Export_generated_headers: []string{name.headersName()},
+ Apex_available: i.properties.Apex_available,
+ Min_sdk_version: getMinSdkVersion(name.string()),
}, &i.properties.VndkProperties)
}
@@ -664,8 +683,9 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
// to build framework, which is used to build system_current. Use core_current
// plus hwbinder.stubs, which together form a subset of system_current that does
// not depend on framework.
- Sdk_version: proptools.StringPtr("core_current"),
- Libs: []string{"hwbinder.stubs"},
+ Sdk_version: proptools.StringPtr("core_current"),
+ Libs: []string{"hwbinder.stubs"},
+ Apex_available: i.properties.Apex_available,
}
mctx.CreateModule(java.LibraryFactory, &javaProperties{
@@ -690,10 +710,11 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
Outputs: []string{name.sanitizedDir() + "Constants.java"},
})
mctx.CreateModule(java.LibraryFactory, &javaProperties{
- Name: proptools.StringPtr(name.javaConstantsName()),
- Defaults: []string{"hidl-java-module-defaults"},
- Sdk_version: proptools.StringPtr("core_current"),
- Srcs: []string{":" + name.javaConstantsSourcesName()},
+ Name: proptools.StringPtr(name.javaConstantsName()),
+ Defaults: []string{"hidl-java-module-defaults"},
+ Sdk_version: proptools.StringPtr("core_current"),
+ Srcs: []string{":" + name.javaConstantsSourcesName()},
+ Apex_available: i.properties.Apex_available,
})
}
@@ -875,17 +896,15 @@ This corresponds to the "-r%s:<some path>" option that would be passed into hidl
Inputs: i.properties.Srcs,
})
- if i.ModuleBase.ExportedToMake() {
- mctx.CreateModule(hidlGenFactory, &nameProperties{
- Name: proptools.StringPtr(name.inheritanceHierarchyName()),
- }, &hidlGenProperties{
- Language: "inheritance-hierarchy",
- FqName: name.string(),
- Root: i.properties.Root,
- Interfaces: i.properties.Interfaces,
- Inputs: i.properties.Srcs,
- })
- }
+ mctx.CreateModule(hidlGenFactory, &nameProperties{
+ Name: proptools.StringPtr(name.inheritanceHierarchyName()),
+ }, &hidlGenProperties{
+ Language: "inheritance-hierarchy",
+ FqName: name.string(),
+ Root: i.properties.Root,
+ Interfaces: i.properties.Interfaces,
+ Inputs: i.properties.Srcs,
+ })
}
func (h *hidlInterface) Name() string {
@@ -918,6 +937,49 @@ func hidlInterfaceFactory() android.Module {
return i
}
+var minSdkVersion = map[string]string{
+ "android.hardware.audio.common@5.0": "30",
+ "android.hardware.bluetooth.a2dp@1.0": "30",
+ "android.hardware.bluetooth.audio@2.0": "30",
+ "android.hardware.bluetooth@1.0": "30",
+ "android.hardware.bluetooth@1.1": "30",
+ "android.hardware.cas.native@1.0": "29",
+ "android.hardware.cas@1.0": "29",
+ "android.hardware.graphics.allocator@2.0": "29",
+ "android.hardware.graphics.allocator@3.0": "29",
+ "android.hardware.graphics.allocator@4.0": "29",
+ "android.hardware.graphics.bufferqueue@1.0": "29",
+ "android.hardware.graphics.bufferqueue@2.0": "29",
+ "android.hardware.graphics.common@1.0": "29",
+ "android.hardware.graphics.common@1.1": "29",
+ "android.hardware.graphics.common@1.2": "29",
+ "android.hardware.graphics.mapper@2.0": "29",
+ "android.hardware.graphics.mapper@2.1": "29",
+ "android.hardware.graphics.mapper@3.0": "29",
+ "android.hardware.graphics.mapper@4.0": "29",
+ "android.hardware.media.bufferpool@2.0": "29",
+ "android.hardware.media.c2@1.0": "29",
+ "android.hardware.media.c2@1.1": "29",
+ "android.hardware.media.omx@1.0": "29",
+ "android.hardware.media@1.0": "29",
+ "android.hardware.neuralnetworks@1.0": "30",
+ "android.hardware.neuralnetworks@1.1": "30",
+ "android.hardware.neuralnetworks@1.2": "30",
+ "android.hardware.neuralnetworks@1.3": "30",
+ "android.hidl.allocator@1.0": "29",
+ "android.hidl.memory.token@1.0": "29",
+ "android.hidl.memory@1.0": "29",
+ "android.hidl.safe_union@1.0": "29",
+ "android.hidl.token@1.0": "29",
+}
+
+func getMinSdkVersion(name string) *string {
+ if ver, ok := minSdkVersion[name]; ok {
+ return proptools.StringPtr(ver)
+ }
+ return nil
+}
+
var doubleLoadablePackageNames = []string{
"android.frameworks.bufferhub@1.0",
"android.hardware.cas@1.0",
diff --git a/build/properties.go b/build/properties.go
index 1616b7b3..b0b4b853 100644
--- a/build/properties.go
+++ b/build/properties.go
@@ -41,17 +41,20 @@ type ccProperties struct {
Export_generated_headers []string
Double_loadable *bool
Cflags []string
+ Apex_available []string
+ Min_sdk_version *string
}
type javaProperties struct {
- Name *string
- Owner *string
- Defaults []string
- Installable *bool
- Sdk_version *string
- Srcs []string
- Libs []string
- Static_libs []string
+ Name *string
+ Owner *string
+ Defaults []string
+ Installable *bool
+ Sdk_version *string
+ Srcs []string
+ Libs []string
+ Static_libs []string
+ Apex_available []string
}
type fuzzConfig struct {
diff --git a/hidl2aidl/test/Android.bp b/hidl2aidl/test/Android.bp
index e1a7adb5..fa923d25 100644
--- a/hidl2aidl/test/Android.bp
+++ b/hidl2aidl/test/Android.bp
@@ -46,6 +46,7 @@ genrule {
aidl_interface {
name: "hidl2aidl_test_gen",
+ unstable: true,
srcs: [":hidl2aidl_test_gen_aidl"],
}
diff --git a/test/lazy_test/Android.bp b/test/lazy_test/Android.bp
index 04acf6f4..a2c67cb7 100644
--- a/test/lazy_test/Android.bp
+++ b/test/lazy_test/Android.bp
@@ -1,13 +1,33 @@
cc_test {
name: "hidl_lazy_test",
defaults: ["hidl-gen-defaults"],
- srcs: ["main.cpp"],
+ srcs: ["hidl_lazy_test.cpp"],
shared_libs: [
"libbase",
+ "libhidl-gen-utils",
+ "libhidlbase",
"liblog",
+ "libutils",
+ ],
+
+ test_suites: ["general-tests"],
+ require_root: true,
+}
+
+cc_binary {
+ name: "hidl_lazy_test_server",
+ system_ext_specific: true,
+
+ vintf_fragments: ["hidl_lazy_test_server.xml"],
+ init_rc: ["hidl_lazy_test_server.rc"],
+
+ srcs: ["hidl_lazy_test_server.cpp"],
+
+ shared_libs: [
+ "android.hardware.tests.lazy@1.0",
+ "libbase",
"libhidlbase",
- "libhidlmemory",
"libutils",
],
}
diff --git a/test/lazy_test/main.cpp b/test/lazy_test/hidl_lazy_test.cpp
index 48512e07..9becc354 100644
--- a/test/lazy_test/main.cpp
+++ b/test/lazy_test/hidl_lazy_test.cpp
@@ -25,11 +25,13 @@
#include <android/hidl/manager/1.2/IServiceManager.h>
#include <gtest/gtest.h>
+#include <hidl-util/FqInstance.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/HidlTransportUtils.h>
#include <hwbinder/IPCThreadState.h>
+using ::android::FqInstance;
using ::android::sp;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
@@ -37,11 +39,11 @@ using ::android::hardware::IPCThreadState;
using ::android::hidl::base::V1_0::IBase;
using ::android::hidl::manager::V1_2::IServiceManager;
-static std::string gDescriptor;
-static std::string gInstance;
+static FqInstance gInstance;
sp<IBase> getHal() {
- return ::android::hardware::details::getRawServiceInternal(gDescriptor, gInstance,
+ return ::android::hardware::details::getRawServiceInternal(gInstance.getFqName().string(),
+ gInstance.getInstance(),
true /*retry*/, false /*getStub*/);
}
@@ -53,10 +55,10 @@ class HidlLazyTest : public ::testing::Test {
manager = IServiceManager::getService();
ASSERT_NE(manager, nullptr);
- ASSERT_FALSE(isServiceRunning()) << "Service '" << gDescriptor << "/" << gInstance
- << "' is already running. Please ensure this "
- << "service is implemented as a lazy HAL, then kill all "
- << "clients of this service and try again.";
+ ASSERT_FALSE(isServiceRunning())
+ << "Service '" << gInstance.string() << "' is already running. Please ensure this "
+ << "service is implemented as a lazy HAL, then kill all "
+ << "clients of this service and try again.";
}
static constexpr size_t SHUTDOWN_WAIT_TIME = 10;
@@ -71,10 +73,10 @@ class HidlLazyTest : public ::testing::Test {
bool isServiceRunning() {
bool isRunning = false;
EXPECT_TRUE(
- manager->listByInterface(gDescriptor,
+ manager->listByInterface(gInstance.getFqName().string(),
[&isRunning](const hidl_vec<hidl_string>& instanceNames) {
for (const hidl_string& name : instanceNames) {
- if (name == gInstance) {
+ if (name == gInstance.getInstance()) {
isRunning = true;
break;
}
@@ -143,13 +145,21 @@ int main(int argc, char** argv) {
srand(time(nullptr));
- if (argc != 3) {
- std::cerr << "Usage: lazy_test fqname instance" << std::endl;
+ std::string fqInstance;
+
+ if (argc == 1) {
+ fqInstance = "android.hardware.tests.lazy@1.0::ILazy/default";
+ } else if (argc == 2) {
+ fqInstance = argv[1];
+ } else {
+ std::cerr << "Usage: lazy_test fqinstance" << std::endl;
return 1;
}
- gDescriptor = argv[1];
- gInstance = argv[2];
+ if (!gInstance.setTo(fqInstance)) {
+ std::cerr << "Invalid fqinstance: " << fqInstance << std::endl;
+ return 1;
+ }
return RUN_ALL_TESTS();
}
diff --git a/test/lazy_test/hidl_lazy_test_server.cpp b/test/lazy_test/hidl_lazy_test_server.cpp
new file mode 100644
index 00000000..f1b381c2
--- /dev/null
+++ b/test/lazy_test/hidl_lazy_test_server.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include <android-base/logging.h>
+#include <android/hardware/tests/lazy/1.0/ILazy.h>
+#include <hidl/HidlLazyUtils.h>
+#include <hidl/HidlTransportSupport.h>
+
+using android::OK;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::hardware::LazyServiceRegistrar;
+using android::hardware::tests::lazy::V1_0::ILazy;
+
+class Lazy : public ILazy {};
+
+int main() {
+ configureRpcThreadpool(1, true /*willJoin*/);
+ CHECK(OK == LazyServiceRegistrar::getInstance().registerService(new Lazy, "default"));
+ joinRpcThreadpool();
+ return EXIT_FAILURE; // should not reach
+}
diff --git a/test/lazy_test/hidl_lazy_test_server.rc b/test/lazy_test/hidl_lazy_test_server.rc
new file mode 100644
index 00000000..00a52375
--- /dev/null
+++ b/test/lazy_test/hidl_lazy_test_server.rc
@@ -0,0 +1,7 @@
+service hidl_lazy_test_server /system_ext/bin/hidl_lazy_test_server
+ interface android.hardware.tests.lazy@1.0::ILazy default
+ user nobody
+ group nobody
+ oneshot
+ disabled
+
diff --git a/test/lazy_test/hidl_lazy_test_server.xml b/test/lazy_test/hidl_lazy_test_server.xml
new file mode 100644
index 00000000..e5e071e4
--- /dev/null
+++ b/test/lazy_test/hidl_lazy_test_server.xml
@@ -0,0 +1,7 @@
+<manifest version="1.0" type="framework">
+ <hal format="hidl">
+ <name>android.hardware.tests.lazy</name>
+ <transport>hwbinder</transport>
+ <fqname>@1.0::ILazy/default</fqname>
+ </hal>
+</manifest>
diff --git a/test/vendor/1.0/Android.bp b/test/vendor/1.0/Android.bp
index 85f4af2c..c02197e2 100644
--- a/test/vendor/1.0/Android.bp
+++ b/test/vendor/1.0/Android.bp
@@ -1,13 +1,11 @@
-// This file is autogenerated by hidl-gen -Landroidbp.
-
hidl_interface {
name: "hidl.tests.vendor@1.0",
owner: "some-owner-name",
root: "hidl.tests",
system_ext_specific: true,
srcs: [
- "types.hal",
"IVendor.hal",
+ "types.hal",
],
interfaces: [
"android.hardware.tests.baz@1.0",
@@ -18,5 +16,10 @@ hidl_interface {
// tests that license is copied
notice: "FAKE_NOTICE_FILE",
-}
+ // test apex_available resolves
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
+}