mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-25 12:23:20 -04:00
fix logout user
Signed-off-by: yuwenze <yuwenze1@huawei.com> Change-Id: I5e939e35b1751586cdcc073c7eb776c46dc693cb
This commit is contained in:
@@ -257,6 +257,8 @@ public:
|
||||
|
||||
void TerminateAbilityWindowLocked(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const sptr<SessionInfo> &sessionInfo);
|
||||
|
||||
void RemoveLauncherDeathRecipient();
|
||||
|
||||
// MSG 0 - 20 represents timeout message
|
||||
static constexpr uint32_t LOAD_TIMEOUT_MSG = 0;
|
||||
|
||||
@@ -1441,6 +1441,8 @@ public:
|
||||
*/
|
||||
int32_t GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list) override;
|
||||
|
||||
void RemoveLauncherDeathRecipient(int32_t userId);
|
||||
|
||||
// MSG 0 - 20 represents timeout message
|
||||
static constexpr uint32_t LOAD_TIMEOUT_MSG = 0;
|
||||
static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1;
|
||||
|
||||
@@ -1952,6 +1952,22 @@ void AbilityConnectManager::PauseExtensions()
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityConnectManager::RemoveLauncherDeathRecipient()
|
||||
{
|
||||
HILOG_INFO("Call.");
|
||||
std::lock_guard guard(Lock_);
|
||||
for (auto it = serviceMap_.begin(); it != serviceMap_.end();) {
|
||||
auto targetExtension = it->second;
|
||||
if (targetExtension != nullptr && targetExtension->GetAbilityInfo().type == AbilityType::EXTENSION &&
|
||||
(IsLauncher(targetExtension) || IsSceneBoard(targetExtension))) {
|
||||
targetExtension->RemoveAbilityDeathRecipient();
|
||||
break;
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AbilityConnectManager::IsLauncher(std::shared_ptr<AbilityRecord> serviceExtension) const
|
||||
{
|
||||
if (serviceExtension == nullptr) {
|
||||
|
||||
@@ -9353,5 +9353,15 @@ int AbilityManagerService::SendDialogResult(const Want &want, const std::string
|
||||
return StartAbilityAsCaller(targetWant, callerToken, nullptr, dialogCallerInfo->userId,
|
||||
dialogCallerInfo->requestCode, true);
|
||||
}
|
||||
|
||||
void AbilityManagerService::RemoveLauncherDeathRecipient(int32_t userId)
|
||||
{
|
||||
auto connectManager = GetConnectManagerByUserId(userId);
|
||||
if (connectManager == nullptr) {
|
||||
HILOG_ERROR("connectManager is nullptr. userId=%{public}d", userId);
|
||||
return;
|
||||
}
|
||||
connectManager->RemoveLauncherDeathRecipient();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "app_scheduler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "mock_session_manager_service.h"
|
||||
#include "os_account_manager_wrapper.h"
|
||||
#include "scene_board_judgement.h"
|
||||
#include "task_data_persistence_mgr.h"
|
||||
@@ -200,19 +201,27 @@ int32_t UserController::LogoutUser(int32_t userId)
|
||||
HILOG_ERROR("not exist such account:%{public}d", userId);
|
||||
return INVALID_USERID_VALUE;
|
||||
}
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
if (!abilityManagerService) {
|
||||
HILOG_ERROR("abilityManagerService is null");
|
||||
return -1;
|
||||
}
|
||||
abilityManagerService->RemoveLauncherDeathRecipient(userId);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
HILOG_INFO("SceneBoard exit normally.");
|
||||
Rosen::MockSessionManagerService::GetInstance().NotifyNotKillService();
|
||||
}
|
||||
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
|
||||
if (!appScheduler) {
|
||||
HILOG_ERROR("appScheduler is null");
|
||||
return INVALID_USERID_VALUE;
|
||||
}
|
||||
appScheduler->KillProcessesByUserId(userId);
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
if (!abilityManagerService) {
|
||||
HILOG_ERROR("abilityManagerService is null");
|
||||
return -1;
|
||||
}
|
||||
abilityManagerService->ClearUserData(userId);
|
||||
ClearAbilityUserItems(userId);
|
||||
if (IsCurrentUser(userId)) {
|
||||
SetCurrentUserId(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user