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 CELLULAR_DATA_RDB_HELPER_H 17 #define CELLULAR_DATA_RDB_HELPER_H 18 19 #include <memory> 20 #include <regex> 21 #include <singleton.h> 22 #include <utility> 23 24 #include "datashare_helper.h" 25 #include "datashare_predicates.h" 26 #include "datashare_result_set.h" 27 #include "datashare_values_bucket.h" 28 #include "iservice_registry.h" 29 #include "pdp_profile_data.h" 30 #include "refbase.h" 31 #include "system_ability_definition.h" 32 #include "uri.h" 33 34 namespace OHOS { 35 namespace Telephony { 36 class CellularDataRdbHelper : public DelayedSingleton<CellularDataRdbHelper> { 37 DECLARE_DELAYED_SINGLETON(CellularDataRdbHelper); 38 39 public: 40 bool QueryApns(const std::string &mcc, const std::string &mnc, std::vector<PdpProfile> &apnVec, int32_t slotId); 41 bool QueryMvnoApnsByType(const std::string &mcc, const std::string &mnc, const std::string &mvnoType, 42 const std::string &mvnoDataFromSim, std::vector<PdpProfile> &mvnoApnVec, int32_t slotId); 43 bool QueryPreferApn(int32_t slotId, std::vector<PdpProfile> &apnVec); 44 void RegisterObserver(const sptr<AAFwk::IDataAbilityObserver> &dataObserver); 45 void UnRegisterObserver(const sptr<AAFwk::IDataAbilityObserver> &dataObserver); 46 bool ResetApns(int32_t slotId); 47 48 private: 49 std::shared_ptr<DataShare::DataShareHelper> CreateDataAbilityHelper(); 50 int Update(const DataShare::DataShareValuesBucket &value, const DataShare::DataSharePredicates &predicates); 51 int Insert(const DataShare::DataShareValuesBucket &values); 52 void ReadApnResult(const std::shared_ptr<DataShare::DataShareResultSet> &result, std::vector<PdpProfile> &apnVec); 53 void ReadMvnoApnResult(const std::shared_ptr<DataShare::DataShareResultSet> &result, 54 const std::string &mvnoDataFromSim, std::vector<PdpProfile> &apnVec); 55 bool IsMvnoDataMatched(const std::string &mvnoDataFromSim, const PdpProfile &apnBean); 56 void MakePdpProfile(const std::shared_ptr<DataShare::DataShareResultSet> &result, int i, PdpProfile &apnBean); 57 58 private: 59 Uri cellularDataUri_; 60 }; 61 } // namespace Telephony 62 } // namespace OHOS 63 #endif // CELLULAR_DATA_RDB_HELPER_H 64