完善获取用户id逻辑,user0使用当前用户空间获取用户id

Signed-off-by: 侯志雄 <houzhixiong1@h-partners.com>
This commit is contained in:
侯志雄 2024-11-19 17:04:08 +08:00
parent 9532f2b037
commit 5bede25439
2 changed files with 12 additions and 12 deletions

View File

@ -183,11 +183,11 @@ napi_value napi_get_uri_sync(napi_env env, napi_callback_info info)
std::string tmpIdStr = "100"; std::string tmpIdStr = "100";
if (currentUserId > 0) { if (currentUserId > 0) {
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("userId is %d", currentUserId); SETTING_LOG_INFO("userId is %{public}s", tmpIdStr.c_str());
} else if (currentUserId == 0) { } else if (currentUserId == 0) {
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId); OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("user0 userId is %d", currentUserId); SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
} else { } else {
SETTING_LOG_ERROR("userid is invalid, use id 100 instead"); SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
} }
@ -270,11 +270,11 @@ napi_value napi_get_uri(napi_env env, napi_callback_info info)
std::string tmpIdStr = "100"; std::string tmpIdStr = "100";
if (currentUserId > 0) { if (currentUserId > 0) {
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("userId is %d", currentUserId); SETTING_LOG_INFO("userId is %{public}s", tmpIdStr.c_str());
} else if (currentUserId == 0) { } else if (currentUserId == 0) {
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId); OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("user0 userId is %d", currentUserId); SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
} else { } else {
SETTING_LOG_ERROR("userid is invalid, use id 100 instead"); SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
} }
@ -428,11 +428,11 @@ std::shared_ptr<DataShareHelper> getDataShareHelper(
std::string tmpIdStr = "100"; std::string tmpIdStr = "100";
if (currentUserId > 0) { if (currentUserId > 0) {
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("userId is %d", currentUserId); SETTING_LOG_INFO("userId is %{public}s", tmpIdStr.c_str());
} else if (currentUserId == 0) { } else if (currentUserId == 0) {
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId); OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("user0 userId is %d", currentUserId); SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
} else { } else {
SETTING_LOG_ERROR("userid is invalid, use id 100 instead"); SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
} }
@ -518,11 +518,11 @@ void GetValueExecuteExt(napi_env env, void *data)
std::string tmpIdStr = "100"; std::string tmpIdStr = "100";
if (currentUserId > 0) { if (currentUserId > 0) {
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("userId is %d", currentUserId); SETTING_LOG_INFO("userId is %{public}s", tmpIdStr.c_str());
} else if (currentUserId == 0) { } else if (currentUserId == 0) {
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId); OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("user0 userId is %d", currentUserId); SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
} else { } else {
SETTING_LOG_ERROR("userid is invalid, use id 100 instead"); SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
} }
@ -604,11 +604,11 @@ void SetValueExecuteExt(napi_env env, void *data, const std::string setValue)
std::string tmpIdStr = "100"; std::string tmpIdStr = "100";
if (currentUserId > 0) { if (currentUserId > 0) {
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("userId is %d", currentUserId); SETTING_LOG_INFO("userId is %{public}s", tmpIdStr.c_str());
} else if (currentUserId == 0) { } else if (currentUserId == 0) {
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId); OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("user0 userId is %d", currentUserId); SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
} else { } else {
SETTING_LOG_ERROR("userid is invalid, use id 100 instead"); SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
} }

View File

@ -132,11 +132,11 @@ namespace Settings {
std::string tmpIdStr = "100"; std::string tmpIdStr = "100";
if (currentUserId > 0) { if (currentUserId > 0) {
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("userId is %d", currentUserId); SETTING_LOG_INFO("userId is %{public}s", tmpIdStr.c_str());
} else if (currentUserId == 0) { } else if (currentUserId == 0) {
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId); OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
tmpIdStr = std::to_string(currentUserId); tmpIdStr = std::to_string(currentUserId);
SETTING_LOG_INFO("user0 userId is %d", currentUserId); SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
} else { } else {
SETTING_LOG_INFO("%{public}s, user id 100.", __func__); SETTING_LOG_INFO("%{public}s, user id 100.", __func__);
} }