/* * 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_MANAGER_H #define APN_MANAGER_H #include #include #include #include "apn_holder.h" #include "apn_item.h" #include "cellular_data_rdb_helper.h" #include "net_all_capabilities.h" namespace OHOS { namespace Telephony { class ApnManager : public RefBase { public: ApnManager(); ~ApnManager(); sptr GetApnHolder(const std::string &apnType) const; std::vector> GetAllApnHolder() const; std::vector> GetSortApnHolder() const; void CreateAllApnItem(); std::vector> FilterMatchedApns(const std::string &requestApnType, const int32_t slotId); void InitApnHolders(); sptr FindApnHolderById(const int32_t id) const; static int32_t FindApnIdByApnName(const std::string &type); static std::string FindApnNameByApnId(const int32_t id); static int32_t FindApnIdByCapability(const uint64_t capabilities); static NetManagerStandard::NetCap FindBestCapability(const uint64_t capabilities); bool IsDataConnectionNotUsed(const std::shared_ptr &stateMachine) const; int32_t CreateAllApnItemByDatabase(int32_t slotId); bool HasAnyConnectedState() const; ApnProfileState GetOverallApnState() const; ApnProfileState GetOverallDefaultApnState() const; sptr GetRilAttachApn(); sptr GetApnItemById(const int32_t id); bool ResetApns(int32_t slotId); void FetchDunApns(std::vector> &matchApnItemList, const int32_t slotId); bool IsPreferredApnUserEdited(); private: void AddApnHolder(const std::string &apnType, const int32_t priority); int32_t CreateMvnoApnItems(int32_t slotId, const std::string &mcc, const std::string &mnc); int32_t MakeSpecificApnItem(std::vector &apnVec); void GetCTOperator(int32_t slotId, std::string &numeric); private: static const std::map apnIdApnNameMap_; static const std::vector apnStateArr_; std::vector> allApnItem_; std::vector> apnHolders_; std::map> apnIdApnHolderMap_; std::vector> sortedApnHolders_; std::mutex mutex_; int32_t preferId_ = INVALID_PROFILE_ID; }; } // namespace Telephony } // namespace OHOS #endif // APN_MANAGER_H