diff options
author | Alex Deymo <deymo@google.com> | 2016-02-04 11:48:37 -0800 |
---|---|---|
committer | Alex Deymo <deymo@google.com> | 2016-02-04 14:05:27 -0800 |
commit | f2a37dca848bb4abaa86e62e1f6f0384cc2559c1 (patch) | |
tree | d99dad5f22953e96bf5666c813fa5b5b206dbf09 | |
parent | c7aa24adb840d04c381c5d1c4721de4c322cc4e2 (diff) | |
download | common-f2a37dca848bb4abaa86e62e1f6f0384cc2559c1.tar.gz |
service_example: Pass the brillo::MessageLoop to BinderWatcher.
The default BinderWatcher constructor expects the brillo::MessageLoop
to be marked as current. This patch passes the brillo::MessageLoop
explicitly to the BinderWatcher instead.
While at it, fixed the stdin line parsing when the message has spaces.
Bug: 26356682
TEST=mmma product/google/common/service_example
TEST=Deployed on edison-eng. It works.
Change-Id: I126a553fa1df5fd1e4bc0588b989fa38ec8d0fc9
-rw-r--r-- | service_example/brillo_example_client.cpp | 4 | ||||
-rw-r--r-- | service_example/brillo_example_service.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/service_example/brillo_example_client.cpp b/service_example/brillo_example_client.cpp index 21804ee..cb49720 100644 --- a/service_example/brillo_example_client.cpp +++ b/service_example/brillo_example_client.cpp @@ -49,7 +49,7 @@ class AlertCallback : public android::brillo::example::BnAlertCallback { void StdinCallback( android::sp<android::brillo::example::IExampleService> service) { std::string line; - std::cin >> line; + std::getline(std::cin, line); service->Log(android::String16(line.c_str())); } @@ -73,7 +73,7 @@ int main() { brillo::BaseMessageLoop message_loop{&message_loop_for_io}; // Initialize a binder watcher. - brillo::BinderWatcher watcher; + brillo::BinderWatcher watcher(&message_loop); watcher.Init(); // Poll stdin. diff --git a/service_example/brillo_example_service.cpp b/service_example/brillo_example_service.cpp index cf98665..fd24a7e 100644 --- a/service_example/brillo_example_service.cpp +++ b/service_example/brillo_example_service.cpp @@ -73,7 +73,7 @@ int main() { brillo::BaseMessageLoop message_loop{&message_loop_for_io}; // Initialize a binder watcher. - brillo::BinderWatcher watcher; + brillo::BinderWatcher watcher(&message_loop); watcher.Init(); // Run the message loop. |