binder_manager.h 1.7 KB

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