15c735df2Sopenharmony_ci/*
25c735df2Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
35c735df2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45c735df2Sopenharmony_ci * you may not use this file except in compliance with the License.
55c735df2Sopenharmony_ci * You may obtain a copy of the License at
65c735df2Sopenharmony_ci *
75c735df2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85c735df2Sopenharmony_ci *
95c735df2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105c735df2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115c735df2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125c735df2Sopenharmony_ci * See the License for the specific language governing permissions and
135c735df2Sopenharmony_ci * limitations under the License.
145c735df2Sopenharmony_ci */
155c735df2Sopenharmony_ci
165c735df2Sopenharmony_ci#ifndef GNSS_STATUS_CALLBACK_H
175c735df2Sopenharmony_ci#define GNSS_STATUS_CALLBACK_H
185c735df2Sopenharmony_ci
195c735df2Sopenharmony_ci#include <cstdint>
205c735df2Sopenharmony_ci#include <functional>
215c735df2Sopenharmony_ci#include <string>
225c735df2Sopenharmony_ci#include <vector>
235c735df2Sopenharmony_ci#include "gnss_status_callback_napi.h"
245c735df2Sopenharmony_ci#include "geolocationmanager_utils.h"
255c735df2Sopenharmony_ci
265c735df2Sopenharmony_cinamespace OHOS {
275c735df2Sopenharmony_cinamespace GeoLocationManager {
285c735df2Sopenharmony_ciclass GnssStatusCallback : public IRemoteStub<Location::IGnssStatusCallback> {
295c735df2Sopenharmony_cipublic:
305c735df2Sopenharmony_ci    GnssStatusCallback();
315c735df2Sopenharmony_ci    GnssStatusCallback(int64_t callbackId);
325c735df2Sopenharmony_ci    virtual ~GnssStatusCallback();
335c735df2Sopenharmony_ci    virtual int OnRemoteRequest(
345c735df2Sopenharmony_ci        uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
355c735df2Sopenharmony_ci    bool IsRemoteDied();
365c735df2Sopenharmony_ci    bool Send(std::unique_ptr<Location::SatelliteStatus>& statusInfo);
375c735df2Sopenharmony_ci    void OnStatusChange(const std::unique_ptr<Location::SatelliteStatus>& statusInfo) override;
385c735df2Sopenharmony_ci    void DeleteHandler();
395c735df2Sopenharmony_ci    void UvQueueWork(uv_loop_s* loop, uv_work_t* work);
405c735df2Sopenharmony_ci
415c735df2Sopenharmony_ci    inline bool GetRemoteDied() const
425c735df2Sopenharmony_ci    {
435c735df2Sopenharmony_ci        return remoteDied_;
445c735df2Sopenharmony_ci    }
455c735df2Sopenharmony_ci
465c735df2Sopenharmony_ci    inline void SetRemoteDied(const bool remoteDied)
475c735df2Sopenharmony_ci    {
485c735df2Sopenharmony_ci        remoteDied_ = remoteDied;
495c735df2Sopenharmony_ci    }
505c735df2Sopenharmony_ci
515c735df2Sopenharmony_ci    int64_t GetCallBackId()
525c735df2Sopenharmony_ci    {
535c735df2Sopenharmony_ci        return callbackId_;
545c735df2Sopenharmony_ci    };
555c735df2Sopenharmony_ci
565c735df2Sopenharmony_ciprivate:
575c735df2Sopenharmony_ci    int64_t callbackId_ = -1;
585c735df2Sopenharmony_ci    std::function<void(const std::unique_ptr<Location::SatelliteStatus>& statusInfo)> callback_ = nullptr;
595c735df2Sopenharmony_ci    std::mutex mutex_;
605c735df2Sopenharmony_ci    bool remoteDied_;
615c735df2Sopenharmony_ci};
625c735df2Sopenharmony_ci}
635c735df2Sopenharmony_ci}
645c735df2Sopenharmony_ci
655c735df2Sopenharmony_ci#endif // GNSS_STATUS_CALLBACK_H