• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-2024 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 CALL_EARTHQUAKE_ALARM_SUBSCRIBER_H
17 #define CALL_EARTHQUAKE_ALARM_SUBSCRIBER_H
18 
19 #include <mutex>
20 #include <unordered_map>
21 #include <memory>
22 #include "common_event_manager.h"
23 #include "common_event_subscribe_info.h"
24 #include "common_event_subscriber.h"
25 #include "common_event_support.h"
26 #include "matching_skills.h"
27 #include "system_ability_definition.h"
28 #include "uri.h"
29 #include "iservice_registry.h"
30 #include "telephony_errors.h"
31 #include "want.h"
32 #include "datashare_helper.h"
33 #include "datashare_predicates.h"
34 #include "rdb_errno.h"
35 #include "singleton.h"
36 #include "system_ability_status_change_stub.h"
37 #include "call_earthquake_alarm_locator.h"
38 #include "call_manager_inner_type.h"
39 #include "os_account_manager_wrapper.h"
40 #include "securec.h"
41 
42 namespace OHOS {
43 namespace Telephony {
44 class LocationSubscriber : public EventFwk::CommonEventSubscriber {
45 public:
46     LocationSubscriber() = default;
47     explicit LocationSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo);
48     virtual ~LocationSubscriber() = default;
49     virtual void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override;
50     static bool Subscriber(void);
51 public:
52     static const std::string SWITCH_STATE_CHANGE_EVENTS;
53     static const std::string SWITCH_STATE_START;
54     static const std::string SWITCH_STATE_STOP;
55     static const std::string SWITCH_STATE;
56     static std::shared_ptr<LocationSubscriber> subscriber_;
57     static const std::string SWITCH_STATE_KEY;
58 };
59 
60 class DataShareSwitchState {
61 public:
62     DataShareSwitchState();
63     int32_t QueryData(Uri& uri, const std::string& key, std::string& values);
64 public:
65     static const int TELEPHONY_SUCCESS;
66     static const int COW_COUNT_NULL;
67     static const int TELEPHONY_ERR_LOCAL_PTR_NULL;
68     static const int TELEPHONY_ERR_DATABASE_READ_FAIL;
69     static const int TELEPHONY_ERR_DATABASE_WRITE_FAIL;
70     static const int INVALID_VALUE;
71 private:
72     std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(int systemAbilityId);
73     std::shared_ptr<DataShare::DataShareHelper> datashareHelper_ = nullptr;
74 };
75 
76 class LocationSystemAbilityListener : public SystemAbilityStatusChangeStub {
77 public:
78     LocationSystemAbilityListener() = default;
79     ~LocationSystemAbilityListener() = default;
80     void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
81     void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
82     static bool SystemAbilitySubscriber();
83     static bool GetSystemAbility(int32_t systemAbilityId);
84 private:
85     static sptr<ISystemAbilityStatusChange> statusChangeListener_;
86 };
87 } // namespace Telephony
88 } // namespace OHOS
89 #endif //  CALL_MANAGER_SERVICE_SUBSCRIBER_H