shill: use BinderWrapper
Use BinderWrapper instead of calling IServiceManager methods
directly, so we can mock libbinder calls later if necessary.
BUG: 25160005
Change-Id: I699340e2ece0af3e31078b968816a1792121edbd
TEST: shill compiles successfully.
diff --git a/Android.mk b/Android.mk
index 83b6a1b..72cb4c0 100644
--- a/Android.mk
+++ b/Android.mk
@@ -281,7 +281,7 @@
LOCAL_AIDL_INCLUDES := \
system/connectivity/shill/binder \
frameworks/native/aidl/binder
-LOCAL_SHARED_LIBRARIES += libbinder libutils libbrillo-binder
+LOCAL_SHARED_LIBRARIES += libbinder libbinderwrapper libutils libbrillo-binder
LOCAL_SRC_FILES += \
adaptor_stub.cc \
binder/android/system/connectivity/shill/IDevice.aidl \
@@ -371,7 +371,7 @@
libmetrics \
libprotobuf-cpp-lite
ifeq ($(SHILL_USE_BINDER), true)
-LOCAL_SHARED_LIBRARIES += libbinder libutils libbrillo-binder
+LOCAL_SHARED_LIBRARIES += libbinder libbinderwrapper libutils libbrillo-binder
endif # SHILL_USE_BINDER
ifdef BRILLO
LOCAL_SHARED_LIBRARIES += libhardware
@@ -554,7 +554,7 @@
vpn/mock_vpn_provider.cc \
json_store_unittest.cc
ifeq ($(SHILL_USE_BINDER), true)
-LOCAL_SHARED_LIBRARIES += libbinder libutils libbrillo-binder
+LOCAL_SHARED_LIBRARIES += libbinder libbinderwrapper libutils libbrillo-binder
else
LOCAL_SRC_FILES += \
dbus/chromeos_dbus_adaptor_unittest.cc
diff --git a/binder/binder_control.cc b/binder/binder_control.cc
index 96adbad..75dc698 100644
--- a/binder/binder_control.cc
+++ b/binder/binder_control.cc
@@ -18,6 +18,7 @@
#include <base/bind.h>
#include <binder/IServiceManager.h>
+#include <binderwrapper/binder_wrapper.h>
#include <brillo/binder_watcher.h>
// TODO(samueltan): remove when shill is no longer dependent on DBus proxies.
@@ -47,6 +48,7 @@
#include "shill/dbus/chromeos_supplicant_process_proxy.h"
#endif // DISABLE_WIFI || DISABLE_WIRED_8021X
+using android::BinderWrapper;
using android::defaultServiceManager;
using std::string;
using std::to_string;
@@ -60,6 +62,7 @@
: next_unique_binder_adaptor_id_(0),
dispatcher_(dispatcher),
null_identifier_(kNullRpcIdentifier) {
+ BinderWrapper::Create();
// Watch Binder events in the main loop
brillo::BinderWatcher binder_watcher;
CHECK(binder_watcher.Init()) << "Binder FD watcher init failed";
diff --git a/binder/manager_binder_adaptor.cc b/binder/manager_binder_adaptor.cc
index 43ce1e6..cfa34da 100644
--- a/binder/manager_binder_adaptor.cc
+++ b/binder/manager_binder_adaptor.cc
@@ -16,18 +16,20 @@
#include "shill/binder/manager_binder_adaptor.h"
-#include <binder/IServiceManager.h>
#include <binder/Status.h>
+#include <binderwrapper/binder_wrapper.h>
#include <utils/String16.h>
+#include <utils/String8.h>
#include "shill/logging.h"
#include "shill/manager.h"
using android::binder::Status;
-using android::defaultServiceManager;
+using android::BinderWrapper;
using android::IBinder;
using android::sp;
using android::String16;
+using android::String8;
using android::system::connectivity::shill::IPropertyChangedCallback;
using std::string;
using std::vector;
@@ -50,7 +52,8 @@
void ManagerBinderAdaptor::RegisterAsync(
const base::Callback<void(bool)>& /*completion_callback*/) {
// Registration is performed synchronously in Binder.
- defaultServiceManager()->addService(getInterfaceDescriptor(), this);
+ BinderWrapper::Get()->RegisterService(
+ String8(getInterfaceDescriptor()).string(), this);
}
void ManagerBinderAdaptor::EmitBoolChanged(const string& name, bool /*value*/) {