mission list module

Signed-off-by: wangzhen <wangzhen346@huawei.com>
Change-Id: I1381e16918408cd9b7eebcdf73e139cfe53673b2
This commit is contained in:
wangzhen 2024-07-02 21:45:19 +08:00
parent 5e15dbb008
commit a2b6d4967b
56 changed files with 866 additions and 337 deletions

View File

@ -20,6 +20,7 @@ group("abilityms_target") {
deps = [
":abilityms",
":ams_service_config",
":mission_list",
]
}
@ -256,6 +257,142 @@ ohos_prebuilt_etc("default_recovery_config.json") {
part_name = "ability_runtime"
}
ohos_shared_library("mission_list") {
sanitize = {
integer_overflow = true
ubsan = true
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
cfi_vcall_icall_only = true
debug = false
}
branch_protector_ret = "pac_ret"
include_dirs = [
"${ability_runtime_innerkits_path}/ability_manager/include",
"${ability_runtime_innerkits_path}/ability_manager/include/status_bar_delegate",
"${ability_runtime_innerkits_path}/connectionobs_manager/include",
"${ability_runtime_innerkits_path}/deps_wrapper/include",
"${ability_runtime_innerkits_path}/session_handler/include",
"${ability_runtime_path}/interfaces/kits/native/ability/native",
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
"${ability_runtime_services_path}/abilitymgr/include",
"${ability_runtime_services_path}/common/include",
"${ability_runtime_services_path}/appdfr/include",
"${ability_runtime_utils_path}/global/constant",
"${ability_runtime_utils_path}/server/constant",
]
defines = []
if (ability_command_for_test) {
defines += [ "ABILITY_COMMAND_FOR_TEST" ]
}
if (ability_runtime_graphics) {
defines += [
"SUPPORT_GRAPHICS",
"SUPPORT_SCREEN",
]
}
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
sources = [
"src/mission.cpp",
"src/mission_data_storage.cpp",
"src/mission_info_mgr.cpp",
"src/mission_list.cpp",
"src/mission_list_manager.cpp",
"src/task_data_persistence_mgr.cpp",
]
deps = [
":abilityms",
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
"${ability_runtime_innerkits_path}/ability_manager:process_options",
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:auto_startup_callback",
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
"${ability_runtime_path}/utils/global/freeze:freeze_util",
"${ability_runtime_path}/utils/server/startup:startup_util",
"${ability_runtime_services_path}/common:app_util",
"${ability_runtime_services_path}/common:event_report",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_services_path}/common:res_sched_util",
"${ability_runtime_services_path}/common:task_handler_wrap",
]
external_deps = [
"ability_base:base",
"ability_base:configuration",
"ability_base:session_info",
"ability_base:view_data",
"ability_base:want",
"ability_base:zuri",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"background_task_mgr:bgtaskmgr_innerkits",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"bundle_framework:libappexecfwk_common",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"config_policy:configpolicy_util",
"dsoftbus:softbus_client",
"ffrt:libffrt",
"graphic_2d:color_manager",
"hicollie:libhicollie",
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"icu:shared_icuuc",
"init:libbeget_proxy",
"init:libbegetutil",
"ipc:ipc_core",
"json:nlohmann_json_static",
"kv_store:distributeddata_inner",
"os_account:os_account_innerkits",
"relational_store:native_appdatafwk",
"relational_store:native_dataability",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (background_task_mgr_continuous_task_enable) {
external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
}
if (os_dlp_part_enabled) {
defines += [ "WITH_DLP" ]
external_deps += [ "dlp_permission_service:libdlp_permission_sdk" ]
}
if (ability_runtime_graphics) {
external_deps += [
"ability_base:session_info",
"i18n:intl_util",
"image_framework:image_native",
"resource_management:global_resmgr",
"window_manager:libdm",
"window_manager:libwm",
]
}
subsystem_name = "ability"
innerapi_tags = [ "platformsdk_indirect" ]
part_name = "ability_runtime"
}
group("ams_service_config") {
deps = [
":ams_service_config.json",

View File

@ -79,7 +79,6 @@ abilityms_files = [
"src/start_ability_utils.cpp",
# new ability manager service here
"src/task_data_persistence_mgr.cpp",
"src/extension_record_manager.cpp",
"src/extension_record.cpp",
"src/extension_record_factory.cpp",
@ -91,17 +90,12 @@ abilityms_files = [
"src/call_container.cpp",
"src/call_record.cpp",
"src/inner_mission_info.cpp",
"src/mission.cpp",
"src/mission_data_storage.cpp",
"src/mission_info_mgr.cpp",
"src/mission_listener_controller.cpp",
"src/mission_listener_proxy.cpp",
"src/rdb/ability_resident_process_rdb.cpp",
"src/rdb/parser_util.cpp",
"src/rdb/rdb_data_manager.cpp",
"src/remote_mission_listener_proxy.cpp",
"src/mission_list_manager.cpp",
"src/mission_list.cpp",
"src/scene_board/status_bar_delegate_manager.cpp",
"src/scene_board/ui_ability_lifecycle_manager.cpp",
"src/deeplink_reserve/deeplink_reserve_config.cpp",

View File

@ -53,7 +53,7 @@
#include "iacquire_share_data_callback_interface.h"
#include "interceptor/ability_interceptor_executer.h"
#include "iremote_object.h"
#include "mission_list_manager.h"
#include "mission_list_manager_interface.h"
#include "parameter.h"
#include "pending_want_manager.h"
#include "permission_verification.h"
@ -101,6 +101,8 @@ class AbilityManagerService : public SystemAbility,
DECLARE_DELAYED_SINGLETON(AbilityManagerService)
DECLEAR_SYSTEM_ABILITY(AbilityManagerService)
public:
static std::shared_ptr<AbilityManagerService> GetPubInstance();
void OnStart() override;
void OnStop() override;
@ -1143,7 +1145,7 @@ public:
virtual int UnregisterAbilityFirstFrameStateObserver(
const sptr<IAbilityFirstFrameStateObserver> &observer) override;
bool GetAnimationFlag();
#endif
@ -1703,7 +1705,9 @@ public:
virtual int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode,
const Want &want) override;
std::shared_ptr<MissionListManager> GetMissionListManagerByUserId(int32_t userId);
std::shared_ptr<MissionListManagerInterface> GetMissionListManagerByUserId(int32_t userId);
std::shared_ptr<MissionListWrap> GetMissionListWrap();
/**
* Notify ability manager service frozen process.
*
@ -1947,8 +1951,8 @@ private:
std::shared_ptr<AbilityConnectManager> GetConnectManagerByToken(const sptr<IRemoteObject> &token);
std::shared_ptr<PendingWantManager> GetCurrentPendingWantManager();
std::shared_ptr<PendingWantManager> GetPendingWantManagerByUserId(int32_t userId);
std::unordered_map<int, std::shared_ptr<MissionListManager>> GetMissionListManagers();
std::shared_ptr<MissionListManager> GetCurrentMissionListManager();
std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>> GetMissionListManagers();
std::shared_ptr<MissionListManagerInterface> GetCurrentMissionListManager();
std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> GetUIAbilityManagers();
std::shared_ptr<UIAbilityLifecycleManager> GetCurrentUIAbilityManager();
std::shared_ptr<UIAbilityLifecycleManager> GetUIAbilityManagerByUserId(int32_t userId);

View File

@ -24,6 +24,7 @@
#include "ability_running_info.h"
#include "mission_list.h"
#include "mission_list_manager_interface.h"
#include "mission_listener_controller.h"
#include "mission_info.h"
#include "mission_snapshot.h"
@ -34,16 +35,17 @@
namespace OHOS {
namespace AAFwk {
class MissionListManager : public std::enable_shared_from_this<MissionListManager> {
class MissionListManager : public MissionListManagerInterface,
public std::enable_shared_from_this<MissionListManager> {
public:
explicit MissionListManager(int userId);
~MissionListManager();
virtual ~MissionListManager();
/**
* init ability mission manager.
*
*/
void Init();
void Init() override;
/**
* StartAbility with request.
@ -51,7 +53,7 @@ public:
* @param abilityRequest, the request of the service ability to start.
* @return Returns ERR_OK on success, others on failure.
*/
int StartAbility(AbilityRequest &abilityRequest);
int StartAbility(AbilityRequest &abilityRequest) override;
/**
* MinimizeAbility, minimize the special ability.
@ -60,24 +62,24 @@ public:
* @param fromUser mark the minimize operation source.
* @return Returns ERR_OK on success, others on failure.
*/
int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser);
int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser) override;
int RegisterMissionListener(const sptr<IMissionListener> &listener);
int RegisterMissionListener(const sptr<IMissionListener> &listener) override;
int UnRegisterMissionListener(const sptr<IMissionListener> &listener);
int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override;
int GetMissionInfos(int32_t numMax, std::vector<MissionInfo> &missionInfos);
int GetMissionInfos(int32_t numMax, std::vector<MissionInfo> &missionInfos) override;
int GetMissionInfo(int32_t missionId, MissionInfo &missionInfo);
int GetMissionInfo(int32_t missionId, MissionInfo &missionInfo) override;
int MoveMissionToFront(int32_t missionId, std::shared_ptr<StartOptions> startOptions = nullptr);
int MoveMissionToFront(int32_t missionId, std::shared_ptr<StartOptions> startOptions = nullptr) override;
int MoveMissionToFront(int32_t missionId, bool isCallerFromLauncher, bool isRecent,
std::shared_ptr<AbilityRecord> callerAbility, std::shared_ptr<StartOptions> startOptions = nullptr);
std::shared_ptr<AbilityRecord> callerAbility, std::shared_ptr<StartOptions> startOptions = nullptr) override;
void NotifyMissionFocused(const int32_t missionId);
void NotifyMissionFocused(int32_t missionId) override;
void NotifyMissionUnfocused(const int32_t missionId);
void NotifyMissionUnfocused(int32_t missionId) override;
/**
* OnAbilityRequestDone, app manager service call this interface after ability request done.
@ -85,9 +87,9 @@ public:
* @param token,ability's token.
* @param state,the state of ability lift cycle.
*/
void OnAbilityRequestDone(const sptr<IRemoteObject> &token, const int32_t state);
void OnAbilityRequestDone(const sptr<IRemoteObject> &token, int32_t state) override;
void OnAppStateChanged(const AppInfo &info);
void OnAppStateChanged(const AppInfo &info) override;
/**
* attach ability thread ipc object.
@ -96,7 +98,8 @@ public:
* @param token, the token of ability.
* @return Returns ERR_OK on success, others on failure.
*/
int AttachAbilityThread(const sptr<AAFwk::IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token);
int AttachAbilityThread(const sptr<AAFwk::IAbilityScheduler> &scheduler,
const sptr<IRemoteObject> &token) override;
/**
* start waiting ability.
@ -109,7 +112,7 @@ public:
* @param token the search token
* @return std::shared_ptr<AbilityRecord> the AbilityRecord of the token
*/
std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token) const;
std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token) override;
/**
* @brief Get the Mission By Id object
@ -125,7 +128,7 @@ public:
* @param abilityRecord the ability to move
* @return int error code
*/
int MoveAbilityToBackground(const std::shared_ptr<AbilityRecord> &abilityRecord);
int MoveAbilityToBackground(const std::shared_ptr<AbilityRecord> &abilityRecord) override;
/**
* @brief Terminate ability with the given abilityRecord
@ -137,7 +140,7 @@ public:
* @return int error code
*/
int TerminateAbility(const std::shared_ptr<AbilityRecord> &abilityRecord,
int resultCode, const Want *resultWant, bool flag);
int resultCode, const Want *resultWant, bool flag) override;
/**
* @brief remove the mission list from the mission list manager
@ -154,7 +157,7 @@ public:
* @param saveData the saved data
* @return execute error code
*/
int AbilityTransactionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData);
int AbilityTransactionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) override;
/**
* @brief search the ability from terminating list
@ -162,7 +165,7 @@ public:
* @param token the ability token
* @return the ability need to terminate
*/
std::shared_ptr<AbilityRecord> GetAbilityFromTerminateList(const sptr<IRemoteObject> &token);
std::shared_ptr<AbilityRecord> GetAbilityFromTerminateList(const sptr<IRemoteObject> &token) override;
/**
* @brief clear the mission with the given id
@ -170,14 +173,14 @@ public:
* @param missionId the mission need to delete
* @return int error code
*/
int ClearMission(int missionId);
int ClearMission(int missionId) override;
/**
* @brief clear all the missions
*
* @return int error code
*/
int ClearAllMissions();
int ClearAllMissions() override;
void ClearAllMissionsLocked(std::list<std::shared_ptr<Mission>> &missionList,
std::list<std::shared_ptr<Mission>> &foregroundAbilities, bool searchActive);
@ -188,7 +191,7 @@ public:
* @param missionId the id of the mission
* @return int error code
*/
int SetMissionLockedState(int missionId, bool lockedState);
int SetMissionLockedState(int missionId, bool lockedState) override;
/**
* @brief schedule to background
@ -204,21 +207,21 @@ public:
* @param abilityRecordId the id of ability record
* @param isHalf is half
*/
void OnTimeOut(uint32_t msgId, int64_t abilityRecordId, bool isHalf = false);
void OnTimeOut(uint32_t msgId, int64_t abilityRecordId, bool isHalf = false) override;
/**
* @brief handle when ability died
*
* @param abilityRecord the died ability
*/
void OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord, int32_t currentUserId);
void OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord, int32_t currentUserId) override;
/**
* @brief handle when call connection died
*
* @param callRecord the died call connection
*/
void OnCallConnectDied(const std::shared_ptr<CallRecord> &callRecord);
void OnCallConnectDied(const std::shared_ptr<CallRecord> &callRecord) override;
/**
* Get mission id by target ability token.
@ -226,7 +229,7 @@ public:
* @param token target ability token.
* @return the missionId of target mission.
*/
int32_t GetMissionIdByAbilityToken(const sptr<IRemoteObject> &token);
int32_t GetMissionIdByAbilityToken(const sptr<IRemoteObject> &token) override;
/**
* Get ability token by target mission id.
@ -234,21 +237,22 @@ public:
* @param missionId target missionId.
* @return the ability token of target mission.
*/
sptr<IRemoteObject> GetAbilityTokenByMissionId(int32_t missionId);
sptr<IRemoteObject> GetAbilityTokenByMissionId(int32_t missionId) override;
std::shared_ptr<AbilityRecord> GetAbilityRecordByMissionId(int32_t missionId) override;
/**
* @brief dump all abilities
*
* @param info dump result.
*/
void Dump(std::vector<std::string>& info);
void Dump(std::vector<std::string>& info) override;
/**
* @brief dump mission list
*
* @param info dump result.
*/
void DumpMissionList(std::vector<std::string> &info, bool isClient, const std::string &args = "");
void DumpMissionList(std::vector<std::string> &info, bool isClient, const std::string &args = "") override;
/**
* @brief dump mission list by id with params
@ -256,32 +260,32 @@ public:
* @param info dump result.
* @param params dump params.
*/
void DumpMissionListByRecordId(
std::vector<std::string>& info, bool isClient, int32_t abilityRecordId, const std::vector<std::string>& params);
void DumpMissionListByRecordId(std::vector<std::string>& info, bool isClient, int32_t abilityRecordId,
const std::vector<std::string>& params) override;
/**
* @brief dump mission by id
*
* @param info dump result.
*/
void DumpMission(int missionId, std::vector<std::string> &info);
void DumpMission(int missionId, std::vector<std::string> &info) override;
/**
* @brief dump mission infos
*
* @param info dump result.
*/
void DumpMissionInfos(std::vector<std::string> &info);
void DumpMissionInfos(std::vector<std::string> &info) override;
void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag);
void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag) override;
void OnStartSpecifiedAbilityTimeoutResponse(const AAFwk::Want &want);
void OnStartSpecifiedAbilityTimeoutResponse(const AAFwk::Want &want) override;
/**
* resolve the call ipc of ability for scheduling oncall.
*
* @param abilityRequest, target ability request.
*/
int ResolveLocked(const AbilityRequest &abilityRequest);
int ResolveLocked(const AbilityRequest &abilityRequest) override;
/**
* release the connection of this call.
@ -289,12 +293,12 @@ public:
* @param connect, caller callback ipc.
* @param element, target ability name.
*/
int ReleaseCallLocked(const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element);
int ReleaseCallLocked(const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override;
/**
* @brief register snapshotHandler
* @param handler the snapshotHandler
*/
void RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler);
void RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
/**
* @brief Get the Mission Snapshot object
@ -305,8 +309,8 @@ public:
* @return Returns true on success, false on failure.
*/
bool GetMissionSnapshot(int32_t missionId, const sptr<IRemoteObject>& abilityToken,
MissionSnapshot& missionSnapshot, bool isLowResolution);
void GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info, bool isPerm);
MissionSnapshot& missionSnapshot, bool isLowResolution) override;
void GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info, bool isPerm) override;
/**
* Called to update mission snapshot.
@ -314,7 +318,7 @@ public:
* @param pixelMap The snapshot.
*/
#ifdef SUPPORT_SCREEN
void UpdateSnapShot(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &pixelMap);
void UpdateSnapShot(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &pixelMap) override;
#endif // SUPPORT_SCREEN
/**
@ -324,7 +328,7 @@ public:
*/
int32_t GetAbilityNumber(const AppExecFwk::ElementName &element) const;
void EnableRecoverAbility(int32_t missionId);
void EnableRecoverAbility(int32_t missionId) override;
#ifdef ABILITY_COMMAND_FOR_TEST
/**
@ -333,32 +337,34 @@ public:
* @param abilityRecordId The Ability Record Id.
* @return Returns ERR_OK on success, others on failure.
*/
int BlockAbility(int abilityRecordId);
int BlockAbility(int abilityRecordId) override;
#endif
void UninstallApp(const std::string &bundleName, int32_t uid);
void UninstallApp(const std::string &bundleName, int32_t uid) override;
bool IsStarted();
void PauseManager();
void ResumeManager();
bool IsStarted() override;
void PauseManager() override;
void ResumeManager() override;
void SetMissionANRStateByTokens(const std::vector<sptr<IRemoteObject>> &tokens);
int32_t IsValidMissionIds(const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results);
int32_t IsValidMissionIds(const std::vector<int32_t> &missionIds,
std::vector<MissionValidResult> &results) override;
int DoAbilityForeground(std::shared_ptr<AbilityRecord> &abilityRecord, uint32_t flag);
int DoAbilityForeground(std::shared_ptr<AbilityRecord> &abilityRecord, uint32_t flag) override;
void GetActiveAbilityList(int32_t uid, std::vector<std::string> &abilityList, int32_t pid = NO_PID);
void GetActiveAbilityList(int32_t uid, std::vector<std::string> &abilityList, int32_t pid = NO_PID) override;
void CallRequestDone(const std::shared_ptr<AbilityRecord> &abilityRecord, const sptr<IRemoteObject> &callStub);
void CallRequestDone(const std::shared_ptr<AbilityRecord> &abilityRecord,
const sptr<IRemoteObject> &callStub) override;
int SetMissionContinueState(const sptr<IRemoteObject> &token, const int32_t missionId,
const AAFwk::ContinueState &state);
int SetMissionContinueState(const sptr<IRemoteObject> &token, int32_t missionId,
const AAFwk::ContinueState &state) override;
bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord);
bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord) override;
void SignRestartAppFlag(const std::string &bundleName) override;
void SignRestartAppFlag(const std::string &bundleName);
void SetAnimationFlag(bool IsAnimationEnabled);
#ifdef SUPPORT_SCREEN
public:
@ -369,7 +375,7 @@ public:
* @param label target label.
* @return Return 0 if success.
*/
int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label);
int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override;
/**
* Set mission icon of this ability.
@ -378,9 +384,9 @@ public:
* @param icon target label.
* @return Return 0 if success.
*/
int SetMissionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon);
int SetMissionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon) override;
void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) const;
void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) override;
void PostMissionLabelUpdateTask(int missionId) const;

View File

@ -0,0 +1,143 @@
/*
* Copyright (c) 2024 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_MISSION_LIST_MANAGER_INTERFACE_H
#define OHOS_ABILITY_RUNTIME_MISSION_LIST_MANAGER_INTERFACE_H
#include <memory>
#include <string>
#include <vector>
#include "ability_running_info.h"
#include "mission_list.h"
#include "mission_listener_controller.h"
#include "mission_info.h"
#include "mission_snapshot.h"
#include "snapshot.h"
#include "start_options.h"
#include "want.h"
#include "iability_info_callback.h"
namespace OHOS {
namespace AAFwk {
class MissionListManagerInterface {
public:
virtual ~MissionListManagerInterface() = default;
virtual void Init() = 0;
virtual int StartAbility(AbilityRequest &abilityRequest) = 0;
virtual int MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser) = 0;
virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) = 0;
virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) = 0;
virtual int GetMissionInfos(int32_t numMax, std::vector<MissionInfo> &missionInfos) = 0;
virtual int GetMissionInfo(int32_t missionId, MissionInfo &missionInfo) = 0;
virtual int MoveMissionToFront(int32_t missionId, std::shared_ptr<StartOptions> startOptions = nullptr) = 0;
virtual int MoveMissionToFront(int32_t missionId, bool isCallerFromLauncher, bool isRecent,
std::shared_ptr<AbilityRecord> callerAbility, std::shared_ptr<StartOptions> startOptions = nullptr) = 0;
virtual void NotifyMissionFocused(int32_t missionId) = 0;
virtual void NotifyMissionUnfocused(int32_t missionId) = 0;
virtual void OnAbilityRequestDone(const sptr<IRemoteObject> &token, int32_t state) = 0;
virtual void OnAppStateChanged(const AppInfo &info) = 0;
virtual int AttachAbilityThread(const sptr<AAFwk::IAbilityScheduler> &scheduler,
const sptr<IRemoteObject> &token) = 0;
virtual std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token) = 0;
virtual std::shared_ptr<AbilityRecord> GetAbilityRecordByMissionId(int missionId) = 0;
virtual int MoveAbilityToBackground(const std::shared_ptr<AbilityRecord> &abilityRecord) = 0;
virtual int TerminateAbility(const std::shared_ptr<AbilityRecord> &abilityRecord,
int resultCode, const Want *resultWant, bool flag) = 0;
virtual int AbilityTransactionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData) = 0;
virtual std::shared_ptr<AbilityRecord> GetAbilityFromTerminateList(const sptr<IRemoteObject> &token) = 0;
virtual int ClearMission(int missionId) = 0;
virtual int ClearAllMissions() = 0;
virtual int SetMissionLockedState(int missionId, bool lockedState) = 0;
virtual void OnTimeOut(uint32_t msgId, int64_t abilityRecordId, bool isHalf = false) = 0;
virtual void OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord, int32_t currentUserId) = 0;
virtual void OnCallConnectDied(const std::shared_ptr<CallRecord> &callRecord) = 0;
virtual int32_t GetMissionIdByAbilityToken(const sptr<IRemoteObject> &token) = 0;
virtual sptr<IRemoteObject> GetAbilityTokenByMissionId(int32_t missionId) = 0;
virtual void Dump(std::vector<std::string> &info) = 0;
virtual void DumpMissionList(std::vector<std::string> &info, bool isClient, const std::string &args = "");
virtual void DumpMissionListByRecordId(std::vector<std::string> &info, bool isClient, int32_t abilityRecordId,
const std::vector<std::string> &params) = 0;
virtual void DumpMission(int missionId, std::vector<std::string> &info) = 0;
virtual void DumpMissionInfos(std::vector<std::string> &info) = 0;
virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag) = 0;
virtual void OnStartSpecifiedAbilityTimeoutResponse(const AAFwk::Want &want) = 0;
virtual int ResolveLocked(const AbilityRequest &abilityRequest) = 0;
virtual int ReleaseCallLocked(const sptr<IAbilityConnection> &connect,
const AppExecFwk::ElementName &element) = 0;
virtual void RegisterSnapshotHandler(const sptr<ISnapshotHandler> &handler) = 0;
virtual bool GetMissionSnapshot(int32_t missionId, const sptr<IRemoteObject> &abilityToken,
MissionSnapshot &missionSnapshot, bool isLowResolution) = 0;
virtual void GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info, bool isPerm) = 0;
#ifdef SUPPORT_SCREEN
virtual void UpdateSnapShot(const sptr<IRemoteObject> &token,
const std::shared_ptr<Media::PixelMap> &pixelMap) = 0;
#endif // SUPPORT_SCREEN
virtual void EnableRecoverAbility(int32_t missionId) = 0;
#ifdef ABILITY_COMMAND_FOR_TEST
virtual int BlockAbility(int abilityRecordId) = 0;
#endif
virtual void UninstallApp(const std::string &bundleName, int32_t uid) = 0;
virtual bool IsStarted() = 0;
virtual void PauseManager() = 0;
virtual void ResumeManager() = 0;
virtual int32_t IsValidMissionIds(const std::vector<int32_t> &missionIds,
std::vector<MissionValidResult> &results) = 0;
virtual int DoAbilityForeground(std::shared_ptr<AbilityRecord> &abilityRecord, uint32_t flag);
virtual void GetActiveAbilityList(int32_t uid, std::vector<std::string> &abilityList, int32_t pid = NO_PID) = 0;
virtual void CallRequestDone(const std::shared_ptr<AbilityRecord> &abilityRecord,
const sptr<IRemoteObject> &callStub) = 0;
virtual int SetMissionContinueState(const sptr<IRemoteObject> &token, int32_t missionId,
const AAFwk::ContinueState &state) = 0;
virtual bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord) = 0;
virtual void SignRestartAppFlag(const std::string &bundleName) = 0;
#ifdef SUPPORT_SCREEN
public:
virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) = 0;
virtual int SetMissionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon) = 0;
virtual void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) = 0;
#endif
};
class MissionListWrap {
public:
virtual ~MissionListWrap() = default;
virtual std::shared_ptr<MissionListManagerInterface> CreateMissionListManager(int32_t userId) = 0;
virtual void RemoveUserDir(int32_t userId) = 0;
virtual void InitMissionInfoMgr(int32_t userId) = 0;
virtual void SetMissionAbilityState(int32_t missionId, AbilityState state) = 0;
virtual int32_t GetInnerMissionInfoById(int32_t missionId, InnerMissionInfo &innerMissionInfo) = 0;
#ifdef SUPPORT_SCREEN
virtual std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t missionId) = 0;
#endif
};
} // namespace AAFwk
} // namespace OHOS
extern "C" __attribute__((visibility("default"))) OHOS::AAFwk::MissionListWrap* CreateMissionListWrap();
#endif // OHOS_ABILITY_RUNTIME_MISSION_LIST_MANAGER_INTERFACE_H

View File

@ -24,7 +24,7 @@
#include "ability_event_handler.h"
#include "cpp/mutex.h"
#include "data_ability_manager.h"
#include "mission_list_manager.h"
#include "mission_list_manager_interface.h"
#include "nocopyable.h"
#include "pending_want_manager.h"
#include "scene_board/ui_ability_lifecycle_manager.h"
@ -32,10 +32,11 @@
namespace OHOS {
namespace AAFwk {
using CreateMissionListMgrFunc = MissionListWrap*(*)();
class SubManagersHelper {
public:
SubManagersHelper(std::shared_ptr<TaskHandlerWrap> taskHandler, std::shared_ptr<AbilityEventHandler> eventHandler);
virtual ~SubManagersHelper() = default;
virtual ~SubManagersHelper();
void InitSubManagers(int userId, bool switchUser);
void InitMissionListManager(int userId, bool switchUser);
@ -59,10 +60,10 @@ public:
std::shared_ptr<PendingWantManager> GetCurrentPendingWantManager();
std::shared_ptr<PendingWantManager> GetPendingWantManagerByUserId(int32_t userId);
std::unordered_map<int, std::shared_ptr<MissionListManager>> GetMissionListManagers();
std::shared_ptr<MissionListManager> GetCurrentMissionListManager();
std::shared_ptr<MissionListManager> GetMissionListManagerByUserId(int32_t userId);
std::shared_ptr<MissionListManager> GetMissionListManagerByUid(int32_t uid);
std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>> GetMissionListManagers();
std::shared_ptr<MissionListManagerInterface> GetCurrentMissionListManager();
std::shared_ptr<MissionListManagerInterface> GetMissionListManagerByUserId(int32_t userId);
std::shared_ptr<MissionListManagerInterface> GetMissionListManagerByUid(int32_t uid);
std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> GetUIAbilityManagers();
std::shared_ptr<UIAbilityLifecycleManager> GetCurrentUIAbilityManager();
@ -75,6 +76,8 @@ public:
bool VerificationAllToken(const sptr<IRemoteObject> &token);
bool VerificationAllTokenForConnectManagers(const sptr<IRemoteObject> &token);
std::shared_ptr<MissionListWrap> GetMissionListWrap();
std::shared_ptr<MissionListManagerInterface> CreateMissionListMgr(int32_t userId);
private:
DISALLOW_COPY_AND_MOVE(SubManagersHelper);
@ -88,10 +91,14 @@ private:
std::shared_ptr<DataAbilityManager> currentDataAbilityManager_;
std::unordered_map<int, std::shared_ptr<PendingWantManager>> pendingWantManagers_;
std::shared_ptr<PendingWantManager> currentPendingWantManager_;
std::unordered_map<int, std::shared_ptr<MissionListManager>> missionListManagers_;
std::shared_ptr<MissionListManager> currentMissionListManager_;
std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>> missionListManagers_;
std::shared_ptr<MissionListManagerInterface> currentMissionListManager_;
std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> uiAbilityManagers_;
std::shared_ptr<UIAbilityLifecycleManager> currentUIAbilityManager_;
std::mutex missionListWrapMutex_;
void* missionLibHandle_ = nullptr;
std::shared_ptr<MissionListWrap> missionListWrap_;
};
} // namespace AAFwk
} // namespace OHOS

View File

@ -19,6 +19,7 @@
*AbilityConnectionStub*;
*AbilityConnectManager*;
*AbilityEventHandler*;
*AbilityFirstFrameStateObserverManager*;
*AbilityInterceptorExecuter*;
*AbilityManagerService*;
*AbilityManagerStub*;
@ -27,6 +28,7 @@
*AbilitySchedulerProxy*;
*AbilitySchedulerStub*;
*AmsConfigurationParameter*;
*AppExitReasonDataManager*;
*ApplicationAnrListener*;
*AppScheduler*;
*AtomicServiceStatusCallback*;

View File

@ -338,6 +338,11 @@ AbilityManagerService::AbilityManagerService()
AbilityManagerService::~AbilityManagerService()
{}
std::shared_ptr<AbilityManagerService> AbilityManagerService::GetPubInstance()
{
return DelayedSingleton<AbilityManagerService>::GetInstance();
}
void AbilityManagerService::OnStart()
{
if (state_ == ServiceRunningState::STATE_RUNNING) {
@ -4751,9 +4756,13 @@ int32_t AbilityManagerService::GetMissionIdByToken(const sptr<IRemoteObject> &to
bool AbilityManagerService::IsAbilityControllerStartById(int32_t missionId)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
auto missionListWrap = GetMissionListWrap();
if (missionListWrap == nullptr) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "missionListWrap null.");
return false;
}
InnerMissionInfo innerMissionInfo;
int getMission = DelayedSingleton<MissionInfoMgr>::GetInstance()->GetInnerMissionInfoById(
missionId, innerMissionInfo);
int getMission = missionListWrap->GetInnerMissionInfoById(missionId, innerMissionInfo);
if (getMission != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR,
"cannot find mission info from MissionInfoList by missionId: %{public}d", missionId);
@ -4944,7 +4953,7 @@ void AbilityManagerService::DumpSysMissionListInner(
DumpSysMissionListInnerBySCB(args, info, isClient, isUserID, userId);
return;
}
std::shared_ptr<MissionListManager> targetManager;
std::shared_ptr<MissionListManagerInterface> targetManager;
if (isUserID) {
auto missionListManager = GetMissionListManagerByUserId(userId);
if (missionListManager == nullptr) {
@ -5004,7 +5013,7 @@ void AbilityManagerService::DumpSysAbilityInner(
DumpSysAbilityInnerBySCB(args, info, isClient, isUserID, userId);
return;
}
std::shared_ptr<MissionListManager> targetManager;
std::shared_ptr<MissionListManagerInterface> targetManager;
if (isUserID) {
auto missionListManager = GetMissionListManagerByUserId(userId);
if (missionListManager == nullptr) {
@ -6440,27 +6449,33 @@ std::shared_ptr<PendingWantManager> AbilityManagerService::GetPendingWantManager
return subManagersHelper_->GetPendingWantManagerByUserId(userId);
}
std::unordered_map<int, std::shared_ptr<MissionListManager>> AbilityManagerService::GetMissionListManagers()
std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>> AbilityManagerService::GetMissionListManagers()
{
if (subManagersHelper_ == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "pointer is nullptr.");
return std::unordered_map<int, std::shared_ptr<MissionListManager>>();
return std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>>();
}
return subManagersHelper_->GetMissionListManagers();
}
std::shared_ptr<MissionListManager> AbilityManagerService::GetCurrentMissionListManager()
std::shared_ptr<MissionListManagerInterface> AbilityManagerService::GetCurrentMissionListManager()
{
CHECK_POINTER_AND_RETURN(subManagersHelper_, nullptr);
return subManagersHelper_->GetCurrentMissionListManager();
}
std::shared_ptr<MissionListManager> AbilityManagerService::GetMissionListManagerByUserId(int32_t userId)
std::shared_ptr<MissionListManagerInterface> AbilityManagerService::GetMissionListManagerByUserId(int32_t userId)
{
CHECK_POINTER_AND_RETURN(subManagersHelper_, nullptr);
return subManagersHelper_->GetMissionListManagerByUserId(userId);
}
std::shared_ptr<MissionListWrap> AbilityManagerService::GetMissionListWrap()
{
CHECK_POINTER_AND_RETURN(subManagersHelper_, nullptr);
return subManagersHelper_->GetMissionListWrap();
}
std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> AbilityManagerService::GetUIAbilityManagers()
{
if (subManagersHelper_ == nullptr) {
@ -9462,12 +9477,7 @@ int32_t AbilityManagerService::AcquireShareData(
} else {
auto missionListManager = GetCurrentMissionListManager();
CHECK_POINTER_AND_RETURN(missionListManager, ERR_INVALID_VALUE);
std::shared_ptr<Mission> mission = missionListManager->GetMissionById(missionId);
if (!mission) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "mission is null.");
return ERR_INVALID_VALUE;
}
abilityRecord = mission->GetAbilityRecord();
abilityRecord = missionListManager->GetAbilityRecordByMissionId(missionId);
}
if (!abilityRecord) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityRecord is null.");

View File

@ -701,7 +701,13 @@ void AbilityRecord::StartingWindowHot()
return;
}
auto pixelMap = DelayedSingleton<MissionInfoMgr>::GetInstance()->GetSnapshot(missionId_);
auto missionListWrap = DelayedSingleton<AbilityManagerService>::GetInstance()->GetMissionListWrap();
if (missionListWrap == nullptr) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "missionListWrap null.");
return;
}
auto pixelMap = missionListWrap->GetSnapshot(missionId_);
if (!pixelMap) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "Get snapshot failed.");
}
@ -767,9 +773,14 @@ void AbilityRecord::ProcessForegroundAbility(bool isRecent, const AbilityRequest
std::shared_ptr<Want> AbilityRecord::GetWantFromMission() const
{
auto missionListWrap = DelayedSingleton<AbilityManagerService>::GetInstance()->GetMissionListWrap();
if (missionListWrap == nullptr) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "missionListWrap null.");
return nullptr;
}
InnerMissionInfo innerMissionInfo;
int getMission = DelayedSingleton<MissionInfoMgr>::GetInstance()->GetInnerMissionInfoById(
missionId_, innerMissionInfo);
int getMission = missionListWrap->GetInnerMissionInfoById(missionId_, innerMissionInfo);
if (getMission != ERR_OK) {
TAG_LOGE(
AAFwkTag::ABILITYMGR, "cannot find mission info from MissionInfoList by missionId: %{public}d", missionId_);
@ -1109,7 +1120,13 @@ void AbilityRecord::StartingWindowHot(const std::shared_ptr<StartOptions> &start
return;
}
auto pixelMap = DelayedSingleton<MissionInfoMgr>::GetInstance()->GetSnapshot(missionId_);
auto missionListWrap = DelayedSingleton<AbilityManagerService>::GetInstance()->GetMissionListWrap();
if (missionListWrap == nullptr) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "missionListWrap null.");
return;
}
auto pixelMap = missionListWrap->GetSnapshot(missionId_);
if (!pixelMap) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "%{public}s, Get snapshot failed.", __func__);
}
@ -1407,7 +1424,9 @@ void AbilityRecord::SetAbilityStateInner(AbilityState state)
}
}
DelayedSingleton<MissionInfoMgr>::GetInstance()->SetMissionAbilityState(missionId_, currentState_);
auto missionListWrap = DelayedSingleton<AbilityManagerService>::GetInstance()->GetMissionListWrap();
CHECK_POINTER(missionListWrap);
missionListWrap->SetMissionAbilityState(missionId_, currentState_);
}
#endif // SUPPORT_SCREEN
bool AbilityRecord::GetAbilityForegroundingFlag() const

View File

@ -454,7 +454,7 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord>
if (supportBackToOtherMissionStack && needBackToOtherMissionStack) {
// mark if need back to other mission stack
targetAbilityRecord->SetNeedBackToOtherMissionStack(true);
auto focusAbility = OHOS::DelayedSingleton<AbilityManagerService>::GetInstance()->GetFocusAbility();
auto focusAbility = AbilityManagerService::GetPubInstance()->GetFocusAbility();
if (focusAbility && (GetMissionIdByAbilityTokenInner(focusAbility->GetToken()) != -1)) {
targetAbilityRecord->SetOtherMissionStackAbilityRecord(focusAbility);
} else {
@ -751,10 +751,11 @@ std::shared_ptr<MissionList> MissionListManager::GetTargetMissionListByDefault(
return nullptr;
}
auto missionListMgr = DelayedSingleton<AbilityManagerService>::GetInstance()->GetMissionListManagerByUserId(
auto missionListMgr = AbilityManagerService::GetPubInstance()->GetMissionListManagerByUserId(
callerAbility->GetOwnerMissionUserId());
CHECK_POINTER_AND_RETURN(missionListMgr, nullptr);
auto callerMission = missionListMgr->GetMissionById(callerAbility->GetMissionId());
auto callerMission = reinterpret_cast<MissionListManager*>(missionListMgr.get())->GetMissionById(
callerAbility->GetMissionId());
CHECK_POINTER_AND_RETURN(callerMission, nullptr);
auto callerList = callerMission->GetMissionList();
CHECK_POINTER_AND_RETURN(callerList, nullptr);
@ -1009,7 +1010,7 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityMS attach abilityThread, name is %{public}s.",
abilityRecord->GetAbilityInfo().name.c_str());
auto eventHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
auto eventHandler = AbilityManagerService::GetPubInstance()->GetEventHandler();
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
eventHandler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
abilityRecord->SetLoading(false);
@ -1034,7 +1035,7 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
abilityRecord->CallRequest();
}
auto taskHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto taskHandler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER_AND_RETURN_LOG(taskHandler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
auto taskName = std::to_string(abilityRecord->GetMissionId()) + "_cold";
taskHandler->CancelTask(taskName);
@ -1047,7 +1048,7 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
return ERR_OK;
}
void MissionListManager::OnAbilityRequestDone(const sptr<IRemoteObject> &token, const int32_t state)
void MissionListManager::OnAbilityRequestDone(const sptr<IRemoteObject> &token, int32_t state)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "Ability request state %{public}d done.", state);
std::lock_guard guard(managerLock_);
@ -1123,7 +1124,7 @@ void MissionListManager::OnAppStateChanged(const AppInfo &info)
}
std::shared_ptr<AbilityRecord> MissionListManager::GetAbilityRecordByToken(
const sptr<IRemoteObject> &token) const
const sptr<IRemoteObject> &token)
{
std::lock_guard guard(managerLock_);
return GetAbilityRecordByTokenInner(token);
@ -1250,12 +1251,12 @@ int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord>
AbilityState::FOREGROUNDING, abilityRecord->GetAbilityState());
return ERR_INVALID_VALUE;
}
auto eventHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
auto eventHandler = AbilityManagerService::GetPubInstance()->GetEventHandler();
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
eventHandler->RemoveEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
g_deleteLifecycleEventTask(abilityRecord->GetToken(), FreezeUtil::TimeoutState::FOREGROUND);
auto self(weak_from_this());
auto taskHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto taskHandler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER_AND_RETURN_LOG(taskHandler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
if (success) {
#ifdef SUPPORT_SCREEN
@ -1377,7 +1378,7 @@ void MissionListManager::TerminatePreviousAbility(const std::shared_ptr<AbilityR
int MissionListManager::DispatchBackground(const std::shared_ptr<AbilityRecord> &abilityRecord)
{
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityTasktHandler.");
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
@ -1759,7 +1760,7 @@ int MissionListManager::DispatchTerminate(const std::shared_ptr<AbilityRecord> &
}
// remove terminate timeout task.
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityTasktHandler.");
handler->CancelTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
auto self(shared_from_this());
@ -1771,7 +1772,7 @@ int MissionListManager::DispatchTerminate(const std::shared_ptr<AbilityRecord> &
void MissionListManager::DelayCompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord)
{
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER(handler);
PrintTimeOutLog(abilityRecord, AbilityManagerService::TERMINATE_TIMEOUT_MSG);
@ -1977,7 +1978,7 @@ void MissionListManager::ClearAllMissionsLocked(std::list<std::shared_ptr<Missio
continue;
}
auto abilityMs_ = OHOS::DelayedSingleton<AbilityManagerService>::GetInstance();
auto abilityMs_ = AbilityManagerService::GetPubInstance();
if (abilityMs_->IsBackgroundTaskUid(mission->GetAbilityRecord()->GetUid())) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "the mission is background task, do not need clear");
continue;
@ -2083,7 +2084,7 @@ void MissionListManager::MoveToBackgroundTask(const std::shared_ptr<AbilityRecor
abilityRecord->SetIsNewWant(false);
if (abilityRecord->lifeCycleStateInfo_.sceneFlag != SCENE_FLAG_KEYGUARD &&
!abilityRecord->IsClearMissionFlag() &&
!(isClose && OHOS::DelayedSingleton<AbilityManagerService>::GetInstance()->GetAnimationFlag())) {
!(isClose && AbilityManagerService::GetPubInstance()->GetAnimationFlag())) {
UpdateMissionSnapshot(abilityRecord);
}
@ -2117,7 +2118,7 @@ void MissionListManager::NotifyMissionCreated(const std::shared_ptr<AbilityReco
#ifdef SUPPORT_SCREEN
void MissionListManager::PostMissionLabelUpdateTask(int missionId) const
{
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
if (handler == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Fail to get EventHandler, do not post mission label update message.");
return;
@ -2393,7 +2394,7 @@ void MissionListManager::HandleTimeoutAndResumeAbility(const std::shared_ptr<Abi
void MissionListManager::DelayedResumeTimeout(const std::shared_ptr<AbilityRecord> &callerAbility)
{
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
auto abilityManagerService = AbilityManagerService::GetPubInstance();
CHECK_POINTER(abilityManagerService);
auto handler = abilityManagerService->GetTaskHandler();
CHECK_POINTER(handler);
@ -2537,7 +2538,7 @@ void MissionListManager::OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRec
return;
}
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetEventHandler();
CHECK_POINTER_LOG(handler, "Get AbilityEventHandler failed.");
if (abilityRecord->GetAbilityState() == AbilityState::INITIAL) {
handler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
@ -2546,7 +2547,7 @@ void MissionListManager::OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRec
if (abilityRecord->GetAbilityState() == AbilityState::FOREGROUNDING) {
handler->RemoveEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
}
auto taskHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto taskHandler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER_LOG(taskHandler, "Fail to get AbilityTaskHandler.");
if (abilityRecord->GetAbilityState() == AbilityState::BACKGROUNDING) {
taskHandler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
@ -2606,7 +2607,7 @@ std::shared_ptr<MissionList> MissionListManager::GetTargetMissionList(int missio
// generate a new mission and missionList
AbilityRequest abilityRequest;
int generateAbility = DelayedSingleton<AbilityManagerService>::GetInstance()->GenerateAbilityRequest(
int generateAbility = AbilityManagerService::GetPubInstance()->GenerateAbilityRequest(
innerMissionInfo.missionInfo.want, DEFAULT_INVAL_VALUE, abilityRequest, nullptr, userId_);
if (generateAbility != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "cannot find generate ability request, missionId: %{public}d", missionId);
@ -2669,12 +2670,17 @@ sptr<IRemoteObject> MissionListManager::GetAbilityTokenByMissionId(int32_t missi
return defaultStandardList_->GetAbilityTokenByMissionId((missionId));
}
std::shared_ptr<AbilityRecord> MissionListManager::GetAbilityRecordByMissionId(int32_t missionId)
{
return Token::GetAbilityRecordByToken(GetAbilityTokenByMissionId(missionId));
}
void MissionListManager::PostStartWaitingAbility()
{
auto self(shared_from_this());
auto startWaitingAbilityTask = [self]() { self->StartWaitingAbility(); };
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
CHECK_POINTER_LOG(handler, "Fail to get AbilityTaskHandler.");
/* PostTask to trigger start Ability from waiting queue */
@ -2779,7 +2785,7 @@ void MissionListManager::HandleAbilityDiedByDefault(std::shared_ptr<AbilityRecor
void MissionListManager::DelayedStartLauncher()
{
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
auto abilityManagerService = AbilityManagerService::GetPubInstance();
CHECK_POINTER(abilityManagerService);
auto handler = abilityManagerService->GetTaskHandler();
CHECK_POINTER(handler);
@ -2825,7 +2831,7 @@ void MissionListManager::BackToLauncher()
launcherRootAbility->ProcessForegroundAbility(0);
}
int MissionListManager::SetMissionContinueState(const sptr<IRemoteObject> &token, const int32_t missionId,
int MissionListManager::SetMissionContinueState(const sptr<IRemoteObject> &token, int32_t missionId,
const AAFwk::ContinueState &state)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "SetMissionContinueState start. Mission id: %{public}d, state: %{public}d",
@ -2896,7 +2902,7 @@ int MissionListManager::SetMissionIcon(const sptr<IRemoteObject> &token, const s
return 0;
}
void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) const
void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken)
{
FinishAsyncTrace(HITRACE_TAG_ABILITY_MANAGER, TRACE_ATOMIC_SERVICE, TRACE_ATOMIC_SERVICE_ID);
TAG_LOGD(AAFwkTag::ABILITYMGR, "CompleteFirstFrameDrawing called.");
@ -2919,7 +2925,7 @@ void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &ab
abilityRecord->SetCompleteFirstFrameDrawing(true);
AppExecFwk::AbilityFirstFrameStateObserverManager::GetInstance().
HandleOnFirstFrameState(abilityRecord);
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
if (handler == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Fail to get Ability task handler.");
return;
@ -2932,7 +2938,7 @@ void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &ab
return;
}
mgr->NotifyMissionCreated(abilityRecord);
if (DelayedSingleton<AbilityManagerService>::GetInstance()->IsDmsAlive()) {
if (AbilityManagerService::GetPubInstance()->IsDmsAlive()) {
mgr->UpdateMissionSnapshot(abilityRecord);
}
};
@ -2962,7 +2968,7 @@ void MissionListManager::ProcessPreload(const std::shared_ptr<AbilityRecord> &re
Closure MissionListManager::GetCancelStartingWindowTask(const std::shared_ptr<AbilityRecord> &abilityRecord) const
{
auto windowHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetWMSHandler();
auto windowHandler = AbilityManagerService::GetPubInstance()->GetWMSHandler();
if (!windowHandler) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s, Get WMS handler failed.", __func__);
return nullptr;
@ -2980,7 +2986,7 @@ Closure MissionListManager::GetCancelStartingWindowTask(const std::shared_ptr<Ab
void MissionListManager::PostCancelStartingWindowTask(const std::shared_ptr<AbilityRecord> &abilityRecord) const
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "call");
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
if (!handler) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Fail to get AbilityTaskHandler.");
return;
@ -3613,7 +3619,7 @@ bool MissionListManager::CheckLimit()
if (IsAppLastAbility(earliestMission->GetAbilityRecord())) {
ExitReason exitReason = { REASON_RESOURCE_CONTROL,
"Already reach ability max limit, terminate earliest ability." };
OHOS::DelayedSingleton<AbilityManagerService>::GetInstance()->RecordAppExitReason(exitReason);
AbilityManagerService::GetPubInstance()->RecordAppExitReason(exitReason);
}
TAG_LOGI(AAFwkTag::ABILITYMGR,
"already reach limit instance. limit: %{public}d, and terminate earliestAbility success.",
@ -3696,12 +3702,12 @@ void MissionListManager::GetAbilityRunningInfos(std::vector<AbilityRunningInfo>
}
if (isPerm) {
DelayedSingleton<AbilityManagerService>::GetInstance()->GetAbilityRunningInfo(info, ability);
AbilityManagerService::GetPubInstance()->GetAbilityRunningInfo(info, ability);
} else {
auto callingTokenId = IPCSkeleton::GetCallingTokenID();
auto tokenID = ability->GetApplicationInfo().accessTokenId;
if (callingTokenId == tokenID) {
DelayedSingleton<AbilityManagerService>::GetInstance()->GetAbilityRunningInfo(info, ability);
AbilityManagerService::GetPubInstance()->GetAbilityRunningInfo(info, ability);
}
}
};
@ -3725,7 +3731,7 @@ void MissionListManager::GetAbilityRunningInfos(std::vector<AbilityRunningInfo>
void MissionListManager::UninstallApp(const std::string &bundleName, int32_t uid)
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "Uninstall app, bundleName: %{public}s, uid:%{public}d", bundleName.c_str(), uid);
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
auto abilityManagerService = AbilityManagerService::GetPubInstance();
CHECK_POINTER(abilityManagerService);
auto handler = abilityManagerService->GetTaskHandler();
CHECK_POINTER(handler);
@ -3983,7 +3989,7 @@ bool MissionListManager::UpdateAbilityRecordLaunchReason(
return true;
}
void MissionListManager::NotifyMissionFocused(const int32_t missionId)
void MissionListManager::NotifyMissionFocused(int32_t missionId)
{
if (listenerController_) {
listenerController_->NotifyMissionFocused(missionId);
@ -3992,7 +3998,7 @@ void MissionListManager::NotifyMissionFocused(const int32_t missionId)
}
}
void MissionListManager::NotifyMissionUnfocused(const int32_t missionId)
void MissionListManager::NotifyMissionUnfocused(int32_t missionId)
{
if (listenerController_) {
listenerController_->NotifyMissionUnfocused(missionId);
@ -4140,7 +4146,7 @@ int MissionListManager::PrepareClearMissionLocked(int missionId, const std::shar
mgr->ClearMissionLocking(missionId, mission);
}
};
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
auto handler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
int prepareTerminateTimeout =
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * PREPARE_TERMINATE_TIMEOUT_MULTIPLE;
if (handler) {
@ -4227,5 +4233,47 @@ void MissionListManager::SignRestartAppFlag(const std::string &bundleName)
defaultSingleList_->SignRestartAppFlag(bundleName);
}
}
class MissionListWrapImpl : public MissionListWrap {
public:
~MissionListWrapImpl() = default;
std::shared_ptr<MissionListManagerInterface> CreateMissionListManager(int32_t userId) override
{
return std::make_shared<MissionListManager>(userId);
}
void RemoveUserDir(int32_t userId) override
{
DelayedSingleton<TaskDataPersistenceMgr>::GetInstance()->RemoveUserDir(userId);
}
void InitMissionInfoMgr(int32_t userId) override
{
DelayedSingleton<MissionInfoMgr>::GetInstance()->Init(userId);
}
void SetMissionAbilityState(int32_t missionId, AbilityState state) override
{
DelayedSingleton<MissionInfoMgr>::GetInstance()->SetMissionAbilityState(missionId, state);
}
int32_t GetInnerMissionInfoById(int32_t missionId, InnerMissionInfo &innerMissionInfo) override
{
return DelayedSingleton<MissionInfoMgr>::GetInstance()->GetInnerMissionInfoById(
missionId, innerMissionInfo);
}
#ifdef SUPPORT_SCREEN
std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t missionId) override
{
return DelayedSingleton<MissionInfoMgr>::GetInstance()->GetSnapshot(missionId);
}
#endif
};
} // namespace AAFwk
} // namespace OHOS
extern "C" __attribute__((visibility("default"))) OHOS::AAFwk::MissionListWrap* CreateMissionListWrap()
{
return new OHOS::AAFwk::MissionListWrapImpl();
}

View File

@ -15,6 +15,8 @@
#include "sub_managers_helper.h"
#include <dlfcn.h>
#include "hilog_tag_wrapper.h"
#include "hitrace_meter.h"
#include "mission_info_mgr.h"
@ -30,6 +32,15 @@ SubManagersHelper::SubManagersHelper(
std::shared_ptr<TaskHandlerWrap> taskHandler, std::shared_ptr<AbilityEventHandler> eventHandler)
: taskHandler_(taskHandler), eventHandler_(eventHandler) {}
SubManagersHelper::~SubManagersHelper()
{
if (missionLibHandle_ != nullptr) {
missionListWrap_ = nullptr;
dlclose(missionLibHandle_);
missionLibHandle_ = nullptr;
}
}
void SubManagersHelper::InitSubManagers(int userId, bool switchUser)
{
InitConnectManager(userId, switchUser);
@ -103,12 +114,19 @@ void SubManagersHelper::InitMissionListManager(int userId, bool switchUser)
auto it = missionListManagers_.find(userId);
if (it != missionListManagers_.end()) {
if (switchUser) {
DelayedSingleton<MissionInfoMgr>::GetInstance()->Init(userId);
auto missionListWrap = GetMissionListWrap();
if (missionListWrap) {
missionListWrap->InitMissionInfoMgr(userId);
}
currentMissionListManager_ = it->second;
}
return;
}
auto manager = std::make_shared<MissionListManager>(userId);
auto manager = CreateMissionListMgr(userId);
if (manager == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed to create mission list manager");
return;
}
manager->Init();
missionListManagers_.emplace(userId, manager);
if (switchUser) {
@ -249,19 +267,19 @@ std::shared_ptr<PendingWantManager> SubManagersHelper::GetPendingWantManagerByUs
return nullptr;
}
std::unordered_map<int, std::shared_ptr<MissionListManager>> SubManagersHelper::GetMissionListManagers()
std::unordered_map<int, std::shared_ptr<MissionListManagerInterface>> SubManagersHelper::GetMissionListManagers()
{
std::lock_guard<ffrt::mutex> lock(managersMutex_);
return missionListManagers_;
}
std::shared_ptr<MissionListManager> SubManagersHelper::GetCurrentMissionListManager()
std::shared_ptr<MissionListManagerInterface> SubManagersHelper::GetCurrentMissionListManager()
{
std::lock_guard<ffrt::mutex> lock(managersMutex_);
return currentMissionListManager_;
}
std::shared_ptr<MissionListManager> SubManagersHelper::GetMissionListManagerByUserId(int32_t userId)
std::shared_ptr<MissionListManagerInterface> SubManagersHelper::GetMissionListManagerByUserId(int32_t userId)
{
std::lock_guard<ffrt::mutex> lock(managersMutex_);
auto it = missionListManagers_.find(userId);
@ -272,7 +290,7 @@ std::shared_ptr<MissionListManager> SubManagersHelper::GetMissionListManagerByUs
return nullptr;
}
std::shared_ptr<MissionListManager> SubManagersHelper::GetMissionListManagerByUid(int32_t uid)
std::shared_ptr<MissionListManagerInterface> SubManagersHelper::GetMissionListManagerByUid(int32_t uid)
{
int32_t userId = INVALID_USER_ID;
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->GetOsAccountLocalIdFromUid(
@ -431,5 +449,47 @@ bool SubManagersHelper::VerificationAllToken(const sptr<IRemoteObject> &token)
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to verify all token.");
return false;
}
std::shared_ptr<MissionListWrap> SubManagersHelper::GetMissionListWrap()
{
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
return nullptr;
}
std::lock_guard lock(missionListWrapMutex_);
if (missionListWrap_) {
return missionListWrap_;
}
if (missionLibHandle_ == nullptr) {
missionLibHandle_ = dlopen("libmission_list.z.so", RTLD_NOW | RTLD_GLOBAL);
if (missionLibHandle_ == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed to open mission_list library");
return nullptr;
}
}
auto createMissionListWrapFunc = reinterpret_cast<CreateMissionListMgrFunc>(dlsym(missionLibHandle_,
"CreateMissionListWrap"));
if (createMissionListWrapFunc == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed to get create func");
dlclose(missionLibHandle_);
missionLibHandle_ = nullptr;
return nullptr;
}
missionListWrap_ = std::shared_ptr<MissionListWrap>(createMissionListWrapFunc());
return missionListWrap_;
}
std::shared_ptr<MissionListManagerInterface> SubManagersHelper::CreateMissionListMgr(int32_t userId)
{
auto missionListWrap = GetMissionListWrap();
if (missionListWrap != nullptr) {
return missionListWrap->CreateMissionListManager(userId);
}
return nullptr;
}
} // namespace AAFwk
} // namespace OHOS

View File

@ -175,20 +175,21 @@ int32_t UserController::StopUser(int32_t userId)
}
appScheduler->KillProcessesByUserId(userId);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto taskDataPersistenceMgr = DelayedSingleton<TaskDataPersistenceMgr>::GetInstance();
if (!taskDataPersistenceMgr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "taskDataPersistenceMgr is null");
return -1;
}
taskDataPersistenceMgr->RemoveUserDir(userId);
}
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
if (!abilityManagerService) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityManagerService is null");
return -1;
}
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto missionListWrap = abilityManagerService->GetMissionListWrap();
if (!missionListWrap) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "missionListWrap is null");
return -1;
}
missionListWrap->RemoveUserDir(userId);
}
abilityManagerService->ClearUserData(userId);
BroadcastUserStopped(userId);

View File

@ -48,6 +48,7 @@ ohos_fuzztest("MissionInfoMgrAFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -48,6 +48,7 @@ ohos_fuzztest("MissionInfoMgrBFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -48,6 +48,7 @@ ohos_fuzztest("MissionInfoMgrCFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -48,6 +48,7 @@ ohos_fuzztest("MissionListManagerFourthFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -49,6 +49,7 @@ ohos_fuzztest("MissionListManagerSecondFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -48,6 +48,7 @@ ohos_fuzztest("MissionListManagerThirdFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -49,6 +49,7 @@ ohos_fuzztest("PendingWantManagerFuzzTest") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/jsoncpp:jsoncpp",
]

View File

@ -29,6 +29,7 @@ ohos_moduletest("ability_manager_service_dump_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
]

View File

@ -17,6 +17,7 @@
#define private public
#define protected public
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
#include "scene_board_judgement.h"
@ -212,9 +213,10 @@ HWTEST_F(AbilityManagerServiceDumpTest, AbilityManagerService_OnAppStateChanged_
EXPECT_NE(abilityRecord, nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
abilityMs_->subManagersHelper_->currentMissionListManager_ = std::make_shared<MissionListManager>(USER_ID);
EXPECT_NE(abilityMs_->subManagersHelper_->currentMissionListManager_, nullptr);
abilityMs_->subManagersHelper_->currentMissionListManager_->terminateAbilityList_.push_back(abilityRecord);
auto missionListManager = std::make_shared<MissionListManager>(USER_ID);
missionListManager->Init();
abilityMs_->subManagersHelper_->currentMissionListManager_ = missionListManager;
missionListManager->terminateAbilityList_.push_back(abilityRecord);
abilityMs_->subManagersHelper_->currentDataAbilityManager_ = std::make_shared<DataAbilityManager>();
EXPECT_NE(abilityMs_->subManagersHelper_->currentDataAbilityManager_, nullptr);
@ -224,7 +226,7 @@ HWTEST_F(AbilityManagerServiceDumpTest, AbilityManagerService_OnAppStateChanged_
info.state = AppState::TERMINATED;
abilityMs_->OnAppStateChanged(info);
abilityRecord = abilityMs_->subManagersHelper_->currentMissionListManager_->terminateAbilityList_.front();
abilityRecord = missionListManager->terminateAbilityList_.front();
EXPECT_NE(abilityRecord, nullptr);
EXPECT_EQ(abilityRecord->GetAppState(), AppState::TERMINATED);
}

View File

@ -63,6 +63,7 @@ ohos_moduletest("ability_timeout_module_test") {
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_path}/utils/server/startup:startup_util",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:event_report",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_services_path}/common:task_handler_wrap",

View File

@ -18,6 +18,7 @@
#define protected public
#include "ability_manager_service.h"
#include "ability_event_handler.h"
#include "mission_list_manager.h"
#undef private
#undef protected
@ -121,13 +122,7 @@ void AbilityTimeoutModuleTest::SetUp()
void AbilityTimeoutModuleTest::TearDown()
{
WaitUntilTaskFinishedByTimer();
abilityMs_->subManagersHelper_->currentMissionListManager_->terminateAbilityList_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_->missions_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->defaultStandardList_->missions_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->defaultSingleList_->missions_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_
.push_front(abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_);
abilityMs_->subManagersHelper_->currentMissionListManager_.reset();
}
void AbilityTimeoutModuleTest::MockOnStart()
@ -185,11 +180,13 @@ void AbilityTimeoutModuleTest::MockOnStop()
std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateRootLauncher()
{
if (!abilityMs_->subManagersHelper_->currentMissionListManager_ ||
!abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_) {
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
if (!curListManager ||
!curListManager->launcherList_) {
return nullptr;
}
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto lauList = curListManager->launcherList_;
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
abilityRequest.abilityInfo.name = AbilityConfig::LAUNCHER_ABILITY_NAME;
@ -208,11 +205,13 @@ std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateRootLauncher()
std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateLauncherAbility()
{
if (!abilityMs_->subManagersHelper_->currentMissionListManager_ ||
!abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_) {
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
if (!curListManager ||
!curListManager->launcherList_) {
return nullptr;
}
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto lauList = curListManager->launcherList_;
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
abilityRequest.abilityInfo.name = "com.ix.hiworld.SecAbility";
@ -230,7 +229,8 @@ std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateLauncherAbility()
std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateServiceAbility()
{
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
if (!curListManager) {
return nullptr;
}
@ -247,7 +247,8 @@ std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateServiceAbility()
std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateExtensionAbility()
{
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
if (!curListManager) {
return nullptr;
}
@ -265,7 +266,8 @@ std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateExtensionAbility(
std::shared_ptr<AbilityRecord> AbilityTimeoutModuleTest::CreateCommonAbility()
{
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
if (!curListManager) {
return nullptr;
}
@ -301,8 +303,10 @@ HWTEST_F(AbilityTimeoutModuleTest, OnAbilityDied_001, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
int maxRestart = -1;
@ -316,7 +320,7 @@ HWTEST_F(AbilityTimeoutModuleTest, OnAbilityDied_001, TestSize.Level1)
EXPECT_TRUE(rootLauncher->IsLauncherRoot());
GTEST_LOG_(INFO) << "userId:" << abilityMs_->GetUserId();
GTEST_LOG_(INFO) << "currentmanager userId" << abilityMs_->subManagersHelper_->currentMissionListManager_->userId_;
GTEST_LOG_(INFO) << "currentmanager userId" << curListManager->userId_;
// died rootlauncher ability
rootLauncher->SetAbilityState(AbilityState::FOREGROUND);
@ -341,8 +345,10 @@ HWTEST_F(AbilityTimeoutModuleTest, OnAbilityDied_002, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
int maxRestart = -1;
@ -359,14 +365,14 @@ HWTEST_F(AbilityTimeoutModuleTest, OnAbilityDied_002, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
topAbility->SetAbilityState(AbilityState::FOREGROUND);
// died rootlauncher ability
abilityMs_->OnAbilityDied(rootLauncher);
WaitUntilTaskFinishedByTimer();
topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility != nullptr);
EXPECT_EQ(topAbility, rootLauncher);
EXPECT_TRUE(lauList->GetAbilityRecordByToken(rootLauncher->GetToken()) != nullptr);
@ -386,8 +392,10 @@ HWTEST_F(AbilityTimeoutModuleTest, OnAbilityDied_003, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
int maxRestart = -1;
@ -427,12 +435,12 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_001, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
auto ability = CreateRootLauncher();
auto rootLauncher = lauList->GetTopAbility();
@ -457,9 +465,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_002, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -471,7 +480,7 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_002, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
// rootlauncher load timeout
@ -493,9 +502,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_003, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -507,14 +517,14 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_003, TestSize.Level1)
// add common ability to abilityMs as caller
auto callerAbility = CreateCommonAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, callerAbility);
callerAbility->SetAbilityState(AbilityState::FOREGROUND);
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
// rootlauncher load timeout
@ -536,9 +546,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_004, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -550,14 +561,14 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_004, TestSize.Level1)
// add launcher ability to abilityMs as caller
auto callerAbility = CreateLauncherAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, callerAbility);
callerAbility->SetAbilityState(AbilityState::FOREGROUND);
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
// rootlauncher load timeout
@ -579,9 +590,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_005, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -597,8 +609,8 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_005, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
auto currentList = abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_;
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto currentList = curListManager->currentMissionLists_;
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
// rootlauncher load timeout
@ -620,9 +632,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_006, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -638,8 +651,8 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_006, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
auto currentList = abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_;
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto currentList = curListManager->currentMissionLists_;
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
// rootlauncher load timeout
@ -661,9 +674,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_007, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -675,7 +689,7 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleLoadTimeOut_007, TestSize.Level1)
// add common laucher ability to abilityMs
auto commonLauncherAbility = CreateLauncherAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonLauncherAbility);
// rootlauncher load timeout
@ -697,9 +711,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_001, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
@ -728,9 +743,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_002, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -742,7 +758,7 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_002, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
commonAbility->SetAbilityState(AbilityState::FOREGROUNDING);
@ -765,9 +781,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_003, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -779,14 +796,14 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_003, TestSize.Level1)
// add common ability to abilityMs as caller
auto callerAbility = CreateCommonAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager>GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, callerAbility);
callerAbility->SetAbilityState(AbilityState::FOREGROUND);
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
commonAbility->SetAbilityState(AbilityState::FOREGROUNDING);
@ -809,9 +826,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_004, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -823,14 +841,14 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_004, TestSize.Level1)
// add launcher ability to abilityMs as caller
auto callerAbility = CreateLauncherAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, callerAbility);
callerAbility->SetAbilityState(AbilityState::FOREGROUND);
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
commonAbility->SetAbilityState(AbilityState::FOREGROUNDING);
@ -853,9 +871,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_005, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -871,8 +890,8 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_005, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
auto currentList = abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_;
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto currentList = curListManager->currentMissionLists_;
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
commonAbility->SetAbilityState(AbilityState::FOREGROUNDING);
@ -895,9 +914,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_006, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -913,8 +933,8 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_006, TestSize.Level1)
// add common ability to abilityMs
auto commonAbility = CreateCommonAbility();
commonAbility->AddCallerRecord(callerAbility->GetToken(), -1);
auto currentList = abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_;
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto currentList = curListManager->currentMissionLists_;
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonAbility);
commonAbility->SetAbilityState(AbilityState::FOREGROUNDING);
@ -937,9 +957,10 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_007, TestSize.Level1)
{
// test config is success.
EXPECT_TRUE(abilityMs_ != nullptr);
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
// add rootlauncher to abilityMs.
@ -951,7 +972,7 @@ HWTEST_F(AbilityTimeoutModuleTest, HandleForegroundTimeOut_007, TestSize.Level1)
// add common laucher ability to abilityMs
auto commonLauncherAbility = CreateLauncherAbility();
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = curListManager->GetCurrentTopAbilityLocked();
EXPECT_EQ(topAbility, commonLauncherAbility);
commonLauncherAbility->SetAbilityState(AbilityState::FOREGROUNDING);

View File

@ -29,6 +29,7 @@ ohos_moduletest("specified_ability_service_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",

View File

@ -25,6 +25,7 @@
#define protected public
#include "ability_manager_errors.h"
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
@ -112,8 +113,9 @@ HWTEST_F(SpecifiedAbilityServiceTest, OnAcceptWantResponse_001, TestSize.Level1)
abilityMgrServ_->subManagersHelper_->InitMissionListManager(11, true);
Want want;
want.SetElementName("DemoDeviceId", "DemoBundleName", "DemoAbilityName");
EXPECT_TRUE(abilityMgrServ_->subManagersHelper_->currentMissionListManager_);
abilityMgrServ_->subManagersHelper_->currentMissionListManager_->EnqueueWaitingAbility(abilityRequest);
auto missionListMgr = abilityMgrServ_->subManagersHelper_->currentMissionListManager_;
EXPECT_TRUE(missionListMgr);
reinterpret_cast<MissionListManager*>(missionListMgr.get())->EnqueueWaitingAbility(abilityRequest);
abilityMgrServ_->OnAcceptWantResponse(want, "flag");
EXPECT_EQ(false, abilityRecord->IsNewWant());

View File

@ -42,6 +42,7 @@ ohos_moduletest("mission_dump_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",

View File

@ -19,6 +19,7 @@
#include "ability_manager_service.h"
#include "ability_event_handler.h"
#include "ams_configuration_parameter.h"
#include "mission_list_manager.h"
#undef private
#undef protected
@ -32,6 +33,7 @@
#include "mock_ability_token.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
using namespace testing;
using namespace testing::ext;
using namespace OHOS::AppExecFwk;

View File

@ -29,6 +29,7 @@ ohos_moduletest("on_new_want_module_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",

View File

@ -65,6 +65,7 @@ ohos_moduletest("running_infos_module_test") {
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_path}/utils/server/startup:startup_util",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:event_report",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_services_path}/common:task_handler_wrap",

View File

@ -43,6 +43,7 @@
#include "wants_info.h"
#include "want_receiver_stub.h"
#include "want_sender_stub.h"
#include "mission_list_manager.h"
using namespace std::placeholders;
using namespace testing::ext;
@ -130,7 +131,8 @@ void RunningInfosModuleTest::OnStartAms()
abilityMgrServ_->subManagersHelper_ = std::make_shared<SubManagersHelper>(nullptr, nullptr);
abilityMgrServ_->subManagersHelper_->InitSubManagers(userId, true);
abilityMgrServ_->subManagersHelper_->currentConnectManager_->SetTaskHandler(abilityMgrServ_->taskHandler_);
auto topAbility = abilityMgrServ_->GetMissionListManagerByUserId(userId)->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMgrServ_->
GetMissionListManagerByUserId(userId).get())->GetCurrentTopAbilityLocked();
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -281,7 +283,8 @@ HWTEST_F(RunningInfosModuleTest, GetAbilityRunningInfos_004, TestSize.Level1)
auto result = abilityMgrServ_->StartAbility(want);
EXPECT_EQ(OHOS::ERR_OK, result);
auto topAbility = abilityMgrServ_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMgrServ_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility);
topAbility->SetAbilityState(AbilityState::FOREGROUND);
@ -357,7 +360,8 @@ HWTEST_F(RunningInfosModuleTest, GetAbilityRunningInfos_006, TestSize.Level1)
auto result = abilityMgrServ_->StartAbility(want);
EXPECT_EQ(OHOS::ERR_OK, result);
auto topAbility = abilityMgrServ_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMgrServ_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility);
topAbility->SetAbilityState(AbilityState::FOREGROUND);

View File

@ -53,6 +53,7 @@ ohos_moduletest("start_ability_implicit_module_test") {
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_services_path}/common:task_handler_wrap",
"${distributedschedule_path}/safwk/interfaces/innerkits/safwk:system_ability_fwk",

View File

@ -29,6 +29,7 @@
#include "sa_mgr_client.h"
#include "system_ability_definition.h"
#include "ui_service_mgr_client_mock.h"
#include "mission_list_manager.h"
using namespace testing;
using namespace testing::ext;
@ -113,10 +114,7 @@ void StartAbilityImplicitModuleTest::OnStartAms() const
void StartAbilityImplicitModuleTest::OnStopAms() const
{
abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_->missions_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->defaultStandardList_->missions_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->defaultSingleList_->missions_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_.clear();
abilityMs_->subManagersHelper_->currentMissionListManager_.reset();
abilityMs_->OnStop();
}
@ -161,7 +159,8 @@ HWTEST_F(StartAbilityImplicitModuleTest, StartAbility_001, TestSize.Level1)
EXPECT_TRUE(!params.empty());
EXPECT_TRUE(isCallBack);
auto abilityRecord = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto abilityRecord = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(abilityRecord != nullptr);
GTEST_LOG_(INFO) << "ability:" << abilityRecord->GetAbilityInfo().name;
@ -193,7 +192,8 @@ HWTEST_F(StartAbilityImplicitModuleTest, StartAbility_002, TestSize.Level1)
EXPECT_TRUE(!params.empty());
EXPECT_TRUE(isCallBack);
auto abilityRecord = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto abilityRecord = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(abilityRecord == nullptr);
}
@ -222,7 +222,8 @@ HWTEST_F(StartAbilityImplicitModuleTest, StartAbility_003, TestSize.Level1)
EXPECT_TRUE(params.empty());
EXPECT_TRUE(!isCallBack);
auto abilityRecord = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto abilityRecord = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(abilityRecord != nullptr);
}
@ -251,7 +252,8 @@ HWTEST_F(StartAbilityImplicitModuleTest, StartAbility_004, TestSize.Level1)
EXPECT_TRUE(!params.empty());
EXPECT_TRUE(isCallBack);
auto abilityRecord = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto abilityRecord = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(abilityRecord == nullptr);
}

View File

@ -29,6 +29,7 @@ ohos_moduletest("start_option_module_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
]

View File

@ -17,6 +17,7 @@
#define private public
#define protected public
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
#include "ability_manager_errors.h"
@ -64,7 +65,8 @@ HWTEST_F(StartOptionDisplayIdTest, start_option_001, TestSize.Level1)
option.SetDisplayID(DISPLAY_ID);
auto result = abilityMgrServ_->StartAbility(want, option, nullptr, USER_ID_U100, 0);
if (result == OHOS::ERR_OK) {
auto topAbility = abilityMgrServ_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMgrServ_->
GetMissionListManagerByUserId(USER_ID_U100).get())->GetCurrentTopAbilityLocked();
if (topAbility) {
auto defualtDisplayId = 0;
auto displayId = topAbility->GetWant().GetIntParam(Want::PARAM_RESV_DISPLAY_ID, defualtDisplayId);

View File

@ -20,6 +20,7 @@
#include "ability_event_handler.h"
#include "ability_connect_manager.h"
#include "ams_configuration_parameter.h"
#include "mission_list_manager.h"
#undef private
#undef protected
@ -57,6 +58,16 @@ static void WaitUntilTaskFinished()
}
}
}
static std::shared_ptr<AbilityRecord> GetMissionListTopAbility(
std::shared_ptr<MissionListManagerInterface> missionListMgr)
{
if (!missionListMgr) {
return nullptr;
}
return reinterpret_cast<MissionListManager*>(missionListMgr.get()).GetCurrentTopAbilityLocked();
}
namespace {
const int32_t USER_ID_U100 = 100;
const int32_t ERROR_USER_ID_U256 = 256;
@ -112,7 +123,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_001, TestSize.Le
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_StartAbility_001 start";
abilityMs_->StartUser(USER_ID_U100, nullptr);
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -124,7 +135,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_001, TestSize.Le
EXPECT_EQ(OHOS::ERR_OK, result);
abilityMs_->StartUser(newUserId, nullptr);
topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -147,7 +158,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_001, TestSize.Le
HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_StartAbility_002 start";
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -158,7 +169,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_002, TestSize.Le
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
@ -186,7 +197,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_003, TestSize.Le
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_StartAbility_003 start";
AbilityStartSetting abilityStartSetting;
// default user
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -198,7 +209,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_003, TestSize.Le
EXPECT_EQ(OHOS::ERR_OK, result);
abilityMs_->StartUser(newUserId, nullptr);
topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -222,7 +233,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_004, TestSize.Le
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_StartAbility_004 start";
StartOptions abilityStartOptions;
// default user
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -234,7 +245,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_004, TestSize.Le
EXPECT_EQ(OHOS::ERR_OK, result);
abilityMs_->StartUser(newUserId, nullptr);
topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -386,7 +397,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_011, TestSize.Le
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_StartAbility_011 start";
abilityMs_->StartUser(USER_ID_U100, nullptr);
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -410,7 +421,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_StartAbility_011, TestSize.Le
HWTEST_F(AbilityManagerServiceAccountTest, Account_TerminateAbility_001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_TerminateAbility_001 start";
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -421,7 +432,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_TerminateAbility_001, TestSiz
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -761,7 +772,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleConnectAbilityDone_00
HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleConnectAbilityDone_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_ScheduleConnectAbilityDone_002 start";
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -772,7 +783,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleConnectAbilityDone_00
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -843,7 +854,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleConnectAbilityDone_00
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_ScheduleConnectAbilityDone_004 start";
abilityMs_->StartUser(newUserId, nullptr);
auto topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -854,7 +865,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleConnectAbilityDone_00
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -923,7 +934,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleDisconnectAbilityDone
HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleDisconnectAbilityDone_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_ScheduleDisconnectAbilityDone_002 start";
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -934,7 +945,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleDisconnectAbilityDone
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -961,7 +972,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleDisconnectAbilityDone
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_ScheduleDisconnectAbilityDone_003 start";
abilityMs_->StartUser(newUserId, nullptr);
auto topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -972,7 +983,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleDisconnectAbilityDone
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -1041,7 +1052,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleCommandAbilityDone_00
HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleCommandAbilityDone_002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_ScheduleCommandAbilityDone_002 start";
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -1052,7 +1063,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleCommandAbilityDone_00
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -1123,7 +1134,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleCommandAbilityDone_00
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_ScheduleCommandAbilityDone_004 start";
abilityMs_->StartUser(newUserId, nullptr);
auto topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -1134,7 +1145,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_ScheduleCommandAbilityDone_00
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(newUserId)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(newUserId));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -1306,7 +1317,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_MinimizeAbility_001, TestSize
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_MinimizeAbility_001 start";
// default user
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -1317,7 +1328,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_MinimizeAbility_001, TestSize
WaitUntilTaskFinished();
EXPECT_EQ(ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
@ -1340,7 +1351,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_AttachAbilityThread_001, Test
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_AttachAbilityThread_001 start";
// default user
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -1351,7 +1362,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_AttachAbilityThread_001, Test
WaitUntilTaskFinished();
EXPECT_EQ(OHOS::ERR_OK, result);
OHOS::sptr<IAbilityScheduler> scheduler = new AbilityScheduler();
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
token = topAbility->GetToken();
@ -1372,7 +1383,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_OnAbilityRequestDone_001, Tes
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_OnAbilityRequestDone_001 start";
// default user
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}
@ -1382,7 +1393,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_OnAbilityRequestDone_001, Tes
auto result = abilityMs_->StartAbility(want, USER_ID_U100, -1);
WaitUntilTaskFinished();
EXPECT_EQ(ERR_OK, result);
topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
sptr<IRemoteObject> token = nullptr;
if (topAbility) {
token = topAbility->GetToken();
@ -1403,7 +1414,7 @@ HWTEST_F(AbilityManagerServiceAccountTest, Account_KillProcess_001, TestSize.Lev
{
GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest Account_KillProcess_001 start";
// default user
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = GetMissionListTopAbility(abilityMs_->GetMissionListManagerByUserId(USER_ID_U100));
if (topAbility) {
topAbility->SetAbilityState(AAFwk::AbilityState::FOREGROUND);
}

View File

@ -59,6 +59,7 @@ ohos_unittest("ability_record_test") {
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_native_path}/ability/native:auto_startup_callback",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_services_path}/uripermmgr:libupms_static",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",

View File

@ -29,6 +29,7 @@ ohos_unittest("ability_timeout_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
]

View File

@ -17,6 +17,7 @@
#define private public
#define protected public
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
@ -92,8 +93,10 @@ HWTEST_F(AbilityTimeoutTest, OnAbilityDied_001, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto defList = abilityMs_->subManagersHelper_->currentMissionListManager_->defaultStandardList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto defList = curListManager->defaultStandardList_;
EXPECT_TRUE(defList != nullptr);
AbilityRequest abilityRequest;
@ -129,10 +132,12 @@ HWTEST_F(AbilityTimeoutTest, OnAbilityDied_002, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
EXPECT_EQ((int)(abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_.size()), 1);
EXPECT_EQ((int)(curListManager->currentMissionLists_.size()), 1);
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
@ -171,10 +176,12 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_001, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
EXPECT_TRUE(abilityMs_->subManagersHelper_->currentMissionListManager_ != nullptr);
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
EXPECT_EQ((int)(abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_.size()), 1);
EXPECT_EQ((int)(curListManager->currentMissionLists_.size()), 1);
// root launcher ability load timeout
AbilityRequest abilityRequest;
@ -215,11 +222,12 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_002, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
EXPECT_EQ((int)(abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_.size()), 1);
EXPECT_EQ((int)(curListManager->currentMissionLists_.size()), 1);
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
@ -274,11 +282,12 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_003, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
EXPECT_EQ((int)(abilityMs_->subManagersHelper_->currentMissionListManager_->currentMissionLists_.size()), 1);
EXPECT_EQ((int)(curListManager->currentMissionLists_.size()), 1);
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
abilityRequest.abilityInfo.name = "com.test.rootLauncher";
@ -339,10 +348,10 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_004, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -406,10 +415,10 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_005, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -473,12 +482,11 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_006, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
abilityRequest.abilityInfo.name = "com.test.rootLauncher";
@ -538,10 +546,10 @@ HWTEST_F(AbilityTimeoutTest, HandleLoadTimeOut_007, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -605,10 +613,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_001, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -650,10 +658,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_002, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -707,9 +715,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_003, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
abilityRequest.abilityInfo.type = AbilityType::PAGE;
@ -774,10 +783,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_004, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -841,10 +850,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_005, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -909,10 +918,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_006, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;
@ -977,10 +986,10 @@ HWTEST_F(AbilityTimeoutTest, HandleForgroundNewTimeout_007, TestSize.Level1)
abilityMs_->OnStart();
EXPECT_TRUE(abilityMs_ != nullptr);
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
auto curListManager = abilityMs_->subManagersHelper_->currentMissionListManager_;
auto lauList = abilityMs_->subManagersHelper_->currentMissionListManager_->launcherList_;
auto curListManager = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get());
EXPECT_TRUE(curListManager != nullptr);
auto lauList = curListManager->launcherList_;
EXPECT_TRUE(lauList != nullptr);
AbilityRequest abilityRequest;

View File

@ -35,6 +35,7 @@ ohos_unittest("app_exit_reason_data_manager_test") {
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]

View File

@ -45,6 +45,7 @@ ohos_unittest("call_container_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"//third_party/googletest:gmock_main",

View File

@ -19,6 +19,7 @@
#include "call_container.h"
#include "ability_record.h"
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
#include "ability_scheduler_mock.h"

View File

@ -41,6 +41,7 @@ ohos_unittest("mission_data_storage_test") {
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_services_path}/common:task_handler_wrap",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",

View File

@ -42,6 +42,7 @@ ohos_unittest("mission_info_mgr_test") {
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",

View File

@ -23,7 +23,10 @@ ohos_unittest("mission_list_dump_test") {
configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
deps = [ "${ability_runtime_services_path}/abilitymgr:abilityms" ]
deps = [
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
]
external_deps = [
"ability_base:session_info",

View File

@ -25,6 +25,7 @@ ohos_unittest("mission_list_manager_dump_test") {
deps = [
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"//third_party/googletest:gtest_main",
]

View File

@ -50,6 +50,7 @@ ohos_unittest("mission_list_manager_test") {
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",

View File

@ -45,6 +45,7 @@ ohos_unittest("mission_list_manager_ut_test") {
"${ability_runtime_native_path}/ability/native:ability_thread",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",

View File

@ -40,6 +40,7 @@ ohos_unittest("mission_list_test") {
deps = [
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",
@ -86,6 +87,7 @@ ohos_unittest("mission_list_test_call") {
deps = [
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"//third_party/googletest:gtest_main",
]

View File

@ -40,6 +40,7 @@ ohos_unittest("mission_test") {
deps = [
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",

View File

@ -29,6 +29,7 @@ ohos_unittest("running_infos_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
]

View File

@ -17,6 +17,7 @@
#define private public
#define protected public
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
#include "ability_manager_errors.h"
@ -148,7 +149,8 @@ HWTEST_F(RunningInfosTest, GetAbilityRunningInfos_004, TestSize.Level1)
auto result = abilityMs_->StartAbility(want);
if (result == OHOS::ERR_OK) {
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility);
topAbility->SetAbilityState(AbilityState::FOREGROUND);
}
@ -223,7 +225,8 @@ HWTEST_F(RunningInfosTest, GetAbilityRunningInfos_006, TestSize.Level1)
auto result = abilityMs_->StartAbility(want);
if (result == OHOS::ERR_OK) {
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility);
topAbility->SetAbilityState(AbilityState::FOREGROUND);
}
@ -262,7 +265,8 @@ HWTEST_F(RunningInfosTest, GetAbilityRunningInfos_007, TestSize.Level1)
auto result = abilityMs_->StartAbility(want);
if (result == OHOS::ERR_OK) {
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility);
topAbility->SetAbilityState(AbilityState::ACTIVE);
@ -535,7 +539,8 @@ HWTEST_F(RunningInfosTest, MissionGetAbilityRunningInfos_002, TestSize.Level1)
auto result = abilityMs_->StartAbility(want);
if (result == OHOS::ERR_OK) {
auto topAbility = abilityMs_->subManagersHelper_->currentMissionListManager_->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMs_->subManagersHelper_->
currentMissionListManager_.get())->GetCurrentTopAbilityLocked();
EXPECT_TRUE(topAbility);
topAbility->SetAbilityState(AbilityState::FOREGROUND);
}

View File

@ -48,6 +48,7 @@ ohos_unittest("specified_mission_list_test") {
"${ability_runtime_native_path}/ability/native:auto_startup_callback",
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:app_util",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",

View File

@ -29,6 +29,7 @@ ohos_unittest("start_option_display_id_test") {
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
]

View File

@ -17,6 +17,7 @@
#define private public
#define protected public
#include "ability_manager_service.h"
#include "mission_list_manager.h"
#undef private
#undef protected
@ -67,7 +68,8 @@ HWTEST_F(StartOptionDisplayIdTest, start_option_display_id_001, TestSize.Level1)
option.SetDisplayID(DISPLAY_ID);
auto result = abilityMs_->StartAbility(want, option, nullptr);
if (result == OHOS::ERR_OK) {
auto topAbility = abilityMs_->GetMissionListManagerByUserId(USER_ID_U100)->GetCurrentTopAbilityLocked();
auto topAbility = reinterpret_cast<MissionListManager*>(abilityMs_->
GetMissionListManagerByUserId(USER_ID_U100).get())->GetCurrentTopAbilityLocked();
if (topAbility) {
auto defualtDisplayId = 0;
auto displayId = topAbility->GetWant().GetIntParam(Want::PARAM_RESV_DISPLAY_ID, defualtDisplayId);

View File

@ -41,6 +41,7 @@ ohos_unittest("task_data_persistence_mgr_test") {
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
"${ability_runtime_services_path}/abilitymgr:mission_list",
"${ability_runtime_services_path}/common:perm_verification",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock",

View File

@ -48,6 +48,7 @@ ohos_unittest("ui_ability_lifecycle_manager_test") {
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
"${ability_runtime_innerkits_path}/ability_manager:process_options",
"${ability_runtime_innerkits_path}/app_manager:app_manager",
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_native_path}/ability/native:auto_startup_callback",
"${ability_runtime_native_path}/appkit:appkit_manager_helper",