• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "coordination_util.h"
17 
18 #include "coordination_sm.h"
19 #include "softbus_bus_center.h"
20 
21 #include "devicestatus_define.h"
22 
23 namespace OHOS {
24 namespace Msdp {
25 namespace DeviceStatus {
26 namespace COORDINATION {
27 namespace {
28 constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "CoordinationUtil" };
29 } // namespace
GetLocalNetworkId()30 std::string GetLocalNetworkId()
31 {
32     CALL_DEBUG_ENTER;
33     auto localNode = std::make_unique<NodeBasicInfo>();
34     int32_t ret = GetLocalNodeDeviceInfo(FI_PKG_NAME, localNode.get());
35     if (ret != RET_OK) {
36         FI_HILOGE("GetLocalNodeDeviceInfo ret:%{public}d", ret);
37         return {};
38     }
39     std::string networkId(localNode->networkId, sizeof(localNode->networkId));
40     FI_HILOGD("GetLocalNodeDeviceInfo networkId:%{public}s", networkId.substr(0, SUBSTR_NETWORKID_LEN).c_str());
41     return localNode->networkId;
42 }
43 } // namespace COORDINATION
44 } // namespace DeviceStatus
45 } // namespace Msdp
46 } // namespace OHOS
47