• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "netsys_event_message.h"
17 
18 #include "netnative_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace nmd {
PushMessage(NetsysEventMessage::Type type,const std::string & value)22 void NetsysEventMessage::PushMessage(NetsysEventMessage::Type type, const std::string &value)
23 {
24     std::unique_lock<std::shared_mutex> lock(messageMapMutex_);
25     messageMap_[type] = value;
26 }
27 
GetMessage(NetsysEventMessage::Type type)28 const std::string NetsysEventMessage::GetMessage(NetsysEventMessage::Type type)
29 {
30     std::unique_lock<std::shared_mutex> lock(messageMapMutex_);
31     const std::string empty = "";
32     if (messageMap_.find(type) == messageMap_.end()) {
33         return empty;
34     }
35     return messageMap_[type];
36 }
37 
DumpMessage()38 void NetsysEventMessage::DumpMessage()
39 {
40     NETNATIVE_LOG_D("DumpMessage: Action: %{public}d; SybSys: %{public}d; SeqNum: %{public}d; ", action_, subSys_,
41                     seqNum_);
42     std::shared_lock<std::shared_mutex> lock(messageMapMutex_);
43     for (auto &item : messageMap_) {
44         NETNATIVE_LOG_D("type: %{public}d", item.first);
45     }
46 }
47 } // namespace nmd
48 } // namespace OHOS