• 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_HOLDER_H
17 #define APN_HOLDER_H
18 
19 #include <map>
20 
21 #include "apn_item.h"
22 #include "cellular_data_constant.h"
23 #include "connection_retry_policy.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 class CellularDataStateMachine;
28 
29 class ApnHolder : public RefBase {
30 public:
31     ApnHolder(const std::string &apnType, const int32_t priority);
32     ~ApnHolder();
33     sptr<ApnItem> GetNextRetryApn() const;
34     void SetAllMatchedApns(std::vector<sptr<ApnItem>> &matchedApns);
35     int64_t GetRetryDelay() const;
36     void SetCurrentApn(sptr<ApnItem> &apnItem);
37     sptr<ApnItem> GetCurrentApn() const;
38     void SetApnState(ApnProfileState state);
39     ApnProfileState GetApnState() const;
40     bool IsDataCallEnabled() const;
41     bool IsDataCallConnectable() const;
42     std::string GetApnType() const;
43     void ReleaseDataConnection();
44     int32_t GetProfileId(const std::string &apnType) const;
45     void SetCellularDataStateMachine(const std::shared_ptr<CellularDataStateMachine> &stateMachine);
46     std::shared_ptr<CellularDataStateMachine> GetCellularDataStateMachine() const;
47     uint32_t GetCapability() const;
48     int32_t GetPriority() const;
49     void RequestCellularData(const NetRequest &netRequest);
50     void ReleaseCellularData(const NetRequest &netRequest);
51     bool IsEmergencyType() const;
52     void InitialApnRetryCount();
53 
54 private:
55     ApnHolder(ApnHolder &apnHolder) = default;
56     ApnHolder &operator=(ApnHolder &apnHolder) = default;
57 
58 private:
59     static const std::map<std::string, int32_t> apnTypeDataProfileMap_;
60     bool dataCallEnabled_ = false;
61     uint64_t capability_ = 0;
62     ConnectionRetryPolicy retryPolicy_;
63     ApnProfileState apnState_ = ApnProfileState::PROFILE_STATE_IDLE;
64     sptr<ApnItem> apnItem_;
65     std::string apnType_;
66     int32_t priority_;
67     std::shared_ptr<CellularDataStateMachine> cellularDataStateMachine_;
68     std::vector<NetRequest> netRequests_;
69 };
70 } // namespace Telephony
71 } // namespace OHOS
72 #endif // APN_HOLDER_H
73