Signed-off-by: wendel <yuwenze1@huawei.com>
Change-Id: I28a5a2884572f561fd11e6348fd0e378d7a29c22
This commit is contained in:
wendel
2025-09-11 10:51:35 +08:00
parent 0253a54ceb
commit 7edb418db1
5 changed files with 12 additions and 8 deletions
@@ -24,6 +24,7 @@
#include "hilog_tag_wrapper.h"
#include "in_process_call_wrapper.h"
#include "permission_constants.h"
#include "server_constant.h"
#include "user_controller/user_controller.h"
namespace OHOS {
@@ -429,7 +430,7 @@ int32_t AbilityAutoStartupService::GetValidUserId(int32_t userId)
validUserId = IPCSkeleton::GetCallingUid() / AppExecFwk::Constants::BASE_USER_RANGE;
}
if (validUserId == U0_USER_ID || validUserId == U1_USER_ID) {
validUserId = UserController::GetInstance().GetForegroundUserId(AAFwk::DisplayUtil::ObtainDefaultDisplayId());
validUserId = UserController::GetInstance().GetForegroundUserId(ServerConstant::DEFAULT_DISPLAY_ID);
}
return validUserId;
}
@@ -12780,7 +12780,7 @@ void AbilityManagerService::NotifyConfigurationChange(const AppExecFwk::Configur
void AbilityManagerService::NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos)
{
int32_t callerUser =
AbilityRuntime::UserController::GetInstance().GetForegroundUserId(DisplayUtil::ObtainDefaultDisplayId());
AbilityRuntime::UserController::GetInstance().GetForegroundUserId(ServerConstant::DEFAULT_DISPLAY_ID);
std::vector<AppExecFwk::BundleInfo> bundleInfosForU0;
std::map<int32_t, std::vector<AppExecFwk::BundleInfo>> bundleInfosMap;
for (const auto &item: bundleInfos) {
@@ -12823,7 +12823,7 @@ void AbilityManagerService::NotifyStartKeepAliveProcess(std::vector<AppExecFwk::
}
auto userId =
AbilityRuntime::UserController::GetInstance().GetForegroundUserId(DisplayUtil::ObtainDefaultDisplayId());
AbilityRuntime::UserController::GetInstance().GetForegroundUserId(ServerConstant::DEFAULT_DISPLAY_ID);
std::map<int32_t, std::vector<AppExecFwk::BundleInfo>> bundleInfosMap;
std::vector<AppExecFwk::BundleInfo> bundleInfosForU1;
for (const auto &item: bundleInfos) {
@@ -304,6 +304,7 @@ constexpr int32_t PROCESS_START_FAILED_SUB_REASON_UNKNOWN = 0;
constexpr int32_t MAX_SPECIFIED_PROCESS_NAME_LENGTH = 255;
constexpr int32_t NWEB_PRELOAD_DELAY = 3000000;
constexpr uint64_t DEFAULT_DISPLAY_ID = 0;
constexpr const char* APP_INSTANCE_KEY_0 = "app_instance_0";
@@ -583,7 +584,7 @@ int32_t AppMgrServiceInner::PreloadApplication(const std::string &bundleName, in
if (userId == DEFAULT_INVAL_VALUE) {
userId = GetUserIdByUid(IPCSkeleton::GetCallingUid());
if (userId == U0_USER_ID || userId == U1_USER_ID) {
userId = UserController::GetInstance().GetForegroundUserId(AAFwk::DisplayUtil::ObtainDefaultDisplayId());
userId = UserController::GetInstance().GetForegroundUserId(DEFAULT_DISPLAY_ID);
}
}
if (UserRecordManager::GetInstance().IsLogoutUser(userId)) {
@@ -2324,7 +2325,7 @@ int32_t AppMgrServiceInner::ClearUpApplicationData(const std::string &bundleName
if (userId == DEFAULT_INVAL_VALUE) {
newUserId = GetUserIdByUid(callerUid);
if (newUserId == U0_USER_ID || newUserId == U1_USER_ID) {
newUserId = UserController::GetInstance().GetForegroundUserId(AAFwk::DisplayUtil::ObtainDefaultDisplayId());
newUserId = UserController::GetInstance().GetForegroundUserId(DEFAULT_DISPLAY_ID);
}
}
TAG_LOGI(AAFwkTag::APPMGR, "bundleName: %{public}s, uId: %{public}d, appIndex: %{public}d", bundleName.c_str(),
@@ -2346,7 +2347,7 @@ int32_t AppMgrServiceInner::ClearUpApplicationDataBySelf(int32_t callerUid, pid_
if (userId == DEFAULT_INVAL_VALUE) {
newUserId = GetUserIdByUid(callerUid);
if (newUserId == U0_USER_ID) {
newUserId = UserController::GetInstance().GetForegroundUserId(AAFwk::DisplayUtil::ObtainDefaultDisplayId());
newUserId = UserController::GetInstance().GetForegroundUserId(DEFAULT_DISPLAY_ID);
}
}
auto appCloneIndex = appRecord->GetAppIndex();
@@ -6027,7 +6028,7 @@ void AppMgrServiceInner::HandleConfigurationChange(const Configuration& config,
for (const auto &item : appStateCallbacks_) {
if (item.callback != nullptr && (userId == -1 || item.userId == 0 || item.userId == userId)) {
item.callback->NotifyConfigurationChange(config,
UserController::GetInstance().GetForegroundUserId(AAFwk::DisplayUtil::ObtainDefaultDisplayId()));
UserController::GetInstance().GetForegroundUserId(DEFAULT_DISPLAY_ID));
}
}
}
@@ -31,6 +31,7 @@ constexpr int32_t U0_USER_ID = 0;
constexpr int32_t U1_USER_ID = 1;
constexpr int32_t USER_ID_DEFAULT = 100;
constexpr int32_t ACCOUNT_MGR_SERVICE_UID = 3058;
constexpr uint64_t DEFAULT_DISPLAY_ID = 0;
}
UserController& UserController::GetInstance()
{
@@ -112,7 +113,7 @@ int32_t UserController::GetCallerUserId()
int32_t callerUser = callerUid / BASE_USER_RANGE;
TAG_LOGD(AAFwkTag::USER_CONTROLLER, "callerUser = %{public}d, CallingUid = %{public}d.", callerUser, callerUid);
if (callerUser == U0_USER_ID || callerUser == U1_USER_ID) {
callerUser = GetForegroundUserId(AAFwk::DisplayUtil::ObtainDefaultDisplayId());
callerUser = GetForegroundUserId(DEFAULT_DISPLAY_ID);
}
return callerUser;
}
+1
View File
@@ -26,6 +26,7 @@ constexpr uint32_t SCENARIO_BACK_TO_CALLER_ABILITY_WITH_RESULT = 0x00000004;
// skip onNewWant in these scenerios
constexpr uint32_t SKIP_ON_NEW_WANT_SCENARIOS = SCENARIO_MOVE_MISSION_TO_FRONT |
SCENARIO_SHOW_ABILITY | SCENARIO_BACK_TO_CALLER_ABILITY_WITH_RESULT;
constexpr uint64_t DEFAULT_DISPLAY_ID = 0;
} // namespace ServerConstant
} // namespace OHOS::AbilityRuntime
#endif // OHOS_ABILITY_RUNTIME_SERVER_CONSTANT_H