1 #ifndef WIFI_OFFLOAD_SERVER_H_ 2 #define WIFI_OFFLOAD_SERVER_H_ 3 4 #include <android/hardware/wifi/offload/1.0/IOffload.h> 5 6 #include "chre_interface_factory.h" 7 8 namespace android { 9 namespace hardware { 10 namespace wifi { 11 namespace offload { 12 namespace V1_0 { 13 namespace implementation { 14 15 class OffloadServer; 16 17 class ChreInterfaceCallbacksImpl : public ChreInterfaceCallbacks { 18 public: 19 ChreInterfaceCallbacksImpl(OffloadServer* server); 20 ~ChreInterfaceCallbacksImpl() override; 21 22 void handleConnectionEvents(ChreInterfaceCallbacks::ConnectionEvent event); 23 void handleMessage(uint32_t messageType, const std::vector<uint8_t>& message); 24 25 private: 26 OffloadServer* mServer; 27 }; 28 29 /** 30 * Interface object to communicate with Offload HAL 31 */ 32 class OffloadServer { 33 public: 34 OffloadServer(ChreInterfaceFactory* factory); 35 36 OffloadStatus configureScans(const ScanParam& param, const ScanFilter& filter); 37 std::pair<OffloadStatus, ScanStats> getScanStats(); 38 OffloadStatus subscribeScanResults(uint32_t delayMs); 39 bool unsubscribeScanResults(); 40 bool setEventCallback(const sp<IOffloadCallback>& cb); 41 void clearEventCallback(); 42 43 private: 44 void invokeErrorCallbackAndResetIfNeeded( 45 const android::hardware::wifi::offload::V1_0::OffloadStatus& status); 46 void handleScanResult(const std::vector<uint8_t>& message); 47 void handleScanStats(const std::vector<uint8_t>& message); 48 void resetNanoApp(); 49 50 ScanStats mScanStats; 51 std::mutex mScanStatsLock; 52 std::condition_variable mScanStatsCond; 53 std::mutex mOffloadLock; 54 OffloadStatus mScanStatsStatus; 55 56 std::unique_ptr<ChreInterfaceCallbacksImpl> mChreInterfaceCallbacks; 57 std::unique_ptr<ChreInterface> mChreInterface; 58 sp<IOffloadCallback> mEventCallback; 59 60 friend class ChreInterfaceCallbacksImpl; 61 }; 62 63 } // namespace implementation 64 } // namespace V1_0 65 } // namespace offload 66 } // namespace wifi 67 } // namespace hardware 68 } // namespace android 69 70 #endif // WIFI_OFFLOAD_SERVER_H_ 71