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 #include "wifi_protect.h"
17 #ifndef OHOS_ARCH_LITE
18 #include "wifi_log.h"
19
20 #undef LOG_TAG
21 #define LOG_TAG "OHWIFI_MANAGER_PROTECT"
22 #endif
23
24 namespace OHOS {
25 namespace Wifi {
WifiProtect(const WifiProtectType & protectType,const WifiProtectMode & protectMode,const std::string & name)26 WifiProtect::WifiProtect(
27 const WifiProtectType &protectType, const WifiProtectMode &protectMode, const std::string &name)
28 : mName(name),
29 mType(protectType),
30 mMode(protectMode),
31 mAcqTimestamp(0)
32 {}
33
WifiProtect(const std::string & name)34 WifiProtect::WifiProtect(const std::string &name)
35 : mName(name),
36 mType(WifiProtectType::WIFI_PROTECT_COMMON),
37 mMode(WifiProtectMode::WIFI_PROTECT_NO_HELD),
38 mAcqTimestamp(0)
39 {}
40
WifiProtect()41 WifiProtect::WifiProtect()
42 : mName(""),
43 mType(WifiProtectType::WIFI_PROTECT_COMMON),
44 mMode(WifiProtectMode::WIFI_PROTECT_NO_HELD),
45 mAcqTimestamp(0)
46 {}
47
~WifiProtect()48 WifiProtect::~WifiProtect()
49 {}
50
SetProtectType(const WifiProtectType & protectType)51 void WifiProtect::SetProtectType(const WifiProtectType &protectType)
52 {
53 std::unique_lock<std::mutex> lock(mMutex);
54 mType = protectType;
55 }
56
GetProtectType() const57 WifiProtectType WifiProtect::GetProtectType() const
58 {
59 return mType;
60 }
61
SetProtectMode(const WifiProtectMode & protectMode)62 void WifiProtect::SetProtectMode(const WifiProtectMode &protectMode)
63 {
64 std::unique_lock<std::mutex> lock(mMutex);
65 mMode = protectMode;
66 }
67
GetProtectMode() const68 WifiProtectMode WifiProtect::GetProtectMode() const
69 {
70 return mMode;
71 }
72
SetName(const std::string & name)73 void WifiProtect::SetName(const std::string &name)
74 {
75 std::unique_lock<std::mutex> lock(mMutex);
76 mName = name;
77 }
78
GetName() const79 std::string WifiProtect::GetName() const
80 {
81 return mName;
82 }
83
GetAcqTimestamp() const84 long WifiProtect::GetAcqTimestamp() const
85 {
86 return mAcqTimestamp;
87 }
88 #ifndef OHOS_ARCH_LITE
SetAppState(int state)89 void WifiProtect::SetAppState(int state)
90 {
91 std::unique_lock<std::mutex> lock(mMutex);
92 mAppState = state;
93 }
94
GetAppState() const95 int WifiProtect::GetAppState() const
96 {
97 return mAppState;
98 }
99 #endif
100 } // namespace Wifi
101 } // namespace OHOS
102