mirror of
https://gitee.com/openharmony/applications_settings
synced 2024-11-26 16:10:49 +00:00
完善获取用户id逻辑,user0使用当前用户空间获取用户id
Signed-off-by: 侯志雄 <houzhixiong1@h-partners.com>
This commit is contained in:
parent
9c894d8472
commit
c4b0245ab1
@ -181,8 +181,13 @@ napi_value napi_get_uri_sync(napi_env env, napi_callback_info info)
|
||||
int currentUserId = -1;
|
||||
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(currentUserId);
|
||||
std::string tmpIdStr = "100";
|
||||
if (currentUserId >= 0) {
|
||||
if (currentUserId > 0) {
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("userId is %d", currentUserId);
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %d", currentUserId);
|
||||
} else {
|
||||
SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
|
||||
}
|
||||
@ -263,8 +268,13 @@ napi_value napi_get_uri(napi_env env, napi_callback_info info)
|
||||
int currentUserId = -1;
|
||||
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(currentUserId);
|
||||
std::string tmpIdStr = "100";
|
||||
if (currentUserId >= 0) {
|
||||
if (currentUserId > 0) {
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("userId is %d", currentUserId);
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %d", currentUserId);
|
||||
} else {
|
||||
SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
|
||||
}
|
||||
@ -416,8 +426,13 @@ std::shared_ptr<DataShareHelper> getDataShareHelper(
|
||||
int currentUserId = -1;
|
||||
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(currentUserId);
|
||||
std::string tmpIdStr = "100";
|
||||
if (currentUserId >= 0) {
|
||||
if (currentUserId > 0) {
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("userId is %d", currentUserId);
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %d", currentUserId);
|
||||
} else {
|
||||
SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
|
||||
}
|
||||
@ -501,8 +516,13 @@ void GetValueExecuteExt(napi_env env, void *data)
|
||||
int currentUserId = -1;
|
||||
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(currentUserId);
|
||||
std::string tmpIdStr = "100";
|
||||
if (currentUserId >= 0) {
|
||||
if (currentUserId > 0) {
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("userId is %d", currentUserId);
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %d", currentUserId);
|
||||
} else {
|
||||
SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
|
||||
}
|
||||
@ -582,8 +602,13 @@ void SetValueExecuteExt(napi_env env, void *data, const std::string setValue)
|
||||
int currentUserId = -1;
|
||||
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(currentUserId);
|
||||
std::string tmpIdStr = "100";
|
||||
if (currentUserId >= 0) {
|
||||
if (currentUserId > 0) {
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("userId is %d", currentUserId);
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %d", currentUserId);
|
||||
} else {
|
||||
SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
|
||||
}
|
||||
|
@ -121,8 +121,13 @@ namespace Settings {
|
||||
int currentUserId = -1;
|
||||
OHOS::AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(currentUserId);
|
||||
std::string tmpIdStr = "100";
|
||||
if (currentUserId >= 0) {
|
||||
if (currentUserId > 0) {
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("userId is %d", currentUserId);
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %d", currentUserId);
|
||||
} else {
|
||||
SETTING_LOG_INFO("%{public}s, user id 100.", __func__);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user