hostapd/wpa_supplicant/binder/binder_manager.cpp
Roshan Pius 7b4bbb9f94 binder: Add binder skeletal code for Android
Create the skeletal binder interface for wpa_supplicant. The interface
hierarchy is based off the existing dbus
interface(https://w1.fi/wpa_supplicant/devel/dbus.html).

Since we use libbinder, the binder interface codebase needs to be
written in C++ and can only be compiled on Android platform for now.

The aidl files define binder RPC interfaces. The Android build system
generates the corresponding C++ interface classes which needs to be
implemented by the server process.

The clients can obtain a reference to the binder service (root object)
using:
android::String16 service_name("fi.w1.wpa_supplicant");
android::sp<android::IBinder> binder =
  android::defaultServiceManager()->getService(service_name);

Once a reference to the root object is retrieved, the clients can
obtain references to other RPC objects using that root object methods.

Signed-off-by: Roshan Pius <rpius@google.com>
2016-04-02 17:35:26 +03:00

53 lines
1.2 KiB
C++

/*
* binder interface for wpa_supplicant daemon
* Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
* Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include <binder/IServiceManager.h>
#include "binder_manager.h"
extern "C" {
#include "utils/includes.h"
#include "utils/common.h"
}
namespace wpa_supplicant_binder {
const char BinderManager::kBinderServiceName[] = "fi.w1.wpa_supplicant";
BinderManager *BinderManager::instance_ = NULL;
BinderManager * BinderManager::getInstance()
{
if (!instance_)
instance_ = new BinderManager();
return instance_;
}
void BinderManager::destroyInstance()
{
if (instance_)
delete instance_;
instance_ = NULL;
}
int BinderManager::registerBinderService(struct wpa_global *global)
{
/* Create the main binder service object and register with
* system service manager. */
supplicant_object_ = new Supplicant(global);
android::String16 service_name(kBinderServiceName);
android::defaultServiceManager()->addService(
service_name,
android::IInterface::asBinder(supplicant_object_));
return 0;
}
} /* namespace wpa_supplicant_binder */