• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef WIFICOND_OFFLOAD_SERVICE_UTILS_H_
17 #define WIFICOND_OFFLOAD_SERVICE_UTILS_H_
18 
19 #include <android/hardware/wifi/offload/1.0/IOffload.h>
20 #include "wificond/scanning/offload/offload_callback.h"
21 #include "wificond/scanning/offload/offload_callback_handlers.h"
22 #include "wificond/scanning/offload_scan_callback_interface_impl.h"
23 
24 namespace android {
25 namespace wificond {
26 
27 typedef std::function<void(uint64_t)> OffloadDeathRecipientHandler;
28 class ScannerImpl;
29 class OffloadServiceUtils;
30 class OffloadScanManager;
31 
32 class OffloadDeathRecipient : public android::hardware::hidl_death_recipient {
33  public:
34   OffloadDeathRecipient(OffloadDeathRecipientHandler handler);
35 
serviceDied(uint64_t cookie,const android::wp<android::hidl::base::V1_0::IBase> & who)36   void serviceDied(
37       uint64_t cookie,
38       const android::wp<android::hidl::base::V1_0::IBase>& who) override {
39     this->handler_(cookie);
40   }
41 
42  private:
43   OffloadDeathRecipientHandler handler_;
44 };
45 
46 // Provides methods to get Offload HAL service and create callback
47 class OffloadServiceUtils {
48  public:
49   OffloadServiceUtils() = default;
50   virtual ~OffloadServiceUtils() = default;
51   virtual android::sp<android::hardware::wifi::offload::V1_0::IOffload>
52       GetOffloadService();
53   // Check if Offload scan is supported on this device.
54   virtual bool IsOffloadScanSupported() const;
55   virtual android::sp<OffloadCallback> GetOffloadCallback(
56       OffloadCallbackHandlers* handlers);
57   virtual OffloadDeathRecipient* GetOffloadDeathRecipient(
58       OffloadDeathRecipientHandler handler);
59   virtual std::shared_ptr<OffloadScanCallbackInterfaceImpl>
60   GetOffloadScanCallbackInterface(ScannerImpl* parent);
61   virtual std::shared_ptr<OffloadScanManager> GetOffloadScanManager(
62       std::weak_ptr<OffloadServiceUtils> service_utils,
63       std::shared_ptr<OffloadScanCallbackInterfaceImpl> callback_interface);
64 };
65 
66 }  // namespace wificond
67 }  // namespace android
68 
69 #endif  // WIFICOND_OFFLOAD_SERVICE_UTILS_H
70