• 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 APN_MANAGER_H
17 #define APN_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "apn_holder.h"
23 #include "apn_item.h"
24 #include "cellular_data_rdb_helper.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class ApnManager : public RefBase {
29 public:
30     ApnManager();
31     ~ApnManager();
32     sptr<ApnHolder> GetApnHolder(const std::string &apnType) const;
33     std::vector<sptr<ApnHolder>> GetAllApnHolder() const;
34     std::vector<sptr<ApnHolder>> GetSortApnHolder() const;
35     void CreateAllApnItem();
36     std::vector<sptr<ApnItem>> FilterMatchedApns(const std::string &requestApnType) const;
37     void InitApnHolders();
38     sptr<ApnHolder> FindApnHolderById(const int32_t id) const;
39     static int32_t FindApnIdByApnName(const std::string &type);
40     static std::string FindApnNameByApnId(const int32_t id);
41     static int32_t FindApnIdByCapability(const uint64_t capability);
42     bool IsDataConnectionNotUsed(const std::shared_ptr<CellularDataStateMachine> &stateMachine) const;
43     int32_t CreateAllApnItemByDatabase(const std::string &numeric);
44     bool HasAnyConnectedState() const;
45     ApnProfileState GetOverallApnState() const;
46     sptr<ApnItem> GetRilAttachApn() const;
47 
48 private:
49     void AddApnHolder(const std::string &apnType, const int32_t priority);
50 
51 private:
52     static const std::map<std::string, int32_t> apnIdApnNameMap_;
53     std::vector<sptr<ApnItem>> allApnItem_;
54     std::vector<sptr<ApnHolder>> apnHolders_;
55     std::map<int32_t, sptr<ApnHolder>> apnIdApnHolderMap_;
56     std::vector<sptr<ApnHolder>> sortedApnHolders_;
57 };
58 } // namespace Telephony
59 } // namespace OHOS
60 #endif // APN_MANAGER_H