• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 TELEPHONY_CALL_DATA_BASE_HELPER_H
17 #define TELEPHONY_CALL_DATA_BASE_HELPER_H
18 
19 #include "ability_manager_interface.h"
20 #include "common_type.h"
21 #include "data_ability_observer_stub.h"
22 #include "datashare_helper.h"
23 #include "datashare_predicates.h"
24 #include "if_system_ability_manager.h"
25 #include "refbase.h"
26 #include "singleton.h"
27 #include "system_ability.h"
28 #include "system_ability_definition.h"
29 
30 namespace OHOS {
31 namespace Telephony {
32 constexpr const char *CALL_PHONE_NUMBER = "phone_number";
33 constexpr const char *CALL_DISPLAY_NAME = "display_name";
34 constexpr const char *CALL_DIRECTION = "call_direction";
35 constexpr const char *CALL_VOICEMAIL_URI = "voicemail_uri";
36 constexpr const char *CALL_SIM_TYPE = "sim_type";
37 constexpr const char *CALL_IS_HD = "is_hd";
38 constexpr const char *CALL_IS_READ = "is_read";
39 constexpr const char *CALL_RING_DURATION = "ring_duration";
40 constexpr const char *CALL_TALK_DURATION = "talk_duration";
41 constexpr const char *CALL_FORMAT_NUMBER = "format_number";
42 constexpr const char *CALL_QUICKSEARCH_KEY = "quicksearch_key";
43 constexpr const char *CALL_NUMBER_TYPE = "number_type";
44 constexpr const char *CALL_NUMBER_TYPE_NAME = "number_type_name";
45 constexpr const char *CALL_BEGIN_TIME = "begin_time";
46 constexpr const char *CALL_END_TIME = "end_time";
47 constexpr const char *CALL_ANSWER_STATE = "answer_state";
48 constexpr const char *CALL_CREATE_TIME = "create_time";
49 constexpr const char *CALL_NUMBER_LOCATION = "number_location";
50 constexpr const char *CALL_PHOTO_ID = "photo_id";
51 constexpr const char *CALL_DETAIL_INFO = "detail_info";
52 constexpr const char *CALL_CONTENT_TYPE = "content_type";
53 constexpr const char *CALL_PHONE = "phone";
54 constexpr const char *CALL_SLOT_ID = "slot_id";
55 
56 class CallDataRdbObserver : public AAFwk::DataAbilityObserverStub {
57 public:
58     CallDataRdbObserver(std::vector<std::string> *phones);
59     ~CallDataRdbObserver();
60     void OnChange() override;
61 
62 private:
63     std::vector<std::string> *phones;
64 };
65 
66 class CallDataBaseHelper {
67     DECLARE_DELAYED_SINGLETON(CallDataBaseHelper)
68 public:
69     void RegisterObserver(std::vector<std::string> *phones);
70     void UnRegisterObserver();
71     bool Insert(DataShare::DataShareValuesBucket &values);
72     bool Query(std::vector<std::string> *phones, DataShare::DataSharePredicates &predicates);
73     bool Query(ContactInfo &contactInfo, DataShare::DataSharePredicates &predicates);
74     bool Delete(DataShare::DataSharePredicates &predicates);
75 
76 private:
77     sptr<CallDataRdbObserver> callDataRdbObserverPtr_;
78     std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(std::string uri);
79 };
80 } // namespace Telephony
81 } // namespace OHOS
82 #endif