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 GNSS_EVENT_CALLBACK_H
17#define GNSS_EVENT_CALLBACK_H
18#ifdef FEATURE_GNSS_SUPPORT
19
20#include <v2_0/ignss_callback.h>
21#include "satellite_status.h"
22
23namespace OHOS {
24namespace Location {
25using HDI::Location::Gnss::V2_0::IGnssCallback;
26using HDI::Location::Gnss::V2_0::LocationInfo;
27using HDI::Location::Gnss::V2_0::GnssWorkingStatus;
28using HDI::Location::Gnss::V2_0::GnssCapabilities;
29using HDI::Location::Gnss::V2_0::SatelliteStatusInfo;
30using HDI::Location::Gnss::V2_0::GnssRefInfoType;
31using HDI::Location::Gnss::V2_0::GnssNiNotificationRequest;
32
33class GnssEventCallback : public IGnssCallback {
34public:
35    ~GnssEventCallback() override {}
36    int32_t ReportLocation(const LocationInfo& location) override;
37    int32_t ReportGnssWorkingStatus(GnssWorkingStatus status) override;
38    int32_t ReportNmea(int64_t timestamp, const std::string& nmea, int32_t length) override;
39    int32_t ReportGnssCapabilities(unsigned int capabilities) override;
40    int32_t ReportSatelliteStatusInfo(const SatelliteStatusInfo& info) override;
41    int32_t RequestGnssReferenceInfo(GnssRefInfoType type) override;
42    int32_t RequestPredictGnssData() override;
43    int32_t ReportCachedLocation(const std::vector<LocationInfo>& gnssLocations) override;
44    int32_t ReportGnssNiNotification(const GnssNiNotificationRequest& notification) override;
45private:
46    void SendDummySvInfo();
47    bool IsNeedSvIncrease();
48    bool IsSvTypeGps(const std::unique_ptr<SatelliteStatus> &sv, int index);
49    bool IsSvUsed(const std::unique_ptr<SatelliteStatus> &sv, int index);
50    void AddDummySv(std::unique_ptr<SatelliteStatus> &sv, int svid, int cN0Dbhz);
51    void ReportDummySv(const std::unique_ptr<SatelliteStatus> &sv);
52    std::mutex svInfoMutex_;
53};
54}  // namespace Location
55}  // namespace OHOS
56#endif // FEATURE_GNSS_SUPPORT
57#endif // GNSS_EVENT_CALLBACK_H
58