Merge "Update to use the correct library for logging." am: f5e1ac67ed

am: 34d006ee9c

Change-Id: Ib0d77e4267966729600f581309900de5cd8dd780
This commit is contained in:
Yifan Hong
2016-11-30 20:48:20 +00:00
committed by android-build-merger
10 changed files with 90 additions and 62 deletions

View File

@@ -2,7 +2,7 @@
#define LOG_TAG "hidl_test" #define LOG_TAG "hidl_test"
#include "Bar.h" #include "Bar.h"
#include <android-base/logging.h> #include <android/log.h>
#include <inttypes.h> #include <inttypes.h>
namespace android { namespace android {

View File

@@ -17,7 +17,7 @@ namespace implementation {
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow. // Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
Return<void> Foo::doThis(float param) { Return<void> Foo::doThis(float param) {
ALOGI("SERVER(Foo) doThis(%.2f)", param); LOG(INFO) << "SERVER(Foo) doThis(" << param << ")";
return Void(); return Void();
} }
@@ -49,7 +49,7 @@ Return<double> Foo::doQuiteABit(
Return<void> Foo::doSomethingElse( Return<void> Foo::doSomethingElse(
const hidl_array<int32_t, 15> &param, doSomethingElse_cb _cb) { const hidl_array<int32_t, 15> &param, doSomethingElse_cb _cb) {
ALOGI("SERVER(Foo) doSomethingElse(...)"); LOG(INFO) << "SERVER(Foo) doSomethingElse(...)";
hidl_array<int32_t, 32> result; hidl_array<int32_t, 32> result;
for (size_t i = 0; i < 15; ++i) { for (size_t i = 0; i < 15; ++i) {
@@ -66,7 +66,7 @@ Return<void> Foo::doSomethingElse(
Return<void> Foo::doStuffAndReturnAString( Return<void> Foo::doStuffAndReturnAString(
doStuffAndReturnAString_cb _cb) { doStuffAndReturnAString_cb _cb) {
ALOGI("SERVER(Foo) doStuffAndReturnAString"); LOG(INFO) << "SERVER(Foo) doStuffAndReturnAString";
_cb("Hello, world"); _cb("Hello, world");
@@ -75,7 +75,7 @@ Return<void> Foo::doStuffAndReturnAString(
Return<void> Foo::mapThisVector( Return<void> Foo::mapThisVector(
const hidl_vec<int32_t> &param, mapThisVector_cb _cb) { const hidl_vec<int32_t> &param, mapThisVector_cb _cb) {
ALOGI("SERVER(Foo) mapThisVector"); LOG(INFO) << "SERVER(Foo) mapThisVector";
hidl_vec<int32_t> out; hidl_vec<int32_t> out;
out.resize(param.size()); out.resize(param.size());
@@ -91,80 +91,98 @@ Return<void> Foo::mapThisVector(
Return<void> Foo::callMe( Return<void> Foo::callMe(
const sp<IFooCallback> &cb) { const sp<IFooCallback> &cb) {
ALOGI("SERVER(Foo) callMe %p", cb.get()); LOG(INFO) << "SERVER(Foo) callMe " << cb.get();
if (cb != NULL) { if (cb != NULL) {
hidl_array<nsecs_t, 3> c; hidl_array<nsecs_t, 3> c;
ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYou, " \ LOG(INFO) << "SERVER(Foo) callMe "
"should return immediately", cb.get()); << cb.get()
<< " calling IFooCallback::heyItsYou, should return immediately";
c[0] = systemTime(); c[0] = systemTime();
cb->heyItsYou(cb); cb->heyItsYou(cb);
c[0] = systemTime() - c[0]; c[0] = systemTime() - c[0];
ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYou " \ LOG(INFO) << "SERVER(Foo) callMe "
"returned after %" PRId64 "ns", cb.get(), c[0]); << cb.get()
<< " calling IFooCallback::heyItsYou, returned after"
ALOGI("SERVER(Foo) callMe %p calling IFooCallback::heyItsYouIsntIt, " \ << c[0]
"should block for %" PRId64 " seconds", cb.get(), << "ns";
DELAY_S); LOG(INFO) << "SERVER(Foo) callMe "
<< cb.get()
<< " calling IFooCallback::heyItsYouIsntIt, should block for"
<< DELAY_S
<< " seconds";
c[1] = systemTime(); c[1] = systemTime();
Return<bool> ret = cb->heyItsYouIsntIt(cb); Return<bool> ret = cb->heyItsYouIsntIt(cb);
if (!ret.isOk()) { if (!ret.isOk()) {
ALOGE("SERVER(Foo) callMe %p encountered transport error (%d).", LOG(ERROR) << "SERVER(Foo) callMe "
cb.get(), ret.getStatus().exceptionCode()); << cb.get()
<< " encountered transport error ("
<< ret.getStatus().exceptionCode()
<< ").";
return Void(); return Void();
} }
bool answer = ret.get(); bool answer = ret.get();
c[1] = systemTime() - c[1]; c[1] = systemTime() - c[1];
ALOGI("SERVER(Foo) callMe %p IFooCallback::heyItsYouIsntIt " \
"responded with %d after %" PRId64 "ns", cb.get(), answer, c[1]);
ALOGI("SERVER(Foo) callMe %p calling " \ LOG(INFO) << "SERVER(Foo) callMe "
"IFooCallback::heyItsTheMeaningOfLife, " \ << cb.get()
"should return immediately ", 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(); c[2] = systemTime();
cb->heyItsTheMeaningOfLife(42); cb->heyItsTheMeaningOfLife(42);
c[2] = systemTime() - c[2]; c[2] = systemTime() - c[2];
ALOGI("SERVER(Foo) callMe %p After call to " \
"IFooCallback::heyItsTheMeaningOfLife " \
"responded after %" PRId64 "ns", cb.get(), c[2]);
ALOGI("SERVER(Foo) callMe %p calling IFooCallback::youBlockedMeFor " \ LOG(INFO) << "SERVER(Foo) callMe "
"to report times", cb.get()); << 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); cb->youBlockedMeFor(c);
ALOGI("SERVER(Foo) callMe %p After call to " \ LOG(INFO) << "SERVER(Foo) callMe "
"IFooCallback::heyYouBlockedMeFor", cb.get()); << cb.get()
<< " After call to IFooCallback::youBlockedMeFor";
} }
return Void(); return Void();
} }
Return<Foo::SomeEnum> Foo::useAnEnum(SomeEnum param) { Return<Foo::SomeEnum> Foo::useAnEnum(SomeEnum param) {
ALOGI("SERVER(Foo) useAnEnum %d", (int)param); LOG(INFO) << "SERVER(Foo) useAnEnum " << (int)param;
return SomeEnum::goober; return SomeEnum::goober;
} }
Return<void> Foo::haveAGooberVec(const hidl_vec<Goober>& param) { Return<void> Foo::haveAGooberVec(const hidl_vec<Goober>& param) {
ALOGI("SERVER(Foo) haveAGooberVec &param = %p", &param); LOG(INFO) << "SERVER(Foo) haveAGooberVec &param = " << &param;
return Void(); return Void();
} }
Return<void> Foo::haveAGoober(const Goober &g) { Return<void> Foo::haveAGoober(const Goober &g) {
ALOGI("SERVER(Foo) haveaGoober g=%p", &g); LOG(INFO) << "SERVER(Foo) haveaGoober g=" << &g;
return Void(); return Void();
} }
Return<void> Foo::haveAGooberArray(const hidl_array<Goober, 20> & /* lots */) { Return<void> Foo::haveAGooberArray(const hidl_array<Goober, 20> & /* lots */) {
ALOGI("SERVER(Foo) haveAGooberArray"); LOG(INFO) << "SERVER(Foo) haveAGooberArray";
return Void(); return Void();
} }
Return<void> Foo::haveATypeFromAnotherFile(const Abc &def) { Return<void> Foo::haveATypeFromAnotherFile(const Abc &def) {
ALOGI("SERVER(Foo) haveATypeFromAnotherFile def=%p", &def); LOG(INFO) << "SERVER(Foo) haveATypeFromAnotherFile def=" << &def;
return Void(); return Void();
} }
@@ -172,10 +190,14 @@ Return<void> Foo::haveATypeFromAnotherFile(const Abc &def) {
Return<void> Foo::haveSomeStrings( Return<void> Foo::haveSomeStrings(
const hidl_array<hidl_string, 3> &array, const hidl_array<hidl_string, 3> &array,
haveSomeStrings_cb _cb) { haveSomeStrings_cb _cb) {
ALOGI("SERVER(Foo) haveSomeStrings([\"%s\", \"%s\", \"%s\"])",
array[0].c_str(), LOG(INFO) << "SERVER(Foo) haveSomeStrings([\""
array[1].c_str(), << array[0].c_str()
array[2].c_str()); << "\", \""
<< array[1].c_str()
<< "\", \""
<< array[2].c_str()
<< "\"])";
hidl_array<hidl_string, 2> result; hidl_array<hidl_string, 2> result;
result[0] = "Hello"; result[0] = "Hello";
@@ -189,10 +211,13 @@ Return<void> Foo::haveSomeStrings(
Return<void> Foo::haveAStringVec( Return<void> Foo::haveAStringVec(
const hidl_vec<hidl_string> &vector, const hidl_vec<hidl_string> &vector,
haveAStringVec_cb _cb) { haveAStringVec_cb _cb) {
ALOGI("SERVER(Foo) haveAStringVec([\"%s\", \"%s\", \"%s\"])", LOG(INFO) << "SERVER(Foo) haveAStringVec([\""
vector[0].c_str(), << vector[0].c_str()
vector[1].c_str(), << "\", \""
vector[2].c_str()); << vector[1].c_str()
<< "\", \""
<< vector[2].c_str()
<< "\"])";
hidl_vec<hidl_string> result; hidl_vec<hidl_string> result;
result.resize(2); result.resize(2);
@@ -207,7 +232,7 @@ Return<void> Foo::haveAStringVec(
Return<void> Foo::transposeMe( Return<void> Foo::transposeMe(
const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) { const hidl_array<float, 3, 5> &in, transposeMe_cb _cb) {
ALOGI("SERVER(Foo) transposeMe(%s)", to_string(in).c_str()); LOG(INFO) << "SERVER(Foo) transposeMe(" << to_string(in).c_str() << ")";
hidl_array<float, 5, 3> out; hidl_array<float, 5, 3> out;
for (size_t i = 0; i < 5; ++i) { for (size_t i = 0; i < 5; ++i) {
@@ -216,7 +241,7 @@ Return<void> Foo::transposeMe(
} }
} }
ALOGI("SERVER(Foo) transposeMe returning %s", to_string(out).c_str()); LOG(INFO) << "SERVER(Foo) transposeMe returning " << to_string(out).c_str();
_cb(out); _cb(out);
@@ -225,7 +250,7 @@ Return<void> Foo::transposeMe(
Return<void> Foo::callingDrWho( Return<void> Foo::callingDrWho(
const MultiDimensional &in, callingDrWho_cb _hidl_cb) { const MultiDimensional &in, callingDrWho_cb _hidl_cb) {
ALOGI("SERVER(Foo) callingDrWho(%s)", MultiDimensionalToString(in).c_str()); LOG(INFO) << "SERVER(Foo) callingDrWho(" << MultiDimensionalToString(in).c_str() << ")";
MultiDimensional out; MultiDimensional out;
for (size_t i = 0; i < 5; ++i) { for (size_t i = 0; i < 5; ++i) {

View File

@@ -2,7 +2,7 @@
#define LOG_TAG "hidl_test" #define LOG_TAG "hidl_test"
#include "FooCallback.h" #include "FooCallback.h"
#include <android-base/logging.h> #include <android/log.h>
#include <hidl-test/FooHelper.h> #include <hidl-test/FooHelper.h>
#include <inttypes.h> #include <inttypes.h>
#include <utils/Timers.h> #include <utils/Timers.h>

View File

@@ -1,5 +1,5 @@
#define LOG_TAG "hidl_test" #define LOG_TAG "hidl_test"
#include <android-base/logging.h> #include <android/log.h>
#include "Child.h" #include "Child.h"

View File

@@ -28,7 +28,7 @@ Return<void> selectService(bool sendRemote, CB &_hidl_cb, sp<IChild> &local) {
} else { } else {
toSend = local; toSend = local;
} }
ALOGI("SERVER(Fetcher) selectService returning %p", toSend.get()); LOG(INFO) << "SERVER(Fetcher) selectService returning " << toSend.get();
_hidl_cb(toSend); _hidl_cb(toSend);
return Void(); return Void();
} }

View File

@@ -1,5 +1,5 @@
#define LOG_TAG "hidl_test" #define LOG_TAG "hidl_test"
#include <android-base/logging.h> #include <android/log.h>
#include "Parent.h" #include "Parent.h"

View File

@@ -1,5 +1,7 @@
#define LOG_TAG "hidl_test"
#include "Graph.h" #include "Graph.h"
#include <android-base/logging.h> #include <android/log.h>
#include <hidl-test/PointerHelper.h> #include <hidl-test/PointerHelper.h>
#define PUSH_ERROR_IF(__cond__) if(__cond__) { errors.push_back(std::to_string(__LINE__) + ": " + #__cond__); } #define PUSH_ERROR_IF(__cond__) if(__cond__) { errors.push_back(std::to_string(__LINE__) + ": " + #__cond__); }

View File

@@ -1,4 +1,7 @@
#define LOG_TAG "hidl_test"
#include "Pointer.h" #include "Pointer.h"
#include <android/log.h>
namespace android { namespace android {
namespace hardware { namespace hardware {
@@ -7,6 +10,14 @@ namespace pointer {
namespace V1_0 { namespace V1_0 {
namespace implementation { namespace implementation {
Return<int32_t> Pointer::getErrors() {
if(!errors.empty()) {
for(const auto& e : errors)
ALOGW("SERVER(Pointer) error: %s", e.c_str());
}
return errors.size();
}
IPointer* HIDL_FETCH_IPointer(const char* /* name */) { IPointer* HIDL_FETCH_IPointer(const char* /* name */) {
return new Pointer(); return new Pointer();
} }

View File

@@ -2,7 +2,6 @@
#define ANDROID_HARDWARE_TESTS_POINTER_V1_0_POINTER_H #define ANDROID_HARDWARE_TESTS_POINTER_V1_0_POINTER_H
#include <android/hardware/tests/pointer/1.0/IPointer.h> #include <android/hardware/tests/pointer/1.0/IPointer.h>
#include <android-base/logging.h>
#include <hidl/Status.h> #include <hidl/Status.h>
#include <hidl/MQDescriptor.h> #include <hidl/MQDescriptor.h>
@@ -28,13 +27,7 @@ struct Pointer : public IPointer {
private: private:
std::vector<std::string> errors; std::vector<std::string> errors;
public: public:
Return<int32_t> getErrors() { Return<int32_t> getErrors() override;
if(!errors.empty()) {
for(const auto& e : errors)
ALOGW("SERVER(Pointer) error: %s", e.c_str());
}
return errors.size();
}
Return<void> foo1(const IPointer::Sam& s, IPointer::Sam const* s_ptr) override { Return<void> foo1(const IPointer::Sam& s, IPointer::Sam const* s_ptr) override {
PUSH_ERROR_IF(!(&s == s_ptr)); PUSH_ERROR_IF(!(&s == s_ptr));
return Void(); return Void();
@@ -71,9 +64,6 @@ public:
return Void(); return Void();
} }
Return<void> foo9(::android::hardware::hidl_string const* str_ref) override { Return<void> foo9(::android::hardware::hidl_string const* str_ref) override {
ALOGI("SERVER(Pointer) foo9 got string @ %p (size = %ld) \"%s\"",
str_ref->c_str(),
(unsigned long) str_ref->size(), str_ref->c_str());
PUSH_ERROR_IF(!(strcmp(str_ref->c_str(), "meowmeowmeow") == 0)); PUSH_ERROR_IF(!(strcmp(str_ref->c_str(), "meowmeowmeow") == 0));
return Void(); return Void();
} }

View File

@@ -1,5 +1,5 @@
#define LOG_TAG "hidl_test" #define LOG_TAG "hidl_test"
#include <android-base/logging.h> #include <android/log.h>
#include "PointerHelper.h" #include "PointerHelper.h"
namespace android { namespace android {