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 LOCATION_DATA_MANAGER_H
17#define LOCATION_DATA_MANAGER_H
18
19#include <map>
20#include <singleton.h>
21#include "iremote_object.h"
22#include "constant_definition.h"
23#include "i_switch_callback.h"
24#include "common_utils.h"
25#include "app_identity.h"
26
27namespace OHOS {
28namespace Location {
29class LocationDataManager {
30public:
31    LocationDataManager();
32    ~LocationDataManager();
33    LocationErrCode ReportSwitchState(bool isEnabled);
34    LocationErrCode RegisterSwitchCallback(const sptr<IRemoteObject>& callback, AppIdentity& appIdentity);
35    LocationErrCode UnregisterSwitchCallback(const sptr<IRemoteObject>& callback);
36    bool IsSwitchObserverReg();
37    void SetIsSwitchObserverReg(bool isSwitchObserverReg);
38    bool IsFirstReport();
39    void SetIsFirstReport(bool isFirstReport);
40    void RegisterLocationSwitchObserver();
41    static LocationDataManager* GetInstance();
42
43private:
44    std::mutex mutex_;
45    std::mutex isSwitchObserverRegMutex_;
46    bool isSwitchObserverReg_ = false;
47    std::map<sptr<IRemoteObject>, std::vector<int>> switchCallbackMap_;
48    std::mutex isFirstReportMutex_;
49    bool isFirstReport_ = true;
50};
51}  // namespace Location
52}  // namespace OHOS
53#endif // LOCATION_DATA_MANAGER_H
54