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_ITEM_H 17 #define APN_ITEM_H 18 19 #include <string> 20 #include <vector> 21 22 #include "refbase.h" 23 24 #include "pdp_profile_data.h" 25 26 #include "cellular_data_constant.h" 27 28 namespace OHOS { 29 namespace Telephony { 30 struct ApnActivateInfo { 31 uint64_t actSuccTime; 32 uint32_t duration; 33 uint32_t reason; 34 uint32_t apnId; 35 }; 36 37 struct ApnActivateReportInfo { 38 uint32_t actTimes; 39 uint32_t averDuration; 40 uint32_t topReason; 41 uint32_t actSuccTimes; 42 }; 43 class ApnItem : public RefBase { 44 public: 45 ApnItem(); 46 ~ApnItem(); 47 std::vector<std::string> GetApnTypes() const; 48 bool CanDealWithType(const std::string &type) const; 49 void MarkBadApn(bool badApn); 50 bool IsBadApn() const; 51 static sptr<ApnItem> MakeDefaultApn(const std::string &apnType); 52 static sptr<ApnItem> MakeApn(const PdpProfile &apnData); 53 static bool IsSimilarPdpProfile(const PdpProfile &newPdpProfile, const PdpProfile &oldPdpProfile); 54 55 private: 56 static sptr<ApnItem> BuildOtherApnAttributes(sptr<ApnItem> &apnItem, const PdpProfile &apnData); 57 static bool IsSimilarProtocol(const std::string &newProtocol, const std::string &oldProtocol); 58 59 public: 60 constexpr static int ALL_APN_ITEM_CHAR_LENGTH = 256; 61 struct Attribute { 62 char types_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 63 char numeric_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 64 int32_t profileId_ = 0; 65 char protocol_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 66 char roamingProtocol_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 67 int32_t authType_ = 0; 68 char apn_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 69 char apnName_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 70 char user_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 71 char password_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 72 bool isRoamingApn_ = false; 73 char homeUrl_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 74 char proxyIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 75 char mmsIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 }; 76 bool isEdited_ = false; 77 } attr_; 78 79 private: 80 std::vector<std::string> apnTypes_; 81 bool badApn_ = false; 82 }; 83 } // namespace Telephony 84 } // namespace OHOS 85 #endif // APN_ITEM_H 86