From 00ad16128b3b5a53c27ffe87585db116abf2e1c5 Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Thu, 7 Aug 2025 20:53:38 +0800 Subject: [PATCH] 0807GetUserIdByCallerType Signed-off-by: lanhaoyu --- services/bundlemgr/src/base_bundle_installer.cpp | 2 +- services/bundlemgr/src/bundle_common_event_mgr.cpp | 2 +- services/bundlemgr/src/bundle_mgr_service.cpp | 4 ++-- services/bundlemgr/src/bundle_mgr_service_event_handler.cpp | 2 +- services/bundlemgr/src/bundle_permission_mgr.cpp | 4 ++-- .../extend_resource/extend_resource_manager_host_impl.cpp | 6 +++--- .../src/sandbox_app/bundle_sandbox_exception_handler.cpp | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index 50b8694eb7..a0354bde73 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -4798,7 +4798,7 @@ int32_t BaseBundleInstaller::GetConfirmUserId( return userId; } int32_t currUserId = sysEventInfo_.callingUid / Constants::BASE_USER_RANGE; - currUserId = currUserId < Constants::START_USERID ? AccountHelper::GetCurrentActiveUserId() : currUserId; + currUserId = currUserId < Constants::START_USERID ? AccountHelper::GetUserIdByCallerType() : currUserId; return currUserId; } diff --git a/services/bundlemgr/src/bundle_common_event_mgr.cpp b/services/bundlemgr/src/bundle_common_event_mgr.cpp index 3ae5656599..8890f691fe 100755 --- a/services/bundlemgr/src/bundle_common_event_mgr.cpp +++ b/services/bundlemgr/src/bundle_common_event_mgr.cpp @@ -115,7 +115,7 @@ void BundleCommonEventMgr::NotifyBundleStatus(const NotifyBundleEvents &installR static_cast(InstallType::INSTALL_CALLBACK); int32_t bundleUserId = BundleUtil::GetUserIdByUid(installResult.uid); int32_t publishUserId = (bundleUserId == Constants::DEFAULT_USERID || bundleUserId == Constants::U1) ? - AccountHelper::GetCurrentActiveUserId() : bundleUserId; + AccountHelper::GetUserIdByCallerType() : bundleUserId; // trigger the status callback for status listening if ((dataMgr != nullptr) && (installResult.type != NotifyType::START_INSTALL)) { diff --git a/services/bundlemgr/src/bundle_mgr_service.cpp b/services/bundlemgr/src/bundle_mgr_service.cpp index 9051b2f95d..a429357be9 100644 --- a/services/bundlemgr/src/bundle_mgr_service.cpp +++ b/services/bundlemgr/src/bundle_mgr_service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -385,7 +385,7 @@ const std::shared_ptr BundleMgrService::GetConnectAbili { int32_t currentUserId = userId; if (currentUserId == Constants::UNSPECIFIED_USERID) { - currentUserId = AccountHelper::GetCurrentActiveUserId(); + currentUserId = AccountHelper::GetUserIdByCallerType(); } std::lock_guard connectLock(bundleConnectMutex_); if (connectAbilityMgr_.find(userId) == connectAbilityMgr_.end() || diff --git a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp index 58407b6b82..276faf11f5 100644 --- a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp +++ b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp @@ -3991,7 +3991,7 @@ void BMSEventHandler::RemoveUnreservedSandbox() const std::this_thread::sleep_for(std::chrono::milliseconds(eachTime)); LOG_D(BMS_TAG_DEFAULT, "wait for account started"); if (currentUserId == Constants::INVALID_USERID) { - currentUserId = AccountHelper::GetCurrentActiveUserId(); + currentUserId = AccountHelper::GetUserIdByCallerType(); LOG_D(BMS_TAG_DEFAULT, "current active userId is %{public}d", currentUserId); if (currentUserId == Constants::INVALID_USERID) { continue; diff --git a/services/bundlemgr/src/bundle_permission_mgr.cpp b/services/bundlemgr/src/bundle_permission_mgr.cpp index 609b078e80..cfab398f74 100644 --- a/services/bundlemgr/src/bundle_permission_mgr.cpp +++ b/services/bundlemgr/src/bundle_permission_mgr.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -814,7 +814,7 @@ bool BundlePermissionMgr::CheckUserFromShell(int32_t userId) if (!BundlePermissionMgr::IsShellTokenType()) { return true; } - auto curUser = AccountHelper::GetCurrentActiveUserId(); + auto curUser = AccountHelper::GetUserIdByCallerType(); if (curUser == Constants::INVALID_USERID) { LOG_E(BMS_TAG_DEFAULT, "get current user fail"); return false; diff --git a/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp b/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp index 1986d8fabd..e2afc24c52 100644 --- a/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp +++ b/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp @@ -673,7 +673,7 @@ ErrCode ExtendResourceManagerHostImpl::GetDynamicIcon( std::string curDynamicModule = info.GetCurDynamicIconModule(userId, appIndex); if (curDynamicModule.empty() && (userId == Constants::UNSPECIFIED_USERID)) { int32_t realUserId = BundleUtil::GetUserIdByCallingUid(); - realUserId = (realUserId == Constants::DEFAULT_USERID) ? AccountHelper::GetCurrentActiveUserId() : realUserId; + realUserId = (realUserId == Constants::DEFAULT_USERID) ? AccountHelper::GetUserIdByCallerType() : realUserId; curDynamicModule = info.GetCurDynamicIconModule(realUserId, appIndex); } if (curDynamicModule.empty()) { @@ -826,7 +826,7 @@ bool ExtendResourceManagerHostImpl::IsNeedUpdateBundleResourceInfo( if (userId == Constants::DEFAULT_USERID) { return true; } - int32_t currentUserId = AccountHelper::GetCurrentActiveUserId(); + int32_t currentUserId = AccountHelper::GetUserIdByCallerType(); if ((currentUserId <= 0)) { currentUserId = Constants::START_USERID; } @@ -872,7 +872,7 @@ bool ExtendResourceManagerHostImpl::CheckWhetherDynamicIconNeedProcess( int32_t currentUserId = userId; if (currentUserId == Constants::UNSPECIFIED_USERID) { if (BundlePermissionMgr::IsNativeTokenType()) { - currentUserId = AccountHelper::GetCurrentActiveUserId(); + currentUserId = AccountHelper::GetUserIdByCallerType(); } else { currentUserId = BundleUtil::GetUserIdByCallingUid(); } diff --git a/services/bundlemgr/src/sandbox_app/bundle_sandbox_exception_handler.cpp b/services/bundlemgr/src/sandbox_app/bundle_sandbox_exception_handler.cpp index 88a88a209b..3625fc77ab 100644 --- a/services/bundlemgr/src/sandbox_app/bundle_sandbox_exception_handler.cpp +++ b/services/bundlemgr/src/sandbox_app/bundle_sandbox_exception_handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -173,7 +173,7 @@ void BundleSandboxExceptionHandler::RemoveDataDir() std::this_thread::sleep_for(std::chrono::milliseconds(eachTime)); APP_LOGD("wait for account started"); if (currentUserId == Constants::INVALID_USERID) { - currentUserId = AccountHelper::GetCurrentActiveUserId(); + currentUserId = AccountHelper::GetUserIdByCallerType(); APP_LOGD("current active userId is %{public}d", currentUserId); if (currentUserId == Constants::INVALID_USERID) { continue; -- Gitee