binder: Clang format the source code

Add a ".clang-format" file which is pretty close to the rest of
wpa_supplicant code base and reformat the binder codebase.

Signed-off-by: Roshan Pius <rpius@google.com>
This commit is contained in:
Roshan Pius 2016-07-07 09:48:58 -07:00 committed by Jouni Malinen
parent fe1d0771f7
commit a1979469fd
11 changed files with 105 additions and 107 deletions

View file

@ -0,0 +1,9 @@
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Mozilla
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -8
AlignAfterOpenBracket: AlwaysBreak
SortIncludes: false

View file

@ -8,17 +8,17 @@
*/
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include "binder_manager.h"
extern "C" {
#include "utils/includes.h"
#include "utils/common.h"
#include "utils/eloop.h"
#include "binder.h"
#include "binder_i.h"
#include "utils/common.h"
#include "utils/eloop.h"
#include "utils/includes.h"
}
void wpas_binder_sock_handler(int sock, void *eloop_ctx, void *sock_ctx)
@ -26,12 +26,11 @@ void wpas_binder_sock_handler(int sock, void *eloop_ctx, void *sock_ctx)
struct wpa_global *global = (wpa_global *)eloop_ctx;
struct wpas_binder_priv *priv = (wpas_binder_priv *)sock_ctx;
wpa_printf(MSG_DEBUG, "Processing binder events on FD %d",
priv->binder_fd);
wpa_printf(
MSG_DEBUG, "Processing binder events on FD %d", priv->binder_fd);
android::IPCThreadState::self()->handlePolledCommands();
}
struct wpas_binder_priv *wpas_binder_init(struct wpa_global *global)
{
struct wpas_binder_priv *priv;
@ -49,8 +48,8 @@ struct wpas_binder_priv * wpas_binder_init(struct wpa_global *global)
if (priv->binder_fd < 0)
goto err;
/* Look for read events from the binder socket in the eloop. */
if (eloop_register_read_sock(priv->binder_fd, wpas_binder_sock_handler,
global, priv) < 0)
if (eloop_register_read_sock(
priv->binder_fd, wpas_binder_sock_handler, global, priv) < 0)
goto err;
binder_manager = wpa_supplicant_binder::BinderManager::getInstance();
@ -68,7 +67,6 @@ err:
return NULL;
}
void wpas_binder_deinit(struct wpas_binder_priv *priv)
{
if (!priv)
@ -79,7 +77,6 @@ void wpas_binder_deinit(struct wpas_binder_priv *priv)
android::IPCThreadState::shutdown();
}
int wpas_binder_register_interface(struct wpa_supplicant *wpa_s)
{
if (!wpa_s->global->binder)
@ -93,7 +90,6 @@ int wpas_binder_register_interface(struct wpa_supplicant *wpa_s)
return binder_manager->registerInterface(wpa_s);
}
int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s)
{
if (!wpa_s->global->binder)

View file

@ -7,8 +7,8 @@
* See README for more details.
*/
#ifndef BINDER_H
#define BINDER_H
#ifndef WPA_SUPPLICANT_BINDER_BINDER_H
#define WPA_SUPPLICANT_BINDER_BINDER_H
#ifdef _cplusplus
extern "C" {
@ -43,4 +43,4 @@ static inline int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s)
}
#endif /* _cplusplus */
#endif /* BINDER_H */
#endif /* WPA_SUPPLICANT_BINDER_BINDER_H */

View file

@ -7,8 +7,8 @@
* See README for more details.
*/
#ifndef BINDER_CONSTANTS_H
#define BINDER_CONSTANTS_H
#ifndef WPA_SUPPLICANT_BINDER_BINDER_CONSTANTS_H
#define WPA_SUPPLICANT_BINDER_BINDER_CONSTANTS_H
namespace wpa_supplicant_binder {
namespace binder_constants {
@ -18,4 +18,4 @@ extern const char kServiceName[];
} /* namespace binder_constants */
} /* namespace wpa_supplicant_binder */
#endif /* BINDER_CONSTANTS_H */
#endif /* WPA_SUPPLICANT_BINDER_BINDER_CONSTANTS_H */

View file

@ -14,7 +14,8 @@
extern "C" {
#endif // _cplusplus
struct wpas_binder_priv {
struct wpas_binder_priv
{
int binder_fd;
struct wpa_global *global;
void *binder_manager;

View file

@ -13,8 +13,8 @@
#include "binder_manager.h"
extern "C" {
#include "utils/includes.h"
#include "utils/common.h"
#include "utils/includes.h"
}
namespace wpa_supplicant_binder {
@ -28,7 +28,6 @@ BinderManager * BinderManager::getInstance()
return instance_;
}
void BinderManager::destroyInstance()
{
if (instance_)
@ -36,7 +35,6 @@ void BinderManager::destroyInstance()
instance_ = NULL;
}
int BinderManager::registerBinderService(struct wpa_global *global)
{
/* Create the main binder service object and register with
@ -44,12 +42,10 @@ int BinderManager::registerBinderService(struct wpa_global *global)
supplicant_object_ = new Supplicant(global);
android::String16 service_name(binder_constants::kServiceName);
android::defaultServiceManager()->addService(
service_name,
android::IInterface::asBinder(supplicant_object_));
service_name, android::IInterface::asBinder(supplicant_object_));
return 0;
}
int BinderManager::registerInterface(struct wpa_supplicant *wpa_s)
{
if (!wpa_s)
@ -72,7 +68,6 @@ int BinderManager::registerInterface(struct wpa_supplicant *wpa_s)
return 0;
}
int BinderManager::unregisterInterface(struct wpa_supplicant *wpa_s)
{
if (!wpa_s || !wpa_s->binder_object_key)
@ -88,7 +83,6 @@ int BinderManager::unregisterInterface(struct wpa_supplicant *wpa_s)
return 0;
}
int BinderManager::getIfaceBinderObjectByKey(
const void *iface_object_key,
android::sp<fi::w1::wpa_supplicant::IIface> *iface_object)

View file

@ -7,14 +7,14 @@
* See README for more details.
*/
#ifndef BINDER_MANAGER_H
#define BINDER_MANAGER_H
#ifndef WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H
#define WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H
#include <map>
#include <string>
#include "supplicant.h"
#include "iface.h"
#include "supplicant.h"
struct wpa_global;
struct wpa_supplicant;
@ -27,7 +27,8 @@ namespace wpa_supplicant_binder {
* class which is created by the supplicant core and can be used
* to get references to the binder objects.
*/
class BinderManager {
class BinderManager
{
public:
static BinderManager *getInstance();
static void destroyInstance();
@ -54,4 +55,4 @@ private:
} /* namespace wpa_supplicant_binder */
#endif /* BINDER_MANAGER_H */
#endif /* WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H */

View file

@ -11,9 +11,6 @@
namespace wpa_supplicant_binder {
Iface::Iface(struct wpa_supplicant *wpa_s)
: wpa_s_(wpa_s)
{
}
Iface::Iface(struct wpa_supplicant *wpa_s) : wpa_s_(wpa_s) {}
} /* namespace wpa_supplicant_binder */

View file

@ -7,14 +7,14 @@
* See README for more details.
*/
#ifndef IFACE_H
#define IFACE_H
#ifndef WPA_SUPPLICANT_BINDER_IFACE_H
#define WPA_SUPPLICANT_BINDER_IFACE_H
#include "fi/w1/wpa_supplicant/BnIface.h"
extern "C" {
#include "utils/includes.h"
#include "utils/common.h"
#include "utils/includes.h"
#include "../wpa_supplicant_i.h"
}
@ -39,4 +39,4 @@ private:
} /* namespace wpa_supplicant_binder */
#endif /* IFACE_H */
#endif /* WPA_SUPPLICANT_BINDER_IFACE_H */

View file

@ -7,16 +7,12 @@
* See README for more details.
*/
#include "binder_manager.h"
#include "supplicant.h"
#include "binder_manager.h"
namespace wpa_supplicant_binder {
Supplicant::Supplicant(struct wpa_global *global)
: wpa_global_(global)
{
}
Supplicant::Supplicant(struct wpa_global *global) : wpa_global_(global) {}
android::binder::Status Supplicant::CreateInterface(
const android::os::PersistableBundle &params,
@ -38,11 +34,12 @@ android::binder::Status Supplicant::CreateInterface(
* Try to get the wpa_supplicant record for this iface, return
* an error if we already control it.
*/
if (wpa_supplicant_get_iface(wpa_global_,
android::String8(ifname).string()) != NULL)
if (wpa_supplicant_get_iface(
wpa_global_, android::String8(ifname).string()) != NULL)
return android::binder::Status::fromServiceSpecificError(
ERROR_IFACE_EXISTS,
android::String8("wpa_supplicant already controls this interface."));
android::String8("wpa_supplicant already controls this "
"interface."));
android::binder::Status status;
struct wpa_supplicant *wpa_s = NULL;
@ -52,8 +49,8 @@ android::binder::Status Supplicant::CreateInterface(
iface.driver = os_strdup(android::String8(driver).string());
iface.ifname = os_strdup(android::String8(ifname).string());
iface.confname = os_strdup(android::String8(confname).string());
iface.bridge_ifname = os_strdup(
android::String8(bridge_ifname).string());
iface.bridge_ifname =
os_strdup(android::String8(bridge_ifname).string());
/* Otherwise, have wpa_supplicant attach to it. */
wpa_s = wpa_supplicant_add_iface(wpa_global_, &iface, NULL);
/* The supplicant core creates a corresponding binder object via
@ -61,16 +58,19 @@ android::binder::Status Supplicant::CreateInterface(
if (!wpa_s || !wpa_s->binder_object_key) {
status = android::binder::Status::fromServiceSpecificError(
ERROR_UNKNOWN,
android::String8("wpa_supplicant couldn't grab this interface."));
android::String8(
"wpa_supplicant couldn't grab this interface."));
} else {
BinderManager *binder_manager = BinderManager::getInstance();
if (!binder_manager ||
binder_manager->getIfaceBinderObjectByKey(
wpa_s->binder_object_key, aidl_return))
status = android::binder::Status::fromServiceSpecificError(
status =
android::binder::Status::fromServiceSpecificError(
ERROR_UNKNOWN,
android::String8("wpa_supplicant encountered a binder error."));
android::String8("wpa_supplicant encountered a "
"binder error."));
else
status = android::binder::Status::ok();
}
@ -81,7 +81,6 @@ android::binder::Status Supplicant::CreateInterface(
return status;
}
android::binder::Status Supplicant::RemoveInterface(const std::string &ifname)
{
struct wpa_supplicant *wpa_s;
@ -90,15 +89,16 @@ android::binder::Status Supplicant::RemoveInterface(const std::string &ifname)
if (!wpa_s || !wpa_s->binder_object_key)
return android::binder::Status::fromServiceSpecificError(
ERROR_IFACE_UNKNOWN,
android::String8("wpa_supplicant does not control this interface."));
android::String8("wpa_supplicant does not control this "
"interface."));
if (wpa_supplicant_remove_iface(wpa_global_, wpa_s, 0))
return android::binder::Status::fromServiceSpecificError(
ERROR_UNKNOWN,
android::String8("wpa_supplicant couldn't remove this interface."));
android::String8(
"wpa_supplicant couldn't remove this interface."));
return android::binder::Status::ok();
}
android::binder::Status Supplicant::GetInterface(
const std::string &ifname,
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
@ -109,15 +109,17 @@ android::binder::Status Supplicant::GetInterface(
if (!wpa_s || !wpa_s->binder_object_key)
return android::binder::Status::fromServiceSpecificError(
ERROR_IFACE_UNKNOWN,
android::String8("wpa_supplicant does not control this interface."));
android::String8(
"wpa_supplicant does not control this interface."));
BinderManager *binder_manager = BinderManager::getInstance();
if (!binder_manager ||
binder_manager->getIfaceBinderObjectByKey(wpa_s->binder_object_key,
aidl_return))
binder_manager->getIfaceBinderObjectByKey(
wpa_s->binder_object_key, aidl_return))
return android::binder::Status::fromServiceSpecificError(
ERROR_UNKNOWN,
android::String8("wpa_supplicant encountered a binder error."));
android::String8(
"wpa_supplicant encountered a binder error."));
return android::binder::Status::ok();
}

View file

@ -7,16 +7,16 @@
* See README for more details.
*/
#ifndef SUPPLICANT_H
#define SUPPLICANT_H
#ifndef WPA_SUPPLICANT_BINDER_SUPPLICANT_H
#define WPA_SUPPLICANT_BINDER_SUPPLICANT_H
#include "fi/w1/wpa_supplicant/BnSupplicant.h"
#include "fi/w1/wpa_supplicant/IIface.h"
#include "fi/w1/wpa_supplicant/ISupplicantCallbacks.h"
extern "C" {
#include "utils/includes.h"
#include "utils/common.h"
#include "utils/includes.h"
#include "../wpa_supplicant_i.h"
}
@ -35,14 +35,12 @@ public:
android::binder::Status CreateInterface(
const android::os::PersistableBundle &params,
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
override;
android::binder::Status RemoveInterface(
const std::string &ifname) override;
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return) override;
android::binder::Status
RemoveInterface(const std::string &ifname) override;
android::binder::Status GetInterface(
const std::string &ifname,
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
override;
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return) override;
private:
/* Raw pointer to the global structure maintained by the core. */
@ -54,4 +52,4 @@ private:
} /* namespace wpa_supplicant_binder */
#endif /* SUPPLICANT_H */
#endif /* WPA_SUPPLICANT_BINDER_SUPPLICANT_H */