1 /* 2 * Copyright (C) 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 #include "pdp_profile_rdb_helper.h" 17 #include "telephony_data_helper.h" 18 #include "telephony_log_wrapper.h" 19 20 static constexpr const char *PDP_PROFILE_RDB_INIT_URI = 21 "datashare:///com.ohos.pdpprofileability/net/pdp_profile/init"; 22 static constexpr const char *SLOT_ID = "slotId"; 23 24 namespace OHOS { 25 namespace Telephony { PdpProfileRdbHelper()26PdpProfileRdbHelper::PdpProfileRdbHelper() {} 27 28 PdpProfileRdbHelper::~PdpProfileRdbHelper() = default; 29 CreatePdpProfileDataHelper()30std::shared_ptr<DataShare::DataShareHelper> PdpProfileRdbHelper::CreatePdpProfileDataHelper() 31 { 32 TELEPHONY_LOGI("PdpProfileRdbHelper::CreatePdpProfileDataHelper"); 33 auto helper = TelephonyDataHelper::GetInstance(); 34 if (helper == nullptr) { 35 TELEPHONY_LOGE("get CreatePdpProfileDataHelper Failed"); 36 return nullptr; 37 } 38 return helper->CreatePdpHelper(); 39 } 40 notifyInitApnConfigs(int32_t slotId)41void PdpProfileRdbHelper::notifyInitApnConfigs(int32_t slotId) 42 { 43 std::shared_ptr<DataShare::DataShareHelper> dataShareHelper = CreatePdpProfileDataHelper(); 44 if (dataShareHelper == nullptr) { 45 TELEPHONY_LOGE("dataShareHelper is nullptr"); 46 return; 47 } 48 std::vector<DataShare::DataShareValuesBucket> values; 49 DataShare::DataShareValuesBucket value; 50 value.Put(SLOT_ID, slotId); 51 values.push_back(value); 52 Uri pdpProfileUri(PDP_PROFILE_RDB_INIT_URI); 53 dataShareHelper->BatchInsert(pdpProfileUri, values); 54 dataShareHelper->Release(); 55 dataShareHelper = nullptr; 56 } 57 } // namespace Telephony 58 } // namespace OHOS