OSDN Git Service

Offload HAL Wificond Client: Handle binder death
[android-x86/system-connectivity-wificond.git] / scanning / offload / offload_service_utils.h
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
23 namespace android {
24 namespace wificond {
25
26 typedef std::function<void(uint64_t)> OffloadDeathRecipientHandler;
27
28 class OffloadDeathRecipient : public android::hardware::hidl_death_recipient {
29  public:
30   OffloadDeathRecipient(OffloadDeathRecipientHandler handler);
31
32   void serviceDied(
33       uint64_t cookie,
34       const android::wp<android::hidl::base::V1_0::IBase>& who) override {
35     this->handler_(cookie);
36   }
37
38  private:
39   OffloadDeathRecipientHandler handler_;
40 };
41
42 // Provides methods to get Offload HAL service and create callback
43 class OffloadServiceUtils {
44  public:
45   OffloadServiceUtils() = default;
46   virtual ~OffloadServiceUtils() = default;
47   virtual android::sp<android::hardware::wifi::offload::V1_0::IOffload>
48       GetOffloadService();
49   virtual android::sp<OffloadCallback> GetOffloadCallback(
50       OffloadCallbackHandlers* handlers);
51   virtual OffloadDeathRecipient* GetOffloadDeathRecipient(
52       OffloadDeathRecipientHandler handler);
53 };
54
55 }  // namespace wificond
56 }  // namespace android
57
58 #endif  // WIFICOND_OFFLOAD_SERVICE_UTILS_H