• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 SERVICES_EDM_INCLUDE_UTILS_APN_UTILS_H
17 #define SERVICES_EDM_INCLUDE_UTILS_APN_UTILS_H
18 
19 #include <string>
20 #include <memory>
21 
22 #include "datashare_helper.h"
23 #include "cellular_data_client.h"
24 #include "securec.h"
25 #include "apn_password.h"
26 
27 namespace OHOS {
28 namespace EDM {
29 struct ApnUtilsPassword : ApnPassword {
~ApnUtilsPasswordApnUtilsPassword30     ~ApnUtilsPassword()
31     {
32         if (password != nullptr) {
33             password = nullptr;
34         }
35         passwordSize = 0;
36     }
37 };
38 
39 class ApnUtils {
40 public:
41     static int32_t ApnInsert(const std::map<std::string, std::string> &apnInfo,
42         const ApnUtilsPassword &apnUtilsPassword);
43     static int32_t ApnDelete(const std::string &apnId);
44     static int32_t ApnUpdate(const std::map<std::string, std::string> &apnInfo, const std::string &apnId,
45         const ApnUtilsPassword &apnUtilsPassword);
46     static std::vector<std::string> ApnQuery(const std::map<std::string, std::string> &apnInfo);
47     static std::map<std::string, std::string> ApnQuery(const std::string &apnId);
48     static int32_t ApnSetPrefer(const std::string &apnId);
49 private:
50     static std::shared_ptr<DataShare::DataShareHelper> CreatePdpProfileAbilityHelper();
51     static std::shared_ptr<DataShare::DataShareHelper> CreateOpkeyAbilityHelper();
52     static int32_t ApnQueryResultSet(std::shared_ptr<DataShare::DataShareHelper> helper, const std::string &apnId,
53         std::map<std::string, std::string> &results);
54     static void ApnQueryVector(std::shared_ptr<DataShare::DataShareHelper> helper,
55         const std::map<std::string, std::string> &apnInfo, std::vector<std::string> &result);
56     static int32_t GetOpkey(const std::string &mccmnc, std::string &opkey);
57     static int32_t GetValidSimId(const std::string &apnId);
58     static int32_t MatchValidSimId(const std::string &opkey, int32_t slotId);
59 };
60 } // namespace EDM
61 } // namespace OHOS
62 #endif // SERVICES_EDM_INCLUDE_UTILS_APN_UTILS_H