Fix tests for using IBase instead of IBinder.

Echoed interfaces cannot be casted properly, because
interfaceChain cannot be called. So the given vector
of interfaces is re-wrapped. This is temporary; when
b/33173166 is fixed, this change should be reverted.

Test: hidl_test

Generates: b/33173166

Change-Id: I12166f69cf04abf7485dc2455ad731b87c80b3d1
This commit is contained in:
Yifan Hong
2016-11-28 14:50:15 -08:00
parent 76dd1951ae
commit 0bd75e02b0

View File

@@ -122,10 +122,36 @@ Return<void> Bar::haveAVectorOfInterfaces(
return Void();
}
// TODO: remove after b/33173166 is fixed.
struct Simple : public ISimple {
Simple(int32_t cookie)
: mCookie(cookie) {
}
Return<int32_t> getCookie() override {
return mCookie;
}
private:
int32_t mCookie;
};
// TODO: use _hidl_cb(in) after b/33173166 is fixed.
Return<void> Bar::haveAVectorOfGenericInterfaces(
const hidl_vec<sp<android::hidl::base::V1_0::IBase> > &in,
haveAVectorOfGenericInterfaces_cb _hidl_cb) {
_hidl_cb(in);
// _hidl_cb(in);
hidl_vec<sp<android::hidl::base::V1_0::IBase> > out;
out.resize(in.size());
for (size_t i = 0; i < in.size(); ++i) {
sp<ISimple> s = ISimple::castFrom(in[i]);
if (s.get() == nullptr) {
out[i] = new Simple(-1);
} else {
out[i] = new Simple(s->getCookie());
}
}
_hidl_cb(out);
return Void();
}