binder_manager.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 BinderManager * getInstance();
  27. static void destroyInstance();
  28. int registerBinderService(struct wpa_global *global);
  29. int registerInterface(struct wpa_supplicant *wpa_s);
  30. int unregisterInterface(struct wpa_supplicant *wpa_s);
  31. int getIfaceBinderObjectByKey(
  32. const void *iface_object_key,
  33. android::sp<fi::w1::wpa_supplicant::IIface> *iface_object);
  34. private:
  35. BinderManager() = default;
  36. ~BinderManager() = default;
  37. /* Singleton instance of this class. */
  38. static BinderManager *instance_;
  39. /* The main binder service object. */
  40. android::sp<Supplicant> supplicant_object_;
  41. /* Map of all the interface specific binder objects controlled by
  42. * wpa_supplicant. This map is keyed in by the corresponding
  43. * wpa_supplicant structure pointer. */
  44. std::map<const void *, android::sp<Iface>> iface_object_map_;
  45. };
  46. } /* namespace wpa_supplicant_binder */
  47. #endif /* BINDER_MANAGER_H */