1 #ifndef ANDROID_PDX_UDS_CHANNEL_MANAGER_H_ 2 #define ANDROID_PDX_UDS_CHANNEL_MANAGER_H_ 3 4 #include <mutex> 5 #include <unordered_map> 6 7 #include <pdx/channel_handle.h> 8 #include <pdx/file_handle.h> 9 #include <uds/channel_event_set.h> 10 11 namespace android { 12 namespace pdx { 13 namespace uds { 14 15 class ChannelManager : public ChannelManagerInterface { 16 public: 17 static ChannelManager& Get(); 18 19 LocalChannelHandle CreateHandle(LocalHandle data_fd, LocalHandle event_fd); 20 struct ChannelData { 21 LocalHandle data_fd; 22 ChannelEventReceiver event_receiver; 23 }; 24 25 ChannelData* GetChannelData(int32_t handle); 26 27 private: 28 ChannelManager() = default; 29 30 void CloseHandle(int32_t handle) override; 31 32 std::mutex mutex_; 33 std::unordered_map<int32_t, ChannelData> channels_; 34 }; 35 36 } // namespace uds 37 } // namespace pdx 38 } // namespace android 39 40 #endif // ANDROID_PDX_UDS_CHANNEL_MANAGER_H_ 41