Home | History | Annotate | Download | only in binder
      1 /*
      2  * binder interface for wpa_supplicant daemon
      3  * Copyright (c) 2004-2016, Jouni Malinen <j (at) w1.fi>
      4  * Copyright (c) 2004-2016, Roshan Pius <rpius (at) google.com>
      5  *
      6  * This software may be distributed under the terms of the BSD license.
      7  * See README for more details.
      8  */
      9 
     10 #ifndef BINDER_MANAGER_H
     11 #define BINDER_MANAGER_H
     12 
     13 #include <map>
     14 #include <string>
     15 
     16 #include "supplicant.h"
     17 #include "iface.h"
     18 
     19 struct wpa_global;
     20 struct wpa_supplicant;
     21 
     22 namespace wpa_supplicant_binder {
     23 
     24 /**
     25  * BinderManager is responsible for managing the lifetime of all
     26  * binder objects created by wpa_supplicant. This is a singleton
     27  * class which is created by the supplicant core and can be used
     28  * to get references to the binder objects.
     29  */
     30 class BinderManager {
     31 public:
     32 	static const char kBinderServiceName[];
     33 
     34 	static BinderManager * getInstance();
     35 	static void destroyInstance();
     36 	int registerBinderService(struct wpa_global *global);
     37 	int registerInterface(struct wpa_supplicant *wpa_s);
     38 	int unregisterInterface(struct wpa_supplicant *wpa_s);
     39 	int getIfaceBinderObjectByKey(
     40 		const void *iface_object_key,
     41 		android::sp<fi::w1::wpa_supplicant::IIface> *iface_object);
     42 
     43 private:
     44 	BinderManager() = default;
     45 	~BinderManager() = default;
     46 
     47 	/* Singleton instance of this class. */
     48 	static BinderManager *instance_;
     49 	/* The main binder service object. */
     50 	android::sp<Supplicant> supplicant_object_;
     51 	/* Map of all the interface specific binder objects controlled by
     52 	 * wpa_supplicant. This map is keyed in by the corresponding
     53 	 * wpa_supplicant structure pointer. */
     54 	std::map<const void *, android::sp<Iface>> iface_object_map_;
     55 };
     56 
     57 } /* namespace wpa_supplicant_binder */
     58 
     59 #endif /* BINDER_MANAGER_H */
     60