diff options
author | Ralph Nathan <ralphnathan@google.com> | 2016-01-13 12:42:24 -0800 |
---|---|---|
committer | Ralph Nathan <ralphnathan@google.com> | 2016-01-14 17:12:10 -0800 |
commit | aa20905df5eb037e7941e661dc52fa35da1f7c22 (patch) | |
tree | 8bc06ba9f898000b0e73172882d89f9961d33bb7 | |
parent | 19ba873ed351d646cf5bbf3e42198617d35f2aaf (diff) | |
download | common-aa20905df5eb037e7941e661dc52fa35da1f7c22.tar.gz |
Add a README for the example service.
Add a README in markdown for the example service.
BUG=26346663
Change-Id: I4cb450df904e829bf45bf5442ff6c88658532824
-rw-r--r-- | service_example/README.md | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/service_example/README.md b/service_example/README.md new file mode 100644 index 0000000..16ef39a --- /dev/null +++ b/service_example/README.md @@ -0,0 +1,69 @@ +Brillo Example Service +====================== + +This folder contains an example Brillo service and client that use AIDL. This +example is intended to show: + +1. Implementing an interface defined in AIDL. +2. Registering a service with the service manager. +3. Calling a service from a client. +4. Registering a callback object from the client so the service can talk back + to the client. + +Folder layout +------------- + +* android/brillo/example/IExampleService.aidl - AIDL interface for an example + service that accepts a string and logs it. The service also provides an + interface to let a client be notified once it has called the service n + times. +* android/brillo/example/IAlertCallback.aidl - AIDL interface for the callback + object that the client registers with the service. Note the use of the + keyword oneway in the interface. This keyword prevents the service from + blocking on the client handling the callback. +* brillo_example_service.cpp - The implementation of the AIDL service + interface. The service has to implement + android::brillo::example::BnExampleService which is done in ExampleService + class. The service also illustrates how to use brillo::BinderWatcher with a + message loop to drive the service. +* brillo_example_client.cpp - Client application that calls the service and + receives callbacks. The client implements the callback object in + AlertCallback. AlertCallback by extending + android::brillo::example::BnAlertCallback. The client also uses + brillo::BinderWatcher and message loops to receive callbacks. + +The brillo_example_client reads std::in and passes that information to the +brillo_example_service which logs it using logcat. + +Usage +----- + +To use this example service/client: + +1. Open two terminals. +2. In the first one, run + + adb shell + + and then start the example service in the background + + brillo_example_service & + +3. Start logcat in the second terminal + + adb logcat + +4. In the first terminal, start the example client. + + brillo_example_client + +5. If you type "foo" in the first terminal followed by a newline, you should see + the following text in the logcat output: + + brillo_example_service: foo + +6. After 3 messages have been sent to the service by the client, the following + statement will be logged by the client. + + brillo_example_client: Received Callback from service: Received 3 log messages. + |