• 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 SMS_PERSIST_HELPER_H
17 #define SMS_PERSIST_HELPER_H
18 
19 #include "singleton.h"
20 
21 #include "data_ability_helper.h"
22 #include "data_ability_predicates.h"
23 #include "values_bucket.h"
24 #include "abs_shared_result_set.h"
25 
26 #include "sms_receive_indexer.h"
27 #include "sms_mms_data.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 class SmsPersistHelper {
32     DECLARE_DELAYED_SINGLETON(SmsPersistHelper)
33 public:
34     bool Insert(NativeRdb::ValuesBucket &values);
35     bool Query(NativeRdb::DataAbilityPredicates &predicates, std::vector<SmsReceiveIndexer> &indexers);
36     bool Delete(NativeRdb::DataAbilityPredicates &predicates);
37     bool QueryBlockPhoneNumber(const std::string &phoneNum);
38     bool QueryParamBoolean(const std::string key, bool defValue);
39 
40     inline static const std::string SMS_CAPABLE_KEY = "sms_config_capable";
41     inline static const std::string SMS_ENCODING_KEY = "sms_config_force_7bit_encoding";
42     inline static const std::string SMS_CAPABLE_PARAM_KEY = "const.telephony.sms.capable";
43     inline static const std::string SMS_ENCODING_PARAM_KEY = "persist.sys.sms.config.7bitforce";
44 
45 private:
46     const std::string SMS_SUBSECTION = "dataability:///com.ohos.smsmmsability/sms_mms/sms_subsection";
47     const std::string CONTACT_BLOCK =
48         "dataability:///com.ohos.contactsdataability/contacts/contact_blocklist";
49 
50     std::shared_ptr<AppExecFwk::DataAbilityHelper> CreateDataAHelper();
51     void ResultSetConvertToIndexer(
52         SmsReceiveIndexer &info, const std::shared_ptr<NativeRdb::AbsSharedResultSet> &resultSet);
53     void ConvertIntToIndexer(
54         SmsReceiveIndexer &info, const std::shared_ptr<NativeRdb::AbsSharedResultSet> &resultSet);
55     void ConvertStringToIndexer(
56         SmsReceiveIndexer &info, const std::shared_ptr<NativeRdb::AbsSharedResultSet> &resultSet);
57 };
58 } // namespace Telephony
59 } // namespace OHOS
60 #endif
61