1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef OHOS_I_WIFI_SCAN_CALLBACK_STUB_H
16 #define OHOS_I_WIFI_SCAN_CALLBACK_STUB_H
17 
18 #ifdef OHOS_ARCH_LITE
19 #include "serializer.h"
20 #else
21 #include "iremote_stub.h"
22 #endif
23 #include "i_wifi_scan_callback.h"
24 
25 namespace OHOS {
26 namespace Wifi {
27 #ifdef OHOS_ARCH_LITE
28 class WifiScanCallbackStub : public IWifiScanCallback {
29 #else
30 class WifiScanCallbackStub : public IRemoteStub<IWifiScanCallback> {
31 #endif
32 public:
33     WifiScanCallbackStub();
34     virtual ~WifiScanCallbackStub();
35 #ifdef OHOS_ARCH_LITE
36     int OnRemoteRequest(uint32_t code, IpcIo *data);
37 #else
38     virtual int OnRemoteRequest(
39         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
40 #endif
41     void OnWifiScanStateChanged(int state) override;
42 #ifdef OHOS_ARCH_LITE
43     void RegisterCallBack(const std::shared_ptr<IWifiScanCallback> &userCallback);
44 #else
45     void RegisterCallBack(const sptr<IWifiScanCallback> &userCallback);
46 #endif
47     bool IsRemoteDied() const;
48     void SetRemoteDied(bool val);
49 
50 private:
51 #ifdef OHOS_ARCH_LITE
52     int RemoteOnWifiScanStateChanged(uint32_t code, IpcIo *data);
53     std::shared_ptr<IWifiScanCallback> userCallback_;
54 #else
55     int RemoteOnWifiScanStateChanged(uint32_t code, MessageParcel &data, MessageParcel &reply);
56     sptr<IWifiScanCallback> userCallback_;
57 #endif
58 
59     bool mRemoteDied;
60 };
61 }  // namespace Wifi
62 }  // namespace OHOS
63 #endif