diff options
author | Casey Dahlin <sadmac@google.com> | 2016-03-11 15:12:31 -0800 |
---|---|---|
committer | Casey Dahlin <sadmac@google.com> | 2016-03-16 11:34:10 -0700 |
commit | cb64183ecef46558c2a52afa2ed5716702c71777 (patch) | |
tree | 09d8c0a786090989a0ea061b6996d158c51d6722 /test-client | |
parent | 2ab9b67af1ab783c176ef05d1c310ad2f21a6ac2 (diff) | |
download | webservd-cb64183ecef46558c2a52afa2ed5716702c71777.tar.gz |
Switch webservd to binder in Android
This should fix chromeos building as a side effect, as we're not
depending on flags the gyp file doesn't set anymore.
Change-Id: Ibab792660600c761eb85f81e3f1fe4dce050b286
Test: Weaved can successfully connect to webservd.
Bug: 27204884
Bug: 27504653
Diffstat (limited to 'test-client')
-rw-r--r-- | test-client/Android.mk | 13 | ||||
-rw-r--r-- | test-client/main.cc | 42 |
2 files changed, 21 insertions, 34 deletions
diff --git a/test-client/Android.mk b/test-client/Android.mk index f145e08..a15958f 100644 --- a/test-client/Android.mk +++ b/test-client/Android.mk @@ -40,20 +40,9 @@ LOCAL_C_INCLUDES := LOCAL_SHARED_LIBRARIES := \ libbrillo \ libchrome \ - libwebserv - -ifeq ($(system_webservd_use_dbus),true) -LOCAL_SHARED_LIBRARIES += \ - libdbus \ - libbrillo-dbus \ - libchrome-dbus -endif - -ifeq ($(system_webservd_use_binder),true) -LOCAL_SHARED_LIBRARIES += \ + libwebserv \ libbinder \ libbrillo-binder \ libbinderwrapper -endif include $(BUILD_EXECUTABLE) diff --git a/test-client/main.cc b/test-client/main.cc index dcb219c..d9d9b6a 100644 --- a/test-client/main.cc +++ b/test-client/main.cc @@ -23,16 +23,7 @@ #define LOG_TAG webservd_testc -#if defined(WEBSERV_USE_DBUS) - -#include <brillo/daemons/dbus_daemon.h> -#include <brillo/dbus/async_event_sequencer.h> - -// If we're using DBus, pick a base class that does DBus related init. -using WebservTestClientBaseClass = brillo::DBusDaemon; -using brillo::dbus_utils::AsyncEventSequencer; - -#elif defined(WEBSERV_USE_BINDER) +#ifdef __ANDROID__ #include <binderwrapper/binder_wrapper.h> @@ -41,8 +32,15 @@ using brillo::dbus_utils::AsyncEventSequencer; using WebservTestClientBaseClass = brillo::Daemon; #else -#error "You must select one of Binder or DBus as an RPC mechanism." -#endif // defined(WEBSERV_USE_DBUS) + +#include <brillo/daemons/dbus_daemon.h> +#include <brillo/dbus/async_event_sequencer.h> + +// If we're using DBus, pick a base class that does DBus related init. +using WebservTestClientBaseClass = brillo::DBusDaemon; +using brillo::dbus_utils::AsyncEventSequencer; + +#endif // __ANDROID__ using libwebserv::Server; using libwebserv::ProtocolHandler; @@ -85,13 +83,7 @@ class WebservTestClient : public WebservTestClientBaseClass { if (exit_code != EX_OK) return exit_code; -#ifdef WEBSERV_USE_DBUS - webserver_ = Server::ConnectToServerViaDBus( - bus_, bus_->GetConnectionName(), - AsyncEventSequencer::GetDefaultCompletionAction(), - base::Bind(&LogServerOnlineStatus, true /* online */), - base::Bind(&LogServerOnlineStatus, false /* offline */)); -#elif WEBSERV_USE_BINDER +#ifdef __ANDROID__ android::BinderWrapper::Create(); if (!binder_watcher_.Init()) { return EX_OSERR; @@ -101,7 +93,13 @@ class WebservTestClient : public WebservTestClientBaseClass { brillo::MessageLoop::current(), base::Bind(&LogServerOnlineStatus, true /* online */), base::Bind(&LogServerOnlineStatus, false /* offline */)); -#endif // WEBSERV_USE_DBUS || WEBSERV_USE_BINDER +#else + webserver_ = Server::ConnectToServerViaDBus( + bus_, bus_->GetConnectionName(), + AsyncEventSequencer::GetDefaultCompletionAction(), + base::Bind(&LogServerOnlineStatus, true /* online */), + base::Bind(&LogServerOnlineStatus, false /* offline */)); +#endif // __ANDROID__ // Note that adding this handler is only local, and we won't receive // requests until the library does some async book keeping. @@ -116,9 +114,9 @@ class WebservTestClient : public WebservTestClientBaseClass { private: std::unique_ptr<Server> webserver_; -#if WEBSERV_USE_BINDER +#ifdef __ANDROID__ brillo::BinderWatcher binder_watcher_; -#endif // WEBSERV_USE_BINDER +#endif // __ANDROID__ DISALLOW_COPY_AND_ASSIGN(WebservTestClient); }; // class WebservTestClient |