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 OHOS_WIFIPROTECT_H 17 #define OHOS_WIFIPROTECT_H 18 19 #include <string> 20 #include <mutex> 21 #include "wifi_msg.h" 22 23 namespace OHOS { 24 namespace Wifi { 25 class WifiProtect { 26 public: 27 /** 28 * @Description Construct a new Wifi Protect object 29 * 30 * @param protectType - protect type 31 * @param protectMode - protect mode 32 * @param name - protect name, which is a unique identifier 33 */ 34 WifiProtect(const WifiProtectType &protectType, const WifiProtectMode &protectMode, const std::string &name); 35 36 /** 37 * @Description Construct a new Wifi Full Protect object 38 * 39 * @param tag - protect name, which is a unique identifier 40 */ 41 explicit WifiProtect(const std::string &name); 42 43 /** 44 * @Description Construct a new Default Wifi Protect object 45 * 46 */ 47 WifiProtect(); 48 49 /** 50 * @Description Destroy the Wifi Protect object 51 * 52 */ 53 ~WifiProtect(); 54 55 /** 56 * @Description Set the Tag object 57 * 58 * @param tag - protect name 59 */ 60 void SetName(const std::string &name); 61 62 /** 63 * @Description Get the Tag object 64 * 65 * @return std::string - Wifi protect Tag 66 */ 67 std::string GetName() const; 68 69 /** 70 * @Description Set the Protect Type object 71 * 72 * @param protectType - protect type 73 */ 74 void SetProtectType(const WifiProtectType &protectType); 75 76 /** 77 * @Description Get the Protect Type object 78 * 79 * @return WifiProtectType - protect type 80 */ 81 WifiProtectType GetProtectType() const; 82 83 /** 84 * @Description Set the Protect Mode object 85 * 86 * @param protectMode - protect mode 87 */ 88 void SetProtectMode(const WifiProtectMode &protectMode); 89 90 /** 91 * @Description Get the Protect Mode object 92 * 93 * @return WifiProtectMode - protect mode 94 */ 95 WifiProtectMode GetProtectMode() const; 96 97 /** 98 * @Description Get the Acq Timestamp 99 * 100 * @return long - timestamp 101 */ 102 long GetAcqTimestamp() const; 103 #ifndef OHOS_ARCH_LITE 104 /** 105 * @Description Set the Protect app state 106 * 107 * @param state - app state 108 */ 109 void SetAppState(int state); 110 111 /** 112 * @Description Get the Protect app state 113 * 114 * @param state - app state 115 */ 116 int GetAppState() const; 117 #endif 118 private: 119 std::string mName; 120 /* not used: int mUid; */ 121 WifiProtectType mType {WifiProtectType::WIFI_PROTECT_COMMON}; 122 WifiProtectMode mMode {WifiProtectMode::WIFI_PROTECT_NO_HELD}; 123 long mAcqTimestamp {0}; 124 std::mutex mMutex; 125 #ifndef OHOS_ARCH_LITE 126 int mAppState {6}; 127 #endif 128 }; 129 } // namespace Wifi 130 } // namespace OHOS 131 #endif 132