Signed-off-by: unknown <sijunjie@huawei.com>
This commit is contained in:
unknown 2022-03-31 16:23:46 +08:00
parent 10b542f049
commit 8ea9c89d31
3 changed files with 7 additions and 118 deletions

View File

@ -338,13 +338,6 @@ public:
*/
std::shared_ptr<AbilityEventHandler> GetEventHandler();
/**
* SetStackManager, set the user id of stack manager.
*
* @param userId, user id.
*/
void SetStackManager(int userId, bool switchUser);
/**
* GetStackManager, get the current stack manager.
*
@ -711,7 +704,6 @@ public:
void OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord);
void OnCallConnectDied(std::shared_ptr<CallRecord> callRecord);
void GetMaxRestartNum(int &max);
bool IsUseNewMission();
void HandleLoadTimeOut(int64_t eventId);
void HandleActiveTimeOut(int64_t eventId);
void HandleInactiveTimeOut(int64_t eventId);
@ -1058,15 +1050,11 @@ private:
int ReleaseRemoteAbility(const sptr<IRemoteObject> &connect, const AppExecFwk::ElementName &element);
void DumpInner(const std::string &args, std::vector<std::string> &info);
void DumpStackListInner(const std::string &args, std::vector<std::string> &info);
void DumpStackInner(const std::string &args, std::vector<std::string> &info);
void DumpMissionInner(const std::string &args, std::vector<std::string> &info);
void DumpTopAbilityInner(const std::string &args, std::vector<std::string> &info);
void DumpWaittingAbilityQueueInner(const std::string &args, std::vector<std::string> &info);
void DumpStateInner(const std::string &args, std::vector<std::string> &info);
void DataDumpStateInner(const std::string &args, std::vector<std::string> &info);
void DumpFocusMapInner(const std::string &args, std::vector<std::string> &info);
void DumpWindowModeInner(const std::string &args, std::vector<std::string> &info);
void DumpMissionListInner(const std::string &args, std::vector<std::string> &info);
void DumpMissionInfosInner(const std::string &args, std::vector<std::string> &info);
void DumpFuncInit();
@ -1123,7 +1111,6 @@ private:
void StartUserApps(int32_t userId, bool isBoot);
void StartSystemAbilityByUser(int32_t userId, bool isBoot);
void PauseOldUser(int32_t userId);
void PauseOldStackManager(int32_t userId);
void PauseOldMissionListManager(int32_t userId);
void PauseOldConnectManager(int32_t userId);
bool IsSystemUI(const std::string &bundleName) const;
@ -1131,11 +1118,9 @@ private:
bool VerificationAllToken(const sptr<IRemoteObject> &token);
std::shared_ptr<DataAbilityManager> GetDataAbilityManager(const sptr<IAbilityScheduler> &scheduler);
bool CheckDataAbilityRequest(AbilityRequest &abilityRequest);
std::shared_ptr<AbilityStackManager> GetStackManagerByUserId(int32_t userId);
std::shared_ptr<MissionListManager> GetListManagerByUserId(int32_t userId);
std::shared_ptr<AbilityConnectManager> GetConnectManagerByUserId(int32_t userId);
std::shared_ptr<DataAbilityManager> GetDataAbilityManagerByUserId(int32_t userId);
std::shared_ptr<AbilityStackManager> GetStackManagerByToken(const sptr<IRemoteObject> &token);
std::shared_ptr<MissionListManager> GetListManagerByToken(const sptr<IRemoteObject> &token);
std::shared_ptr<AbilityConnectManager> GetConnectManagerByToken(const sptr<IRemoteObject> &token);
std::shared_ptr<DataAbilityManager> GetDataAbilityManagerByToken(const sptr<IRemoteObject> &token);
@ -1175,7 +1160,6 @@ private:
std::shared_ptr<AppExecFwk::EventRunner> eventLoop_;
std::shared_ptr<AbilityEventHandler> handler_;
ServiceRunningState state_;
std::unordered_map<int, std::shared_ptr<AbilityStackManager>> stackManagers_;
std::shared_ptr<AbilityStackManager> currentStackManager_;
std::unordered_map<int, std::shared_ptr<AbilityConnectManager>> connectManagers_;
std::shared_ptr<AbilityConnectManager> connectManager_;
@ -1190,8 +1174,6 @@ private:
const static std::map<std::string, AbilityManagerService::DumpKey> dumpMap;
const static std::map<std::string, AbilityManagerService::DumpsysKey> dumpsysMap;
// new ams here
bool useNewMission_ {false};
std::unordered_map<int, std::shared_ptr<MissionListManager>> missionListManagers_;
std::shared_ptr<MissionListManager> currentMissionListManager_;
std::shared_ptr<UserController> userController_;

View File

@ -1007,11 +1007,7 @@ void AbilityConnectManager::DumpState(std::vector<std::string> &info, bool isCli
}
} else {
auto abilityMgr = DelayedSingleton<AbilityManagerService>::GetInstance();
if (abilityMgr && abilityMgr->IsUseNewMission()) {
info.emplace_back(" ExtensionRecords:");
} else {
info.emplace_back(" serviceAbilityRecords:");
}
info.emplace_back(" ExtensionRecords:");
for (auto &&service : serviceMap_) {
info.emplace_back(" uri [" + service.first + "]");
service.second->DumpService(info, isClient);

View File

@ -224,7 +224,6 @@ bool AbilityManagerService::Init()
amsConfigResolver_ = std::make_shared<AmsConfigurationParameter>();
amsConfigResolver_->Parse();
HILOG_INFO("ams config parse");
useNewMission_ = amsConfigResolver_->IsUseNewMission();
InitMissionListManager(userId, true);
SwitchManagers(U0_USER_ID, false);
int amsTimeOut = amsConfigResolver_->GetAMSTimeOutTime();
@ -715,7 +714,7 @@ int AbilityManagerService::TerminateAbilityByCaller(const sptr<IRemoteObject> &c
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
auto type = abilityRecord->GetAbilityInfo().type;
auto stackManager = GetStackManagerByUserId(userId);
auto stackManager = currentStackManager_;
auto connectManager = GetConnectManagerByUserId(userId);
switch (type) {
case AppExecFwk::AbilityType::SERVICE:
@ -831,8 +830,7 @@ int AbilityManagerService::SetMissionDescriptionInfo(
auto abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
auto stackManager = GetStackManagerByUserId(userId);
auto stackManager = currentStackManager_;
if (!stackManager) {
return ERR_INVALID_VALUE;
}
@ -872,8 +870,7 @@ int AbilityManagerService::MoveMissionToEnd(const sptr<IRemoteObject> &token, co
}
auto abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
auto stackManager = GetStackManagerByUserId(userId);
auto stackManager = currentStackManager_;
if (!stackManager) {
return ERR_INVALID_VALUE;
}
@ -1720,15 +1717,11 @@ int AbilityManagerService::AttachAbilityThread(
void AbilityManagerService::DumpFuncInit()
{
dumpFuncMap_[KEY_DUMP_ALL] = &AbilityManagerService::DumpInner;
dumpFuncMap_[KEY_DUMP_STACK_LIST] = &AbilityManagerService::DumpStackListInner;
dumpFuncMap_[KEY_DUMP_STACK] = &AbilityManagerService::DumpStackInner;
dumpFuncMap_[KEY_DUMP_MISSION] = &AbilityManagerService::DumpMissionInner;
dumpFuncMap_[KEY_DUMP_TOP_ABILITY] = &AbilityManagerService::DumpTopAbilityInner;
dumpFuncMap_[KEY_DUMP_WAIT_QUEUE] = &AbilityManagerService::DumpWaittingAbilityQueueInner;
dumpFuncMap_[KEY_DUMP_SERVICE] = &AbilityManagerService::DumpStateInner;
dumpFuncMap_[KEY_DUMP_DATA] = &AbilityManagerService::DataDumpStateInner;
dumpFuncMap_[KEY_DUMP_FOCUS_ABILITY] = &AbilityManagerService::DumpFocusMapInner;
dumpFuncMap_[KEY_DUMP_WINDOW_MODE] = &AbilityManagerService::DumpWindowModeInner;
dumpFuncMap_[KEY_DUMP_MISSION_LIST] = &AbilityManagerService::DumpMissionListInner;
dumpFuncMap_[KEY_DUMP_MISSION_INFOS] = &AbilityManagerService::DumpMissionInfosInner;
}
@ -1973,21 +1966,6 @@ void AbilityManagerService::DumpInner(const std::string &args, std::vector<std::
}
}
void AbilityManagerService::DumpStackListInner(const std::string &args, std::vector<std::string> &info)
{
currentStackManager_->DumpStackList(info);
}
void AbilityManagerService::DumpFocusMapInner(const std::string &args, std::vector<std::string> &info)
{
currentStackManager_->DumpFocusMap(info);
}
void AbilityManagerService::DumpWindowModeInner(const std::string &args, std::vector<std::string> &info)
{
currentStackManager_->DumpWindowMode(info);
}
void AbilityManagerService::DumpMissionListInner(const std::string &args, std::vector<std::string> &info)
{
if (currentMissionListManager_) {
@ -2034,11 +2012,6 @@ void AbilityManagerService::DumpMissionInner(const std::string &args, std::vecto
currentMissionListManager_->DumpMission(missionId, info);
}
void AbilityManagerService::DumpTopAbilityInner(const std::string &args, std::vector<std::string> &info)
{
currentStackManager_->DumpTopAbility(info);
}
void AbilityManagerService::DumpWaittingAbilityQueueInner(const std::string &args, std::vector<std::string> &info)
{
std::string result;
@ -2270,7 +2243,7 @@ void AbilityManagerService::AddWindowInfo(const sptr<IRemoteObject> &token, int3
auto abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER(abilityRecord);
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
auto stackManager = GetStackManagerByUserId(userId);
auto stackManager = currentStackManager_;
if (!stackManager) {
HILOG_ERROR("stackManager is nullptr. userId=%{public}d", userId);
return ;
@ -2333,23 +2306,6 @@ std::shared_ptr<AbilityEventHandler> AbilityManagerService::GetEventHandler()
return handler_;
}
void AbilityManagerService::SetStackManager(int userId, bool switchUser)
{
auto iterator = stackManagers_.find(userId);
if (iterator != stackManagers_.end()) {
if (switchUser) {
currentStackManager_ = iterator->second;
}
} else {
auto manager = std::make_shared<AbilityStackManager>(userId);
manager->Init();
stackManagers_.emplace(userId, manager);
if (switchUser) {
currentStackManager_ = manager;
}
}
}
void AbilityManagerService::InitMissionListManager(int userId, bool switchUser)
{
bool find = false;
@ -2654,11 +2610,6 @@ void AbilityManagerService::GetMaxRestartNum(int &max)
}
}
bool AbilityManagerService::IsUseNewMission()
{
return useNewMission_;
}
int AbilityManagerService::KillProcess(const std::string &bundleName)
{
HILOG_DEBUG("Kill process, bundleName: %{public}s", bundleName.c_str());
@ -2934,16 +2885,6 @@ std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager
return nullptr;
}
std::shared_ptr<AbilityStackManager> AbilityManagerService::GetStackManagerByUserId(int32_t userId)
{
auto it = stackManagers_.find(userId);
if (it != stackManagers_.end()) {
return it->second;
}
HILOG_ERROR("%{public}s, Failed to get Manager. UserId = %{public}d", __func__, userId);
return nullptr;
}
std::shared_ptr<MissionListManager> AbilityManagerService::GetListManagerByUserId(int32_t userId)
{
std::shared_lock<std::shared_mutex> lock(managersMutex_);
@ -2977,21 +2918,6 @@ std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager
return nullptr;
}
std::shared_ptr<AbilityStackManager> AbilityManagerService::GetStackManagerByToken(const sptr<IRemoteObject> &token)
{
for (auto item: stackManagers_) {
if (item.second && item.second->GetAbilityRecordByToken(token)) {
return item.second;
}
if (item.second && item.second->GetAbilityFromTerminateList(token)) {
return item.second;
}
}
return nullptr;
}
std::shared_ptr<MissionListManager> AbilityManagerService::GetListManagerByToken(const sptr<IRemoteObject> &token)
{
std::shared_lock<std::shared_mutex> lock(managersMutex_);
@ -3109,7 +3035,7 @@ bool AbilityManagerService::IsFirstInMission(const sptr<IRemoteObject> &token)
auto abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER_RETURN_BOOL(abilityRecord);
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
auto stackManager = GetStackManagerByUserId(userId);
auto stackManager = currentStackManager_;
if (!stackManager) {
HILOG_ERROR("stackManager is nullptr. userId=%{public}d", userId);
return ERR_INVALID_VALUE;
@ -3178,7 +3104,7 @@ void AbilityManagerService::RestartAbility(const sptr<IRemoteObject> &token)
CHECK_POINTER(abilityRecord);
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
auto stackManager = GetStackManagerByUserId(userId);
auto stackManager = currentStackManager_;
if (!stackManager) {
HILOG_ERROR("stackManager is nullptr. userId=%{public}d", userId);
return;
@ -3736,7 +3662,6 @@ void AbilityManagerService::UserStarted(int32_t userId)
{
HILOG_INFO("%{public}s", __func__);
InitConnectManager(userId, false);
SetStackManager(userId, false);
InitMissionListManager(userId, false);
InitDataAbilityManager(userId, false);
InitPendWantManager(userId, false);
@ -3759,7 +3684,6 @@ void AbilityManagerService::SwitchManagers(int32_t userId, bool switchUser)
{
HILOG_INFO("%{public}s, SwitchManagers:%{public}d-----begin", __func__, userId);
InitConnectManager(userId, switchUser);
SetStackManager(userId, switchUser);
InitMissionListManager(userId, switchUser);
InitDataAbilityManager(userId, switchUser);
InitPendWantManager(userId, switchUser);
@ -3814,19 +3738,6 @@ void AbilityManagerService::PauseOldConnectManager(int32_t userId)
HILOG_INFO("%{public}s, PauseOldConnectManager:%{public}d-----end", __func__, userId);
}
void AbilityManagerService::PauseOldStackManager(int32_t userId)
{
auto it = stackManagers_.find(userId);
if (it == stackManagers_.end()) {
return;
}
auto manager = it->second;
if (!manager) {
return;
}
manager->PauseManager();
}
void AbilityManagerService::StartUserApps(int32_t userId, bool isBoot)
{
HILOG_INFO("StartUserApps, userId:%{public}d, currentUserId:%{public}d", userId, GetUserId());