• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
16 #ifndef OHOS_HDI_LOCATION_LOCATION_GNSS_V2_0_GNSSINTERFACEIMPL_H
17 #define OHOS_HDI_LOCATION_LOCATION_GNSS_V2_0_GNSSINTERFACEIMPL_H
18 
19 #include "v2_0/ignss_interface.h"
20 
21 #include "iremote_object.h"
22 #include "location_vendor_interface.h"
23 #include "location_vendor_lib.h"
24 namespace OHOS {
25 namespace HDI {
26 namespace Location {
27 namespace Gnss {
28 namespace V2_0 {
29 
30 void NmeaCallback(int64_t timestamp, const char* nmea, int length);
31 void GetGnssCallbackMethods(GnssCallbackStruct* device);
32 void GetGnssBasicCallbackMethods(GnssBasicCallbackIfaces* device);
33 void GetGnssCacheCallbackMethods(GnssCacheCallbackIfaces* device);
34 void SvStatusCallback(GnssSatelliteStatus* svInfo);
35 void GnssWorkingStatusUpdate(uint16_t* status);
36 void GnssMeasurementUpdate(OHOS::HDI::Location::GnssMeasurementInfo* gnssMeasurementInfo);
37 void LocationUpdate(GnssLocation* location);
38 void SetGnssClock(OHOS::HDI::Location::Gnss::V2_0::GnssMeasurementInfo* gnssMeasurementInfoNew,
39     OHOS::HDI::Location::GnssMeasurementInfo* gnssMeasurementInfo);
40 void NiNotifyCallback(OHOS::HDI::Location::GnssNiNotificationRequest *notification);
41 void GetGnssMeasurementCallbackMethods(GnssMeasurementCallbackIfaces* device);
42 
43 class GnssInterfaceImpl : public IGnssInterface {
44 public:
45     GnssInterfaceImpl();
46     ~GnssInterfaceImpl() override;
47 
48     int32_t SetGnssConfigPara(const GnssConfigPara& para) override;
49 
50     int32_t EnableGnss(const sptr<IGnssCallback>& callbackObj) override;
51 
52     int32_t DisableGnss() override;
53 
54     int32_t StartGnss(GnssStartType type) override;
55 
56     int32_t StopGnss(GnssStartType type) override;
57 
58     int32_t SetGnssReferenceInfo(const GnssRefInfo& refInfo) override;
59 
60     int32_t DeleteAuxiliaryData(unsigned short data) override;
61 
62     int32_t SetPredictGnssData(const std::string& data) override;
63 
64     int32_t GetCachedGnssLocationsSize(int32_t& size) override;
65 
66     int32_t GetCachedGnssLocations() override;
67 
68     int32_t SendNiUserResponse(int32_t gnssNiNotificationId, GnssNiResponseCmd userResponse) override;
69 
70     int32_t SendNetworkInitiatedMsg(const std::string& msg, int32_t length) override;
71 
72     int32_t EnableGnssMeasurement(const sptr<IGnssMeasurementCallback>& callbackObj) override;
73 
74     int32_t DisableGnssMeasurement() override;
75 
76     void ResetGnss();
77 private:
78     int32_t AddGnssDeathRecipient(const sptr<IGnssCallback>& callbackObj);
79 
80     int32_t RemoveGnssDeathRecipient(const sptr<IGnssCallback>& callbackObj);
81 
82     void ResetGnssDeathRecipient();
83 };
84 
85 class GnssCallBackDeathRecipient : public IRemoteObject::DeathRecipient {
86 public:
GnssCallBackDeathRecipient(const wptr<GnssInterfaceImpl> & impl)87     explicit GnssCallBackDeathRecipient(const wptr<GnssInterfaceImpl>& impl) : gnssInterfaceImpl_(impl) {};
88     ~GnssCallBackDeathRecipient() = default;
OnRemoteDied(const wptr<IRemoteObject> & remote)89     void OnRemoteDied(const wptr<IRemoteObject>& remote) override
90     {
91         (void)remote;
92         sptr<GnssInterfaceImpl> impl = gnssInterfaceImpl_.promote();
93         if (impl != nullptr) {
94             impl->ResetGnss();
95         }
96     };
97 private:
98     wptr<GnssInterfaceImpl> gnssInterfaceImpl_;
99 };
100 } // V2_0
101 } // Gnss
102 } // Location
103 } // HDI
104 } // OHOS
105 
106 #endif // OHOS_HDI_LOCATION_LOCATION_GNSS_V2_0_GNSSINTERFACEIMPL_H
107