1 /*
2  * Copyright (C) 2023 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 
16 #ifndef NATIVE_SV_CALLBACK_HOST_H
17 #define NATIVE_SV_CALLBACK_HOST_H
18 
19 #include "iremote_stub.h"
20 #include "message_option.h"
21 #include "message_parcel.h"
22 
23 #include "i_gnss_status_callback.h"
24 #include "satellite_status.h"
25 #include "constant_definition.h"
26 
27 namespace OHOS {
28 namespace Location {
29 typedef void (* SvStatusUpdate)(const std::unique_ptr<SatelliteStatus>& statusInfo);
30 
31 typedef struct {
32     SvStatusUpdate svStatusUpdate;
33 } SvStatusCallbackIfaces;
34 
35 class NativeSvCallbackHost : public IRemoteStub<IGnssStatusCallback> {
36 public:
37     virtual int OnRemoteRequest(
38         uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
39     void OnStatusChange(const std::unique_ptr<SatelliteStatus>& statusInfo) override;
40 
GetCallback()41     inline SvStatusCallbackIfaces GetCallback() const
42     {
43         return svCallback_;
44     }
45 
SetCallback(const SvStatusCallbackIfaces & svCallback)46     inline void SetCallback(const SvStatusCallbackIfaces& svCallback)
47     {
48         svCallback_ = svCallback;
49     }
50 
51 private:
52     SvStatusCallbackIfaces svCallback_;
53 };
54 } // namespace Location
55 } // namespace OHOS
56 #endif // NATIVE_SV_CALLBACK_HOST_H
57