mirror of
https://gitee.com/openharmony/applications_settings
synced 2024-11-26 16:10:49 +00:00
!782 完善获取用户id逻辑,user0使用当前用户空间获取用户id
Merge pull request !782 from 侯志雄/master
This commit is contained in:
commit
ed7f6eaab7
@ -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 %{public}s", tmpIdStr.c_str());
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
|
||||
} 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 %{public}s", tmpIdStr.c_str());
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
|
||||
} 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 %{public}s", tmpIdStr.c_str());
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
|
||||
} 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 %{public}s", tmpIdStr.c_str());
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
|
||||
} 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 %{public}s", tmpIdStr.c_str());
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
|
||||
} else {
|
||||
SETTING_LOG_ERROR("userid is invalid, use id 100 instead");
|
||||
}
|
||||
|
@ -130,8 +130,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 %{public}s", tmpIdStr.c_str());
|
||||
} else if (currentUserId == 0) {
|
||||
OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(currentUserId);
|
||||
tmpIdStr = std::to_string(currentUserId);
|
||||
SETTING_LOG_INFO("user0 userId is %{public}s", tmpIdStr.c_str());
|
||||
} else {
|
||||
SETTING_LOG_INFO("%{public}s, user id 100.", __func__);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user