upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
0
android/hardware/interfaces/tests/foo/1.0/.hidl_for_test
Normal file
0
android/hardware/interfaces/tests/foo/1.0/.hidl_for_test
Normal file
91
android/hardware/interfaces/tests/foo/1.0/Android.bp
Normal file
91
android/hardware/interfaces/tests/foo/1.0/Android.bp
Normal file
|
@ -0,0 +1,91 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.tests.foo@1.0_hal",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IFoo.hal",
|
||||
"IFooCallback.hal",
|
||||
"IMyTypes.hal",
|
||||
"ISimple.hal",
|
||||
"ITheirTypes.hal",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.tests.foo@1.0_genc++",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.foo@1.0",
|
||||
srcs: [
|
||||
":android.hardware.tests.foo@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/tests/foo/1.0/types.cpp",
|
||||
"android/hardware/tests/foo/1.0/FooAll.cpp",
|
||||
"android/hardware/tests/foo/1.0/FooCallbackAll.cpp",
|
||||
"android/hardware/tests/foo/1.0/MyTypesAll.cpp",
|
||||
"android/hardware/tests/foo/1.0/SimpleAll.cpp",
|
||||
"android/hardware/tests/foo/1.0/TheirTypesAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.tests.foo@1.0_genc++_headers",
|
||||
tools: ["hidl-gen"],
|
||||
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.tests.foo@1.0",
|
||||
srcs: [
|
||||
":android.hardware.tests.foo@1.0_hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/tests/foo/1.0/types.h",
|
||||
"android/hardware/tests/foo/1.0/hwtypes.h",
|
||||
"android/hardware/tests/foo/1.0/IFoo.h",
|
||||
"android/hardware/tests/foo/1.0/IHwFoo.h",
|
||||
"android/hardware/tests/foo/1.0/BnHwFoo.h",
|
||||
"android/hardware/tests/foo/1.0/BpHwFoo.h",
|
||||
"android/hardware/tests/foo/1.0/BsFoo.h",
|
||||
"android/hardware/tests/foo/1.0/IFooCallback.h",
|
||||
"android/hardware/tests/foo/1.0/IHwFooCallback.h",
|
||||
"android/hardware/tests/foo/1.0/BnHwFooCallback.h",
|
||||
"android/hardware/tests/foo/1.0/BpHwFooCallback.h",
|
||||
"android/hardware/tests/foo/1.0/BsFooCallback.h",
|
||||
"android/hardware/tests/foo/1.0/IMyTypes.h",
|
||||
"android/hardware/tests/foo/1.0/IHwMyTypes.h",
|
||||
"android/hardware/tests/foo/1.0/BnHwMyTypes.h",
|
||||
"android/hardware/tests/foo/1.0/BpHwMyTypes.h",
|
||||
"android/hardware/tests/foo/1.0/BsMyTypes.h",
|
||||
"android/hardware/tests/foo/1.0/ISimple.h",
|
||||
"android/hardware/tests/foo/1.0/IHwSimple.h",
|
||||
"android/hardware/tests/foo/1.0/BnHwSimple.h",
|
||||
"android/hardware/tests/foo/1.0/BpHwSimple.h",
|
||||
"android/hardware/tests/foo/1.0/BsSimple.h",
|
||||
"android/hardware/tests/foo/1.0/ITheirTypes.h",
|
||||
"android/hardware/tests/foo/1.0/IHwTheirTypes.h",
|
||||
"android/hardware/tests/foo/1.0/BnHwTheirTypes.h",
|
||||
"android/hardware/tests/foo/1.0/BpHwTheirTypes.h",
|
||||
"android/hardware/tests/foo/1.0/BsTheirTypes.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.tests.foo@1.0",
|
||||
defaults: ["hidl-module-defaults"],
|
||||
generated_sources: ["android.hardware.tests.foo@1.0_genc++"],
|
||||
generated_headers: ["android.hardware.tests.foo@1.0_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.tests.foo@1.0_genc++_headers"],
|
||||
vendor_available: true,
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
export_shared_lib_headers: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
],
|
||||
}
|
163
android/hardware/interfaces/tests/foo/1.0/IFoo.hal
Normal file
163
android/hardware/interfaces/tests/foo/1.0/IFoo.hal
Normal file
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.foo@1.0;
|
||||
|
||||
import IFooCallback;
|
||||
import IMyTypes.SomeStruct;
|
||||
import ISimple;
|
||||
import ITheirTypes.FloatArray;
|
||||
|
||||
interface IFoo {
|
||||
|
||||
enum SomeBaseEnum : uint8_t {
|
||||
bar = 66
|
||||
};
|
||||
|
||||
enum SomeEnum : SomeBaseEnum {
|
||||
quux = 33,
|
||||
goober = 192,
|
||||
blah = goober
|
||||
};
|
||||
|
||||
enum BitField : uint8_t {
|
||||
V0 = 1 << 0,
|
||||
V1 = 1 << 1,
|
||||
V2 = 1 << 2,
|
||||
V3 = 1 << 3,
|
||||
VALL = V0 | V1 | V2 | V3,
|
||||
};
|
||||
|
||||
struct Fumble {
|
||||
Outer.Inner data;
|
||||
};
|
||||
|
||||
typedef Fumble Gumble;
|
||||
|
||||
struct Goober {
|
||||
int32_t q;
|
||||
string name;
|
||||
string address;
|
||||
double[10] numbers;
|
||||
Fumble fumble;
|
||||
Gumble gumble;
|
||||
// vec<double> lotsOfFumbles;
|
||||
// handle loveHandle;
|
||||
};
|
||||
|
||||
typedef float[3] ThreeFloats;
|
||||
typedef float[5] FiveFloats;
|
||||
|
||||
struct Quux {
|
||||
string first;
|
||||
string last;
|
||||
};
|
||||
|
||||
typedef Quux[3] ThreeQuuxes;
|
||||
|
||||
struct MultiDimensional {
|
||||
ThreeQuuxes[5] quuxMatrix;
|
||||
};
|
||||
|
||||
typedef string[3] ThreeStrings;
|
||||
typedef string[5] FiveStrings;
|
||||
|
||||
struct StringMatrix3x5 {
|
||||
FiveStrings[3] s;
|
||||
};
|
||||
|
||||
struct StringMatrix5x3 {
|
||||
ThreeStrings[5] s;
|
||||
};
|
||||
|
||||
struct MyStruct {
|
||||
SomeStruct innerStruct;
|
||||
FloatArray myFloatArray;
|
||||
};
|
||||
|
||||
struct MyHandle {
|
||||
handle h;
|
||||
int32_t guard;
|
||||
};
|
||||
|
||||
struct MyMask {
|
||||
bitfield<BitField> value;
|
||||
};
|
||||
|
||||
typedef bitfield<BitField> Mask;
|
||||
|
||||
struct Everything {
|
||||
union U {
|
||||
int8_t number;
|
||||
int8_t[1][2] multidimArray;
|
||||
pointer p;
|
||||
Fumble anotherStruct;
|
||||
bitfield<BitField> bf;
|
||||
} u;
|
||||
|
||||
int8_t number;
|
||||
handle h;
|
||||
fmq_sync<uint8_t> descSync;
|
||||
fmq_unsync<uint8_t> descUnsync;
|
||||
memory mem;
|
||||
pointer p;
|
||||
string s;
|
||||
vec<string> vs;
|
||||
string[2][2] multidimArray;
|
||||
string[3] sArray;
|
||||
Quux anotherStruct;
|
||||
bitfield<BitField> bf;
|
||||
};
|
||||
|
||||
doThis(float param);
|
||||
doThatAndReturnSomething(int64_t param) generates (int32_t result);
|
||||
doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
|
||||
doSomethingElse(int32_t[15] param) generates (int32_t[32] something);
|
||||
doStuffAndReturnAString() generates (string something);
|
||||
mapThisVector(vec<int32_t> param) generates (vec<int32_t> something);
|
||||
oneway callMe(IFooCallback cb);
|
||||
useAnEnum(SomeEnum zzz) generates (SomeEnum sleepy);
|
||||
|
||||
haveAGooberVec(vec<Goober> param);
|
||||
haveAGoober(Goober g);
|
||||
haveAGooberArray(Goober[20] lots);
|
||||
|
||||
haveATypeFromAnotherFile(Abc def);
|
||||
|
||||
haveSomeStrings(string[3] array) generates (string[2] result);
|
||||
haveAStringVec(vec<string> vector) generates (vec<string> result);
|
||||
|
||||
transposeMe(FiveFloats[3] in) generates (ThreeFloats[5] out);
|
||||
callingDrWho(MultiDimensional in) generates (MultiDimensional out);
|
||||
|
||||
transpose(StringMatrix5x3 in) generates (StringMatrix3x5 out);
|
||||
transpose2(ThreeStrings[5] in) generates (FiveStrings[3] out);
|
||||
|
||||
sendVec(vec<uint8_t> data) generates (vec<uint8_t> data);
|
||||
|
||||
sendVecVec() generates (vec<vec<uint8_t>> vecvec);
|
||||
|
||||
haveAVectorOfInterfaces(vec<ISimple> in) generates (vec<ISimple> out);
|
||||
|
||||
haveAVectorOfGenericInterfaces(vec<interface> in)
|
||||
generates (vec<interface> out);
|
||||
|
||||
echoNullInterface(IFooCallback cb) generates (bool receivedNull, IFooCallback cb);
|
||||
|
||||
createMyHandle() generates (MyHandle h);
|
||||
createHandles(uint32_t size) generates (vec<handle> handles);
|
||||
closeHandles();
|
||||
};
|
53
android/hardware/interfaces/tests/foo/1.0/IFooCallback.hal
Normal file
53
android/hardware/interfaces/tests/foo/1.0/IFooCallback.hal
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.foo@1.0;
|
||||
|
||||
//import IFoo;
|
||||
|
||||
interface IFooCallback {
|
||||
//heyItsMe(IFoo cb);
|
||||
heyItsYou(IFooCallback cb);
|
||||
heyItsYouIsntIt(IFooCallback cb) generates (bool yesOrNo);
|
||||
oneway heyItsTheMeaningOfLife(uint8_t tmol);
|
||||
|
||||
// The next two methods are for instrumentation purposes.
|
||||
|
||||
// Block the caller for up to ns nanosesonds and return the number
|
||||
// of nanoseconds it took to invoke each of the three methods
|
||||
// above, both from the point of view of the caller (callerBlockedNs) and
|
||||
// from the point of view of IFooCallback itself (timeNs). timeNs measures
|
||||
// how long a method's body took to execute, regardless of whether the
|
||||
// method was oneway or two-way. callerBlockedNs reflects the amount of
|
||||
// time the caller was blocked before the method returned. For two-way
|
||||
// methods, callerBlockedNs should be slightly higher than timeNs. For
|
||||
// one-way calls, callerBlockedNs will be very low, and unrelated to
|
||||
// timeNs.
|
||||
|
||||
struct InvokeInfo {
|
||||
bool invoked;
|
||||
int64_t callerBlockedNs;
|
||||
int64_t timeNs;
|
||||
};
|
||||
reportResults(int64_t ns) generates (int64_t leftNs, InvokeInfo[3] invokeInfo);
|
||||
|
||||
// This method is used by the caller of IFooCallback to tell IFooCallback
|
||||
// how long the three methods above took, from the point of view of that
|
||||
// caller. IFooCallback adds this information to the one reported by
|
||||
// reportResults in InvokeInfo.
|
||||
|
||||
youBlockedMeFor(int64_t[3] callerBlockedInfo);
|
||||
};
|
24
android/hardware/interfaces/tests/foo/1.0/IMyTypes.hal
Normal file
24
android/hardware/interfaces/tests/foo/1.0/IMyTypes.hal
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.foo@1.0;
|
||||
|
||||
|
||||
interface IMyTypes {
|
||||
struct SomeStruct {
|
||||
};
|
||||
typedef float[30] FloatArray;
|
||||
};
|
25
android/hardware/interfaces/tests/foo/1.0/ISimple.hal
Normal file
25
android/hardware/interfaces/tests/foo/1.0/ISimple.hal
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.foo@1.0;
|
||||
|
||||
interface ISimple {
|
||||
getCookie() generates (int32_t cookie);
|
||||
customVecInt() generates (vec<int32_t> chain);
|
||||
customVecStr() generates (vec<string> chain);
|
||||
mystr() generates (string str);
|
||||
myhandle() generates (handle str);
|
||||
};
|
24
android/hardware/interfaces/tests/foo/1.0/ITheirTypes.hal
Normal file
24
android/hardware/interfaces/tests/foo/1.0/ITheirTypes.hal
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.foo@1.0;
|
||||
|
||||
|
||||
interface ITheirTypes {
|
||||
struct SomeStruct {
|
||||
};
|
||||
typedef float[10] FloatArray;
|
||||
};
|
22
android/hardware/interfaces/tests/foo/1.0/default/Android.bp
Normal file
22
android/hardware/interfaces/tests/foo/1.0/default/Android.bp
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.tests.foo@1.0-impl",
|
||||
defaults: ["hidl_defaults"],
|
||||
relative_install_path: "hw",
|
||||
srcs: [
|
||||
"Foo.cpp",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libfootest",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.tests.foo@1.0",
|
||||
],
|
||||
|
||||
}
|
367
android/hardware/interfaces/tests/foo/1.0/default/Foo.cpp
Normal file
367
android/hardware/interfaces/tests/foo/1.0/default/Foo.cpp
Normal file
|
@ -0,0 +1,367 @@
|
|||
|
||||
#define LOG_TAG "hidl_test"
|
||||
|
||||
#include "Foo.h"
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl-test/FooHelper.h>
|
||||
#include <inttypes.h>
|
||||
#include <utils/Timers.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace tests {
|
||||
namespace foo {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
|
||||
Return<void> Foo::doThis(float param) {
|
||||
LOG(INFO) << "SERVER(Foo) doThis(" << param << ")";
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<int32_t> Foo::doThatAndReturnSomething(
|
||||
int64_t param) {
|
||||
LOG(INFO) << "SERVER(Foo) doThatAndReturnSomething(" << param << ")";
|
||||
|
||||
return 666;
|
||||
}
|
||||
|
||||
Return<double> Foo::doQuiteABit(
|
||||
int32_t a,
|
||||
int64_t b,
|
||||
float c,
|
||||
double d) {
|
||||
LOG(INFO) << "SERVER(Foo) doQuiteABit("
|
||||
<< a
|
||||
<< ", "
|
||||
<< b
|
||||
<< ", "
|
||||
<< c
|
||||
<< ", "
|
||||
<< d
|
||||
<< ")";
|
||||
|
||||
return 666.5;
|
||||
}
|
||||
|
||||
Return<void> Foo::doSomethingElse(
|
||||
const hidl_array<int32_t, 15> ¶m, doSomethingElse_cb _cb) {
|
||||
LOG(INFO) << "SERVER(Foo) doSomethingElse(...)";
|
||||
|
||||
hidl_array<int32_t, 32> result;
|
||||
for (size_t i = 0; i < 15; ++i) {
|
||||
result[i] = 2 * param[i];
|
||||
result[15 + i] = param[i];
|
||||
}
|
||||
result[30] = 1;
|
||||
result[31] = 2;
|
||||
|
||||
_cb(result);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::doStuffAndReturnAString(
|
||||
doStuffAndReturnAString_cb _cb) {
|
||||
LOG(INFO) << "SERVER(Foo) doStuffAndReturnAString";
|
||||
|
||||
_cb("Hello, world");
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::mapThisVector(
|
||||
const hidl_vec<int32_t> ¶m, mapThisVector_cb _cb) {
|
||||
LOG(INFO) << "SERVER(Foo) mapThisVector";
|
||||
|
||||
hidl_vec<int32_t> out;
|
||||
out.resize(param.size());
|
||||
|
||||
for (size_t i = 0; i < out.size(); ++i) {
|
||||
out[i] = param[i] * 2;
|
||||
}
|
||||
|
||||
_cb(out);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::callMe(
|
||||
const sp<IFooCallback> &cb) {
|
||||
LOG(INFO) << "SERVER(Foo) callMe " << cb.get();
|
||||
|
||||
if (cb != NULL) {
|
||||
hidl_array<nsecs_t, 3> c;
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " calling IFooCallback::heyItsYou, should return immediately";
|
||||
c[0] = systemTime();
|
||||
cb->heyItsYou(cb);
|
||||
c[0] = systemTime() - c[0];
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " calling IFooCallback::heyItsYou, returned after"
|
||||
<< c[0]
|
||||
<< "ns";
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " calling IFooCallback::heyItsYouIsntIt, should block for"
|
||||
<< DELAY_S
|
||||
<< " seconds";
|
||||
c[1] = systemTime();
|
||||
bool answer = cb->heyItsYouIsntIt(cb);
|
||||
c[1] = systemTime() - c[1];
|
||||
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " calling IFooCallback::heyItsYouIsntIt, responded with "
|
||||
<< answer
|
||||
<< " after "
|
||||
<< c[1]
|
||||
<< "ns";
|
||||
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " calling IFooCallback::heyItsTheMeaningOfLife,"
|
||||
<< " should return immediately";
|
||||
c[2] = systemTime();
|
||||
cb->heyItsTheMeaningOfLife(42);
|
||||
c[2] = systemTime() - c[2];
|
||||
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " cAfter call to IFooCallback::heyItsTheMeaningOfLife responded after "
|
||||
<< c[2]
|
||||
<< "ns";
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " calling IFooCallback::youBlockedMeFor to report times";
|
||||
cb->youBlockedMeFor(c);
|
||||
LOG(INFO) << "SERVER(Foo) callMe "
|
||||
<< cb.get()
|
||||
<< " After call to IFooCallback::youBlockedMeFor";
|
||||
}
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Foo::SomeEnum> Foo::useAnEnum(SomeEnum param) {
|
||||
LOG(INFO) << "SERVER(Foo) useAnEnum " << (int)param;
|
||||
|
||||
return SomeEnum::goober;
|
||||
}
|
||||
|
||||
Return<void> Foo::haveAGooberVec(const hidl_vec<Goober>& param) {
|
||||
LOG(INFO) << "SERVER(Foo) haveAGooberVec ¶m = " << ¶m;
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveAGoober(const Goober &g) {
|
||||
LOG(INFO) << "SERVER(Foo) haveaGoober g=" << &g;
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveAGooberArray(const hidl_array<Goober, 20> & /* lots */) {
|
||||
LOG(INFO) << "SERVER(Foo) haveAGooberArray";
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveATypeFromAnotherFile(const Abc &def) {
|
||||
LOG(INFO) << "SERVER(Foo) haveATypeFromAnotherFile def=" << &def;
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveSomeStrings(
|
||||
const hidl_array<hidl_string, 3> &array,
|
||||
haveSomeStrings_cb _cb) {
|
||||
|
||||
LOG(INFO) << "SERVER(Foo) haveSomeStrings([\""
|
||||
<< array[0].c_str()
|
||||
<< "\", \""
|
||||
<< array[1].c_str()
|
||||
<< "\", \""
|
||||
<< array[2].c_str()
|
||||
<< "\"])";
|
||||
|
||||
hidl_array<hidl_string, 2> result;
|
||||
result[0] = "Hello";
|
||||
result[1] = "World";
|
||||
|
||||
_cb(result);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveAStringVec(
|
||||
const hidl_vec<hidl_string> &vector,
|
||||
haveAStringVec_cb _cb) {
|
||||
LOG(INFO) << "SERVER(Foo) haveAStringVec([\""
|
||||
<< vector[0].c_str()
|
||||
<< "\", \""
|
||||
<< vector[1].c_str()
|
||||
<< "\", \""
|
||||
<< vector[2].c_str()
|
||||
<< "\"])";
|
||||
|
||||
hidl_vec<hidl_string> result;
|
||||
result.resize(2);
|
||||
|
||||
result[0] = "Hello";
|
||||
result[1] = "World";
|
||||
|
||||
_cb(result);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::transposeMe(
|
||||
const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) {
|
||||
LOG(INFO) << "SERVER(Foo) transposeMe(" << to_string(in).c_str() << ")";
|
||||
|
||||
hidl_array<float, 5, 3> out;
|
||||
for (size_t i = 0; i < 5; ++i) {
|
||||
for (size_t j = 0; j < 3; ++j) {
|
||||
out[i][j] = in[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
LOG(INFO) << "SERVER(Foo) transposeMe returning " << to_string(out).c_str();
|
||||
|
||||
_cb(out);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::callingDrWho(
|
||||
const MultiDimensional &in, callingDrWho_cb _hidl_cb) {
|
||||
LOG(INFO) << "SERVER(Foo) callingDrWho(" << MultiDimensionalToString(in).c_str() << ")";
|
||||
|
||||
MultiDimensional out;
|
||||
for (size_t i = 0; i < 5; ++i) {
|
||||
for (size_t j = 0; j < 3; ++j) {
|
||||
out.quuxMatrix[i][j].first = in.quuxMatrix[4 - i][2 - j].last;
|
||||
out.quuxMatrix[i][j].last = in.quuxMatrix[4 - i][2 - j].first;
|
||||
}
|
||||
}
|
||||
|
||||
_hidl_cb(out);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::transpose(const StringMatrix5x3 &in, transpose_cb _hidl_cb) {
|
||||
LOG(INFO) << "SERVER(Foo) transpose " << to_string(in);
|
||||
|
||||
StringMatrix3x5 out;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
for (size_t j = 0; j < 5; ++j) {
|
||||
out.s[i][j] = in.s[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
_hidl_cb(out);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::transpose2(
|
||||
const hidl_array<hidl_string, 5, 3> &in, transpose2_cb _hidl_cb) {
|
||||
LOG(INFO) << "SERVER(Foo) transpose2 " << to_string(in);
|
||||
|
||||
hidl_array<hidl_string, 3, 5> out;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
for (size_t j = 0; j < 5; ++j) {
|
||||
out[i][j] = in[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
_hidl_cb(out);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::sendVec(
|
||||
const hidl_vec<uint8_t> &data, sendVec_cb _hidl_cb) {
|
||||
_hidl_cb(data);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::sendVecVec(sendVecVec_cb _hidl_cb) {
|
||||
hidl_vec<hidl_vec<uint8_t>> data;
|
||||
_hidl_cb(data);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveAVectorOfInterfaces(
|
||||
const hidl_vec<sp<ISimple> > &in,
|
||||
haveAVectorOfInterfaces_cb _hidl_cb) {
|
||||
_hidl_cb(in);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::haveAVectorOfGenericInterfaces(
|
||||
const hidl_vec<sp<android::hidl::base::V1_0::IBase> > &in,
|
||||
haveAVectorOfGenericInterfaces_cb _hidl_cb) {
|
||||
_hidl_cb(in);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::createMyHandle(createMyHandle_cb _hidl_cb) {
|
||||
native_handle_t* nh = native_handle_create(0, 10);
|
||||
int data[] = {2,3,5,7,11,13,17,19,21,23};
|
||||
CHECK(sizeof(data) == 10 * sizeof(int));
|
||||
memcpy(nh->data, data, sizeof(data));
|
||||
mHandles.push_back(nh);
|
||||
|
||||
MyHandle h;
|
||||
h.guard = 666;
|
||||
h.h = nh;
|
||||
_hidl_cb(h);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::createHandles(uint32_t size, createHandles_cb _hidl_cb) {
|
||||
hidl_vec<hidl_handle> handles;
|
||||
handles.resize(size);
|
||||
for(uint32_t i = 0; i < size; ++i) {
|
||||
createMyHandle([&](const MyHandle& h) {
|
||||
handles[i] = h.h;
|
||||
});
|
||||
}
|
||||
_hidl_cb(handles);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::closeHandles() {
|
||||
for(native_handle_t* h : mHandles) {
|
||||
native_handle_delete(h);
|
||||
}
|
||||
mHandles.clear();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::echoNullInterface(const sp<IFooCallback> &cb, echoNullInterface_cb _hidl_cb) {
|
||||
_hidl_cb(cb == nullptr, cb);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
IFoo* HIDL_FETCH_IFoo(const char* /* name */) {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace foo
|
||||
} // namespace tests
|
||||
} // namespace hardware
|
||||
} // namespace android
|
74
android/hardware/interfaces/tests/foo/1.0/default/Foo.h
Normal file
74
android/hardware/interfaces/tests/foo/1.0/default/Foo.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
#ifndef ANDROID_HARDWARE_TESTS_FOO_V1_0_FOO_H
|
||||
#define ANDROID_HARDWARE_TESTS_FOO_V1_0_FOO_H
|
||||
|
||||
#include <android/hardware/tests/foo/1.0/IFoo.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <vector>
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace tests {
|
||||
namespace foo {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::tests::foo::V1_0::Abc;
|
||||
using ::android::hardware::tests::foo::V1_0::IFoo;
|
||||
using ::android::hardware::tests::foo::V1_0::IFooCallback;
|
||||
using ::android::hardware::tests::foo::V1_0::ISimple;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct Foo : public IFoo {
|
||||
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
|
||||
virtual Return<void> doThis(float param) override;
|
||||
virtual Return<int32_t> doThatAndReturnSomething(int64_t param) override;
|
||||
virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d) override;
|
||||
virtual Return<void> doSomethingElse(const hidl_array<int32_t, 15 /* 15 */>& param, doSomethingElse_cb _hidl_cb) override;
|
||||
virtual Return<void> doStuffAndReturnAString(doStuffAndReturnAString_cb _hidl_cb) override;
|
||||
virtual Return<void> mapThisVector(const hidl_vec<int32_t>& param, mapThisVector_cb _hidl_cb) override;
|
||||
virtual Return<void> callMe(const sp<IFooCallback>& cb) override;
|
||||
virtual Return<IFoo::SomeEnum> useAnEnum(IFoo::SomeEnum zzz) override;
|
||||
virtual Return<void> haveAGooberVec(const hidl_vec<IFoo::Goober>& param) override;
|
||||
virtual Return<void> haveAGoober(const IFoo::Goober& g) override;
|
||||
virtual Return<void> haveAGooberArray(const hidl_array<IFoo::Goober, 20 /* 20 */>& lots) override;
|
||||
virtual Return<void> haveATypeFromAnotherFile(const Abc& def) override;
|
||||
virtual Return<void> haveSomeStrings(const hidl_array<hidl_string, 3 /* 3 */>& array, haveSomeStrings_cb _hidl_cb) override;
|
||||
virtual Return<void> haveAStringVec(const hidl_vec<hidl_string>& vector, haveAStringVec_cb _hidl_cb) override;
|
||||
virtual Return<void> transposeMe(const hidl_array<float, 3 /* 3 */, 5 /* 5 */>& in, transposeMe_cb _hidl_cb) override;
|
||||
virtual Return<void> callingDrWho(const IFoo::MultiDimensional& in, callingDrWho_cb _hidl_cb) override;
|
||||
virtual Return<void> transpose(const IFoo::StringMatrix5x3& in, transpose_cb _hidl_cb) override;
|
||||
virtual Return<void> transpose2(const hidl_array<hidl_string, 5 /* 5 */, 3 /* 3 */>& in, transpose2_cb _hidl_cb) override;
|
||||
virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb) override;
|
||||
virtual Return<void> sendVecVec(sendVecVec_cb _hidl_cb) override;
|
||||
virtual Return<void> createMyHandle(createMyHandle_cb _hidl_cb) override;
|
||||
virtual Return<void> createHandles(uint32_t size, createHandles_cb _hidl_cb) override;
|
||||
virtual Return<void> closeHandles() override;
|
||||
|
||||
Return<void> haveAVectorOfInterfaces(
|
||||
const hidl_vec<sp<ISimple> > &in,
|
||||
haveAVectorOfInterfaces_cb _hidl_cb) override;
|
||||
|
||||
Return<void> haveAVectorOfGenericInterfaces(
|
||||
const hidl_vec<sp<android::hidl::base::V1_0::IBase> > &in,
|
||||
haveAVectorOfGenericInterfaces_cb _hidl_cb) override;
|
||||
|
||||
Return<void> echoNullInterface(const sp<IFooCallback> &cb, echoNullInterface_cb _hidl_cb) override;
|
||||
private:
|
||||
std::vector<::native_handle_t *> mHandles;
|
||||
};
|
||||
|
||||
extern "C" IFoo* HIDL_FETCH_IFoo(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace foo
|
||||
} // namespace tests
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_TESTS_FOO_V1_0_FOO_H
|
|
@ -0,0 +1,16 @@
|
|||
cc_library_shared {
|
||||
name: "libfootest",
|
||||
defaults: ["hidl_defaults"],
|
||||
srcs: [
|
||||
"FooHelper.cpp"
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"android.hardware.tests.foo@1.0",
|
||||
],
|
||||
local_include_dirs: ["include/hidl-test"],
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
#include "FooHelper.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
std::string to_string(const IFoo::StringMatrix5x3 &M) {
|
||||
return to_string(M.s);
|
||||
}
|
||||
|
||||
std::string to_string(const IFoo::StringMatrix3x5 &M) {
|
||||
return to_string(M.s);
|
||||
}
|
||||
|
||||
std::string to_string(const hidl_string &s) {
|
||||
return std::string("'") + s.c_str() + "'";
|
||||
}
|
||||
|
||||
std::string QuuxToString(const IFoo::Quux &val) {
|
||||
std::string s;
|
||||
|
||||
s = "Quux(first='";
|
||||
s += val.first.c_str();
|
||||
s += "', last='";
|
||||
s += val.last.c_str();
|
||||
s += "')";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string MultiDimensionalToString(const IFoo::MultiDimensional &val) {
|
||||
std::string s;
|
||||
|
||||
s += "MultiDimensional(";
|
||||
|
||||
s += "quuxMatrix=[";
|
||||
|
||||
size_t k = 0;
|
||||
for (size_t i = 0; i < 5; ++i) {
|
||||
if (i > 0) {
|
||||
s += ", ";
|
||||
}
|
||||
|
||||
s += "[";
|
||||
for (size_t j = 0; j < 3; ++j, ++k) {
|
||||
if (j > 0) {
|
||||
s += ", ";
|
||||
}
|
||||
|
||||
s += QuuxToString(val.quuxMatrix[i][j]);
|
||||
}
|
||||
}
|
||||
s += "]";
|
||||
|
||||
s += ")";
|
||||
|
||||
return s;
|
||||
}
|
||||
} // namespace android
|
|
@ -0,0 +1,79 @@
|
|||
#ifndef ANDROID_HIDL_TEST_FOO_HELPER_H
|
||||
#define ANDROID_HIDL_TEST_FOO_HELPER_H
|
||||
#include <string>
|
||||
#include <android/hardware/tests/foo/1.0/IFoo.h>
|
||||
#include <utils/Timers.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
using std::to_string;
|
||||
using hardware::hidl_string;
|
||||
using hardware::hidl_vec;
|
||||
using hardware::hidl_array;
|
||||
using hardware::tests::foo::V1_0::IFoo;
|
||||
|
||||
static constexpr nsecs_t DELAY_S = 1;
|
||||
static constexpr nsecs_t DELAY_NS = seconds_to_nanoseconds(DELAY_S);
|
||||
static constexpr nsecs_t TOLERANCE_NS = milliseconds_to_nanoseconds(10);
|
||||
static constexpr nsecs_t ONEWAY_TOLERANCE_NS = milliseconds_to_nanoseconds(1);
|
||||
|
||||
std::string to_string(const IFoo::StringMatrix5x3 &M);
|
||||
std::string to_string(const IFoo::StringMatrix3x5 &M);
|
||||
// Add quotes around s. For testing purposes only.
|
||||
std::string to_string(const hidl_string &s);
|
||||
|
||||
template<typename T>
|
||||
std::string to_string(const T *elems, size_t n) {
|
||||
std::string out;
|
||||
out = "[";
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
if (i > 0) {
|
||||
out += ", ";
|
||||
}
|
||||
out += to_string(elems[i]);
|
||||
}
|
||||
out += "]";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename T, size_t SIZE>
|
||||
std::string to_string(const hidl_array<T, SIZE> &array) {
|
||||
return to_string(&array[0], SIZE);
|
||||
}
|
||||
|
||||
template<typename T, size_t SIZE1, size_t SIZE2>
|
||||
std::string to_string(const hidl_array<T, SIZE1, SIZE2> &array) {
|
||||
std::string out;
|
||||
out = "[";
|
||||
for (size_t i = 0; i < SIZE1; ++i) {
|
||||
if (i > 0) {
|
||||
out += ", ";
|
||||
}
|
||||
|
||||
out += "[";
|
||||
for (size_t j = 0; j < SIZE2; ++j) {
|
||||
if (j > 0) {
|
||||
out += ", ";
|
||||
}
|
||||
|
||||
out += to_string(array[i][j]);
|
||||
}
|
||||
out += "]";
|
||||
}
|
||||
out += "]";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string to_string(const hidl_vec<T> &vec) {
|
||||
return to_string(&vec[0], vec.size());
|
||||
}
|
||||
|
||||
std::string QuuxToString(const IFoo::Quux &val);
|
||||
|
||||
std::string MultiDimensionalToString(const IFoo::MultiDimensional &val);
|
||||
|
||||
} // namespace android
|
||||
#endif // ANDROID_HIDL_TEST_TEST_HELPER_H
|
40
android/hardware/interfaces/tests/foo/1.0/types.hal
Normal file
40
android/hardware/interfaces/tests/foo/1.0/types.hal
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.foo@1.0;
|
||||
|
||||
struct Abc {
|
||||
string x;
|
||||
float y;
|
||||
handle z;
|
||||
};
|
||||
|
||||
struct Def {
|
||||
string g;
|
||||
};
|
||||
|
||||
struct Outer {
|
||||
struct Inner {
|
||||
struct Deep {
|
||||
int32_t data;
|
||||
};
|
||||
int32_t data;
|
||||
};
|
||||
};
|
||||
|
||||
struct Unrelated {
|
||||
Outer.Inner great;
|
||||
};
|
19
android/hardware/interfaces/tests/foo/Android.mk
Normal file
19
android/hardware/interfaces/tests/foo/Android.mk
Normal file
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# Copyright (C) 2016 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-subdir-makefiles)
|
Loading…
Add table
Add a link
Reference in a new issue