1/*
2 * Copyright (c) 2023 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 "mock_wakelock_name.h"
17
18#include <algorithm>
19
20namespace OHOS {
21namespace HDI {
22namespace Power {
23namespace V1_2 {
24std::vector<std::string> MockWakeLockName::wakeLockName = {};
25
26bool MockWakeLockName::FindWakeLockName(const std::string &name)
27{
28    auto it = std::find(wakeLockName.begin(), wakeLockName.end(), name);
29    if (it != wakeLockName.end()) {
30        return true;
31    }
32    return false;
33}
34
35void MockWakeLockName::WriteWakeLockName(const std::string &name)
36{
37    auto it = std::find(wakeLockName.begin(), wakeLockName.end(), name);
38    if (it == wakeLockName.end()) {
39        wakeLockName.emplace_back(name);
40    }
41}
42
43void MockWakeLockName::WriteWakeUnlockName(const std::string &name)
44{
45    auto it = std::find(wakeLockName.begin(), wakeLockName.end(), name);
46    if (it != wakeLockName.end()) {
47        wakeLockName.erase(it);
48    }
49}
50} // namespace V1_2
51} // namespace Power
52} // namespace HDI
53} // namespace OHOS