/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef APN_HOLDER_H #define APN_HOLDER_H #include #include #include "apn_item.h" #include "cellular_data_constant.h" #include "connection_retry_policy.h" #ifdef __cplusplus extern "C" { #endif void ReleaseAllCellularData(); #ifdef __cplusplus } #endif namespace OHOS { namespace Telephony { class CellularDataStateMachine; class ApnHolder : public RefBase { public: ApnHolder(const std::string &apnType, const int32_t priority); ~ApnHolder(); sptr GetNextRetryApn() const; void SetAllMatchedApns(std::vector> &matchedApns); int64_t GetRetryDelay() const; void SetCurrentApn(sptr &apnItem); sptr GetCurrentApn() const; void SetApnState(ApnProfileState state); ApnProfileState GetApnState() const; bool IsDataCallEnabled() const; std::string GetApnType() const; void ReleaseDataConnection(); int32_t GetProfileId(const std::string &apnType) const; void SetCellularDataStateMachine(const std::shared_ptr &stateMachine); std::shared_ptr GetCellularDataStateMachine() const; uint64_t GetCapability() const; int32_t GetPriority() const; void RequestCellularData(const NetRequest &netRequest); void ReleaseCellularData(const NetRequest &netRequest); void ReleaseAllCellularData(); bool IsEmergencyType() const; bool IsMmsType() const; void InitialApnRetryCount(); bool IsSameMatchedApns(std::vector> newMatchedApns, bool roamingState); bool IsSameApnItem(const sptr &newApnItem, const sptr &oldApnItem, bool roamingState); bool IsCompatibleApnItem(const sptr &newApnItem, const sptr &oldApnItem, bool roamingState); private: ApnHolder(ApnHolder &apnHolder) = default; ApnHolder &operator=(ApnHolder &apnHolder) = default; private: static const std::map apnTypeDataProfileMap_; bool dataCallEnabled_ = false; uint64_t capability_ = 0; ConnectionRetryPolicy retryPolicy_; ApnProfileState apnState_ = ApnProfileState::PROFILE_STATE_IDLE; sptr apnItem_; std::string apnType_; int32_t priority_; std::shared_ptr cellularDataStateMachine_; std::vector netRequests_; }; } // namespace Telephony } // namespace OHOS #endif // APN_HOLDER_H