binder_manager.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 BINDER_MANAGER_H
  10. #define BINDER_MANAGER_H
  11. #include <map>
  12. #include <string>
  13. #include "supplicant.h"
  14. #include "iface.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. public:
  26. static const char kBinderServiceName[];
  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 /* BINDER_MANAGER_H */