Merge "Adding HIDL interface type to safeunion test HAL"

am: 5f64ae9872

Change-Id: I232939e4bf2e846f44b948d540c27e0a42fc11a2
This commit is contained in:
Nirav Atre 2018-07-06 13:08:29 -07:00 committed by android-build-merger
commit 807848693d
6 changed files with 144 additions and 92 deletions

View file

@ -4,18 +4,12 @@ hidl_interface {
name: "android.hardware.tests.safeunion@1.0",
root: "android.hardware",
srcs: [
"types.hal",
"IOtherInterface.hal",
"ISafeUnion.hal",
],
interfaces: [
"android.hidl.base@1.0",
],
types: [
"EmptySafeUnion",
"SmallSafeUnion",
"LargeSafeUnion",
"MiscTypesSafeUnion",
],
gen_java: false,
}

View file

@ -0,0 +1,21 @@
/*
* Copyright (C) 2018 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 android.hardware.tests.safeunion@1.0;
interface IOtherInterface {
concatTwoStrings(string a, string b) generates (string result);
};

View file

@ -16,7 +16,66 @@
package android.hardware.tests.safeunion@1.0;
import IOtherInterface;
interface ISafeUnion {
enum BitField : uint8_t {
V0 = 1 << 0,
V1 = 1 << 1,
V2 = 1 << 2,
V3 = 1 << 3,
};
struct J {
vec<uint32_t> j1;
uint8_t[65] j2;
string j3;
};
safe_union EmptySafeUnion {
};
safe_union SmallSafeUnion {
uint8_t a;
};
safe_union LargeSafeUnion {
int8_t a;
uint16_t b;
int32_t c;
uint64_t d;
int8_t[13] e;
int64_t[5] f;
string g;
vec<bool> h;
vec<uint64_t> i;
J j;
struct K {
uint8_t k1;
uint64_t k2;
} k;
SmallSafeUnion l;
};
// TODO(b/110269925): Test more HIDL types. Missing:
// death_recipient, fmq_{sync,unsync}, pointer, ref.
safe_union MiscTypesSafeUnion {
memory a;
handle b;
bitfield<BitField> c;
};
safe_union InterfaceTypeSafeUnion {
uint32_t a;
int8_t[7] b;
IOtherInterface c;
};
newLargeSafeUnion() generates (LargeSafeUnion myUnion);
setA(LargeSafeUnion myUnion, int8_t a) generates (LargeSafeUnion myUnion);
setB(LargeSafeUnion myUnion, uint16_t b) generates (LargeSafeUnion myUnion);
@ -28,11 +87,16 @@ interface ISafeUnion {
setH(LargeSafeUnion myUnion, vec<bool> h) generates (LargeSafeUnion myUnion);
setI(LargeSafeUnion myUnion, vec<uint64_t> i) generates (LargeSafeUnion myUnion);
setJ(LargeSafeUnion myUnion, J j) generates (LargeSafeUnion myUnion);
setK(LargeSafeUnion myUnion, K k) generates (LargeSafeUnion myUnion);
setK(LargeSafeUnion myUnion, LargeSafeUnion.K k) generates (LargeSafeUnion myUnion);
setL(LargeSafeUnion myUnion, SmallSafeUnion l) generates (LargeSafeUnion myUnion);
newMiscTypesSafeUnion() generates (MiscTypesSafeUnion myUnion);
setMiscA(MiscTypesSafeUnion myUnion, memory a) generates (MiscTypesSafeUnion myUnion);
setMiscB(MiscTypesSafeUnion myUnion, handle b) generates (MiscTypesSafeUnion myUnion);
setMiscC(MiscTypesSafeUnion myUnion, bitfield<BitField> c) generates (MiscTypesSafeUnion myUnion);
newInterfaceTypeSafeUnion() generates (InterfaceTypeSafeUnion myUnion);
setInterfaceA(InterfaceTypeSafeUnion myUnion, uint32_t a) generates (InterfaceTypeSafeUnion myUnion);
setInterfaceB(InterfaceTypeSafeUnion myUnion, int8_t[7] b) generates (InterfaceTypeSafeUnion myUnion);
setInterfaceC(InterfaceTypeSafeUnion myUnion, IOtherInterface c) generates (InterfaceTypeSafeUnion myUnion);
};

View file

@ -73,7 +73,7 @@ Return<void> SafeUnion::setD(const LargeSafeUnion& myUnion, uint64_t d, setD_cb
return Void();
}
Return<void> SafeUnion::setE(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_array<int8_t, 13>& e, setE_cb _hidl_cb) {
Return<void> SafeUnion::setE(const LargeSafeUnion& myUnion, const hidl_array<int8_t, 13>& e, setE_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setE(myUnion, " << toString(e) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -83,7 +83,7 @@ Return<void> SafeUnion::setE(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setF(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_array<int64_t, 5>& f, setF_cb _hidl_cb) {
Return<void> SafeUnion::setF(const LargeSafeUnion& myUnion, const hidl_array<int64_t, 5>& f, setF_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setF(myUnion, " << toString(f) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -93,7 +93,7 @@ Return<void> SafeUnion::setF(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setG(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_string& g, setG_cb _hidl_cb) {
Return<void> SafeUnion::setG(const LargeSafeUnion& myUnion, const hidl_string& g, setG_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setG(myUnion, " << toString(g) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -103,7 +103,7 @@ Return<void> SafeUnion::setG(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setH(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_vec<bool>& h, setH_cb _hidl_cb) {
Return<void> SafeUnion::setH(const LargeSafeUnion& myUnion, const hidl_vec<bool>& h, setH_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setH(myUnion, " << toString(h) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -113,7 +113,7 @@ Return<void> SafeUnion::setH(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setI(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_vec<uint64_t>& i, setI_cb _hidl_cb) {
Return<void> SafeUnion::setI(const LargeSafeUnion& myUnion, const hidl_vec<uint64_t>& i, setI_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setI(myUnion, " << toString(i) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -123,7 +123,7 @@ Return<void> SafeUnion::setI(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setJ(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const J& j, setJ_cb _hidl_cb) {
Return<void> SafeUnion::setJ(const LargeSafeUnion& myUnion, const J& j, setJ_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setJ(myUnion, " << toString(j) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -133,7 +133,7 @@ Return<void> SafeUnion::setJ(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setK(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const LargeSafeUnion::K& k, setK_cb _hidl_cb) {
Return<void> SafeUnion::setK(const LargeSafeUnion& myUnion, const LargeSafeUnion::K& k, setK_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setK(myUnion, " << toString(k) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -143,7 +143,7 @@ Return<void> SafeUnion::setK(const ::android::hardware::tests::safeunion::V1_0::
return Void();
}
Return<void> SafeUnion::setL(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const ::android::hardware::tests::safeunion::V1_0::SmallSafeUnion& l, setL_cb _hidl_cb) {
Return<void> SafeUnion::setL(const LargeSafeUnion& myUnion, const SmallSafeUnion& l, setL_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setL(myUnion, " << toString(l) << ")";
LargeSafeUnion myNewUnion = myUnion;
@ -161,7 +161,7 @@ Return<void> SafeUnion::newMiscTypesSafeUnion(newMiscTypesSafeUnion_cb _hidl_cb)
return Void();
}
Return<void> SafeUnion::setMiscA(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_memory& a, setMiscA_cb _hidl_cb) {
Return<void> SafeUnion::setMiscA(const MiscTypesSafeUnion& myUnion, const hidl_memory& a, setMiscA_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setMiscA(myUnion, " << toString(a) << ")";
MiscTypesSafeUnion myNewUnion = myUnion;
@ -171,7 +171,7 @@ Return<void> SafeUnion::setMiscA(const ::android::hardware::tests::safeunion::V1
return Void();
}
Return<void> SafeUnion::setMiscB(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_handle& b, setMiscB_cb _hidl_cb) {
Return<void> SafeUnion::setMiscB(const MiscTypesSafeUnion& myUnion, const hidl_handle& b, setMiscB_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setMiscB(myUnion, " << toString(b) << ")";
MiscTypesSafeUnion myNewUnion = myUnion;
@ -181,7 +181,7 @@ Return<void> SafeUnion::setMiscB(const ::android::hardware::tests::safeunion::V1
return Void();
}
Return<void> SafeUnion::setMiscC(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, hidl_bitfield<BitField> c, setMiscC_cb _hidl_cb) {
Return<void> SafeUnion::setMiscC(const MiscTypesSafeUnion& myUnion, hidl_bitfield<BitField> c, setMiscC_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setMiscC(myUnion, " << c << ")";
MiscTypesSafeUnion myNewUnion = myUnion;
@ -191,6 +191,43 @@ Return<void> SafeUnion::setMiscC(const ::android::hardware::tests::safeunion::V1
return Void();
}
Return<void> SafeUnion::newInterfaceTypeSafeUnion(newInterfaceTypeSafeUnion_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) newInterfaceTypeSafeUnion()";
InterfaceTypeSafeUnion ret;
_hidl_cb(ret);
return Void();
}
Return<void> SafeUnion::setInterfaceA(const InterfaceTypeSafeUnion& myUnion, uint32_t a, setInterfaceA_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setInterfaceA(myUnion, " << a << ")";
InterfaceTypeSafeUnion myNewUnion = myUnion;
myNewUnion.a(a);
_hidl_cb(myNewUnion);
return Void();
}
Return<void> SafeUnion::setInterfaceB(const InterfaceTypeSafeUnion& myUnion, const hidl_array<int8_t, 7>& b, setInterfaceB_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setInterfaceB(myUnion, " << toString(b) << ")";
InterfaceTypeSafeUnion myNewUnion = myUnion;
myNewUnion.b(b);
_hidl_cb(myNewUnion);
return Void();
}
Return<void> SafeUnion::setInterfaceC(const InterfaceTypeSafeUnion& myUnion, const sp<::android::hardware::tests::safeunion::V1_0::IOtherInterface>& c, setInterfaceC_cb _hidl_cb) {
LOG(INFO) << "SERVER(SafeUnion) setInterfaceC(myUnion, " << toString(c) << ")";
InterfaceTypeSafeUnion myNewUnion = myUnion;
myNewUnion.c(c);
_hidl_cb(myNewUnion);
return Void();
}
ISafeUnion* HIDL_FETCH_ISafeUnion(const char* /* name */) {
return new SafeUnion();

View file

@ -30,9 +30,7 @@ namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::tests::safeunion::V1_0::SmallSafeUnion;
using ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion;
using ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion;
using ::android::hardware::tests::safeunion::V1_0::ISafeUnion;
struct SafeUnion : public ISafeUnion {
// Methods from ::android::hardware::tests::safeunion::V1_0::ISafeUnion follow.
@ -51,9 +49,14 @@ struct SafeUnion : public ISafeUnion {
Return<void> setL(const LargeSafeUnion& myUnion, const SmallSafeUnion& l, setL_cb _hidl_cb) override;
Return<void> newMiscTypesSafeUnion(newMiscTypesSafeUnion_cb _hidl_cb) override;
Return<void> setMiscA(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_memory& a, setMiscA_cb _hidl_cb) override;
Return<void> setMiscB(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_handle& b, setMiscB_cb _hidl_cb) override;
Return<void> setMiscC(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, hidl_bitfield<BitField> c, setMiscC_cb _hidl_cb) override;
Return<void> setMiscA(const MiscTypesSafeUnion& myUnion, const hidl_memory& a, setMiscA_cb _hidl_cb) override;
Return<void> setMiscB(const MiscTypesSafeUnion& myUnion, const hidl_handle& b, setMiscB_cb _hidl_cb) override;
Return<void> setMiscC(const MiscTypesSafeUnion& myUnion, hidl_bitfield<BitField> c, setMiscC_cb _hidl_cb) override;
Return<void> newInterfaceTypeSafeUnion(newInterfaceTypeSafeUnion_cb _hidl_cb) override;
Return<void> setInterfaceA(const InterfaceTypeSafeUnion& myUnion, uint32_t a, setInterfaceA_cb _hidl_cb) override;
Return<void> setInterfaceB(const InterfaceTypeSafeUnion& myUnion, const hidl_array<int8_t, 7>& b, setInterfaceB_cb _hidl_cb) override;
Return<void> setInterfaceC(const InterfaceTypeSafeUnion& myUnion, const sp<::android::hardware::tests::safeunion::V1_0::IOtherInterface>& c, setInterfaceC_cb _hidl_cb) override;
};
extern "C" ISafeUnion* HIDL_FETCH_ISafeUnion(const char* name);

View file

@ -1,67 +0,0 @@
/*
* Copyright (C) 2018 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 android.hardware.tests.safeunion@1.0;
enum BitField : uint8_t {
V0 = 1 << 0,
V1 = 1 << 1,
V2 = 1 << 2,
V3 = 1 << 3,
};
struct J {
vec<uint32_t> j1;
uint8_t[65] j2;
string j3;
};
safe_union EmptySafeUnion {
};
safe_union SmallSafeUnion {
uint8_t a;
};
safe_union LargeSafeUnion {
int8_t a;
uint16_t b;
int32_t c;
uint64_t d;
int8_t[13] e;
int64_t[5] f;
string g;
vec<bool> h;
vec<uint64_t> i;
J j;
struct K {
uint8_t k1;
uint64_t k2;
} k;
SmallSafeUnion l;
};
// TODO(b/110269925): Test more HIDL types. Missing:
// death_recipient, fmq_{sync,unsync}, pointer, ref.
safe_union MiscTypesSafeUnion {
memory a;
handle b;
bitfield<BitField> c;
};