From b11b044b815c8e97d1910b72821f6e9ebcfcb550 Mon Sep 17 00:00:00 2001 From: zhaoyongjin1 Date: Mon, 15 Jan 2024 11:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9PC=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoyongjin1 --- .../inner_api/file_access/src/js_file_access_ext_ability.cpp | 5 ++++- interfaces/kits/native/recent/module.cpp | 5 ++++- interfaces/kits/native/trash/module.cpp | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp b/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp index 94e764e2..2f1449a8 100644 --- a/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp +++ b/interfaces/inner_api/file_access/src/js_file_access_ext_ability.cpp @@ -1201,7 +1201,10 @@ bool GetDeviceType(std::string &deviceType) bool GetUserName(std::string &userName) { - userName = "default"; + ErrCode errCode = OHOS::AccountSA::OsAccountManager::GetOsAccountShortName(userName); + if (errCode != ERR_OK) { + return false; + } return true; } diff --git a/interfaces/kits/native/recent/module.cpp b/interfaces/kits/native/recent/module.cpp index 51d3fdbc..c9061d44 100644 --- a/interfaces/kits/native/recent/module.cpp +++ b/interfaces/kits/native/recent/module.cpp @@ -40,7 +40,10 @@ static bool GetDeviceType(std::string &deviceType) static bool GetUserName(std::string &userName) { - userName = "default"; + ErrCode errCode = OHOS::AccountSA::OsAccountManager::GetOsAccountShortName(userName); + if (errCode != ERR_OK) { + return false; + } return true; } diff --git a/interfaces/kits/native/trash/module.cpp b/interfaces/kits/native/trash/module.cpp index 6fed9756..c186cda6 100644 --- a/interfaces/kits/native/trash/module.cpp +++ b/interfaces/kits/native/trash/module.cpp @@ -40,7 +40,10 @@ static bool GetDeviceType(std::string &deviceType) static bool GetUserName(std::string &userName) { - userName = "default"; + ErrCode errCode = OHOS::AccountSA::OsAccountManager::GetOsAccountShortName(userName); + if (errCode != ERR_OK) { + return false; + } return true; } -- Gitee