1 /*
2 * Copyright (C) 2025 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 #include <fstream>
16 #include <iostream>
17 #include <sstream>
18 #include <vector>
19
20 #include "cJSON.h"
21 #include "channel_manager.h"
22 #include "device_manager.h"
23 #include "dfs_error.h"
24 #include "file_ex.h"
25 #include "image_source.h"
26 #include "int_wrapper.h"
27 #include "locale_config.h"
28 #include "locale_info.h"
29 #include "notification_helper.h"
30 #include "system_notifier.h"
31 #include "utils_log.h"
32 #include "want_agent_helper.h"
33 #include "want_agent_info.h"
34
35 namespace OHOS {
36 namespace Storage {
37 namespace DistributedFile {
38 using namespace std;
39 using namespace OHOS::FileManagement;
40
41 namespace {
42 constexpr const char *CAPSULE_ICON_PATH = "/system/etc/dfs_service/resources/icon/capsule_icon.png";
43 constexpr const char *NOTIFICATION_ICON_PATH = "/system/etc/dfs_service/resources/icon/notification_icon.png";
44 constexpr const char *BUTTON_ICON_PATH = "/system/etc/dfs_service/resources/icon/button_icon.png";
45 constexpr const int DFS_SERVICE_UID = 1009;
46 constexpr const int DFS_CAPSULE_TYPE_CODE = 50;
47 constexpr const int MAX_JSON_SIZE = 100;
48 constexpr int PLACEHOLDER_LENGTH = 2;
49
50 constexpr const char *DFS_LANGUAGE_FILEPATH_PREFIX = "/system/etc/dfs_service/resources/i18/";
51 constexpr const char *DFS_LANGUAGE_FILEPATH_SUFFIX = ".json";
52 constexpr const char *DFS_DEFAULT_LANGUAGE = "/system/etc/dfs_service/resources/i18/en-Latn-US.json";
53
54 constexpr const char *NOTIFICATION_TITLE = "notification_title";
55 constexpr const char *NOTIFICATION_TEXT = "notification_text";
56 constexpr const char *CAPSULE_TITLE = "capsule_title";
57 constexpr const char *BUTTON_NAME = "button_name";
58
59 constexpr const char *KEY_STRING = "key-value";
60 constexpr const char *KEY_NAME = "key";
61 constexpr const char *KEY_VALUE = "value";
62
63 constexpr const char *SERVICE_NAME = "ohos.storage.distributedfile.daemon";
64
65 static std::string g_sysLanguage = "";
66 static std::string g_sysRegion = "";
67 static std::mutex g_resourceMapMutex;
68 static std::map<std::string, std::string> g_resourceMap;
69
70 static std::mutex g_notificationMutex;
71 static int32_t g_notificationId = 0;
72
73 class DFSNotificationLocalLiveViewSubscriber : public Notification::NotificationLocalLiveViewSubscriber {
74 /**
75 * @brief Called back when the subscriber is connected to the Advanced Notification Service (ANS).
76 **/
OnConnected()77 void OnConnected() {}
78
79 /**
80 * @brief Called back when the subscriber is disconnected from the ANS.
81 **/
OnDisconnected()82 void OnDisconnected() {}
83
84 /**
85 * @brief Called back when the notificationLocalLiveViewButton clicked.
86 **/
OnResponse(int32_t notificationId,sptr<NotificationButtonOption> buttonOption)87 void OnResponse(int32_t notificationId, sptr<NotificationButtonOption> buttonOption)
88 {
89 LOGI("DFSNotificationLocalLiveViewSubscriber OnResponse, notificationId: %{public}d", notificationId);
90 SystemNotifier::GetInstance().DestroyNotifyByNotificationId(notificationId);
91 }
92
93 /**
94 * @brief Called back when connection to the ANS has died.
95 **/
OnDied()96 void OnDied()
97 {
98 LOGE("DFSNotificationLocalLiveViewSubscriber OnDied enter");
99 }
100 };
101
102 class DfsNotificationSubscriber : public Notification::NotificationSubscriber {
OnConnected()103 void OnConnected() {}
OnDisconnected()104 void OnDisconnected() {}
OnUpdate(const std::shared_ptr<Notification::NotificationSortingMap> & sortingMap)105 void OnUpdate(const std::shared_ptr<Notification::NotificationSortingMap> &sortingMap) {}
OnDoNotDisturbDateChange(const std::shared_ptr<Notification::NotificationDoNotDisturbDate> & date)106 void OnDoNotDisturbDateChange(const std::shared_ptr<Notification::NotificationDoNotDisturbDate> &date) {}
OnEnabledNotificationChanged(const std::shared_ptr<Notification::EnabledNotificationCallbackData> & callbackData)107 void OnEnabledNotificationChanged(
108 const std::shared_ptr<Notification::EnabledNotificationCallbackData> &callbackData) {}
OnDied()109 void OnDied()
110 {
111 LOGE("DfsNotificationSubscriber OnDied enter");
112 }
OnCanceled(const std::shared_ptr<OHOS::Notification::Notification> & request,const std::shared_ptr<Notification::NotificationSortingMap> & sortingMap,int deleteReason)113 void OnCanceled(const std::shared_ptr<OHOS::Notification::Notification> &request,
114 const std::shared_ptr<Notification::NotificationSortingMap> &sortingMap,
115 int deleteReason)
116 {
117 int creatorUid = request->GetUid();
118 int notificationId = request->GetId();
119 LOGI("Oncanceled, creatorUid = %{public}d, notificationId = %{public}d, deleteReason = %{public}d", creatorUid,
120 notificationId, deleteReason);
121 SystemNotifier::GetInstance().DestroyNotifyByNotificationId(notificationId);
122 }
OnConsumed(const std::shared_ptr<OHOS::Notification::Notification> & notification,const std::shared_ptr<Notification::NotificationSortingMap> & sortingMap)123 void OnConsumed(const std::shared_ptr<OHOS::Notification::Notification> ¬ification,
124 const std::shared_ptr<Notification::NotificationSortingMap> &sortingMap)
125 {}
OnBadgeChanged(const std::shared_ptr<Notification::BadgeNumberCallbackData> & badgeData)126 void OnBadgeChanged(const std::shared_ptr<Notification::BadgeNumberCallbackData> &badgeData) {}
OnBadgeEnabledChanged(const sptr<Notification::EnabledNotificationCallbackData> & callbackData)127 void OnBadgeEnabledChanged(const sptr<Notification::EnabledNotificationCallbackData> &callbackData) {}
OnBatchCanceled(const std::vector<std::shared_ptr<OHOS::Notification::Notification>> & requestList,const std::shared_ptr<Notification::NotificationSortingMap> & sortingMap,int32_t deleteReason)128 void OnBatchCanceled(const std::vector<std::shared_ptr<OHOS::Notification::Notification>> &requestList,
129 const std::shared_ptr<Notification::NotificationSortingMap> &sortingMap,
130 int32_t deleteReason)
131 {}
132 };
133
134 static std::shared_ptr<DFSNotificationLocalLiveViewSubscriber> g_notificationLocalLiveViewSubscriber =
135 std::make_shared<DFSNotificationLocalLiveViewSubscriber>();
136
137 static std::shared_ptr<DfsNotificationSubscriber> g_notificationSubscriber =
138 std::make_shared<DfsNotificationSubscriber>();
139 } // namespace
140
CreateNotificationCapsule(std::shared_ptr<Media::PixelMap> pixelMap,const string title)141 static Notification::NotificationCapsule CreateNotificationCapsule(std::shared_ptr<Media::PixelMap> pixelMap,
142 const string title)
143 {
144 LOGI("CreateNotificationCapsule start");
145 auto capsule = Notification::NotificationCapsule();
146 capsule.SetIcon(pixelMap);
147 capsule.SetTitle(title);
148 capsule.SetBackgroundColor("#2E3033");
149 return capsule;
150 }
151
CreateNotificationLocalLiveViewButton(std::shared_ptr<Media::PixelMap> pixelMap)152 static Notification::NotificationLocalLiveViewButton CreateNotificationLocalLiveViewButton(
153 std::shared_ptr<Media::PixelMap> pixelMap)
154 {
155 LOGI("CreateNotificationLocalLiveViewButton start");
156 Notification::NotificationLocalLiveViewButton button;
157 button.addSingleButtonIcon(pixelMap);
158 return button;
159 }
160
SetActionButton(const std::string & buttonName,Notification::NotificationRequest & request)161 static void SetActionButton(const std::string &buttonName, Notification::NotificationRequest &request)
162 {
163 auto want = std::make_shared<AAFwk::Want>();
164 std::vector<std::shared_ptr<AAFwk::Want>> wants;
165 wants.push_back(want);
166 std::vector<AbilityRuntime::WantAgent::WantAgentConstant::Flags> flags;
167 flags.push_back(AbilityRuntime::WantAgent::WantAgentConstant::Flags::CONSTANT_FLAG);
168 AbilityRuntime::WantAgent::WantAgentInfo wantAgentInfo(
169 0, AbilityRuntime::WantAgent::WantAgentConstant::OperationType::UNKNOWN_TYPE, flags, wants, nullptr);
170 auto wantAgentDeal = AbilityRuntime::WantAgent::WantAgentHelper::GetWantAgent(wantAgentInfo);
171 std::shared_ptr<Notification::NotificationActionButton> actionButtonDeal =
172 Notification::NotificationActionButton::Create(nullptr, buttonName, wantAgentDeal);
173 if (actionButtonDeal == nullptr) {
174 LOGE("get notification actionButton nullptr");
175 return;
176 }
177 request.AddActionButton(actionButtonDeal);
178 }
179
UpdateResourceMap(const std::string & resourcePath)180 void SystemNotifier::UpdateResourceMap(const std::string &resourcePath)
181 {
182 std::lock_guard<std::mutex> lock(g_resourceMapMutex);
183 LOGI("Reading resource string from json config.");
184 std::string content;
185 if (!std::filesystem::exists(resourcePath)) {
186 LOGE("hava not found now language json file, use Eng instead.");
187 LoadStringFromFile(DFS_DEFAULT_LANGUAGE, content);
188 } else {
189 LoadStringFromFile(resourcePath, content);
190 }
191
192 cJSON *json = cJSON_Parse(content.c_str());
193 if (json == nullptr) {
194 LOGE("json nullptr.");
195 return;
196 }
197
198 cJSON *resJson = cJSON_GetObjectItemCaseSensitive(json, KEY_STRING);
199 if (resJson == nullptr || cJSON_GetArraySize(resJson) > MAX_JSON_SIZE) {
200 LOGE("fail to parse res json");
201 cJSON_Delete(json);
202 return;
203 }
204
205 g_resourceMap.clear();
206 cJSON *resJsonEach = nullptr;
207 cJSON_ArrayForEach(resJsonEach, resJson)
208 {
209 cJSON *key = cJSON_GetObjectItemCaseSensitive(resJsonEach, KEY_NAME);
210 if (key == nullptr || !cJSON_IsString(key)) {
211 LOGE("json param not string");
212 cJSON_Delete(json);
213 return;
214 }
215
216 cJSON *value = cJSON_GetObjectItemCaseSensitive(resJsonEach, KEY_VALUE);
217 if (value == nullptr || !cJSON_IsString(value)) {
218 LOGE("json param not string");
219 cJSON_Delete(json);
220 return;
221 }
222
223 g_resourceMap.emplace(std::pair<std::string, std::string>(key->valuestring, value->valuestring));
224 }
225 cJSON_Delete(json);
226 }
227
UpdateResourceMapByLanguage()228 void SystemNotifier::UpdateResourceMapByLanguage()
229 {
230 std::string curSysLanguage = Global::I18n::LocaleConfig::GetSystemLanguage();
231 std::string curSysRegion = Global::I18n::LocaleConfig::GetSystemRegion();
232 if (g_sysLanguage == curSysLanguage && curSysRegion == g_sysRegion) {
233 LOGW("same language environment[%{public}s], region[%{public}s] ,no need to update resource map.",
234 curSysLanguage.c_str(), curSysRegion.c_str());
235 return;
236 }
237
238 LOGI("current system language[%{public}s], region[%{public}s] changes, should update resource map",
239 curSysLanguage.c_str(), curSysRegion.c_str());
240 g_sysLanguage = curSysLanguage;
241 g_sysRegion = curSysRegion;
242
243 std::string filePath = DFS_LANGUAGE_FILEPATH_PREFIX + g_sysLanguage + DFS_LANGUAGE_FILEPATH_SUFFIX;
244 UpdateResourceMap(filePath);
245 }
246
247 template<typename... Args>
GetKeyValue(const std::string & key,Args &&...args)248 std::string SystemNotifier::GetKeyValue(const std::string &key, Args &&...args)
249 {
250 std::lock_guard<std::mutex> lock(g_resourceMapMutex);
251 auto it = g_resourceMap.find(key);
252 if (it == g_resourceMap.end()) {
253 return "";
254 }
255 std::string value = it->second;
256
257 if constexpr (sizeof...(args) == 0) {
258 return value;
259 }
260
261 std::vector<std::string> replacements = {std::forward<Args>(args)...};
262 size_t argIndex = 0;
263 size_t pos = 0;
264
265 while ((pos = value.find("{}", pos)) != std::string::npos) {
266 if (argIndex >= replacements.size()) {
267 break;
268 }
269
270 value.replace(pos, PLACEHOLDER_LENGTH, replacements[argIndex]);
271 pos += replacements[argIndex].length();
272 argIndex++;
273 }
274
275 return value;
276 }
277
CreateNotification(const std::string & networkId)278 int32_t SystemNotifier::CreateNotification(const std::string &networkId)
279 {
280 LOGI("CreateNotification enter");
281 {
282 std::shared_lock<std::shared_mutex> readLock(mutex);
283 if (notificationMap_.find(networkId) != notificationMap_.end()) {
284 LOGI("Notification %{public}.6s already exists.", networkId.c_str());
285 return E_OK;
286 }
287 }
288 UpdateResourceMapByLanguage();
289 std::shared_ptr<Notification::NotificationNormalContent> content =
290 std::make_shared<Notification::NotificationNormalContent>();
291 content->SetTitle(GetKeyValue(NOTIFICATION_TITLE));
292 content->SetText(GetKeyValue(NOTIFICATION_TEXT, GetRemoteDeviceName(networkId)));
293
294 std::shared_ptr<Notification::NotificationContent> pcContent =
295 std::make_shared<Notification::NotificationContent>(content);
296
297 int32_t notificationId = GenerateNextNotificationId();
298 Notification::NotificationRequest request;
299 request.SetNotificationId(notificationId);
300 request.SetUnremovable(true);
301 request.SetCreatorUid(DFS_SERVICE_UID);
302 request.SetContent(pcContent);
303 request.SetLittleIcon(notificationIconPixelMap_);
304 request.SetBadgeIconStyle(Notification::NotificationRequest::BadgeStyle::LITTLE);
305 SetActionButton(GetKeyValue(BUTTON_NAME), request);
306
307 auto ret = Notification::NotificationHelper::PublishNotification(request);
308 if (ret != E_OK) {
309 LOGE("DFS service publish notification result = %{public}d", ret);
310 return static_cast<int32_t>(ret);
311 }
312 std::unique_lock<std::shared_mutex> write_lock(mutex_);
313 notificationMap_[networkId] = notificationId;
314 LOGI("DFS service publish CreateNotification result = %{public}d", ret);
315 return E_OK;
316 }
317
CreateLocalLiveView(const std::string & networkId)318 int32_t SystemNotifier::CreateLocalLiveView(const std::string &networkId)
319 {
320 LOGI("CreateLocalLiveView enter");
321 {
322 std::shared_lock<std::shared_mutex> readLock(mutex);
323 if (notificationMap_.find(networkId) != notificationMap_.end()) {
324 LOGI("Notification %{public}.6s already exists.", networkId.c_str());
325 return E_OK;
326 }
327 }
328 UpdateResourceMapByLanguage();
329 std::shared_ptr<Notification::NotificationLocalLiveViewContent> localLiveViewContent =
330 std::make_shared<Notification::NotificationLocalLiveViewContent>();
331 localLiveViewContent->SetTitle(GetKeyValue(NOTIFICATION_TITLE));
332 localLiveViewContent->SetText(GetKeyValue(NOTIFICATION_TEXT, GetRemoteDeviceName(networkId)));
333 localLiveViewContent->SetType(DFS_CAPSULE_TYPE_CODE);
334
335 auto capsule = CreateNotificationCapsule(capsuleIconPixelMap_, GetKeyValue(CAPSULE_TITLE));
336 localLiveViewContent->SetCapsule(capsule);
337 localLiveViewContent->addFlag(Notification::NotificationLocalLiveViewContent::LiveViewContentInner::CAPSULE);
338
339 auto button = CreateNotificationLocalLiveViewButton(buttonIconPixelMap_);
340 localLiveViewContent->SetButton(button);
341 localLiveViewContent->addFlag(Notification::NotificationLocalLiveViewContent::LiveViewContentInner::BUTTON);
342
343 std::shared_ptr<Notification::NotificationContent> content =
344 std::make_shared<Notification::NotificationContent>(localLiveViewContent);
345
346 Notification::NotificationRequest request;
347 int32_t notificationId = GenerateNextNotificationId();
348 request.SetNotificationId(notificationId);
349 request.SetSlotType(Notification::NotificationConstant::SlotType::LIVE_VIEW);
350 request.SetCreatorUid(DFS_SERVICE_UID);
351 request.SetContent(content);
352 request.SetLittleIcon(notificationIconPixelMap_);
353 request.SetWantAgent(std::make_shared<AbilityRuntime::WantAgent::WantAgent>());
354
355 auto ret = Notification::NotificationHelper::PublishNotification(request);
356 if (ret != E_OK) {
357 LOGE("DFS service publish localLiveView result = %{public}d", ret);
358 return static_cast<int32_t>(ret);
359 }
360 std::unique_lock<std::shared_mutex> write_lock(mutex_);
361 notificationMap_[networkId] = notificationId;
362 LOGI("DFS service publish localLiveView result = %{public}d", ret);
363 return E_OK;
364 }
365
DestroyNotifyByNotificationId(int32_t notificationId)366 int32_t SystemNotifier::DestroyNotifyByNotificationId(int32_t notificationId)
367 {
368 LOGI("DestroyNotifyByNotificationId for notificationId: %{public}d", notificationId);
369 std::string networkId = "";
370 {
371 std::unique_lock<std::shared_mutex> write_lock(mutex_);
372 for (auto it = notificationMap_.begin(); it != notificationMap_.end();) {
373 if (it->second == notificationId) {
374 networkId = it->first;
375 LOGI("Removed notification mapping for notificationId: %{public}d (networkId: %{public}.6s)",
376 notificationId, networkId.c_str());
377 it = notificationMap_.erase(it);
378 } else {
379 ++it;
380 }
381 }
382 }
383
384 auto ret = Notification::NotificationHelper::CancelNotification(notificationId);
385 LOGI("DestroyNotification (id: %{public}d), result: %{public}d", notificationId, ret);
386
387 ret = DisconnectByNetworkId(networkId);
388 LOGI("DisconnectByNetworkId networkId = %{public}.6s , ret = %{public}d", networkId.c_str(), ret);
389
390 return ret;
391 }
392
DestroyNotifyByNetworkId(const std::string & networkId)393 int32_t SystemNotifier::DestroyNotifyByNetworkId(const std::string &networkId)
394 {
395 LOGI("DestroyNotifyByNetworkId for networkId: %{public}.6s", networkId.c_str());
396 int32_t notificationId = 0;
397 {
398 std::unique_lock<std::shared_mutex> write_lock(mutex_);
399 auto it = notificationMap_.find(networkId);
400 if (it != notificationMap_.end()) {
401 LOGI("Removed notification mapping for networkId: %{public}.6s", networkId.c_str());
402 notificationId = it->second;
403 notificationMap_.erase(it);
404 } else {
405 LOGW("No notification mapping found for networkId: %{public}.6s", networkId.c_str());
406 return ERR_BAD_VALUE;
407 }
408 }
409
410 auto ret = Notification::NotificationHelper::CancelNotification(notificationId);
411 LOGI("DestroyNotifyByNetworkId (notificationId: %{public}d), result: %{public}d", notificationId, ret);
412
413 ret = DisconnectByNetworkId(networkId);
414 LOGI("DisconnectByNetworkId networkId = %{public}.6s , ret = %{public}d", networkId.c_str(), ret);
415 return ret;
416 }
417
DisconnectByNetworkId(const std::string & networkId)418 int32_t SystemNotifier::DisconnectByNetworkId(const std::string &networkId)
419 {
420 LOGI("DisconnectByNetworkId enter, networkId is %{public}.6s", networkId.c_str());
421 ControlCmd request;
422 ControlCmd response;
423 request.msgType = CMD_ACTIVE_DISCONNECT;
424 std::string srcNetworkId;
425 auto result = DistributedHardware::DeviceManager::GetInstance().GetLocalDeviceNetWorkId(SERVICE_NAME, srcNetworkId);
426 if (result != E_OK || srcNetworkId.empty()) {
427 LOGE("Failed to get local device network ID.");
428 return ERR_BAD_VALUE;
429 }
430 request.networkId = srcNetworkId;
431
432 auto ret = ChannelManager::GetInstance().SendRequest(networkId, request, response);
433 LOGI("DisconnectByNetworkId end. networkId = %{public}.6s ,ret = %{public}d", networkId.c_str(), ret);
434 return ret;
435 }
436
GenerateNextNotificationId()437 int32_t SystemNotifier::GenerateNextNotificationId()
438 {
439 std::lock_guard<std::mutex> lock(g_notificationMutex);
440 if (g_notificationId == INT32_MAX) {
441 g_notificationId = 0;
442 }
443 return ++g_notificationId;
444 }
445
GetPixelMap(const std::string & path,std::shared_ptr<Media::PixelMap> & pixelMap)446 bool SystemNotifier::GetPixelMap(const std::string &path, std::shared_ptr<Media::PixelMap> &pixelMap)
447 {
448 if (pixelMap != nullptr) {
449 LOGI("dfs icon pixel map already exists.");
450 return false;
451 }
452
453 if (!std::filesystem::exists(path)) {
454 LOGE("dfs icon file path not exists. %{public}s.", path.c_str());
455 pixelMap = nullptr;
456 return false;
457 }
458
459 uint32_t errorCode = 0;
460 Media::SourceOptions opts;
461 opts.formatHint = "image/png";
462 std::unique_ptr<Media::ImageSource> imageSource = Media::ImageSource::CreateImageSource(path, opts, errorCode);
463 if (imageSource == nullptr) {
464 LOGE("imageSource nullptr");
465 pixelMap = nullptr;
466 return false;
467 }
468
469 Media::DecodeOptions decodeOpts;
470 std::unique_ptr<Media::PixelMap> pixelMapTmp = imageSource->CreatePixelMap(decodeOpts, errorCode);
471 if (!pixelMapTmp || errorCode != 0) {
472 LOGE("CreatePixelMap failed, error: %{public}u", errorCode);
473 pixelMap = nullptr;
474 return false;
475 }
476
477 pixelMap = std::move(pixelMapTmp);
478 return true;
479 }
480
SystemNotifier()481 SystemNotifier::SystemNotifier()
482 {
483 LOGI("start init Notifer");
484
485 GetPixelMap(CAPSULE_ICON_PATH, capsuleIconPixelMap_);
486 GetPixelMap(NOTIFICATION_ICON_PATH, notificationIconPixelMap_);
487 GetPixelMap(BUTTON_ICON_PATH, buttonIconPixelMap_);
488
489 auto ret = Notification::NotificationHelper::SubscribeNotification(*g_notificationSubscriber);
490 LOGI("SubscribeNotification result: %{public}d", ret);
491
492 ret = Notification::NotificationHelper::SubscribeLocalLiveViewNotification(*g_notificationLocalLiveViewSubscriber);
493 LOGI("SubscribeLocalLiveViewNotification result: %{public}d", ret);
494
495 UpdateResourceMapByLanguage();
496
497 LOGI("end init SystemNotifier");
498 }
499
GetRemoteDeviceName(const std::string & networkId)500 std::string SystemNotifier::GetRemoteDeviceName(const std::string &networkId)
501 {
502 std::string deviceName;
503 int32_t ret = DistributedHardware::DeviceManager::GetInstance().GetDeviceName(SERVICE_NAME, networkId, deviceName);
504 if (ret != E_OK) {
505 LOGE("GetDeviceName failed. ret = %{public}d", ret);
506 }
507 LOGI("networkId is %{public}.6s, deviceName is %{public}s", networkId.c_str(), deviceName.c_str());
508 return deviceName;
509 }
510
511 } // namespace DistributedFile
512 } // namespace Storage
513 } // namespace OHOS