diff options
author | Nirav Atre <natre@google.com> | 2018-07-26 21:24:32 -0700 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2018-08-10 14:46:45 -0700 |
commit | 4b34843cfb82a306b2e3e368ded44e8c141893fd (patch) | |
tree | 8be33824da2b66a7808b02d3591053b93c8f0518 | |
parent | c07a66e169bc8b5a2bebe209c48bf27a553084ce (diff) | |
download | platform_hardware_interfaces-4b34843cfb82a306b2e3e368ded44e8c141893fd.tar.gz platform_hardware_interfaces-4b34843cfb82a306b2e3e368ded44e8c141893fd.tar.bz2 platform_hardware_interfaces-4b34843cfb82a306b2e3e368ded44e8c141893fd.zip |
Adding handle types to Java-compatible test HALs
This change adds HIDL handle types to the baz@1.0 and safeunion@1.0 test
HALs to exercise native handles in Java.
Bug: 35098567
Test: Ran the hidl_test (C++ and Java) suites
Change-Id: Iddf1c269cbdc68ce337f1e787570f3810f7baad2
-rw-r--r-- | tests/baz/1.0/IBaz.hal | 5 | ||||
-rw-r--r-- | tests/safeunion/1.0/ISafeUnion.hal | 15 | ||||
-rw-r--r-- | tests/safeunion/1.0/default/SafeUnion.cpp | 70 | ||||
-rw-r--r-- | tests/safeunion/1.0/default/SafeUnion.h | 12 |
4 files changed, 100 insertions, 2 deletions
diff --git a/tests/baz/1.0/IBaz.hal b/tests/baz/1.0/IBaz.hal index 00fe5686a8..8118d8bf59 100644 --- a/tests/baz/1.0/IBaz.hal +++ b/tests/baz/1.0/IBaz.hal @@ -68,6 +68,11 @@ interface IBaz extends IBase { bitfield<BitField> bf; }; + struct MyHandle { + handle h; + int32_t guard; + }; + struct StructWithInterface { int32_t number; int8_t[7] array; diff --git a/tests/safeunion/1.0/ISafeUnion.hal b/tests/safeunion/1.0/ISafeUnion.hal index e56022f415..c38777a9bc 100644 --- a/tests/safeunion/1.0/ISafeUnion.hal +++ b/tests/safeunion/1.0/ISafeUnion.hal @@ -68,6 +68,14 @@ interface ISafeUnion { IOtherInterface c; string d; vec<string> e; + handle f; + vec<handle> g; + }; + + safe_union HandleTypeSafeUnion { + handle a; + handle[5] b; + vec<handle> c; }; newLargeSafeUnion() generates (LargeSafeUnion myUnion); @@ -90,4 +98,11 @@ interface ISafeUnion { setInterfaceC(InterfaceTypeSafeUnion myUnion, IOtherInterface c) generates (InterfaceTypeSafeUnion myUnion); setInterfaceD(InterfaceTypeSafeUnion myUnion, string d) generates (InterfaceTypeSafeUnion myUnion); setInterfaceE(InterfaceTypeSafeUnion myUnion, vec<string> e) generates (InterfaceTypeSafeUnion myUnion); + setInterfaceF(InterfaceTypeSafeUnion myUnion, handle f) generates (InterfaceTypeSafeUnion myUnion); + setInterfaceG(InterfaceTypeSafeUnion myUnion, vec<handle> g) generates (InterfaceTypeSafeUnion myUnion); + + newHandleTypeSafeUnion() generates (HandleTypeSafeUnion myUnion); + setHandleA(HandleTypeSafeUnion myUnion, handle a) generates (HandleTypeSafeUnion myUnion); + setHandleB(HandleTypeSafeUnion myUnion, handle[5] b) generates (HandleTypeSafeUnion myUnion); + setHandleC(HandleTypeSafeUnion myUnion, vec<handle> c) generates (HandleTypeSafeUnion myUnion); }; diff --git a/tests/safeunion/1.0/default/SafeUnion.cpp b/tests/safeunion/1.0/default/SafeUnion.cpp index 11b2e36782..c39566412e 100644 --- a/tests/safeunion/1.0/default/SafeUnion.cpp +++ b/tests/safeunion/1.0/default/SafeUnion.cpp @@ -191,7 +191,8 @@ Return<void> SafeUnion::setInterfaceC(const InterfaceTypeSafeUnion& myUnion, con return Void(); } -Return<void> SafeUnion::setInterfaceD(const ::android::hardware::tests::safeunion::V1_0::ISafeUnion::InterfaceTypeSafeUnion& myUnion, const hidl_string& d, setInterfaceD_cb _hidl_cb) { +Return<void> SafeUnion::setInterfaceD(const InterfaceTypeSafeUnion& myUnion, const hidl_string& d, + setInterfaceD_cb _hidl_cb) { LOG(INFO) << "SERVER(SafeUnion) setInterfaceD(myUnion, " << toString(d) << ")"; InterfaceTypeSafeUnion myNewUnion = myUnion; @@ -201,7 +202,8 @@ Return<void> SafeUnion::setInterfaceD(const ::android::hardware::tests::safeunio return Void(); } -Return<void> SafeUnion::setInterfaceE(const ::android::hardware::tests::safeunion::V1_0::ISafeUnion::InterfaceTypeSafeUnion& myUnion, const hidl_vec<hidl_string>& e, setInterfaceE_cb _hidl_cb) { +Return<void> SafeUnion::setInterfaceE(const InterfaceTypeSafeUnion& myUnion, + const hidl_vec<hidl_string>& e, setInterfaceE_cb _hidl_cb) { LOG(INFO) << "SERVER(SafeUnion) setInterfaceE(myUnion, " << toString(e) << ")"; InterfaceTypeSafeUnion myNewUnion = myUnion; @@ -211,6 +213,70 @@ Return<void> SafeUnion::setInterfaceE(const ::android::hardware::tests::safeunio return Void(); } +Return<void> SafeUnion::setInterfaceF(const InterfaceTypeSafeUnion& myUnion, const hidl_handle& f, + setInterfaceF_cb _hidl_cb) { + LOG(INFO) << "SERVER(SafeUnion) setInterfaceF(myUnion, " << toString(f) << ")"; + + InterfaceTypeSafeUnion myNewUnion = myUnion; + myNewUnion.f(f); + + _hidl_cb(myNewUnion); + return Void(); +} + +Return<void> SafeUnion::setInterfaceG(const InterfaceTypeSafeUnion& myUnion, + const hidl_vec<hidl_handle>& g, setInterfaceG_cb _hidl_cb) { + LOG(INFO) << "SERVER(SafeUnion) setInterfaceG(myUnion, " << toString(g) << ")"; + + InterfaceTypeSafeUnion myNewUnion = myUnion; + myNewUnion.g(g); + + _hidl_cb(myNewUnion); + return Void(); +} + +Return<void> SafeUnion::newHandleTypeSafeUnion(newHandleTypeSafeUnion_cb _hidl_cb) { + LOG(INFO) << "SERVER(SafeUnion) newHandleTypeSafeUnion()"; + + HandleTypeSafeUnion ret; + _hidl_cb(ret); + return Void(); +} + +Return<void> SafeUnion::setHandleA( + const ::android::hardware::tests::safeunion::V1_0::ISafeUnion::HandleTypeSafeUnion& myUnion, + const hidl_handle& a, setHandleA_cb _hidl_cb) { + LOG(INFO) << "SERVER(SafeUnion) setHandleA(myUnion, " << toString(a) << ")"; + + HandleTypeSafeUnion myNewUnion = myUnion; + myNewUnion.a(a); + + _hidl_cb(myNewUnion); + return Void(); +} + +Return<void> SafeUnion::setHandleB(const HandleTypeSafeUnion& myUnion, + const hidl_array<hidl_handle, 5>& b, setHandleB_cb _hidl_cb) { + LOG(INFO) << "SERVER(SafeUnion) setHandleB(myUnion, " << toString(b) << ")"; + + HandleTypeSafeUnion myNewUnion = myUnion; + myNewUnion.b(b); + + _hidl_cb(myNewUnion); + return Void(); +} + +Return<void> SafeUnion::setHandleC(const HandleTypeSafeUnion& myUnion, + const hidl_vec<hidl_handle>& c, setHandleC_cb _hidl_cb) { + LOG(INFO) << "SERVER(SafeUnion) setHandleC(myUnion, " << toString(c) << ")"; + + HandleTypeSafeUnion myNewUnion = myUnion; + myNewUnion.c(c); + + _hidl_cb(myNewUnion); + return Void(); +} + ISafeUnion* HIDL_FETCH_ISafeUnion(const char* /* name */) { return new SafeUnion(); } diff --git a/tests/safeunion/1.0/default/SafeUnion.h b/tests/safeunion/1.0/default/SafeUnion.h index e900fcec34..e774e09856 100644 --- a/tests/safeunion/1.0/default/SafeUnion.h +++ b/tests/safeunion/1.0/default/SafeUnion.h @@ -54,6 +54,18 @@ struct SafeUnion : public ISafeUnion { Return<void> setInterfaceC(const InterfaceTypeSafeUnion& myUnion, const sp<::android::hardware::tests::safeunion::V1_0::IOtherInterface>& c, setInterfaceC_cb _hidl_cb) override; Return<void> setInterfaceD(const InterfaceTypeSafeUnion& myUnion, const hidl_string& d, setInterfaceD_cb _hidl_cb) override; Return<void> setInterfaceE(const InterfaceTypeSafeUnion& myUnion, const hidl_vec<hidl_string>& e, setInterfaceE_cb _hidl_cb) override; + Return<void> setInterfaceF(const InterfaceTypeSafeUnion& myUnion, const hidl_handle& f, + setInterfaceF_cb _hidl_cb) override; + Return<void> setInterfaceG(const InterfaceTypeSafeUnion& myUnion, + const hidl_vec<hidl_handle>& g, setInterfaceG_cb _hidl_cb) override; + + Return<void> newHandleTypeSafeUnion(newHandleTypeSafeUnion_cb _hidl_cb) override; + Return<void> setHandleA(const HandleTypeSafeUnion& myUnion, const hidl_handle& a, + setHandleA_cb _hidl_cb) override; + Return<void> setHandleB(const HandleTypeSafeUnion& myUnion, const hidl_array<hidl_handle, 5>& b, + setHandleB_cb _hidl_cb) override; + Return<void> setHandleC(const HandleTypeSafeUnion& myUnion, const hidl_vec<hidl_handle>& c, + setHandleC_cb _hidl_cb) override; }; extern "C" ISafeUnion* HIDL_FETCH_ISafeUnion(const char* name); |