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_SIM_RDB_HELPER_H 17 #define TELEPHONY_SIM_RDB_HELPER_H 18 19 #include <vector> 20 21 #include "abs_shared_result_set.h" 22 #include "data_ability_helper.h" 23 #include "data_ability_predicates.h" 24 #include "iservice_registry.h" 25 #include "result_set.h" 26 #include "sim_constant.h" 27 #include "sim_rdb_info.h" 28 #include "sim_utils.h" 29 #include "system_ability_definition.h" 30 #include "telephony_log_wrapper.h" 31 #include "uri.h" 32 #include "values_bucket.h" 33 34 namespace OHOS { 35 namespace Telephony { 36 class SimRdbHelper { 37 public: 38 SimRdbHelper(); 39 ~SimRdbHelper(); 40 41 int32_t GetDefaultMainCardSlotId(); 42 int32_t GetDefaultMessageCardSlotId(); 43 int32_t GetDefaultVoiceCardSlotId(); 44 int32_t GetDefaultCellularDataCardSlotId(); 45 int32_t SetDefaultMainCard(int32_t slotId); 46 int32_t SetDefaultVoiceCard(int32_t slotId); 47 int32_t SetDefaultMessageCard(int32_t slotId); 48 int32_t SetDefaultCellularData(int32_t slotId); 49 int32_t InsertData(int64_t &id, const NativeRdb::ValuesBucket &values); 50 int32_t QueryDataBySlotId(int32_t slotId, SimRdbInfo &simBean); 51 int32_t QueryDataByIccId(std::string iccId, SimRdbInfo &simBean); 52 int32_t QueryAllData(std::vector<SimRdbInfo> &vec); 53 int32_t QueryAllValidData(std::vector<SimRdbInfo> &vec); 54 int32_t UpdateDataBySlotId(int32_t slotId, const NativeRdb::ValuesBucket &values); 55 int32_t UpdateDataByIccId(std::string iccId, const NativeRdb::ValuesBucket &values); 56 int32_t ForgetAllData(); 57 int32_t ForgetAllData(int32_t slotId); 58 int32_t ClearData(); 59 60 private: 61 std::shared_ptr<AppExecFwk::DataAbilityHelper> CreateDataAHelper(); 62 int Insert(const NativeRdb::ValuesBucket &values); 63 std::shared_ptr<NativeRdb::AbsSharedResultSet> Query( 64 std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates); 65 int Update(const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates); 66 int Delete(const NativeRdb::DataAbilityPredicates &predicates); 67 void SaveDataToBean(std::shared_ptr<NativeRdb::AbsSharedResultSet> result, SimRdbInfo &simBean); 68 69 private: 70 std::shared_ptr<AppExecFwk::DataAbilityHelper> helper_ = nullptr; 71 72 private: 73 enum class DefaultCardType { 74 MAIN, 75 VOICE, 76 SMS, 77 DATA, 78 }; 79 }; 80 } // namespace Telephony 81 } // namespace OHOS 82 #endif // TELEPHONY_SIM_RDB_HELPER_H 83