• 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 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 "cellular_data_types.h"
25 #include "datashare_helper.h"
26 #include "datashare_predicates.h"
27 #include "datashare_result_set.h"
28 #include "datashare_values_bucket.h"
29 #include "iservice_registry.h"
30 #include "refbase.h"
31 #include "string_ex.h"
32 #include "system_ability_definition.h"
33 #include "uri.h"
34 
35 namespace OHOS {
36 namespace Telephony {
37 struct PdpProfile;
38 static constexpr int SETUP_DATA_AUTH_NONE = 0;
39 static constexpr int SETUP_DATA_AUTH_PAP_CHAP = 3;
40 class CellularDataRdbHelper : public DelayedSingleton<CellularDataRdbHelper> {
41     DECLARE_DELAYED_SINGLETON(CellularDataRdbHelper);
42 
43 public:
44     bool QueryApns(const std::string &mcc, const std::string &mnc, std::vector<PdpProfile> &apnVec, int32_t slotId);
45     bool QueryMvnoApnsByType(const std::string &mcc, const std::string &mnc, const std::string &mvnoType,
46         const std::string &mvnoDataFromSim, std::vector<PdpProfile> &mvnoApnVec, int32_t slotId);
47     bool QueryPreferApn(int32_t slotId, std::vector<PdpProfile> &apnVec);
48     void RegisterObserver(const sptr<AAFwk::IDataAbilityObserver> &dataObserver);
49     void UnRegisterObserver(const sptr<AAFwk::IDataAbilityObserver> &dataObserver);
50     bool ResetApns(int32_t slotId);
51     void QueryApnIds(const ApnInfo &apnInfo, std::vector<uint32_t> &apnIdList);
52     int32_t SetPreferApn(int32_t apnId);
53     void QueryAllApnInfo(std::vector<ApnInfo> &apnInfoList);
54 
55 private:
56     std::shared_ptr<DataShare::DataShareHelper> CreateDataAbilityHelper();
57     int Update(const DataShare::DataShareValuesBucket &value, const DataShare::DataSharePredicates &predicates);
58     int Insert(const DataShare::DataShareValuesBucket &values);
59     void ReadApnResult(const std::shared_ptr<DataShare::DataShareResultSet> &result, std::vector<PdpProfile> &apnVec);
60     void ReadMvnoApnResult(const std::shared_ptr<DataShare::DataShareResultSet> &result,
61         const std::string &mvnoDataFromSim, std::vector<PdpProfile> &apnVec);
62     bool IsMvnoDataMatched(const std::string &mvnoDataFromSim, const PdpProfile &apnBean);
63     void MakePdpProfile(const std::shared_ptr<DataShare::DataShareResultSet> &result, int i, PdpProfile &apnBean);
64     int32_t GetSimId();
65     void GetApnInfo(ApnInfo &apnInfo, int rowIndex, std::shared_ptr<DataShare::DataShareResultSet> result);
66     std::string GetOpKey(int slotId);
67 
68 private:
69     Uri cellularDataUri_;
70 };
71 } // namespace Telephony
72 } // namespace OHOS
73 #endif // CELLULAR_DATA_RDB_HELPER_H
74