mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Signed-off-by: jiangzhijun8 <jiangzhijun7@huawei.com>
This commit is contained in:
commit
130cd4f6d3
@ -45,7 +45,10 @@ ohos_shared_library("autostartupcallback") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
defines = [
|
||||
"SUPPORT_GRAPHICS",
|
||||
"SUPPORT_SCREEN",
|
||||
]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
|
@ -217,11 +217,6 @@ private:
|
||||
return OnSetLoopWatch(env, argc, argv);
|
||||
}
|
||||
if (type == ON_OFF_TYPE_UNHANDLED_REJECTION) {
|
||||
if (!AppExecFwk::EventRunner::IsAppMainThread()) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "UnhandledRejectionObserver can only be set from main thread.");
|
||||
ThrowInvalidCallerError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc != ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "The number of params is invalid.");
|
||||
ThrowInvalidNumParametersError(env);
|
||||
@ -333,11 +328,6 @@ private:
|
||||
return OnRemoveLoopWatch(env, argc, argv);
|
||||
}
|
||||
if (type == ON_OFF_TYPE_UNHANDLED_REJECTION) {
|
||||
if (!AppExecFwk::EventRunner::IsAppMainThread()) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "UnhandledRejectionObserver can only be unset from main thread.");
|
||||
ThrowInvalidCallerError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc != ARGC_TWO && argc != ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "The number of params is invalid.");
|
||||
ThrowInvalidNumParametersError(env);
|
||||
|
@ -162,6 +162,11 @@ public:
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsApplicationRunning);
|
||||
}
|
||||
|
||||
static napi_value IsAppRunning(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsAppRunning);
|
||||
}
|
||||
#ifdef SUPPORT_SCREEN
|
||||
static bool CheckCallerIsSystemApp()
|
||||
{
|
||||
@ -1104,6 +1109,57 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnIsAppRunning(napi_env env, size_t argc, napi_value *argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
if (argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Params not match.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get bundle name wrong.");
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t appCloneIndex = 0;
|
||||
if (argc > ARGC_ONE && !ConvertFromJsValue(env, argv[1], appCloneIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get appCloneIndex wrong.");
|
||||
ThrowInvalidParamError(env, "Parse param appCloneIndex failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
auto innerErrorCode = std::make_shared<int32_t>(ERR_OK);
|
||||
auto isRunning = std::make_shared<bool>(false);
|
||||
wptr<OHOS::AppExecFwk::IAppMgr> appManager = appManager_;
|
||||
NapiAsyncTask::ExecuteCallback execute =
|
||||
[bundleName, appCloneIndex, appManager, innerErrorCode, isRunning]() {
|
||||
sptr<OHOS::AppExecFwk::IAppMgr> appMgr = appManager.promote();
|
||||
if (appMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "App manager is nullptr.");
|
||||
*innerErrorCode = static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return;
|
||||
}
|
||||
*innerErrorCode = appMgr->IsAppRunning(bundleName, appCloneIndex, *isRunning);
|
||||
};
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[innerErrorCode, isRunning](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (*innerErrorCode == ERR_OK) {
|
||||
task.ResolveWithNoError(env, CreateJsValue(env, *isRunning));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode));
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::IsAppRunning",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnPreloadApplication(napi_env env, size_t argc, napi_value *argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnPreloadApplication called.");
|
||||
@ -1227,12 +1283,10 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj)
|
||||
JsAppManager::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, exportObj, "isRunningInStabilityTest", moduleName,
|
||||
JsAppManager::IsRunningInStabilityTest);
|
||||
BindNativeFunction(env, exportObj, "killProcessWithAccount", moduleName,
|
||||
JsAppManager::KillProcessWithAccount);
|
||||
BindNativeFunction(env, exportObj, "killProcessWithAccount", moduleName, JsAppManager::KillProcessWithAccount);
|
||||
BindNativeFunction(env, exportObj, "killProcessesByBundleName", moduleName,
|
||||
JsAppManager::KillProcessesByBundleName);
|
||||
BindNativeFunction(env, exportObj, "clearUpApplicationData", moduleName,
|
||||
JsAppManager::ClearUpApplicationData);
|
||||
BindNativeFunction(env, exportObj, "clearUpApplicationData", moduleName, JsAppManager::ClearUpApplicationData);
|
||||
BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName, JsAppManager::GetAppMemorySize);
|
||||
BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName, JsAppManager::IsRamConstrainedDevice);
|
||||
BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName, JsAppManager::IsSharedBundleRunning);
|
||||
@ -1241,6 +1295,8 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj)
|
||||
JsAppManager::GetRunningProcessInfoByBundleName);
|
||||
BindNativeFunction(env, exportObj, "getRunningMultiAppInfo", moduleName, JsAppManager::GetRunningMultiAppInfo);
|
||||
BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, JsAppManager::IsApplicationRunning);
|
||||
BindNativeFunction(env, exportObj, "isAppRunning", moduleName,
|
||||
JsAppManager::IsAppRunning);
|
||||
BindNativeFunction(env, exportObj, "preloadApplication", moduleName, JsAppManager::PreloadApplication);
|
||||
BindNativeFunction(env, exportObj, "getRunningProcessInformationByBundleType", moduleName,
|
||||
JsAppManager::GetRunningProcessInformationByBundleType);
|
||||
|
@ -320,7 +320,7 @@ ErrCode AbilityContextImpl::TerminateAbilityWithResult(const AAFwk::Want& want,
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "TerminateAbilityWithResult. ret=%{public}d", err);
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, resultCode, &want);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "TerminateAbilityWithResult. ret=%{public}d", err);
|
||||
return err;
|
||||
@ -562,7 +562,7 @@ ErrCode AbilityContextImpl::TerminateSelf()
|
||||
}
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
AAFwk::Want resultWant;
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, -1, &resultWant);
|
||||
if (err != ERR_OK) {
|
||||
|
@ -964,7 +964,12 @@ ohos_shared_library("dialog_request_callback") {
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines = [
|
||||
"SUPPORT_SCREEN",
|
||||
"SUPPORT_GRAPHICS",
|
||||
]
|
||||
}
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
|
@ -35,7 +35,9 @@
|
||||
#include "cj_runtime.h"
|
||||
#include "cj_ability_object.h"
|
||||
#include "time_util.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "scene_board_judgement.h"
|
||||
#endif
|
||||
#include "string_wrapper.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
@ -47,8 +49,10 @@ const std::string PAGE_STACK_PROPERTY_NAME = "pageStack";
|
||||
const std::string METHOD_NAME = "WindowScene::GoForeground";
|
||||
const std::string SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME = "ohos.extra.param.key.supportContinuePageStack";
|
||||
#endif
|
||||
#ifdef SUPPORT_SCREEN
|
||||
// Numerical base (radix) that determines the valid characters and their interpretation.
|
||||
const int32_t BASE_DISPLAY_ID_NUM (10);
|
||||
#endif
|
||||
}
|
||||
|
||||
UIAbility *CJUIAbility::Create(const std::unique_ptr<Runtime> &runtime)
|
||||
@ -211,6 +215,7 @@ void CJUIAbility::OnStopCallback()
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
void CJUIAbility::OnSceneCreated()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@ -625,7 +630,7 @@ bool CJUIAbility::GetInsightIntentExecutorInfo(const Want &want,
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
int32_t CJUIAbility::OnContinue(WantParams &wantParams)
|
||||
{
|
||||
if (!cjAbilityObj_) {
|
||||
@ -679,9 +684,11 @@ void CJUIAbility::OnNewWant(const Want &want)
|
||||
UIAbility::OnNewWant(want);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
if (scene_) {
|
||||
scene_->OnNewWant(want);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (!cjAbilityObj_) {
|
||||
HILOG_ERROR("CJAbility is not loaded.");
|
||||
|
@ -230,7 +230,7 @@ ohos_shared_library("appkit_native") {
|
||||
defines += [ "NWEB" ]
|
||||
}
|
||||
|
||||
if (purgeable_ashmem_enable && defined(global_parts_info) &&
|
||||
if (memory_utils_purgeable_ashmem_enable && defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_memmgr_override)) {
|
||||
defines += [ "IMAGE_PURGEABLE_PIXELMAP" ]
|
||||
external_deps += [ "memmgr_override:libpurgeablemem_plugin" ]
|
||||
|
@ -519,6 +519,11 @@ enum {
|
||||
* Result(2097252) for unlock screen failed in developer mode.
|
||||
*/
|
||||
ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE,
|
||||
|
||||
/*
|
||||
* Result(2097253) for block startup in lock screen.
|
||||
*/
|
||||
ERR_BLOCK_START_FIRST_BOOT_SCREEN_UNLOCK = 2097253,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -568,6 +568,16 @@ public:
|
||||
*/
|
||||
virtual int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning) = 0;
|
||||
|
||||
/**
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
virtual int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex,
|
||||
bool &isRunning) = 0;
|
||||
|
||||
/**
|
||||
* Start child process, called by ChildProcessManager.
|
||||
*
|
||||
|
@ -104,6 +104,7 @@ enum class AppMgrInterfaceCode {
|
||||
GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME = 78,
|
||||
SET_APP_ASSERT_PAUSE_STATE_SELF = 79,
|
||||
GET_RUNNING_PROCESS_INFO_BY_PID = 80,
|
||||
IS_APP_RUNNING = 81,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
|
@ -501,6 +501,15 @@ public:
|
||||
*/
|
||||
int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning) override;
|
||||
|
||||
/**
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning) override;
|
||||
|
||||
/**
|
||||
* Start child process, called by ChildProcessManager.
|
||||
*
|
||||
|
@ -95,6 +95,7 @@ private:
|
||||
int32_t HandleDumpHeapMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleDumpJsHeapMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsAppRunning(MessageParcel &data, MessageParcel &reply);
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
int32_t HandleBlockAppServiceDone(MessageParcel &data, MessageParcel &reply);
|
||||
#endif
|
||||
|
@ -1707,6 +1707,37 @@ int32_t AppMgrProxy::IsApplicationRunning(const std::string &bundleName, bool &i
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
if (!data.WriteString(bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write bundle name failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
if (!data.WriteInt32(appCloneIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write appCloneIndex failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto ret = SendRequest(AppMgrInterfaceCode::IS_APP_RUNNING,
|
||||
data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Send request is failed, error code: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
isRunning = reply.ReadBool();
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::StartChildProcess(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount,
|
||||
bool isStartWithDebug)
|
||||
{
|
||||
|
@ -201,6 +201,8 @@ AppMgrStub::AppMgrStub()
|
||||
&AppMgrStub::HandleStartNativeChildProcess;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::SAVE_BROWSER_CHANNEL)] =
|
||||
&AppMgrStub::HandleSaveBrowserChannel;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::IS_APP_RUNNING)] =
|
||||
&AppMgrStub::HandleIsAppRunning;
|
||||
}
|
||||
|
||||
AppMgrStub::~AppMgrStub()
|
||||
@ -1164,6 +1166,23 @@ int32_t AppMgrStub::HandleIsApplicationRunning(MessageParcel &data, MessageParce
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleIsAppRunning(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
std::string bundleName = data.ReadString();
|
||||
bool isRunning = false;
|
||||
int32_t appCloneIndex = data.ReadInt32();
|
||||
int32_t result = IsAppRunning(bundleName, appCloneIndex, isRunning);
|
||||
if (!reply.WriteBool(isRunning)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleStartChildProcess(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called.");
|
||||
|
@ -52,8 +52,8 @@ public:
|
||||
void SetSessionId(int32_t sessionId);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void SetUIContent(Ace::UIContent *uiContent);
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
Ace::UIContent *GetUIContent();
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
void SetEventId(uint32_t eventId);
|
||||
void SetWindowType(const AutoFill::AutoFillWindowType &autoFillWindowType);
|
||||
void SetExtensionType(bool isSmartAutoFill);
|
||||
|
@ -204,13 +204,12 @@ void AutoFillExtensionCallback::SetUIContent(Ace::UIContent *uiContent)
|
||||
{
|
||||
uiContent_ = uiContent;
|
||||
}
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
|
||||
Ace::UIContent *AutoFillExtensionCallback::GetUIContent()
|
||||
{
|
||||
return uiContent_;
|
||||
}
|
||||
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
void AutoFillExtensionCallback::SetEventId(uint32_t eventId)
|
||||
{
|
||||
eventId_ = eventId;
|
||||
|
@ -31,9 +31,11 @@
|
||||
#include "start_options.h"
|
||||
#include "want.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "pixel_map.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Ace {
|
||||
@ -327,6 +329,7 @@ public:
|
||||
virtual void UnregisterAbilityLifecycleObserver(
|
||||
const std::shared_ptr<AppExecFwk::ILifecycleObserver> &observer) = 0;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
/**
|
||||
* @brief Set mission label of this ability.
|
||||
@ -366,6 +369,7 @@ public:
|
||||
const std::shared_ptr<JsUIExtensionCallback> &uiExtensionCallbacks) = 0;
|
||||
virtual ErrCode CreateModalUIExtensionWithApp(const AAFwk::Want &want) = 0;
|
||||
virtual void EraseUIExtension(int32_t sessionId) = 0;
|
||||
#endif
|
||||
#endif
|
||||
virtual bool IsTerminating() = 0;
|
||||
virtual void SetTerminating(bool state) = 0;
|
||||
|
@ -167,6 +167,7 @@ public:
|
||||
int32_t OnShare(WantParams &wantParams) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
public:
|
||||
/**
|
||||
* @brief Called after instantiating WindowScene.
|
||||
@ -276,7 +277,7 @@ private:
|
||||
std::shared_ptr<Rosen::CJWindowStageImpl> cjWindowStage_;
|
||||
int32_t windowMode_ = 0;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
private:
|
||||
std::shared_ptr<AppExecFwk::ADelegatorAbilityProperty> CreateADelegatorAbilityProperty();
|
||||
sptr<IRemoteObject> SetNewRuleFlagToCallee(napi_env env, napi_value remoteJsObj);
|
||||
|
@ -18,9 +18,11 @@
|
||||
|
||||
#include "ability_lifecycle_observer_interface.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "pixel_map.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Ace {
|
||||
@ -32,6 +34,7 @@ class IAbilityCallback {
|
||||
public:
|
||||
IAbilityCallback() = default;
|
||||
virtual ~IAbilityCallback() = default;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
/**
|
||||
* @brief Called back at ability context.
|
||||
@ -83,6 +86,7 @@ public:
|
||||
*/
|
||||
virtual Ace::UIContent* GetUIContent() = 0;
|
||||
virtual void EraseUIExtension(int32_t sessionId) = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -63,6 +63,7 @@ abilityms_files = [
|
||||
"src/interceptor/crowd_test_interceptor.cpp",
|
||||
"src/interceptor/disposed_rule_interceptor.cpp",
|
||||
"src/interceptor/ecological_rule_interceptor.cpp",
|
||||
"src/interceptor/screen_unlock_interceptor.cpp",
|
||||
"src/interceptor/start_other_app_interceptor.cpp",
|
||||
"src/uri_utils.cpp",
|
||||
"src/window_focus_changed_listener.cpp",
|
||||
|
@ -1919,6 +1919,7 @@ private:
|
||||
void SubscribeScreenUnlockedEvent();
|
||||
void UnSubscribeScreenUnlockedEvent();
|
||||
void RetrySubscribeScreenUnlockedEvent(int32_t retryCount);
|
||||
void RemoveScreenUnlockInterceptor();
|
||||
|
||||
int VerifyAccountPermission(int32_t userId);
|
||||
|
||||
@ -2161,6 +2162,8 @@ private:
|
||||
int32_t SetBackgroundCall(const AppExecFwk::RunningProcessInfo &processInfo,
|
||||
const AbilityRequest &abilityRequest, bool &isBackgroundCall) const;
|
||||
|
||||
void GetRunningMultiAppIndex(const std::string &bundleName, int32_t uid, int32_t &appIndex);
|
||||
|
||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||
constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5;
|
||||
|
||||
|
@ -33,21 +33,21 @@ public:
|
||||
|
||||
virtual ~AppExitReasonDataManager();
|
||||
|
||||
int32_t SetAppExitReason(const std::string &bundleName, const std::vector<std::string> &abilityList,
|
||||
const AAFwk::ExitReason &exitReason);
|
||||
int32_t SetAppExitReason(const std::string &bundleName, uint32_t accessTokenId,
|
||||
const std::vector<std::string> &abilityList, const AAFwk::ExitReason &exitReason);
|
||||
|
||||
int32_t GetAppExitReason(const std::string &bundleName, const std::string &abilityName, bool &isSetReason,
|
||||
AAFwk::ExitReason &exitReason);
|
||||
int32_t GetAppExitReason(const std::string &bundleName, uint32_t accessTokenId, const std::string &abilityName,
|
||||
bool &isSetReason, AAFwk::ExitReason &exitReason);
|
||||
|
||||
int32_t DeleteAppExitReason(const std::string &bundleName);
|
||||
int32_t DeleteAppExitReason(const std::string &bundleName, int32_t uid);
|
||||
|
||||
int32_t AddAbilityRecoverInfo(const std::string &bundleName,
|
||||
int32_t AddAbilityRecoverInfo(uint32_t accessTokenId,
|
||||
const std::string &moduleName, const std::string &abilityName, const int &sessionId);
|
||||
|
||||
int32_t DeleteAbilityRecoverInfo(
|
||||
const std::string &bundleName, const std::string &moduleName, const std::string &abilityName);
|
||||
uint32_t accessTokenId, const std::string &moduleName, const std::string &abilityName);
|
||||
|
||||
int32_t GetAbilityRecoverInfo(const std::string &bundleName,
|
||||
int32_t GetAbilityRecoverInfo(uint32_t accessTokenId,
|
||||
const std::string &moduleName, const std::string &abilityName, bool &hasRecoverInfo);
|
||||
|
||||
int32_t SetUIExtensionAbilityExitReason(const std::string &bundleName,
|
||||
@ -55,7 +55,7 @@ public:
|
||||
|
||||
bool GetUIExtensionAbilityExitReason(const std::string &keyEx, AAFwk::ExitReason &exitReason);
|
||||
|
||||
int32_t GetAbilitySessionId(const std::string &bundleName,
|
||||
int32_t GetAbilitySessionId(uint32_t accessTokenId,
|
||||
const std::string &moduleName, const std::string &abilityName, int &sessionId);
|
||||
|
||||
private:
|
||||
@ -65,17 +65,18 @@ private:
|
||||
const std::vector<std::string> &abilityList, const AAFwk::ExitReason &exitReason);
|
||||
void ConvertAppExitReasonInfoFromValue(const DistributedKv::Value &value, AAFwk::ExitReason &exitReason,
|
||||
int64_t &time_stamp, std::vector<std::string> &abilityList);
|
||||
void UpdateAppExitReason(const std::string &bundleName, const std::vector<std::string> &abilityList,
|
||||
void UpdateAppExitReason(uint32_t accessTokenId, const std::vector<std::string> &abilityList,
|
||||
const AAFwk::ExitReason &exitReason);
|
||||
void InnerDeleteAppExitReason(const std::string &bundleName);
|
||||
void InnerDeleteAppExitReason(const std::string &keyName);
|
||||
|
||||
void UpdateAbilityRecoverInfo(const std::string &bundleName,
|
||||
void UpdateAbilityRecoverInfo(uint32_t accessTokenId,
|
||||
const std::vector<std::string> &recoverInfoList, const std::vector<int> &sessionIdList);
|
||||
DistributedKv::Value ConvertAbilityRecoverInfoToValue(
|
||||
const std::vector<std::string> &recoverInfoList, const std::vector<int> &sessionIdList);
|
||||
void ConvertAbilityRecoverInfoFromValue(
|
||||
const DistributedKv::Value &value, std::vector<std::string> &recoverInfoList, std::vector<int> &sessionIdList);
|
||||
void InnerDeleteAbilityRecoverInfo(const std::string &bundleName);
|
||||
void InnerDeleteAbilityRecoverInfo(uint32_t accessTokenId);
|
||||
DistributedKv::Key GetAbilityRecoverInfoKey(uint32_t accessTokenId);
|
||||
DistributedKv::Value ConvertAppExitReasonInfoToValueOfExtensionName(
|
||||
const std::string &extensionListName, const AAFwk::ExitReason &exitReason);
|
||||
|
||||
|
@ -34,10 +34,11 @@ public:
|
||||
int32_t RecordProcessExtensionExitReason(
|
||||
const int32_t pid, const std::string &bundleName, const ExitReason &exitReason);
|
||||
int32_t RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason);
|
||||
int32_t RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason, const std::string bundleName,
|
||||
const int32_t uid);
|
||||
int32_t RecordProcessExitReason(const std::string &bundleName, int32_t uid, const ExitReason &exitReason);
|
||||
|
||||
private:
|
||||
int32_t RecordProcessExitReason(const int32_t pid, const std::string bundleName, const int32_t uid,
|
||||
const uint32_t accessTokenId, const ExitReason &exitReason);
|
||||
void GetActiveAbilityListByU0(const std::string bundleName, std::vector<std::string> &abilityLists,
|
||||
const int32_t pid);
|
||||
void GetActiveAbilityListByUser(const std::string bundleName, std::vector<std::string> &abilityLists,
|
||||
|
@ -16,8 +16,9 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_ABILITY_INTERCEPTOR_EXECUTER_H
|
||||
#define OHOS_ABILITY_RUNTIME_ABILITY_INTERCEPTOR_EXECUTER_H
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "ability_interceptor_interface.h"
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
@ -30,9 +31,15 @@ public:
|
||||
/**
|
||||
* Add Interceptor to Executer.
|
||||
*
|
||||
* @param interceptorName, interceptor name.
|
||||
* @param interceptor, interceptor handle the interception processing.
|
||||
*/
|
||||
void AddInterceptor(const std::shared_ptr<IAbilityInterceptor> &interceptor);
|
||||
void AddInterceptor(std::string interceptorName, const std::shared_ptr<IAbilityInterceptor> &interceptor);
|
||||
|
||||
/**
|
||||
* @param interceptorName, interceptor name.
|
||||
*/
|
||||
void RemoveInterceptor(std::string interceptorName);
|
||||
|
||||
/**
|
||||
* Excute the DoProcess of the interceptors.
|
||||
@ -41,7 +48,8 @@ public:
|
||||
|
||||
void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler);
|
||||
private:
|
||||
std::vector<std::shared_ptr<IAbilityInterceptor>> interceptorList_;
|
||||
std::mutex interceptorMapLock_;
|
||||
std::unordered_map<std::string, std::shared_ptr<IAbilityInterceptor>> interceptorMap_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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_SCREEN_UNLOCK_INTERCEPTOR
|
||||
#define OHOS_ABILITY_RUNTIME_SCREEN_UNLOCK_INTERCEPTOR
|
||||
|
||||
#include "ability_interceptor_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class ScreenUnlockInterceptor : public IAbilityInterceptor {
|
||||
public:
|
||||
ScreenUnlockInterceptor() = default;
|
||||
~ScreenUnlockInterceptor() = default;
|
||||
ErrCode DoProcess(AbilityInterceptorParam param) override;
|
||||
virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
|
||||
{
|
||||
return;
|
||||
};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ABILITY_RUNTIME_SCREEN_UNLOCK_INTERCEPTOR
|
@ -41,6 +41,7 @@ public:
|
||||
void SetFlags(int32_t flags);
|
||||
void SetCode(int32_t code);
|
||||
void SetUserId(int32_t userId);
|
||||
void SetAppIndex(int32_t appIndex);
|
||||
|
||||
int32_t GetType();
|
||||
std::string GetBundleName();
|
||||
@ -54,6 +55,7 @@ public:
|
||||
int32_t GetCode();
|
||||
int32_t GetUserId();
|
||||
bool IsEqualsRequestWant(const Want &otherWant);
|
||||
int32_t GetAppIndex();
|
||||
|
||||
private:
|
||||
int32_t type_ = {};
|
||||
@ -66,6 +68,7 @@ private:
|
||||
int32_t flags_ = {};
|
||||
int32_t code_ = {};
|
||||
int32_t userId_ = {};
|
||||
int32_t appIndex_ = 0;
|
||||
std::mutex wantsInfosMutex_;
|
||||
std::mutex requestWantMutex_;
|
||||
};
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
|
||||
public:
|
||||
sptr<IWantSender> GetWantSender(int32_t callingUid, int32_t uid, const bool isSystemApp,
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken);
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex = 0);
|
||||
int32_t SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo);
|
||||
void CancelWantSender(const bool isSystemApp, const sptr<IWantSender> &sender);
|
||||
|
||||
@ -162,7 +162,7 @@ public:
|
||||
|
||||
private:
|
||||
sptr<IWantSender> GetWantSenderLocked(const int32_t callingUid, const int32_t uid, const int32_t userId,
|
||||
WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken);
|
||||
WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex = 0);
|
||||
void MakeWantSenderCanceledLocked(PendingWantRecord &record);
|
||||
|
||||
sptr<PendingWantRecord> GetPendingWantRecordByKey(const std::shared_ptr<PendingWantKey> &key);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "screenlock_manager.h"
|
||||
#include "screenlock_callback_stub.h"
|
||||
|
||||
@ -30,5 +31,6 @@ public:
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // SUPPORT_SCREEN
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UNLOCK_SCREEN_CALLBACK_H
|
||||
|
@ -24,9 +24,11 @@
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "unlock_screen_callback.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "screenlock_manager.h"
|
||||
#include "screenlock_common.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
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<UIAbilityLifecycleManager>> GetUIAbilityManagers();
|
||||
std::shared_ptr<UIAbilityLifecycleManager> GetCurrentUIAbilityManager();
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "interceptor/crowd_test_interceptor.h"
|
||||
#include "interceptor/disposed_rule_interceptor.h"
|
||||
#include "interceptor/ecological_rule_interceptor.h"
|
||||
#include "interceptor/screen_unlock_interceptor.h"
|
||||
#include "interceptor/start_other_app_interceptor.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
@ -107,6 +108,7 @@
|
||||
#include "view_data.h"
|
||||
#include "xcollie/watchdog.h"
|
||||
#include "config_policy_utils.h"
|
||||
#include "running_multi_info.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "dialog_session_record.h"
|
||||
#include "application_anr_listener.h"
|
||||
@ -199,6 +201,7 @@ const std::string FOUNDATION_PROCESS_NAME = "foundation";
|
||||
const std::string IS_PRELOAD_UIEXTENSION_ABILITY = "ability.want.params.is_preload_uiextension_ability";
|
||||
const std::string UIEXTENSION_MODAL_TYPE = "ability.want.params.modalType";
|
||||
const std::string ATOMIC_SERVICE_PREFIX = "com.atomicservice.";
|
||||
constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohosSpecifiedProcessFlag";
|
||||
|
||||
constexpr char ASSERT_FAULT_DETAIL[] = "assertFaultDialogDetail";
|
||||
constexpr char PRODUCT_ASSERT_FAULT_DIALOG_ENABLED[] = "persisit.sys.abilityms.support_assert_fault_dialog";
|
||||
@ -435,18 +438,19 @@ void AbilityManagerService::InitDeepLinkReserve()
|
||||
void AbilityManagerService::InitInterceptor()
|
||||
{
|
||||
interceptorExecuter_ = std::make_shared<AbilityInterceptorExecuter>();
|
||||
interceptorExecuter_->AddInterceptor(std::make_shared<CrowdTestInterceptor>());
|
||||
interceptorExecuter_->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
interceptorExecuter_->AddInterceptor("ScreenUnlock", std::make_shared<ScreenUnlockInterceptor>());
|
||||
interceptorExecuter_->AddInterceptor("CrowdTest", std::make_shared<CrowdTestInterceptor>());
|
||||
interceptorExecuter_->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
|
||||
afterCheckExecuter_ = std::make_shared<AbilityInterceptorExecuter>();
|
||||
afterCheckExecuter_->AddInterceptor(std::make_shared<StartOtherAppInterceptor>());
|
||||
afterCheckExecuter_->AddInterceptor(std::make_shared<DisposedRuleInterceptor>());
|
||||
afterCheckExecuter_->AddInterceptor(std::make_shared<EcologicalRuleInterceptor>());
|
||||
afterCheckExecuter_->AddInterceptor("StartOtherApp", std::make_shared<StartOtherAppInterceptor>());
|
||||
afterCheckExecuter_->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>());
|
||||
afterCheckExecuter_->AddInterceptor("EcologicalRule", std::make_shared<EcologicalRuleInterceptor>());
|
||||
afterCheckExecuter_->SetTaskHandler(taskHandler_);
|
||||
bool isAppJumpEnabled = OHOS::system::GetBoolParameter(
|
||||
OHOS::AppExecFwk::PARAMETER_APP_JUMP_INTERCEPTOR_ENABLE, false);
|
||||
if (isAppJumpEnabled) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "App jump intercetor enabled, add AbilityJumpInterceptor to Executer");
|
||||
interceptorExecuter_->AddInterceptor(std::make_shared<AbilityJumpInterceptor>());
|
||||
interceptorExecuter_->AddInterceptor("AbilityJump", std::make_shared<AbilityJumpInterceptor>());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1159,6 +1163,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
abilityRequest.want.SetParam(SPECIFY_TOKEN_ID, static_cast<int32_t>(specifyTokenId));
|
||||
abilityRequest.specifyTokenId = specifyTokenId;
|
||||
}
|
||||
abilityRequest.want.RemoveParam(PARAM_SPECIFIED_PROCESS_FLAG);
|
||||
// sceneboard
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
ReportEventToSuspendManager(abilityInfo);
|
||||
@ -1304,6 +1309,7 @@ int AbilityManagerService::StartAbilityDetails(const Want &want, const AbilitySt
|
||||
SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return result;
|
||||
}
|
||||
abilityRequest.want.RemoveParam(PARAM_SPECIFIED_PROCESS_FLAG);
|
||||
|
||||
auto abilityInfo = abilityRequest.abilityInfo;
|
||||
validUserId = abilityInfo.applicationInfo.singleton ? U0_USER_ID : validUserId;
|
||||
@ -1747,6 +1753,7 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
|
||||
abilityRequest.want.SetParam(SPECIFY_TOKEN_ID, static_cast<int32_t>(specifyTokenId));
|
||||
abilityRequest.specifyTokenId = specifyTokenId;
|
||||
}
|
||||
abilityRequest.want.RemoveParam(PARAM_SPECIFIED_PROCESS_FLAG);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
abilityRequest.userId = oriValidUserId;
|
||||
abilityRequest.want.SetParam(IS_CALL_BY_SCB, false);
|
||||
@ -2141,7 +2148,7 @@ int32_t AbilityManagerService::ForceExitApp(const int32_t pid, const ExitReason
|
||||
}
|
||||
|
||||
CHECK_POINTER_AND_RETURN(appExitReasonHelper_, ERR_NULL_OBJECT);
|
||||
appExitReasonHelper_->RecordProcessExitReason(NO_PID, exitReason, bundleName, uid);
|
||||
appExitReasonHelper_->RecordProcessExitReason(bundleName, uid, exitReason);
|
||||
|
||||
return DelayedSingleton<AppScheduler>::GetInstance()->KillApplication(bundleName);
|
||||
}
|
||||
@ -3266,7 +3273,8 @@ int AbilityManagerService::CloseUIAbilityBySCB(const sptr<SessionInfo> &sessionI
|
||||
if (sessionInfo->isClearSession) {
|
||||
const auto &abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->
|
||||
DeleteAbilityRecoverInfo(abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name);
|
||||
DeleteAbilityRecoverInfo(abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName,
|
||||
abilityInfo.name);
|
||||
}
|
||||
|
||||
EventInfo eventInfo;
|
||||
@ -4146,6 +4154,7 @@ sptr<IWantSender> AbilityManagerService::GetWantSender(
|
||||
}
|
||||
|
||||
int32_t appUid = 0;
|
||||
int32_t appIndex = 0;
|
||||
if (!wantSenderInfo.allWants.empty()) {
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
std::string bundleName = wantSenderInfo.allWants.back().want.GetElement().GetBundleName();
|
||||
@ -4154,6 +4163,7 @@ sptr<IWantSender> AbilityManagerService::GetWantSender(
|
||||
if (bundleMgrResult) {
|
||||
appUid = bundleInfo.uid;
|
||||
}
|
||||
GetRunningMultiAppIndex(bundleName, callerUid, appIndex);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "App bundleName: %{public}s, uid: %{public}d", bundleName.c_str(), appUid);
|
||||
}
|
||||
if (!CheckSenderWantInfo(callerUid, wantSenderInfo)) {
|
||||
@ -4171,8 +4181,9 @@ sptr<IWantSender> AbilityManagerService::GetWantSender(
|
||||
}
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName = %{public}s", wantSenderInfo.bundleName.c_str());
|
||||
return pendingWantManager->GetWantSender(callerUid, appUid, isSystemApp, wantSenderInfo, callerToken);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName = %{public}s, appIndex:%{public}d",
|
||||
wantSenderInfo.bundleName.c_str(), appIndex);
|
||||
return pendingWantManager->GetWantSender(callerUid, appUid, isSystemApp, wantSenderInfo, callerToken, appIndex);
|
||||
}
|
||||
|
||||
int AbilityManagerService::SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo)
|
||||
@ -5967,7 +5978,7 @@ int32_t AbilityManagerService::UninstallAppInner(const std::string &bundleName,
|
||||
if (isUpgrade) {
|
||||
CHECK_POINTER_AND_RETURN(appExitReasonHelper_, ERR_NULL_OBJECT);
|
||||
AAFwk::ExitReason exitReason = { REASON_UPGRADE, exitMsg };
|
||||
appExitReasonHelper_->RecordProcessExitReason(NO_PID, exitReason, bundleName, uid);
|
||||
appExitReasonHelper_->RecordProcessExitReason(bundleName, uid, exitReason);
|
||||
}
|
||||
|
||||
CHECK_POINTER_AND_RETURN(subManagersHelper_, ERR_NULL_OBJECT);
|
||||
@ -5977,7 +5988,7 @@ int32_t AbilityManagerService::UninstallAppInner(const std::string &bundleName,
|
||||
return UNINSTALL_APP_FAILED;
|
||||
}
|
||||
if (!isUpgrade) {
|
||||
DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->DeleteAppExitReason(bundleName);
|
||||
DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->DeleteAppExitReason(bundleName, uid);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -6438,6 +6449,7 @@ void AbilityManagerService::SubscribeScreenUnlockedEvent()
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid abilityMgr pointer.");
|
||||
return;
|
||||
}
|
||||
abilityMgr->RemoveScreenUnlockInterceptor();
|
||||
abilityMgr->StartAutoStartupApps();
|
||||
abilityMgr->UnSubscribeScreenUnlockedEvent();
|
||||
};
|
||||
@ -6477,6 +6489,11 @@ void AbilityManagerService::RetrySubscribeScreenUnlockedEvent(int32_t retryCount
|
||||
taskHandler_->SubmitTask(retrySubscribeScreenUnlockedEventTask, "RetrySubscribeScreenUnlockedEvent", delaytime);
|
||||
}
|
||||
|
||||
void AbilityManagerService::RemoveScreenUnlockInterceptor()
|
||||
{
|
||||
interceptorExecuter_->RemoveInterceptor("ScreenUnlock");
|
||||
}
|
||||
|
||||
void AbilityManagerService::ConnectBmsService()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s", __func__);
|
||||
@ -7077,7 +7094,7 @@ void AbilityManagerService::EnableRecoverAbility(const sptr<IRemoteObject>& toke
|
||||
CHECK_POINTER(uiAbilityManager);
|
||||
const auto& abilityInfo = record->GetAbilityInfo();
|
||||
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->AddAbilityRecoverInfo(
|
||||
abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name,
|
||||
abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName, abilityInfo.name,
|
||||
uiAbilityManager->GetSessionIdByAbilityToken(token));
|
||||
} else {
|
||||
auto missionListMgr = GetMissionListManagerByUserId(userId);
|
||||
@ -10680,5 +10697,26 @@ int32_t AbilityManagerService::TransferAbilityResultForExtension(const sptr<IRem
|
||||
abilityRecord->SendResultToCallers();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void AbilityManagerService::GetRunningMultiAppIndex(const std::string &bundleName, int32_t uid, int32_t &appIndex)
|
||||
{
|
||||
AppExecFwk::RunningMultiAppInfo runningMultiAppInfo;
|
||||
auto appMgr = GetAppMgr();
|
||||
if (appMgr == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "GetAppMgr failed");
|
||||
return;
|
||||
}
|
||||
auto ret = appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "GetRunningMultiAppInfo failed bundleName = %{public}s",
|
||||
bundleName.c_str());
|
||||
}
|
||||
for (auto &item : runningMultiAppInfo.runningAppClones) {
|
||||
if (item.uid == uid) {
|
||||
appIndex = item.appCloneIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -19,10 +19,12 @@
|
||||
#include <chrono>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "os_account_manager_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@ -88,15 +90,16 @@ bool AppExitReasonDataManager::CheckKvStore()
|
||||
return kvStorePtr_ != nullptr;
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::SetAppExitReason(const std::string &bundleName,
|
||||
int32_t AppExitReasonDataManager::SetAppExitReason(const std::string &bundleName, uint32_t accessTokenId,
|
||||
const std::vector<std::string> &abilityList, const AAFwk::ExitReason &exitReason)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
auto accessTokenIdStr = std::to_string(accessTokenId);
|
||||
if (bundleName.empty() || accessTokenIdStr.empty()) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid value");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s", bundleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s, tokenId: %{private}u", bundleName.c_str(), accessTokenId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -105,7 +108,7 @@ int32_t AppExitReasonDataManager::SetAppExitReason(const std::string &bundleName
|
||||
}
|
||||
}
|
||||
|
||||
DistributedKv::Key key(bundleName);
|
||||
DistributedKv::Key key(accessTokenIdStr);
|
||||
DistributedKv::Value value = ConvertAppExitReasonInfoToValue(abilityList, exitReason);
|
||||
DistributedKv::Status status;
|
||||
{
|
||||
@ -120,14 +123,22 @@ int32_t AppExitReasonDataManager::SetAppExitReason(const std::string &bundleName
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::DeleteAppExitReason(const std::string &bundleName)
|
||||
int32_t AppExitReasonDataManager::DeleteAppExitReason(const std::string &bundleName, int32_t uid)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
int32_t userId;
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->
|
||||
GetOsAccountLocalIdFromUid(uid, userId) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get GetOsAccountLocalIdFromUid failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
uint32_t accessTokenId = Security::AccessToken::AccessTokenKit::GetHapTokenID(userId, bundleName, 0);
|
||||
auto accessTokenIdStr = std::to_string(accessTokenId);
|
||||
if (bundleName.empty() || accessTokenIdStr.empty()) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid value.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s.", bundleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s, tokenId: %{private}u", bundleName.c_str(), accessTokenId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -146,7 +157,7 @@ int32_t AppExitReasonDataManager::DeleteAppExitReason(const std::string &bundleN
|
||||
|
||||
for (const auto &item : allEntries) {
|
||||
const auto &keyValue = item.key.ToString();
|
||||
if (keyValue != bundleName && keyValue.find(keyUiExten) == std::string::npos) {
|
||||
if (keyValue != accessTokenIdStr && keyValue.find(keyUiExten) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -162,15 +173,15 @@ int32_t AppExitReasonDataManager::DeleteAppExitReason(const std::string &bundleN
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::GetAppExitReason(const std::string &bundleName, const std::string &abilityName,
|
||||
bool &isSetReason, AAFwk::ExitReason &exitReason)
|
||||
int32_t AppExitReasonDataManager::GetAppExitReason(const std::string &bundleName, uint32_t accessTokenId,
|
||||
const std::string &abilityName, bool &isSetReason, AAFwk::ExitReason &exitReason)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
auto accessTokenIdStr = std::to_string(accessTokenId);
|
||||
if (bundleName.empty() || accessTokenIdStr.empty()) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s!", bundleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s, tokenId: %{private}u", bundleName.c_str(), accessTokenId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -190,20 +201,20 @@ int32_t AppExitReasonDataManager::GetAppExitReason(const std::string &bundleName
|
||||
int64_t time_stamp;
|
||||
isSetReason = false;
|
||||
for (const auto &item : allEntries) {
|
||||
if (item.key.ToString() == bundleName) {
|
||||
if (item.key.ToString() == accessTokenIdStr) {
|
||||
ConvertAppExitReasonInfoFromValue(item.value, exitReason, time_stamp, abilityList);
|
||||
auto pos = std::find(abilityList.begin(), abilityList.end(), abilityName);
|
||||
if (pos != abilityList.end()) {
|
||||
isSetReason = true;
|
||||
abilityList.erase(std::remove(abilityList.begin(), abilityList.end(), abilityName), abilityList.end());
|
||||
UpdateAppExitReason(bundleName, abilityList, exitReason);
|
||||
UpdateAppExitReason(accessTokenId, abilityList, exitReason);
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "current bundle name: %{public}s reason: %{public}d exitMsg: %{public}s \
|
||||
abilityName:%{public}s isSetReason:%{public}d",
|
||||
item.key.ToString().c_str(), exitReason.reason, exitReason.exitMsg.c_str(), abilityName.c_str(),
|
||||
isSetReason);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "current bundle name: %{public}s, tokenId:%{private}u, reason: %{public}d,"
|
||||
" exitMsg: %{public}s, abilityName:%{public}s isSetReason:%{public}d",
|
||||
bundleName.c_str(), accessTokenId, exitReason.reason, exitReason.exitMsg.c_str(),
|
||||
abilityName.c_str(), isSetReason);
|
||||
if (abilityList.empty()) {
|
||||
InnerDeleteAppExitReason(bundleName);
|
||||
InnerDeleteAppExitReason(accessTokenIdStr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -212,15 +223,15 @@ int32_t AppExitReasonDataManager::GetAppExitReason(const std::string &bundleName
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void AppExitReasonDataManager::UpdateAppExitReason(const std::string &bundleName,
|
||||
const std::vector<std::string> &abilityList, const AAFwk::ExitReason &exitReason)
|
||||
void AppExitReasonDataManager::UpdateAppExitReason(uint32_t accessTokenId, const std::vector<std::string> &abilityList,
|
||||
const AAFwk::ExitReason &exitReason)
|
||||
{
|
||||
if (kvStorePtr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "kvStore is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
DistributedKv::Key key(bundleName);
|
||||
DistributedKv::Key key(std::to_string(accessTokenId));
|
||||
DistributedKv::Status status;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
@ -285,14 +296,14 @@ void AppExitReasonDataManager::ConvertAppExitReasonInfoFromValue(const Distribut
|
||||
}
|
||||
}
|
||||
|
||||
void AppExitReasonDataManager::InnerDeleteAppExitReason(const std::string &bundleName)
|
||||
void AppExitReasonDataManager::InnerDeleteAppExitReason(const std::string &keyName)
|
||||
{
|
||||
if (kvStorePtr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "kvStore is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
DistributedKv::Key key(bundleName);
|
||||
DistributedKv::Key key(keyName);
|
||||
DistributedKv::Status status;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
@ -304,12 +315,12 @@ void AppExitReasonDataManager::InnerDeleteAppExitReason(const std::string &bundl
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::AddAbilityRecoverInfo(const std::string &bundleName,
|
||||
int32_t AppExitReasonDataManager::AddAbilityRecoverInfo(uint32_t accessTokenId,
|
||||
const std::string &moduleName, const std::string &abilityName, const int &sessionId)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR,
|
||||
"AddAbilityRecoverInfo bundle %{public}s module %{public}s ability %{public}s id %{public}d ",
|
||||
bundleName.c_str(), moduleName.c_str(), abilityName.c_str(), sessionId);
|
||||
"AddAbilityRecoverInfo tokenId %{private}u module %{public}s ability %{public}s id %{public}d ",
|
||||
accessTokenId, moduleName.c_str(), abilityName.c_str(), sessionId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -318,7 +329,7 @@ int32_t AppExitReasonDataManager::AddAbilityRecoverInfo(const std::string &bundl
|
||||
}
|
||||
}
|
||||
|
||||
DistributedKv::Key key(KEY_RECOVER_INFO_PREFIX + bundleName);
|
||||
DistributedKv::Key key = GetAbilityRecoverInfoKey(accessTokenId);
|
||||
DistributedKv::Value value;
|
||||
DistributedKv::Status status = kvStorePtr_->Get(key, value);
|
||||
if (status != DistributedKv::Status::SUCCESS && status != DistributedKv::Status::KEY_NOT_FOUND) {
|
||||
@ -358,10 +369,10 @@ int32_t AppExitReasonDataManager::AddAbilityRecoverInfo(const std::string &bundl
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::DeleteAbilityRecoverInfo(
|
||||
const std::string &bundleName, const std::string &moduleName, const std::string &abilityName)
|
||||
uint32_t accessTokenId, const std::string &moduleName, const std::string &abilityName)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "DeleteAbilityRecoverInfo bundle %{public}s module %{public}s ability %{public}s ",
|
||||
bundleName.c_str(), moduleName.c_str(), abilityName.c_str());
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "DeleteAbilityRecoverInfo tokenId %{private}u module %{public}s ability %{public}s ",
|
||||
accessTokenId, moduleName.c_str(), abilityName.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -370,7 +381,7 @@ int32_t AppExitReasonDataManager::DeleteAbilityRecoverInfo(
|
||||
}
|
||||
}
|
||||
|
||||
DistributedKv::Key key(KEY_RECOVER_INFO_PREFIX + bundleName);
|
||||
DistributedKv::Key key = GetAbilityRecoverInfoKey(accessTokenId);
|
||||
DistributedKv::Value value;
|
||||
DistributedKv::Status status = kvStorePtr_->Get(key, value);
|
||||
if (status != DistributedKv::Status::SUCCESS) {
|
||||
@ -389,11 +400,11 @@ int32_t AppExitReasonDataManager::DeleteAbilityRecoverInfo(
|
||||
int index = std::distance(recoverInfoList.begin(), pos);
|
||||
sessionIdList.erase(std::remove(sessionIdList.begin(), sessionIdList.end(), sessionIdList[index]),
|
||||
sessionIdList.end());
|
||||
UpdateAbilityRecoverInfo(bundleName, recoverInfoList, sessionIdList);
|
||||
UpdateAbilityRecoverInfo(accessTokenId, recoverInfoList, sessionIdList);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "DeleteAbilityRecoverInfo remove recoverInfo succeed");
|
||||
}
|
||||
if (recoverInfoList.empty()) {
|
||||
InnerDeleteAbilityRecoverInfo(bundleName);
|
||||
InnerDeleteAbilityRecoverInfo(accessTokenId);
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "DeleteAbilityRecoverInfo finished");
|
||||
@ -401,10 +412,10 @@ int32_t AppExitReasonDataManager::DeleteAbilityRecoverInfo(
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::GetAbilityRecoverInfo(
|
||||
const std::string &bundleName, const std::string &moduleName, const std::string &abilityName, bool &hasRecoverInfo)
|
||||
uint32_t accessTokenId, const std::string &moduleName, const std::string &abilityName, bool &hasRecoverInfo)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "GetAbilityRecoverInfo bundle %{public}s module %{public}s abillity %{public}s ",
|
||||
bundleName.c_str(), moduleName.c_str(), abilityName.c_str());
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "GetAbilityRecoverInfo tokenId %{private}u module %{public}s abillity %{public}s ",
|
||||
accessTokenId, moduleName.c_str(), abilityName.c_str());
|
||||
hasRecoverInfo = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
@ -414,7 +425,7 @@ int32_t AppExitReasonDataManager::GetAbilityRecoverInfo(
|
||||
}
|
||||
}
|
||||
|
||||
DistributedKv::Key key(KEY_RECOVER_INFO_PREFIX + bundleName);
|
||||
DistributedKv::Key key = GetAbilityRecoverInfoKey(accessTokenId);
|
||||
DistributedKv::Value value;
|
||||
DistributedKv::Status status = kvStorePtr_->Get(key, value);
|
||||
if (status != DistributedKv::Status::SUCCESS) {
|
||||
@ -438,11 +449,11 @@ int32_t AppExitReasonDataManager::GetAbilityRecoverInfo(
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppExitReasonDataManager::GetAbilitySessionId(const std::string &bundleName,
|
||||
int32_t AppExitReasonDataManager::GetAbilitySessionId(uint32_t accessTokenId,
|
||||
const std::string &moduleName, const std::string &abilityName, int &sessionId)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "GetAbilityRecoverInfo bundle %{public}s bundle %{public}s bundle %{public}s ",
|
||||
bundleName.c_str(), moduleName.c_str(), abilityName.c_str());
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "GetAbilityRecoverInfo tokenId %{private}u bundle %{public}s bundle %{public}s ",
|
||||
accessTokenId, moduleName.c_str(), abilityName.c_str());
|
||||
sessionId = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
@ -452,7 +463,7 @@ int32_t AppExitReasonDataManager::GetAbilitySessionId(const std::string &bundleN
|
||||
}
|
||||
}
|
||||
|
||||
DistributedKv::Key key(KEY_RECOVER_INFO_PREFIX + bundleName);
|
||||
DistributedKv::Key key = GetAbilityRecoverInfoKey(accessTokenId);
|
||||
DistributedKv::Value value;
|
||||
DistributedKv::Status status = kvStorePtr_->Get(key, value);
|
||||
if (status != DistributedKv::Status::SUCCESS) {
|
||||
@ -545,7 +556,7 @@ bool AppExitReasonDataManager::GetUIExtensionAbilityExitReason(const std::string
|
||||
return isHaveReason;
|
||||
}
|
||||
|
||||
void AppExitReasonDataManager::UpdateAbilityRecoverInfo(const std::string &bundleName,
|
||||
void AppExitReasonDataManager::UpdateAbilityRecoverInfo(uint32_t accessTokenId,
|
||||
const std::vector<std::string> &recoverInfoList, const std::vector<int> &sessionIdList)
|
||||
{
|
||||
if (kvStorePtr_ == nullptr) {
|
||||
@ -553,7 +564,7 @@ void AppExitReasonDataManager::UpdateAbilityRecoverInfo(const std::string &bundl
|
||||
return;
|
||||
}
|
||||
|
||||
DistributedKv::Key key(KEY_RECOVER_INFO_PREFIX + bundleName);
|
||||
DistributedKv::Key key = GetAbilityRecoverInfoKey(accessTokenId);
|
||||
DistributedKv::Status status;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
@ -616,14 +627,14 @@ void AppExitReasonDataManager::ConvertAbilityRecoverInfoFromValue(const Distribu
|
||||
}
|
||||
}
|
||||
|
||||
void AppExitReasonDataManager::InnerDeleteAbilityRecoverInfo(const std::string &bundleName)
|
||||
void AppExitReasonDataManager::InnerDeleteAbilityRecoverInfo(uint32_t accessTokenId)
|
||||
{
|
||||
if (kvStorePtr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "kvStore is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
DistributedKv::Key key(KEY_RECOVER_INFO_PREFIX + bundleName);
|
||||
DistributedKv::Key key = GetAbilityRecoverInfoKey(accessTokenId);
|
||||
DistributedKv::Status status;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
@ -635,6 +646,11 @@ void AppExitReasonDataManager::InnerDeleteAbilityRecoverInfo(const std::string &
|
||||
}
|
||||
}
|
||||
|
||||
DistributedKv::Key AppExitReasonDataManager::GetAbilityRecoverInfoKey(uint32_t accessTokenId)
|
||||
{
|
||||
return DistributedKv::Key(KEY_RECOVER_INFO_PREFIX + std::to_string(accessTokenId));
|
||||
}
|
||||
|
||||
DistributedKv::Value AppExitReasonDataManager::ConvertAppExitReasonInfoToValueOfExtensionName(
|
||||
const std::string &extensionListName, const AAFwk::ExitReason &exitReason)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "ability_util.h"
|
||||
#include "ability_manager_errors.h"
|
||||
#include "accesstoken_kit.h"
|
||||
#include "app_exit_reason_data_manager.h"
|
||||
#include "app_scheduler.h"
|
||||
#include "bundle_constants.h"
|
||||
@ -27,6 +28,7 @@
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "os_account_manager_wrapper.h"
|
||||
#include "scene_board_judgement.h"
|
||||
#include "singleton.h"
|
||||
#include "sub_managers_helper.h"
|
||||
@ -47,15 +49,16 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason)
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto bms = AbilityUtil::GetBundleManagerHelper();
|
||||
CHECK_POINTER_AND_RETURN(bms, ERR_NULL_OBJECT);
|
||||
std::string bundleName;
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
if (IN_PROCESS_CALL(bms->GetNameForUid(callerUid, bundleName)) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get Bundle Name failed.");
|
||||
return GET_BUNDLE_INFO_FAILED;
|
||||
auto pid = IPCSkeleton::GetCallingRealPid();
|
||||
AppExecFwk::ApplicationInfo application;
|
||||
bool debug = false;
|
||||
auto ret = IN_PROCESS_CALL(DelayedSingleton<AppScheduler>::GetInstance()->GetApplicationInfoByProcessID(pid,
|
||||
application, debug));
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "GetApplicationInfoByProcessID failed.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto bundleName = application.bundleName;
|
||||
int32_t resultCode = RecordProcessExtensionExitReason(NO_PID, bundleName, exitReason);
|
||||
if (resultCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Record Process Extension Exit Reason failed.code: %{public}d", resultCode);
|
||||
@ -68,13 +71,12 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason)
|
||||
CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_NULL_OBJECT);
|
||||
uiAbilityManager->GetActiveAbilityList(bundleName, abilityList);
|
||||
} else {
|
||||
auto currentMissionListManager = subManagersHelper_->GetCurrentMissionListManager();
|
||||
CHECK_POINTER_AND_RETURN(currentMissionListManager, ERR_NULL_OBJECT);
|
||||
currentMissionListManager->GetActiveAbilityList(bundleName, abilityList);
|
||||
auto missionListManager = subManagersHelper_->GetMissionListManagerByUid(IPCSkeleton::GetCallingUid());
|
||||
CHECK_POINTER_AND_RETURN(missionListManager, ERR_NULL_OBJECT);
|
||||
missionListManager->GetActiveAbilityList(bundleName, abilityList);
|
||||
}
|
||||
|
||||
auto pid = IPCSkeleton::GetCallingRealPid();
|
||||
auto ret = DelayedSingleton<AppScheduler>::GetInstance()->NotifyAppMgrRecordExitReason(pid, exitReason.reason,
|
||||
ret = DelayedSingleton<AppScheduler>::GetInstance()->NotifyAppMgrRecordExitReason(pid, exitReason.reason,
|
||||
exitReason.exitMsg);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyAppMgrRecordExitReason failed.code: %{public}d", ret);
|
||||
@ -84,38 +86,56 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason)
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Active abilityLists empty.");
|
||||
return ERR_GET_ACTIVE_ABILITY_LIST_EMPTY;
|
||||
}
|
||||
|
||||
return DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->SetAppExitReason(
|
||||
bundleName, abilityList, exitReason);
|
||||
return DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->SetAppExitReason(bundleName,
|
||||
application.accessTokenId, abilityList, exitReason);
|
||||
}
|
||||
|
||||
int32_t AppExitReasonHelper::RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason)
|
||||
{
|
||||
std::string bundleName;
|
||||
int32_t uid;
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetBundleNameByPid(pid, bundleName, uid);
|
||||
if (bundleName.empty()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get bundle name by pid failed.");
|
||||
return GET_BUNDLE_INFO_FAILED;
|
||||
AppExecFwk::ApplicationInfo application;
|
||||
bool debug = false;
|
||||
auto ret = IN_PROCESS_CALL(DelayedSingleton<AppScheduler>::GetInstance()->GetApplicationInfoByProcessID(pid,
|
||||
application, debug));
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "GetApplicationInfoByProcessID failed.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto bundleName = application.bundleName;
|
||||
int32_t resultCode = RecordProcessExtensionExitReason(pid, bundleName, exitReason);
|
||||
if (resultCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Record Process Extension Exit Reason failed.code: %{public}d", resultCode);
|
||||
}
|
||||
|
||||
return RecordProcessExitReason(pid, exitReason, bundleName, uid);
|
||||
return RecordProcessExitReason(pid, bundleName, application.uid, application.accessTokenId, exitReason);
|
||||
}
|
||||
|
||||
int32_t AppExitReasonHelper::RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason,
|
||||
const std::string bundleName, const int32_t uid)
|
||||
int32_t AppExitReasonHelper::RecordProcessExitReason(const std::string &bundleName, int32_t uid,
|
||||
const ExitReason &exitReason)
|
||||
{
|
||||
int32_t userId;
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->
|
||||
GetOsAccountLocalIdFromUid(uid, userId) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get GetOsAccountLocalIdFromUid failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
uint32_t accessTokenId = Security::AccessToken::AccessTokenKit::GetHapTokenID(userId, bundleName, 0);
|
||||
return RecordProcessExitReason(NO_PID, bundleName, uid, accessTokenId, exitReason);
|
||||
}
|
||||
|
||||
int32_t AppExitReasonHelper::RecordProcessExitReason(const int32_t pid, const std::string bundleName,
|
||||
const int32_t uid, const uint32_t accessTokenId, const ExitReason &exitReason)
|
||||
{
|
||||
if (!IsExitReasonValid(exitReason)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Force exit reason invalid.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int32_t targetUserId = uid / AppExecFwk::Constants::BASE_USER_RANGE;
|
||||
int32_t targetUserId;
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->
|
||||
GetOsAccountLocalIdFromUid(uid, targetUserId) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get GetOsAccountLocalIdFromUid failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::vector<std::string> abilityLists;
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
GetActiveAbilityListFromUIAabilityManager(bundleName, abilityLists, targetUserId, pid);
|
||||
@ -135,8 +155,8 @@ int32_t AppExitReasonHelper::RecordProcessExitReason(const int32_t pid, const Ex
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Active abilityLists empty.");
|
||||
return ERR_GET_ACTIVE_ABILITY_LIST_EMPTY;
|
||||
}
|
||||
return DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->SetAppExitReason(
|
||||
bundleName, abilityLists, exitReason);
|
||||
return DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->SetAppExitReason(bundleName,
|
||||
accessTokenId, abilityLists, exitReason);
|
||||
}
|
||||
|
||||
int32_t AppExitReasonHelper::RecordProcessExtensionExitReason(
|
||||
|
@ -468,6 +468,10 @@ int AppScheduler::GetApplicationInfoByProcessID(const int pid, AppExecFwk::Appli
|
||||
|
||||
int32_t AppScheduler::NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg)
|
||||
{
|
||||
if (pid < 0) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "NotifyAppMgrRecordExitReason failed, pid <= 0.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
CHECK_POINTER_AND_RETURN(appMgrClient_, INNER_ERR);
|
||||
auto ret = static_cast<int32_t>(IN_PROCESS_CALL(appMgrClient_->NotifyAppMgrRecordExitReason(pid, reason, exitMsg)));
|
||||
if (ret != ERR_OK) {
|
||||
|
@ -19,10 +19,21 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
void AbilityInterceptorExecuter::AddInterceptor(const std::shared_ptr<IAbilityInterceptor> &interceptor)
|
||||
void AbilityInterceptorExecuter::AddInterceptor(std::string interceptorName,
|
||||
const std::shared_ptr<IAbilityInterceptor> &interceptor)
|
||||
{
|
||||
std::lock_guard lock(interceptorMapLock_);
|
||||
if (interceptor != nullptr) {
|
||||
interceptorList_.push_back(interceptor);
|
||||
interceptorMap_[interceptorName] = interceptor;
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityInterceptorExecuter::RemoveInterceptor(std::string interceptorName)
|
||||
{
|
||||
std::lock_guard lock(interceptorMapLock_);
|
||||
auto iter = interceptorMap_.find(interceptorName);
|
||||
if (iter != interceptorMap_.end()) {
|
||||
interceptorMap_.erase(interceptorName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,9 +41,10 @@ ErrCode AbilityInterceptorExecuter::DoProcess(AbilityInterceptorParam param)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
int32_t result = ERR_OK;
|
||||
auto item = interceptorList_.begin();
|
||||
while (item != interceptorList_.end()) {
|
||||
result = (*item)->DoProcess(param);
|
||||
std::lock_guard lock(interceptorMapLock_);
|
||||
auto item = interceptorMap_.begin();
|
||||
while (item != interceptorMap_.end()) {
|
||||
result = (*item).second->DoProcess(param);
|
||||
if (result != ERR_OK) {
|
||||
break;
|
||||
} else {
|
||||
@ -45,11 +57,13 @@ ErrCode AbilityInterceptorExecuter::DoProcess(AbilityInterceptorParam param)
|
||||
void AbilityInterceptorExecuter::SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
for (auto &interceptor : interceptorList_) {
|
||||
if (interceptor == nullptr) {
|
||||
|
||||
std::lock_guard lock(interceptorMapLock_);
|
||||
for (auto &item : interceptorMap_) {
|
||||
if (item.second == nullptr) {
|
||||
continue;
|
||||
}
|
||||
interceptor->SetTaskHandler(taskHandler);
|
||||
(item.second)->SetTaskHandler(taskHandler);
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "interceptor/screen_unlock_interceptor.h"
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "ability_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "parameters.h"
|
||||
#include "start_ability_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
const std::string SUPPORT_SCREEN_UNLOCK_STARTUP = "persist.sys.ability.support.screen_unlock_startup";
|
||||
}
|
||||
ErrCode ScreenUnlockInterceptor::DoProcess(AbilityInterceptorParam param)
|
||||
{
|
||||
// xts reboot can still run
|
||||
std::string supportStart = OHOS::system::GetParameter(SUPPORT_SCREEN_UNLOCK_STARTUP, "false");
|
||||
if (supportStart == "true") {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Abilityms support screen unlock startup.");
|
||||
return ERR_OK;
|
||||
}
|
||||
// get target application info
|
||||
AppExecFwk::AbilityInfo targetAbilityInfo;
|
||||
if (StartAbilityUtils::startAbilityInfo != nullptr) {
|
||||
targetAbilityInfo = StartAbilityUtils::startAbilityInfo->abilityInfo;
|
||||
} else {
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "The bundleMgrHelper is nullptr.");
|
||||
return ERR_OK;
|
||||
}
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(param.want,
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, param.userId, targetAbilityInfo));
|
||||
}
|
||||
|
||||
// temp add isSystemApp pass, remove after systemapp adjust
|
||||
if (targetAbilityInfo.applicationInfo.isSystemApp ||
|
||||
targetAbilityInfo.applicationInfo.allowAppRunWhenDeviceFirstLocked) {
|
||||
return ERR_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Can not startup when device first locked.");
|
||||
return ERR_BLOCK_START_FIRST_BOOT_SCREEN_UNLOCK;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -4026,8 +4026,10 @@ void MissionListManager::SetLastExitReason(std::shared_ptr<AbilityRecord> &abili
|
||||
|
||||
ExitReason exitReason;
|
||||
bool isSetReason;
|
||||
auto accessTokenId = abilityRecord->GetAbilityInfo().applicationInfo.accessTokenId;
|
||||
DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->GetAppExitReason(
|
||||
abilityRecord->GetAbilityInfo().bundleName, abilityRecord->GetAbilityInfo().name, isSetReason, exitReason);
|
||||
abilityRecord->GetAbilityInfo().bundleName, accessTokenId, abilityRecord->GetAbilityInfo().name,
|
||||
isSetReason, exitReason);
|
||||
|
||||
if (isSetReason) {
|
||||
abilityRecord->SetLastExitReason(exitReason);
|
||||
|
@ -70,6 +70,11 @@ void PendingWantKey::SetUserId(int32_t userId)
|
||||
userId_ = userId;
|
||||
}
|
||||
|
||||
void PendingWantKey::SetAppIndex(int32_t appIndex)
|
||||
{
|
||||
appIndex_ = appIndex;
|
||||
}
|
||||
|
||||
int32_t PendingWantKey::GetType()
|
||||
{
|
||||
return type_;
|
||||
@ -128,6 +133,11 @@ int32_t PendingWantKey::GetUserId()
|
||||
return userId_;
|
||||
}
|
||||
|
||||
int32_t PendingWantKey::GetAppIndex()
|
||||
{
|
||||
return appIndex_;
|
||||
}
|
||||
|
||||
bool PendingWantKey::IsEqualsRequestWant(const Want &otherWant)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(requestWantMutex_);
|
||||
|
@ -45,7 +45,7 @@ PendingWantManager::~PendingWantManager()
|
||||
}
|
||||
|
||||
sptr<IWantSender> PendingWantManager::GetWantSender(int32_t callingUid, int32_t uid, const bool isSystemApp,
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken)
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "begin.");
|
||||
if (wantSenderInfo.type != static_cast<int32_t>(OperationType::SEND_COMMON_EVENT)) {
|
||||
@ -58,11 +58,11 @@ sptr<IWantSender> PendingWantManager::GetWantSender(int32_t callingUid, int32_t
|
||||
}
|
||||
|
||||
WantSenderInfo info = wantSenderInfo;
|
||||
return GetWantSenderLocked(callingUid, uid, wantSenderInfo.userId, info, callerToken);
|
||||
return GetWantSenderLocked(callingUid, uid, wantSenderInfo.userId, info, callerToken, appIndex);
|
||||
}
|
||||
|
||||
sptr<IWantSender> PendingWantManager::GetWantSenderLocked(const int32_t callingUid, const int32_t uid,
|
||||
const int32_t userId, WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken)
|
||||
const int32_t userId, WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t appIndex)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "begin");
|
||||
|
||||
@ -80,6 +80,7 @@ sptr<IWantSender> PendingWantManager::GetWantSenderLocked(const int32_t callingU
|
||||
pendingKey->SetFlags(wantSenderInfo.flags);
|
||||
pendingKey->SetUserId(wantSenderInfo.userId);
|
||||
pendingKey->SetType(wantSenderInfo.type);
|
||||
pendingKey->SetAppIndex(appIndex);
|
||||
if (wantSenderInfo.allWants.size() > 0) {
|
||||
pendingKey->SetRequestWant(wantSenderInfo.allWants.back().want);
|
||||
pendingKey->SetRequestResolvedType(wantSenderInfo.allWants.back().resolvedTypes);
|
||||
@ -150,6 +151,9 @@ bool PendingWantManager::CheckPendingWantRecordByKey(
|
||||
TAG_LOGW(AAFwkTag::WANTAGENT, "inputKey or key is nullptr!");
|
||||
return false;
|
||||
}
|
||||
if (inputKey->GetAppIndex() != key->GetAppIndex()) {
|
||||
return false;
|
||||
}
|
||||
if (inputKey->GetBundleName().compare(key->GetBundleName()) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iremote_object.h"
|
||||
#include "pending_want_manager.h"
|
||||
#include "int_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
@ -138,6 +139,7 @@ void PendingWantRecord::BuildSendWant(SenderInfo &senderInfo, Want &want)
|
||||
wantParams.SetParam(sendInfoWantParamKey, mapIter->second);
|
||||
}
|
||||
}
|
||||
wantParams.SetParam("ohos.extra.param.key.appCloneIndex", Integer::Box(key_->GetAppIndex()));
|
||||
want.SetParams(wantParams);
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ int UIAbilityLifecycleManager::StartUIAbility(AbilityRequest &abilityRequest, sp
|
||||
uiAbilityRecord->SetIsNewWant(sessionInfo->isNewWant);
|
||||
if (sessionInfo->isNewWant) {
|
||||
uiAbilityRecord->SetWant(abilityRequest.want);
|
||||
uiAbilityRecord->GetSessionInfo()->want.CloseAllFd();
|
||||
}
|
||||
} else {
|
||||
uiAbilityRecord = CreateAbilityRecord(abilityRequest, sessionInfo);
|
||||
@ -948,7 +949,8 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr<SessionInfo> &ses
|
||||
auto isStandard = abilityInfo.launchMode == AppExecFwk::LaunchMode::STANDARD && !abilityRequest.startRecent;
|
||||
if (!isStandard) {
|
||||
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->GetAbilitySessionId(
|
||||
abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name, sessionInfo->persistentId);
|
||||
abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName, abilityInfo.name,
|
||||
sessionInfo->persistentId);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "session id: %{public}d.", sessionInfo->persistentId);
|
||||
}
|
||||
}
|
||||
@ -1507,9 +1509,8 @@ void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const AAFwk::Wan
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s.", want.GetElement().GetURI().c_str());
|
||||
it->second.want.SetParam(PARAM_SPECIFIED_PROCESS_FLAG, flag);
|
||||
AbilityRequest abilityRequest = it->second;
|
||||
std::string specifiedProcessFlag = flag;
|
||||
abilityRequest.want.SetParam(PARAM_SPECIFIED_PROCESS_FLAG, specifiedProcessFlag);
|
||||
auto isSpecified = (abilityRequest.abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED);
|
||||
if (isSpecified) {
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->StartSpecifiedAbility(
|
||||
@ -1782,10 +1783,12 @@ void UIAbilityLifecycleManager::SetRevicerInfo(const AbilityRequest &abilityRequ
|
||||
if (!isStandard) {
|
||||
bool hasRecoverInfo = false;
|
||||
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->
|
||||
GetAbilityRecoverInfo(abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name, hasRecoverInfo);
|
||||
GetAbilityRecoverInfo(abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName, abilityInfo.name,
|
||||
hasRecoverInfo);
|
||||
abilityRecord->UpdateRecoveryInfo(hasRecoverInfo);
|
||||
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->
|
||||
DeleteAbilityRecoverInfo(abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name);
|
||||
DeleteAbilityRecoverInfo(abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName,
|
||||
abilityInfo.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1804,8 +1807,10 @@ void UIAbilityLifecycleManager::SetLastExitReason(std::shared_ptr<AbilityRecord>
|
||||
|
||||
ExitReason exitReason;
|
||||
bool isSetReason;
|
||||
auto accessTokenId = abilityRecord->GetAbilityInfo().applicationInfo.accessTokenId;
|
||||
DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->GetAppExitReason(
|
||||
abilityRecord->GetAbilityInfo().bundleName, abilityRecord->GetAbilityInfo().name, isSetReason, exitReason);
|
||||
abilityRecord->GetAbilityInfo().bundleName, accessTokenId, abilityRecord->GetAbilityInfo().name,
|
||||
isSetReason, exitReason);
|
||||
|
||||
if (isSetReason) {
|
||||
abilityRecord->SetLastExitReason(exitReason);
|
||||
@ -1975,7 +1980,8 @@ void UIAbilityLifecycleManager::UninstallApp(const std::string &bundleName, int3
|
||||
auto &abilityInfo = it->second->GetAbilityInfo();
|
||||
if (abilityInfo.bundleName == bundleName && it->second->GetUid() == uid) {
|
||||
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->
|
||||
DeleteAbilityRecoverInfo(abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name);
|
||||
DeleteAbilityRecoverInfo(abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName,
|
||||
abilityInfo.name);
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ bool UnlockScreenManager::UnlockScreen()
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#ifdef SUPPORT_SCREEN
|
||||
bool isScreenLocked = OHOS::ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked();
|
||||
bool isScreenSecured = OHOS::ScreenLock::ScreenLockManager::GetInstance()->GetSecure();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "isScreenLocked: %{public}d, isScreenSecured: %{public}d",
|
||||
@ -63,6 +64,7 @@ bool UnlockScreenManager::UnlockScreen()
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool isScreenOn = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
|
@ -269,6 +269,20 @@ std::shared_ptr<MissionListManager> SubManagersHelper::GetMissionListManagerByUs
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<MissionListManager> SubManagersHelper::GetMissionListManagerByUid(int32_t uid)
|
||||
{
|
||||
int32_t userId = INVALID_USER_ID;
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->GetOsAccountLocalIdFromUid(
|
||||
uid, userId) != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
if (userId == U0_USER_ID) {
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
return currentMissionListManager_;
|
||||
}
|
||||
return GetMissionListManagerByUserId(userId);
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> SubManagersHelper::GetUIAbilityManagers()
|
||||
{
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
|
@ -648,6 +648,15 @@ private:
|
||||
*/
|
||||
int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning) override;
|
||||
|
||||
/**
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning) override;
|
||||
|
||||
/**
|
||||
* Whether the current application process is the last surviving process.
|
||||
*
|
||||
|
@ -416,6 +416,15 @@ public:
|
||||
*/
|
||||
int32_t IsApplicationRunning(const std::string &bundleName, bool &isRunning);
|
||||
|
||||
/**
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning);
|
||||
|
||||
int32_t StartNativeProcessForDebugger(const AAFwk::Want &want);
|
||||
|
||||
std::shared_ptr<AppRunningRecord> CreateAppRunningRecord(
|
||||
@ -1084,9 +1093,12 @@ public:
|
||||
|
||||
int32_t SetSupportedProcessCacheSelf(bool isSupport);
|
||||
|
||||
void OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, ApplicationState state);
|
||||
|
||||
virtual void SaveBrowserChannel(const pid_t hostPid, sptr<IRemoteObject> browser);
|
||||
|
||||
bool IsAppProcessesAllCached(const std::string &bundleName, int32_t uid,
|
||||
const std::set<std::shared_ptr<AppRunningRecord>> &cachedSet);
|
||||
private:
|
||||
|
||||
std::string FaultTypeToString(FaultDataType type);
|
||||
@ -1109,8 +1121,8 @@ private:
|
||||
const std::shared_ptr<ApplicationInfo> &appInfo, std::string &processName) const;
|
||||
|
||||
void MakeProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<ApplicationInfo> &appInfo,
|
||||
const HapModuleInfo &hapModuleInfo, int32_t appIndex, std::string &processName) const;
|
||||
const std::shared_ptr<ApplicationInfo> &appInfo, const HapModuleInfo &hapModuleInfo, int32_t appIndex,
|
||||
const std::string &specifiedProcessFlag, std::string &processName) const;
|
||||
|
||||
void MakeProcessName(const std::shared_ptr<ApplicationInfo> &appInfo, const HapModuleInfo &hapModuleInfo,
|
||||
std::string &processName) const;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <regex>
|
||||
#include <set>
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "app_debug_listener_interface.h"
|
||||
@ -80,6 +81,16 @@ public:
|
||||
*/
|
||||
bool CheckAppRunningRecordIsExistByBundleName(const std::string &bundleName);
|
||||
|
||||
/**
|
||||
* CheckAppRunningRecordIsExistByBundleName, Check whether the process of the application exists.
|
||||
*
|
||||
* @param bundleName, the bundle name.
|
||||
*
|
||||
* @return, Return true if exist.
|
||||
*/
|
||||
int32_t CheckAppCloneRunningRecordIsExistByBundleName(const std::string &bundleName,
|
||||
int32_t appCloneIndex, bool &isRunning);
|
||||
|
||||
/**
|
||||
* GetAppRunningRecordByPid, Get process record by application pid.
|
||||
*
|
||||
@ -301,6 +312,9 @@ public:
|
||||
|
||||
int DumpFfrt(const std::vector<int32_t>& pids, std::string& result);
|
||||
|
||||
bool IsAppProcessesAllCached(const std::string &bundleName, int32_t uid,
|
||||
const std::set<std::shared_ptr<AppRunningRecord>> &cachedSet);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const int64_t eventId);
|
||||
int32_t AssignRunningProcessInfoByAppRecord(
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
void OnProcessReused(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnPageShow(const PageStateData pageStateData);
|
||||
void OnPageHide(const PageStateData pageStateData);
|
||||
void OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, ApplicationState state);
|
||||
private:
|
||||
void HandleAppStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, const ApplicationState state,
|
||||
bool needNotifyApp, bool isFromWindowFocusChanged);
|
||||
@ -102,7 +102,7 @@ private:
|
||||
void HandleOnProcessResued(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void HandleOnPageShow(const PageStateData pageStateData);
|
||||
void HandleOnPageHide(const PageStateData pageStateData);
|
||||
void HandleOnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void HandleOnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, ApplicationState state);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AAFwk::TaskHandlerWrap> handler_;
|
||||
|
@ -41,17 +41,27 @@ public:
|
||||
bool IsAppShouldCache(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void RefreshCacheNum();
|
||||
std::string PrintCacheQueue();
|
||||
void UpdateTypeByToken(const sptr<IRemoteObject> &token, const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void UpdateTypeByAbility(const std::shared_ptr<AbilityRunningRecord> &abilityRecord,
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
private:
|
||||
bool IsAppAbilitiesEmpty(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
int GetCurrentCachedProcNum();
|
||||
void RemoveCacheRecord(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void ShrinkAndKillCache();
|
||||
bool KillProcessByRecord(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void AddToApplicationSet(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void RemoveFromApplicationSet(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
bool CheckAndNotifyCachedState(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
int32_t maxProcCacheNum_ = 0;
|
||||
std::deque<std::shared_ptr<AppRunningRecord>> cachedAppRecordQueue_;
|
||||
ffrt::recursive_mutex cacheQueueMtx;
|
||||
std::weak_ptr<AppMgrServiceInner> appMgr_;
|
||||
bool shouldCheckApi = true;
|
||||
// bundleName->uid->record
|
||||
std::map<std::string, std::map<int32_t, std::set<std::shared_ptr<AppRunningRecord>>>> sameAppSet;
|
||||
// stores records that are servcie extension
|
||||
std::set<std::shared_ptr<AppRunningRecord>> srvExtRecords;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace AppExecFwk
|
||||
|
@ -1310,6 +1310,14 @@ int32_t AppMgrService::IsApplicationRunning(const std::string &bundleName, bool
|
||||
return appMgrServiceInner_->IsApplicationRunning(bundleName, isRunning);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
return appMgrServiceInner_->IsAppRunning(bundleName, appCloneIndex, isRunning);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::StartChildProcess(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount,
|
||||
bool isStartWithDebug)
|
||||
{
|
||||
|
@ -212,6 +212,9 @@ constexpr int32_t NETSYS_SOCKET_GROUPID = 1097;
|
||||
|
||||
constexpr int32_t DEFAULT_INVAL_VALUE = -1;
|
||||
constexpr int32_t NO_ABILITY_RECORD_ID = -1;
|
||||
constexpr int32_t EXIT_REASON_UNKNOWN = 0;
|
||||
|
||||
constexpr int32_t MAX_SPECIFIED_PROCESS_NAME_LENGTH = 255;
|
||||
|
||||
int32_t GetUserIdByUid(int32_t uid)
|
||||
{
|
||||
@ -276,7 +279,7 @@ void AppMgrServiceInner::StartSpecifiedProcess(const AAFwk::Want &want, const Ap
|
||||
|
||||
std::string processName;
|
||||
auto abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
|
||||
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, appIndex, processName);
|
||||
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, appIndex, "", processName);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "processName = %{public}s", processName.c_str());
|
||||
auto mainAppRecord =
|
||||
appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name, processName, appInfo->uid, bundleInfo);
|
||||
@ -366,12 +369,14 @@ void AppMgrServiceInner::HandlePreloadApplication(const PreloadRequest &request)
|
||||
|
||||
auto appInfo = request.appInfo;
|
||||
auto hapModuleInfo = request.hapModuleInfo;
|
||||
std::string processName;
|
||||
MakeProcessName(abilityInfo, appInfo, hapModuleInfo, request.appIndex, processName);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "HandlePreloadApplication processName = %{public}s", processName.c_str());
|
||||
|
||||
auto want = request.want;
|
||||
std::string specifiedProcessFlag = GetSpecifiedProcessFlag(abilityInfo, want);
|
||||
|
||||
std::string processName;
|
||||
MakeProcessName(abilityInfo, appInfo, hapModuleInfo, request.appIndex, specifiedProcessFlag, processName);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "HandlePreloadApplication processName = %{public}s", processName.c_str());
|
||||
|
||||
std::shared_ptr<AppRunningRecord> appRecord = appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name,
|
||||
processName, appInfo->uid, bundleInfo, specifiedProcessFlag);
|
||||
if (appRecord) {
|
||||
@ -425,17 +430,16 @@ void AppMgrServiceInner::LoadAbility(sptr<IRemoteObject> token, sptr<IRemoteObje
|
||||
return;
|
||||
}
|
||||
|
||||
// for isolation process
|
||||
std::string specifiedProcessFlag = GetSpecifiedProcessFlag(abilityInfo, want);
|
||||
std::string processName;
|
||||
MakeProcessName(abilityInfo, appInfo, hapModuleInfo, appIndex, processName);
|
||||
MakeProcessName(abilityInfo, appInfo, hapModuleInfo, appIndex, specifiedProcessFlag, processName);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "processName = %{public}s", processName.c_str());
|
||||
|
||||
std::shared_ptr<AppRunningRecord> appRecord;
|
||||
// for isolation process
|
||||
std::string specifiedProcessFlag = GetSpecifiedProcessFlag(abilityInfo, want);
|
||||
bool isUIAbility = (abilityInfo->type == AppExecFwk::AbilityType::PAGE && abilityInfo->isStageBasedModel);
|
||||
appRecord = appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name,
|
||||
processName, appInfo->uid, bundleInfo, specifiedProcessFlag);
|
||||
if (appRecord && isUIAbility) {
|
||||
if (appRecord && abilityInfo->type == AppExecFwk::AbilityType::PAGE) {
|
||||
NotifyMemMgrPriorityChanged(appRecord);
|
||||
}
|
||||
|
||||
@ -581,7 +585,7 @@ void AppMgrServiceInner::MakeServiceExtProcessName(const std::shared_ptr<Ability
|
||||
|
||||
void AppMgrServiceInner::MakeProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<ApplicationInfo> &appInfo, const HapModuleInfo &hapModuleInfo, int32_t appIndex,
|
||||
std::string &processName) const
|
||||
const std::string &specifiedProcessFlag, std::string &processName) const
|
||||
{
|
||||
if (!abilityInfo || !appInfo) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "param error");
|
||||
@ -597,6 +601,12 @@ void AppMgrServiceInner::MakeProcessName(const std::shared_ptr<AbilityInfo> &abi
|
||||
if (appIndex != 0) {
|
||||
processName += std::to_string(appIndex);
|
||||
}
|
||||
|
||||
if (!specifiedProcessFlag.empty()) {
|
||||
processName = (processName + ":" + specifiedProcessFlag).substr(0, MAX_SPECIFIED_PROCESS_NAME_LENGTH);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "specifiedProcessFlag = %{public}s, processName = %{public}s",
|
||||
specifiedProcessFlag.c_str(), processName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::MakeProcessName(
|
||||
@ -1708,7 +1718,7 @@ int32_t AppMgrServiceInner::KillProcessByPid(const pid_t pid, const std::string&
|
||||
}
|
||||
std::string killReason = KILL_PROCESS_REASON_PREFIX + reason;
|
||||
auto appRecord = GetAppRunningRecordByPid(pid);
|
||||
if (appRecord) {
|
||||
if (appRecord && appRecord->GetExitReason() == EXIT_REASON_UNKNOWN) {
|
||||
appRecord->SetExitMsg(killReason);
|
||||
}
|
||||
int32_t ret = -1;
|
||||
@ -3805,7 +3815,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
|
||||
|
||||
std::string processName;
|
||||
auto abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
|
||||
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, appIndex, processName);
|
||||
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, appIndex, "", processName);
|
||||
|
||||
std::vector<HapModuleInfo> hapModules;
|
||||
hapModules.emplace_back(hapModuleInfo);
|
||||
@ -5335,6 +5345,41 @@ int32_t AppMgrServiceInner::IsApplicationRunning(const std::string &bundleName,
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::IsAppRunning(const std::string &bundleName, int32_t appCloneIndex,
|
||||
bool &isRunning)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called, bundleName: %{public}s", bundleName.c_str());
|
||||
CHECK_CALLER_IS_SYSTEM_APP;
|
||||
if (!CheckGetRunningInfoPermission()) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
auto bundleMgrHelper = remoteClientManager_->GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "The bundleMgrHelper is nullptr.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
BundleInfo bundleInfo;
|
||||
auto userId = GetCurrentAccountId();
|
||||
int32_t bundleMgrResult;
|
||||
if (appCloneIndex == 0) {
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfoV9(bundleName,
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo, userId));
|
||||
} else {
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetCloneBundleInfo(bundleName,
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION),
|
||||
appCloneIndex, bundleInfo, userId));
|
||||
}
|
||||
|
||||
if (bundleMgrResult != ERR_OK) {
|
||||
return AAFwk::ERR_APP_CLONE_INDEX_INVALID;
|
||||
}
|
||||
|
||||
return appRunningManager_->CheckAppCloneRunningRecordIsExistByBundleName(bundleName, appCloneIndex, isRunning);
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::StartNativeProcessForDebugger(const AAFwk::Want &want)
|
||||
{
|
||||
if (!remoteClientManager_ || !appRunningManager_) {
|
||||
@ -5365,7 +5410,7 @@ int32_t AppMgrServiceInner::StartNativeProcessForDebugger(const AAFwk::Want &wan
|
||||
|
||||
std::string processName;
|
||||
auto abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
|
||||
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, 0, processName);
|
||||
MakeProcessName(abilityInfoPtr, appInfo, hapModuleInfo, 0, "", processName);
|
||||
|
||||
auto&& appRecord =
|
||||
appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name, processName, appInfo->uid, bundleInfo);
|
||||
@ -6759,7 +6804,8 @@ int32_t AppMgrServiceInner::CheckSetProcessCachePermission() const
|
||||
return isCallingPerm ? ERR_OK : AAFwk::CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
void AppMgrServiceInner::OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
ApplicationState state)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!appRecord) {
|
||||
@ -6775,7 +6821,7 @@ void AppMgrServiceInner::OnAppCacheStateChanged(const std::shared_ptr<AppRunning
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnAppCacheStateChanged begin, bundleName is %{public}s, pid:%{public}d",
|
||||
appRecord->GetBundleName().c_str(), appRecord->GetPriorityObject()->GetPid());
|
||||
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppCacheStateChanged(appRecord);
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppCacheStateChanged(appRecord, state);
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::StartNativeChildProcess(const pid_t hostPid, const std::string &libName,
|
||||
@ -6820,5 +6866,15 @@ int32_t AppMgrServiceInner::StartNativeChildProcess(const pid_t hostPid, const s
|
||||
hostPid, libName, appRecord, callback, childProcessCount, false);
|
||||
return StartChildProcessImpl(nativeChildRecord, appRecord, dummyChildPid);
|
||||
}
|
||||
|
||||
bool AppMgrServiceInner::IsAppProcessesAllCached(const std::string &bundleName, int32_t uid,
|
||||
const std::set<std::shared_ptr<AppRunningRecord>> &cachedSet)
|
||||
{
|
||||
if (!appRunningManager_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
return appRunningManager_->IsAppProcessesAllCached(bundleName, uid, cachedSet);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -30,6 +30,7 @@
|
||||
#include "quick_fix_callback_with_record.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "scene_board_judgement.h"
|
||||
#include "window_visibility_info.h"
|
||||
#endif //SUPPORT_SCREEN
|
||||
#include "ui_extension_utils.h"
|
||||
#include "app_mgr_service_const.h"
|
||||
@ -38,7 +39,7 @@
|
||||
#include "suspend_manager_client.h"
|
||||
#endif
|
||||
#include "app_mgr_service_dump_error_code.h"
|
||||
#include "window_visibility_info.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -159,6 +160,21 @@ bool AppRunningManager::CheckAppRunningRecordIsExistByBundleName(const std::stri
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::CheckAppCloneRunningRecordIsExistByBundleName(const std::string &bundleName,
|
||||
int32_t appCloneIndex, bool &isRunning)
|
||||
{
|
||||
std::lock_guard guard(runningRecordMapMutex_);
|
||||
for (const auto &item : appRunningRecordMap_) {
|
||||
const auto &appRecord = item.second;
|
||||
if (appRecord && appRecord->GetBundleName() == bundleName && !(appRecord->GetRestartAppFlag()) &&
|
||||
appRecord->GetAppIndex() == appCloneIndex) {
|
||||
isRunning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::GetAllAppRunningRecordCountByBundleName(const std::string &bundleName)
|
||||
{
|
||||
int32_t count = 0;
|
||||
@ -481,6 +497,7 @@ void AppRunningManager::PrepareTerminate(const sptr<IRemoteObject> &token)
|
||||
if (appRecord->IsLastAbilityRecord(token) && (!appRecord->IsKeepAliveApp() ||
|
||||
!ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent())) {
|
||||
auto cacheProcMgr = DelayedSingleton<CacheProcessManager>::GetInstance();
|
||||
cacheProcMgr->UpdateTypeByAbility(abilityRecord, appRecord);
|
||||
if (cacheProcMgr != nullptr && cacheProcMgr->IsAppShouldCache(appRecord)) {
|
||||
cacheProcMgr->PenddingCacheProcess(appRecord);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "App %{public}s supports process cache, not terminate record.",
|
||||
@ -543,6 +560,7 @@ void AppRunningManager::TerminateAbility(const sptr<IRemoteObject> &token, bool
|
||||
if (isLastAbility && (!appRecord->IsKeepAliveApp() ||
|
||||
!ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent()) && !isLauncherApp) {
|
||||
auto cacheProcMgr = DelayedSingleton<CacheProcessManager>::GetInstance();
|
||||
cacheProcMgr->UpdateTypeByToken(token, appRecord);
|
||||
if (cacheProcMgr != nullptr && cacheProcMgr->IsAppShouldCache(appRecord)) {
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "App %{public}s is cached, not terminate app.",
|
||||
appRecord->GetBundleName().c_str());
|
||||
@ -1467,5 +1485,27 @@ int AppRunningManager::DumpFfrt(const std::vector<int32_t>& pids, std::string& r
|
||||
}
|
||||
return DumpErrorCode::ERR_OK;
|
||||
}
|
||||
|
||||
bool AppRunningManager::IsAppProcessesAllCached(const std::string &bundleName, int32_t uid,
|
||||
const std::set<std::shared_ptr<AppRunningRecord>> &cachedSet)
|
||||
{
|
||||
if (cachedSet.size() == 0) {
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "empty cache set.");
|
||||
return false;
|
||||
}
|
||||
std::lock_guard guard(runningRecordMapMutex_);
|
||||
for (const auto &item : appRunningRecordMap_) {
|
||||
auto &itemRecord = item.second;
|
||||
if (itemRecord == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (itemRecord->GetBundleName() == bundleName && itemRecord->GetUid() == uid &&
|
||||
cachedSet.find(itemRecord) == cachedSet.end() &&
|
||||
DelayedSingleton<CacheProcessManager>::GetInstance()->IsAppSupportProcessCache(itemRecord)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -24,8 +24,9 @@
|
||||
#include "app_mgr_service_const.h"
|
||||
#include "app_mgr_service_dump_error_code.h"
|
||||
#include "cache_process_manager.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "window_visibility_info.h"
|
||||
|
||||
#endif //SUPPORT_SCREEN
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
@ -1134,6 +1135,7 @@ void AppRunningRecord::AbilityTerminated(const sptr<IRemoteObject> &token)
|
||||
auto appRecord = shared_from_this();
|
||||
auto cacheProcMgr = DelayedSingleton<CacheProcessManager>::GetInstance();
|
||||
bool needCache = false;
|
||||
cacheProcMgr->UpdateTypeByAbility(abilityRecord, appRecord);
|
||||
if (cacheProcMgr != nullptr && cacheProcMgr->IsAppShouldCache(appRecord)) {
|
||||
cacheProcMgr->CheckAndCacheProcess(appRecord);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "App %{public}s should cache, not remove module and terminate app.",
|
||||
|
@ -936,33 +936,35 @@ void AppStateObserverManager::HandleOnPageHide(const PageStateData pageStateData
|
||||
}
|
||||
}
|
||||
|
||||
void AppStateObserverManager::OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
void AppStateObserverManager::OnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
ApplicationState state)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "handler is nullptr, OnAppCacheStateChanged failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto task = [weak = weak_from_this(), appRecord]() {
|
||||
auto task = [weak = weak_from_this(), appRecord, state]() {
|
||||
auto self = weak.lock();
|
||||
if (self == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "self is nullptr, OnAppCacheStateChanged failed.");
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnAppCacheStateChanged come.");
|
||||
self->HandleOnAppCacheStateChanged(appRecord);
|
||||
self->HandleOnAppCacheStateChanged(appRecord, state);
|
||||
};
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void AppStateObserverManager::HandleOnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
void AppStateObserverManager::HandleOnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
ApplicationState state)
|
||||
{
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "app record is null");
|
||||
return;
|
||||
}
|
||||
|
||||
AppStateData data = WrapAppStateData(appRecord, appRecord->GetState());
|
||||
AppStateData data = WrapAppStateData(appRecord, state);
|
||||
data.isSpecifyTokenId = appRecord->GetAssignTokenId() > 0 ? true : false;
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "HandleOnAppCacheStateChanged, bundle:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
data.bundleName.c_str(), data.uid, data.state);
|
||||
|
@ -78,6 +78,7 @@ bool CacheProcessManager::PenddingCacheProcess(const std::shared_ptr<AppRunningR
|
||||
{
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
cachedAppRecordQueue_.push_back(appRecord);
|
||||
AddToApplicationSet(appRecord);
|
||||
}
|
||||
ShrinkAndKillCache();
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "Pending %{public}s success, %{public}s", appRecord->GetName().c_str(),
|
||||
@ -104,17 +105,44 @@ bool CacheProcessManager::CheckAndCacheProcess(const std::shared_ptr<AppRunningR
|
||||
appRecord->GetName().c_str());
|
||||
return true;
|
||||
}
|
||||
appRecord->SetState(ApplicationState::APP_STATE_CACHED);
|
||||
do {
|
||||
auto appMgrSptr = appMgr_.lock();
|
||||
if (appMgrSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appMgr is nullptr");
|
||||
break;
|
||||
}
|
||||
appMgrSptr->OnAppCacheStateChanged(appRecord);
|
||||
} while (false);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "%{public}s is cached, %{public}s", appRecord->GetName().c_str(),
|
||||
PrintCacheQueue().c_str());
|
||||
CheckAndNotifyCachedState(appRecord);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CacheProcessManager::CheckAndNotifyCachedState(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
{
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRecord nullptr precheck failed");
|
||||
return false;
|
||||
}
|
||||
auto appMgrSptr = appMgr_.lock();
|
||||
if (appMgrSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appMgr is nullptr");
|
||||
return false;
|
||||
}
|
||||
auto &bundleName = appRecord->GetBundleName();
|
||||
auto uid = appRecord->GetUid();
|
||||
std::shared_ptr<AppRunningRecord> notifyRecord = nullptr;
|
||||
{
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
if (sameAppSet.find(bundleName) == sameAppSet.end() ||
|
||||
sameAppSet[bundleName].find(uid) == sameAppSet[bundleName].end()) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "app set not found.");
|
||||
return false;
|
||||
}
|
||||
if (sameAppSet[bundleName][uid].size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!appMgrSptr->IsAppProcessesAllCached(bundleName, uid, sameAppSet[bundleName][uid])) {
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "Not all processes of one app is cached, abort notify");
|
||||
return false;
|
||||
}
|
||||
notifyRecord = *(sameAppSet[bundleName][uid].begin());
|
||||
}
|
||||
appMgrSptr->OnAppCacheStateChanged(notifyRecord, ApplicationState::APP_STATE_CACHED);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "app cached state is notified: %{public}s, uid:%{public}d", bundleName.c_str(), uid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -143,6 +171,11 @@ void CacheProcessManager::OnProcessKilled(const std::shared_ptr<AppRunningRecord
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRecord nullptr precheck failed");
|
||||
return;
|
||||
}
|
||||
CheckAndNotifyCachedState(appRecord);
|
||||
{
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
srvExtRecords.erase(appRecord);
|
||||
}
|
||||
if (!IsCachedProcess(appRecord)) {
|
||||
return;
|
||||
}
|
||||
@ -165,15 +198,14 @@ void CacheProcessManager::ReuseCachedProcess(const std::shared_ptr<AppRunningRec
|
||||
return;
|
||||
}
|
||||
RemoveCacheRecord(appRecord);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "%{public}s is reused, %{public}s", appRecord->GetName().c_str(),
|
||||
PrintCacheQueue().c_str());
|
||||
appRecord->SetState(ApplicationState::APP_STATE_READY);
|
||||
auto appMgrSptr = appMgr_.lock();
|
||||
if (appMgrSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appMgr is nullptr");
|
||||
return;
|
||||
}
|
||||
appMgrSptr->OnAppCacheStateChanged(appRecord);
|
||||
appMgrSptr->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_READY);
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "app none cached state is notified: %{public}s, uid: %{public}d, %{public}s",
|
||||
appRecord->GetBundleName().c_str(), appRecord->GetUid(), PrintCacheQueue().c_str());
|
||||
}
|
||||
|
||||
bool CacheProcessManager::IsAppSupportProcessCache(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
@ -184,6 +216,7 @@ bool CacheProcessManager::IsAppSupportProcessCache(const std::shared_ptr<AppRunn
|
||||
}
|
||||
auto appInfo = appRecord->GetApplicationInfo();
|
||||
if (appInfo == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "appinfo nullptr");
|
||||
return false;
|
||||
}
|
||||
auto actualVer = appInfo->apiTargetVersion % API_VERSION_MOD;
|
||||
@ -192,6 +225,15 @@ bool CacheProcessManager::IsAppSupportProcessCache(const std::shared_ptr<AppRunn
|
||||
appRecord->GetName().c_str(), actualVer);
|
||||
return false;
|
||||
}
|
||||
if (srvExtRecords.find(appRecord) != srvExtRecords.end()) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "%{public}s of %{public}s is service, not support cache",
|
||||
appRecord->GetProcessName().c_str(), appRecord->GetBundleName().c_str());
|
||||
return false;
|
||||
}
|
||||
if (appRecord->IsKeepAliveApp()) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Keepalive app.");
|
||||
return false;
|
||||
}
|
||||
auto supportState = appRecord->GetSupportProcessCacheState();
|
||||
switch (supportState) {
|
||||
case SupportProcessCacheState::UNSPECIFIED:
|
||||
@ -250,6 +292,7 @@ void CacheProcessManager::RemoveCacheRecord(const std::shared_ptr<AppRunningReco
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
for (auto it = cachedAppRecordQueue_.begin(); it != cachedAppRecordQueue_.end();) {
|
||||
if (appRecord == *it) {
|
||||
RemoveFromApplicationSet(*it);
|
||||
it = cachedAppRecordQueue_.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
@ -270,6 +313,7 @@ void CacheProcessManager::ShrinkAndKillCache()
|
||||
while (GetCurrentCachedProcNum() > maxProcCacheNum_) {
|
||||
const auto& tmpAppRecord = cachedAppRecordQueue_.front();
|
||||
cachedAppRecordQueue_.pop_front();
|
||||
RemoveFromApplicationSet(tmpAppRecord);
|
||||
if (tmpAppRecord == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@ -327,5 +371,95 @@ std::string CacheProcessManager::PrintCacheQueue()
|
||||
ss << ".";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void CacheProcessManager::AddToApplicationSet(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
{
|
||||
if (appRecord == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto &bundleName = appRecord->GetBundleName();
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
if (sameAppSet.find(bundleName) == sameAppSet.end()) {
|
||||
std::map<int32_t, std::set<std::shared_ptr<AppRunningRecord>>> uidMap;
|
||||
std::set<std::shared_ptr<AppRunningRecord>> recordSet;
|
||||
recordSet.insert(appRecord);
|
||||
uidMap.insert(std::make_pair(appRecord->GetUid(), recordSet));
|
||||
sameAppSet.insert(std::make_pair(bundleName, uidMap));
|
||||
}
|
||||
auto uid = appRecord->GetUid();
|
||||
if (sameAppSet[bundleName].find(uid) == sameAppSet[bundleName].end()) {
|
||||
std::set<std::shared_ptr<AppRunningRecord>> recordSet;
|
||||
recordSet.insert(appRecord);
|
||||
sameAppSet[bundleName].insert(std::make_pair(uid, recordSet));
|
||||
return;
|
||||
}
|
||||
sameAppSet[bundleName][uid].insert(appRecord);
|
||||
}
|
||||
|
||||
void CacheProcessManager::RemoveFromApplicationSet(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
{
|
||||
if (appRecord == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto &bundleName = appRecord->GetBundleName();
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
if (sameAppSet.find(bundleName) == sameAppSet.end()) {
|
||||
return;
|
||||
}
|
||||
auto uid = appRecord->GetUid();
|
||||
if (sameAppSet[bundleName].find(uid) == sameAppSet[bundleName].end()) {
|
||||
return;
|
||||
}
|
||||
sameAppSet[bundleName][uid].erase(appRecord);
|
||||
if (sameAppSet[bundleName][uid].size() == 0) {
|
||||
sameAppSet[bundleName].erase(uid);
|
||||
}
|
||||
if (sameAppSet[bundleName].size() == 0) {
|
||||
sameAppSet.erase(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
void CacheProcessManager::UpdateTypeByToken(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!QueryEnableProcessCache()) {
|
||||
return;
|
||||
}
|
||||
if (token == nullptr || appRecord == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto abilityRecord = appRecord->GetAbilityRunningRecordByToken(token);
|
||||
if (abilityRecord == nullptr) {
|
||||
return;
|
||||
}
|
||||
UpdateTypeByAbility(abilityRecord, appRecord);
|
||||
}
|
||||
|
||||
void CacheProcessManager::UpdateTypeByAbility(const std::shared_ptr<AbilityRunningRecord> &abilityRecord,
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!QueryEnableProcessCache()) {
|
||||
return;
|
||||
}
|
||||
if (abilityRecord == nullptr || appRecord == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto type = abilityInfo->type;
|
||||
if (type == AppExecFwk::AbilityType::EXTENSION &&
|
||||
abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) {
|
||||
std::lock_guard<ffrt::recursive_mutex> queueLock(cacheQueueMtx);
|
||||
srvExtRecords.insert(appRecord);
|
||||
// incase service record is in cache queue due to delay
|
||||
RemoveCacheRecord(appRecord);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "%{public}s is service, will not cache, service records size: %{public}zu.",
|
||||
appRecord->GetBundleName().c_str(), srvExtRecords.size());
|
||||
}
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace AppExecFwk
|
@ -59,6 +59,7 @@ public:
|
||||
MOCK_METHOD2(GetExtensionSaIds, int32_t(const std::string&, std::vector<int32_t> &));
|
||||
MOCK_METHOD2(GetExtensionRunningSaList, int32_t(const std::string&, std::vector<sptr<IRemoteObject>>&));
|
||||
MOCK_METHOD2(GetRunningSaExtensionInfoList, int32_t(const std::string&, std::vector<SaExtensionInfo>&));
|
||||
MOCK_METHOD3(GetCommonEventExtraDataIdlist, int32_t(int32_t, std::vector<int64_t>&, const std::string&));
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -93,6 +93,8 @@ public:
|
||||
MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName,
|
||||
RunningMultiAppInfo &info));
|
||||
MOCK_METHOD2(IsApplicationRunning, int32_t(const std::string &bundleName, bool &isRunning));
|
||||
MOCK_METHOD3(IsAppRunning, int32_t(const std::string &bundleName,
|
||||
int32_t appCloneIndex, bool &isRunning));
|
||||
MOCK_METHOD4(StartChildProcess, int32_t(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount,
|
||||
bool isStartWithNative));
|
||||
MOCK_METHOD1(GetChildProcessInfoForSelf, int32_t(ChildProcessInfo &info));
|
||||
|
@ -96,7 +96,7 @@ HWTEST_F(AbilityInterceptorTest, CrowdTestInterceptor_001, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<CrowdTestInterceptor>());
|
||||
executer->AddInterceptor("CrowdTest", std::make_shared<CrowdTestInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, true, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -115,7 +115,7 @@ HWTEST_F(AbilityInterceptorTest, CrowdTestInterceptor_002, TestSize.Level1)
|
||||
ElementName element("", "com.test.crowdtest", "CrowdtestExpired");
|
||||
want.SetElement(element);
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<CrowdTestInterceptor>());
|
||||
executer->AddInterceptor("CrowdTest", std::make_shared<CrowdTestInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, userId, false, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -135,7 +135,7 @@ HWTEST_F(AbilityInterceptorTest, ControlInterceptor_001, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
executer->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, true, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -154,7 +154,7 @@ HWTEST_F(AbilityInterceptorTest, ControlInterceptor_002, TestSize.Level1)
|
||||
ElementName element("", "com.test.control", "MainAbility");
|
||||
want.SetElement(element);
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
executer->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, userId, false, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -173,7 +173,7 @@ HWTEST_F(AbilityInterceptorTest, ControlInterceptor_003, TestSize.Level1)
|
||||
ElementName element("", "com.test.control2", "MainAbility");
|
||||
want.SetElement(element);
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
executer->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, userId, false, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -192,7 +192,7 @@ HWTEST_F(AbilityInterceptorTest, ControlInterceptor_004, TestSize.Level1)
|
||||
ElementName element("", "com.test.control3", "MainAbility");
|
||||
want.SetElement(element);
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
executer->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, userId, false, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -213,8 +213,8 @@ HWTEST_F(AbilityInterceptorTest, ControlInterceptor_005, TestSize.Level1)
|
||||
int userId = 100;
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
// make appControlRule become nullptr by crowdtest interceptor
|
||||
executer->AddInterceptor(std::make_shared<CrowdTestInterceptor>());
|
||||
executer->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
executer->AddInterceptor("CrowdTest", std::make_shared<CrowdTestInterceptor>());
|
||||
executer->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, userId, false, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -234,7 +234,7 @@ HWTEST_F(AbilityInterceptorTest, DisposedRuleInterceptor_001, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<DisposedRuleInterceptor>());
|
||||
executer->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, false, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -254,7 +254,7 @@ HWTEST_F(AbilityInterceptorTest, DisposedRuleInterceptor_002, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<DisposedRuleInterceptor>());
|
||||
executer->AddInterceptor("Disposed", std::make_shared<DisposedRuleInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, true, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -274,7 +274,7 @@ HWTEST_F(AbilityInterceptorTest, DisposedRuleInterceptor_003, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<DisposedRuleInterceptor>());
|
||||
executer->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, true, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -294,7 +294,7 @@ HWTEST_F(AbilityInterceptorTest, DisposedRuleInterceptor_004, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<DisposedRuleInterceptor>());
|
||||
executer->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, true, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
@ -314,7 +314,7 @@ HWTEST_F(AbilityInterceptorTest, DisposedRuleInterceptor_005, TestSize.Level1)
|
||||
want.SetElement(element);
|
||||
int requestCode = 0;
|
||||
int userId = 100;
|
||||
executer->AddInterceptor(std::make_shared<DisposedRuleInterceptor>());
|
||||
executer->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>());
|
||||
AbilityInterceptorParam param = AbilityInterceptorParam(want, requestCode, userId, true, nullptr);
|
||||
int result = executer->DoProcess(param);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
@ -66,6 +66,7 @@ ohos_unittest("AmsAppRunningRecordTest") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "window_manager:libwm" ]
|
||||
defines = [ "SUPPORT_SCREEN" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ ohos_unittest("app_exit_reason_data_manager_test") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"kv_store:distributeddata_inner",
|
||||
|
@ -27,9 +27,9 @@ using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
const std::string BUNDLE_NAME = "bundle.name";
|
||||
const std::string MODULE_NAME = "module_name";
|
||||
const std::string ABILITY_NAME = "ability_name";
|
||||
constexpr uint32_t ACCESS_TOKEN_ID = 123;
|
||||
const int SESSION_ID = 111;
|
||||
} // namespace
|
||||
|
||||
@ -50,7 +50,7 @@ void AppExitReasonDataManagerTest::TearDownTestCase(void)
|
||||
void AppExitReasonDataManagerTest::SetUp()
|
||||
{
|
||||
DelayedSingleton<AppExitReasonDataManager>::GetInstance()->DeleteAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME);
|
||||
}
|
||||
|
||||
void AppExitReasonDataManagerTest::TearDown()
|
||||
@ -65,11 +65,11 @@ void AppExitReasonDataManagerTest::TearDown()
|
||||
HWTEST_F(AppExitReasonDataManagerTest, AppExitReasonDataManager_AddAbilityRecoverInfo_001, TestSize.Level1)
|
||||
{
|
||||
auto result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->AddAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->AddAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
}
|
||||
|
||||
@ -82,14 +82,14 @@ HWTEST_F(AppExitReasonDataManagerTest, AppExitReasonDataManager_AddAbilityRecove
|
||||
HWTEST_F(AppExitReasonDataManagerTest, AppExitReasonDataManager_DeleteAbilityRecoverInfo_001, TestSize.Level1)
|
||||
{
|
||||
auto result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->DeleteAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME);
|
||||
EXPECT_EQ(result, ERR_INVALID_VALUE);
|
||||
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->AddAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->DeleteAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
}
|
||||
|
||||
@ -135,15 +135,15 @@ HWTEST_F(AppExitReasonDataManagerTest, AppExitReasonDataManager_GetAbilityRecove
|
||||
{
|
||||
bool hasRecoverInfo = false;
|
||||
auto result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->GetAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, hasRecoverInfo);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, hasRecoverInfo);
|
||||
EXPECT_EQ(result, ERR_INVALID_VALUE);
|
||||
EXPECT_EQ(hasRecoverInfo, false);
|
||||
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->AddAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->GetAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, hasRecoverInfo);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, hasRecoverInfo);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_EQ(hasRecoverInfo, true);
|
||||
}
|
||||
@ -158,15 +158,15 @@ HWTEST_F(AppExitReasonDataManagerTest, AppExitReasonDataManager_GetAbilitySessio
|
||||
{
|
||||
int sessionId = 0;
|
||||
auto result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->GetAbilitySessionId(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, sessionId);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, sessionId);
|
||||
EXPECT_EQ(result, ERR_INVALID_VALUE);
|
||||
EXPECT_EQ(sessionId, 0);
|
||||
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->AddAbilityRecoverInfo(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, SESSION_ID);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
result = DelayedSingleton<AppExitReasonDataManager>::GetInstance()->GetAbilitySessionId(
|
||||
BUNDLE_NAME, MODULE_NAME, ABILITY_NAME, sessionId);
|
||||
ACCESS_TOKEN_ID, MODULE_NAME, ABILITY_NAME, sessionId);
|
||||
EXPECT_EQ(result, ERR_OK);
|
||||
EXPECT_EQ(sessionId, SESSION_ID);
|
||||
}
|
||||
|
@ -367,6 +367,25 @@ HWTEST_F(AppMgrProxyTest, IsApplicationRunning_001, TestSize.Level1)
|
||||
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(AppMgrInterfaceCode::IS_APPLICATION_RUNNING));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsAppRunning_001
|
||||
* @tc.desc: Send request to query the running status of the application.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrProxyTest, IsAppRunning_001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
|
||||
|
||||
std::string bundleName = "testBundleName";
|
||||
int32_t appCloneIndex = 0;
|
||||
bool isRunning = false;
|
||||
|
||||
appMgrProxy_->IsAppRunning(bundleName, appCloneIndex, isRunning);
|
||||
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(AppMgrInterfaceCode::IS_APP_RUNNING));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: RegisterAbilityForegroundStateObserver_0100
|
||||
* @tc.desc: Verify that the RegisterAbilityForegroundStateObserver function is called normally.
|
||||
|
@ -17,6 +17,11 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
module_output_path = "ability_runtime/appmgrservice"
|
||||
|
||||
ohos_unittest("AppMgrServiceInnerTest") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
module_out_path = module_output_path
|
||||
|
||||
include_dirs = [
|
||||
@ -65,12 +70,15 @@ ohos_unittest("AppMgrServiceInnerTest") {
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = []
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "window_manager:libwm" ]
|
||||
defines += [
|
||||
"SUPPORT_SCREEN",
|
||||
"SUPPORT_GRAPHICS",
|
||||
]
|
||||
}
|
||||
|
||||
defines = []
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
|
||||
}
|
||||
|
@ -464,10 +464,10 @@ HWTEST_F(AppMgrServiceInnerTest, MakeProcessName_001, TestSize.Level0)
|
||||
HapModuleInfo hapModuleInfo;
|
||||
hapModuleInfo.moduleName = "module789";
|
||||
std::string processName = "test_processName";
|
||||
appMgrServiceInner->MakeProcessName(nullptr, nullptr, hapModuleInfo, 1, processName);
|
||||
appMgrServiceInner->MakeProcessName(nullptr, applicationInfo_, hapModuleInfo, 1, processName);
|
||||
appMgrServiceInner->MakeProcessName(abilityInfo_, nullptr, hapModuleInfo, 1, processName);
|
||||
appMgrServiceInner->MakeProcessName(abilityInfo_, applicationInfo_, hapModuleInfo, 1, processName);
|
||||
appMgrServiceInner->MakeProcessName(nullptr, nullptr, hapModuleInfo, 1, "", processName);
|
||||
appMgrServiceInner->MakeProcessName(nullptr, applicationInfo_, hapModuleInfo, 1, "", processName);
|
||||
appMgrServiceInner->MakeProcessName(abilityInfo_, nullptr, hapModuleInfo, 1, "", processName);
|
||||
appMgrServiceInner->MakeProcessName(abilityInfo_, applicationInfo_, hapModuleInfo, 1, "", processName);
|
||||
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
TAG_LOGI(AAFwkTag::TEST, "MakeProcessName_001 end");
|
||||
@ -4058,6 +4058,50 @@ HWTEST_F(AppMgrServiceInnerTest, IsApplicationRunning_002, TestSize.Level1)
|
||||
EXPECT_FALSE(isRunning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsAppRunning_001
|
||||
* @tc.desc: Obtain application running status through bundleName.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerTest, IsAppRunning_001, TestSize.Level1)
|
||||
{
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
std::string bundleName = "com.is.hiserice";
|
||||
std::string processName = "test_processName";
|
||||
int32_t appCloneIndex = 0;
|
||||
bool isRunning = false;
|
||||
auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
|
||||
EXPECT_NE(appRecord, nullptr);
|
||||
appRecord->mainBundleName_ = "com.is.hiserice";
|
||||
appMgrServiceInner->appRunningManager_->appRunningRecordMap_.emplace(recordId_, appRecord);
|
||||
int32_t ret = appMgrServiceInner->IsAppRunning(bundleName, appCloneIndex, isRunning);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_TRUE(isRunning);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsAppRunning_002
|
||||
* @tc.desc: Not passing in bundleName, unable to obtain application running status.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerTest, IsAppRunning_002, TestSize.Level1)
|
||||
{
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
std::string bundleName = "com.is.hiserice";
|
||||
std::string processName = "test_processName";
|
||||
int32_t appCloneIndex = 0;
|
||||
bool isRunning = false;
|
||||
auto appRecord = std::make_shared<AppRunningRecord>(applicationInfo_, ++recordId_, processName);
|
||||
EXPECT_NE(appRecord, nullptr);
|
||||
appMgrServiceInner->appRunningManager_->appRunningRecordMap_.emplace(recordId_, appRecord);
|
||||
int32_t ret = appMgrServiceInner->IsAppRunning(bundleName, appCloneIndex, isRunning);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_FALSE(isRunning);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.name: RegisterAbilityForegroundStateObserver_0100
|
||||
* @tc.desc: Verify it when observer is nullptr.
|
||||
@ -4276,7 +4320,7 @@ HWTEST_F(AppMgrServiceInnerTest, OnAppCacheStateChanged_001, TestSize.Level0)
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
|
||||
appMgrServiceInner->OnAppCacheStateChanged(nullptr);
|
||||
appMgrServiceInner->OnAppCacheStateChanged(nullptr, ApplicationState::APP_STATE_CACHED);
|
||||
|
||||
std::string bundleName = "com.is.hiserice";
|
||||
std::string processName = "test_processName";
|
||||
@ -4287,10 +4331,10 @@ HWTEST_F(AppMgrServiceInnerTest, OnAppCacheStateChanged_001, TestSize.Level0)
|
||||
appRecord->SetState(ApplicationState::APP_STATE_CACHED);
|
||||
|
||||
appRecord->priorityObject_ = nullptr;
|
||||
appMgrServiceInner->OnAppCacheStateChanged(appRecord);
|
||||
appMgrServiceInner->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CACHED);
|
||||
|
||||
appRecord->priorityObject_ = std::make_shared<PriorityObject>();
|
||||
appMgrServiceInner->OnAppCacheStateChanged(appRecord);
|
||||
appMgrServiceInner->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CACHED);
|
||||
|
||||
|
||||
TAG_LOGI(AAFwkTag::TEST, "OnAppCacheStateChanged_001 end");
|
||||
|
@ -1401,6 +1401,29 @@ HWTEST_F(AppMgrServiceTest, IsApplicationRunning_001, TestSize.Level1)
|
||||
EXPECT_EQ(res, ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsAppRunning_001
|
||||
* @tc.desc: Determine that the application is running by returning a value.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceTest, IsAppRunning_001, TestSize.Level1)
|
||||
{
|
||||
AAFwk::IsMockSaCall::IsMockSaCallWithPermission();
|
||||
sptr<AppMgrService> appMgrService = new (std::nothrow) AppMgrService();
|
||||
ASSERT_NE(appMgrService, nullptr);
|
||||
appMgrService->SetInnerService(nullptr);
|
||||
|
||||
appMgrService->SetInnerService(std::make_shared<AppMgrServiceInner>());
|
||||
appMgrService->taskHandler_ = taskHandler_;
|
||||
appMgrService->eventHandler_ = std::make_shared<AMSEventHandler>(taskHandler_, appMgrService->appMgrServiceInner_);
|
||||
|
||||
std::string bundleName = "test_bundleName";
|
||||
int32_t appCloneIndex = 0;
|
||||
bool isRunning = false;
|
||||
int32_t res = appMgrService->IsAppRunning(bundleName, appCloneIndex, isRunning);
|
||||
EXPECT_EQ(res, ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RegisterAbilityForegroundStateObserver_0100
|
||||
* @tc.desc: Verify it when judgments is ready and observer is nullptr.
|
||||
|
@ -354,6 +354,32 @@ HWTEST_F(AppMgrStubTest, HandleChangeAppGcState_001, TestSize.Level1)
|
||||
EXPECT_EQ(result, NO_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsAppRunning_001
|
||||
* @tc.desc: On remote request to query the running status of the application.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrStubTest, IsAppRunning_0100, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
WriteInterfaceToken(data);
|
||||
std::string bundleName = "testBundleName";
|
||||
int32_t appCloneIndex = 0;
|
||||
bool isRunning = false;
|
||||
data.WriteString(bundleName);
|
||||
data.WriteInt32(appCloneIndex);
|
||||
data.WriteBool(isRunning);
|
||||
|
||||
EXPECT_CALL(*mockAppMgrService_, IsAppRunning(_, _, _)).Times(1);
|
||||
|
||||
auto result = mockAppMgrService_->OnRemoteRequest(
|
||||
static_cast<uint32_t>(AppMgrInterfaceCode::IS_APP_RUNNING), data, reply, option);
|
||||
EXPECT_EQ(result, NO_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsApplicationRunning_001
|
||||
* @tc.desc: On remote request to query the running status of the application.
|
||||
|
@ -68,6 +68,7 @@ ohos_unittest("app_running_manager_test") {
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwsutils",
|
||||
]
|
||||
defines = [ "SUPPORT_SCREEN" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,5 +611,36 @@ HWTEST_F(AppRunningManagerTest, UIExtensionReleationship_0700, TestSize.Level1)
|
||||
SET_THREAD_NUM(100);
|
||||
GTEST_RUN_TASK(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsAppProcessesAllCached_0100
|
||||
* @tc.desc: MultiProcess application cache check test.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppRunningManagerTest, IsAppProcessesAllCached_0100, TestSize.Level1)
|
||||
{
|
||||
static std::shared_ptr<AppRunningManager> appRunningManager = std::make_shared<AppRunningManager>();
|
||||
ASSERT_NE(appRunningManager, nullptr);
|
||||
std::string bundleName;
|
||||
std::shared_ptr<ApplicationInfo> appInfo = std::make_shared<ApplicationInfo>();
|
||||
appInfo->bundleName = "com.tdd.cacheprocesstest";
|
||||
appInfo->apiTargetVersion = 12;
|
||||
appInfo->uid = 1010101;
|
||||
int32_t recordId1 = RECORD_ID;
|
||||
int32_t recordId2 = RECORD_ID + 1;
|
||||
std::string processName = "com.tdd.cacheprocesstest";
|
||||
auto appRunningRecord1 = std::make_shared<AppRunningRecord>(appInfo, recordId1, processName);
|
||||
appRunningRecord1->SetUid(appInfo->uid);
|
||||
auto appRunningRecord2 = std::make_shared<AppRunningRecord>(appInfo, recordId2, processName);
|
||||
appRunningRecord2->SetUid(appInfo->uid);
|
||||
|
||||
appRunningManager->appRunningRecordMap_.insert(make_pair(recordId1, appRunningRecord1));
|
||||
std::set<std::shared_ptr<AppRunningRecord>> cachedSet;
|
||||
cachedSet.insert(appRunningRecord1);
|
||||
EXPECT_EQ(appRunningManager->IsAppProcessesAllCached(appInfo->bundleName, appInfo->uid, cachedSet), true);
|
||||
|
||||
appRunningManager->appRunningRecordMap_.insert(make_pair(recordId2, appRunningRecord2));
|
||||
EXPECT_EQ(appRunningManager->IsAppProcessesAllCached(appInfo->bundleName, appInfo->uid, cachedSet), false);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1385,9 +1385,9 @@ HWTEST_F(AppSpawnSocketTest, OnAppCacheStateChanged_001, TestSize.Level0)
|
||||
auto manager = std::make_shared<AppStateObserverManager>();
|
||||
ASSERT_NE(manager, nullptr);
|
||||
std::shared_ptr<AppRunningRecord> appRecord;
|
||||
manager->OnAppCacheStateChanged(appRecord);
|
||||
manager->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CACHED);
|
||||
manager->Init();
|
||||
manager->OnAppCacheStateChanged(appRecord);
|
||||
manager->OnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CACHED);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1402,14 +1402,14 @@ HWTEST_F(AppSpawnSocketTest, HandleOnAppCacheStateChanged_001, TestSize.Level0)
|
||||
{
|
||||
auto manager = std::make_shared<AppStateObserverManager>();
|
||||
ASSERT_NE(manager, nullptr);
|
||||
manager->HandleOnAppCacheStateChanged(nullptr);
|
||||
manager->HandleOnAppCacheStateChanged(nullptr, ApplicationState::APP_STATE_CREATE);
|
||||
std::vector<std::string> bundleNameList;
|
||||
std::shared_ptr<AppRunningRecord> appRecord = MockAppRecord();
|
||||
std::string bundleName = "com.ohos.unittest";
|
||||
appRecord->mainBundleName_ = bundleName;
|
||||
bundleNameList.push_back(bundleName);
|
||||
manager->appStateObserverMap_.emplace(observer_, bundleNameList);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CREATE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1429,7 +1429,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnAppCacheStateChanged_002, TestSize.Level0)
|
||||
std::string bundleName = "com.ohos.unittest";
|
||||
appRecord->mainBundleName_ = bundleName;
|
||||
manager->appStateObserverMap_.emplace(observer_, bundleNameList);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CREATE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1451,7 +1451,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnAppCacheStateChanged_003, TestSize.Level0)
|
||||
appRecord->mainBundleName_ = bundleName1;
|
||||
bundleNameList.push_back(bundleName2);
|
||||
manager->appStateObserverMap_.emplace(observer_, bundleNameList);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CREATE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1472,7 +1472,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnAppCacheStateChanged_004, TestSize.Level0)
|
||||
appRecord->mainBundleName_ = bundleName;
|
||||
bundleNameList.push_back(bundleName);
|
||||
manager->appStateObserverMap_.emplace(nullptr, bundleNameList);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord);
|
||||
manager->HandleOnAppCacheStateChanged(appRecord, ApplicationState::APP_STATE_CREATE);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -17,6 +17,11 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
module_output_path = "ability_runtime/appmgrservice"
|
||||
|
||||
ohos_unittest("cache_process_manager_test") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
module_out_path = module_output_path
|
||||
cflags_cc = []
|
||||
include_dirs = [
|
||||
|
@ -29,6 +29,8 @@ namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
const std::string ABILITY_RECORD_NAME = "Ability_Name_Z";
|
||||
const std::string DEFAULT_BUNDLE_NAME = "com.tdd.cacheprocessmanager";
|
||||
const int32_t DEFAULT_UID = 101010;
|
||||
|
||||
class CacheProcessManagerTest : public testing::Test {
|
||||
public:
|
||||
@ -37,6 +39,7 @@ public:
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
std::shared_ptr<AppRunningRecord> MockAppRecord(int apiLevel = 12);
|
||||
int recordId = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -54,16 +57,16 @@ void CacheProcessManagerTest::TearDown()
|
||||
|
||||
std::shared_ptr<AppRunningRecord> CacheProcessManagerTest::MockAppRecord(int apiLevel)
|
||||
{
|
||||
ApplicationInfo appInfo;
|
||||
appInfo.accessTokenId = 1;
|
||||
std::shared_ptr<ApplicationInfo> info = std::make_shared<ApplicationInfo>(appInfo);
|
||||
info->accessTokenId = 1;
|
||||
info->apiTargetVersion = apiLevel;
|
||||
std::shared_ptr<AppRunningRecord> appRecord = std::make_shared<AppRunningRecord>(info, 0, "process");
|
||||
std::shared_ptr<ApplicationInfo> appInfo = std::make_shared<ApplicationInfo>();
|
||||
appInfo->bundleName = DEFAULT_BUNDLE_NAME;
|
||||
appInfo->uid = DEFAULT_UID;
|
||||
appInfo->accessTokenId = 1;
|
||||
appInfo->apiTargetVersion = apiLevel;
|
||||
std::shared_ptr<AppRunningRecord> appRecord = std::make_shared<AppRunningRecord>(appInfo, recordId++, "process");
|
||||
std::shared_ptr<PriorityObject> priorityObject = std::make_shared<PriorityObject>();
|
||||
priorityObject->SetPid(1);
|
||||
appRecord->priorityObject_ = priorityObject;
|
||||
appRecord->SetUid(1);
|
||||
appRecord->SetUid(DEFAULT_UID);
|
||||
appRecord->SetState(ApplicationState::APP_STATE_CREATE);
|
||||
appRecord->SetContinuousTaskAppState(false);
|
||||
appRecord->SetKeepAliveEnableState(false);
|
||||
@ -73,7 +76,7 @@ std::shared_ptr<AppRunningRecord> CacheProcessManagerTest::MockAppRecord(int api
|
||||
return appRecord;
|
||||
}
|
||||
/**
|
||||
* @tc.name: AppRunningManager_QueryEnableProcessCache_0100
|
||||
* @tc.name: CacheProcessManager_QueryEnableProcessCache_0100
|
||||
* @tc.desc: Test the state of QueryEnableProcessCache
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -86,7 +89,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_QueryEnableProcessCache_01
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_QueryEnableProcessCache_0200
|
||||
* @tc.name: CacheProcessManager_QueryEnableProcessCache_0200
|
||||
* @tc.desc: Test the state of QueryEnableProcessCache
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -99,7 +102,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_QueryEnableProcessCache_02
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_SetAppMgr_0100
|
||||
* @tc.name: CacheProcessManager_SetAppMgr_0100
|
||||
* @tc.desc: Test the state of SetAppMgr
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -113,7 +116,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_SetAppMgr_0100, TestSize.L
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_PenddingCacheProcess_0100
|
||||
* @tc.name: CacheProcessManager_PenddingCacheProcess_0100
|
||||
* @tc.desc: Test the state of PenddingCacheProcess
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -147,7 +150,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_PenddingCacheProcess_0100,
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_CheckAndCacheProcess_0100
|
||||
* @tc.name: CacheProcessManager_CheckAndCacheProcess_0100
|
||||
* @tc.desc: Test the state of CheckAndCacheProcess
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -173,7 +176,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_CheckAndCacheProcess_0100,
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_IsCachedProcess_0100
|
||||
* @tc.name: CacheProcessManager_IsCachedProcess_0100
|
||||
* @tc.desc: Test the state of IsCachedProcess
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -192,7 +195,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_IsCachedProcess_0100, Test
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_OnProcessKilled_0100
|
||||
* @tc.name: CacheProcessManager_OnProcessKilled_0100
|
||||
* @tc.desc: Test the state of OnProcessKilled
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -218,7 +221,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_OnProcessKilled_0100, Test
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_ReuseCachedProcess_0100
|
||||
* @tc.name: CacheProcessManager_ReuseCachedProcess_0100
|
||||
* @tc.desc: Test the state of ReuseCachedProcess
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -244,7 +247,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_ReuseCachedProcess_0100, T
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_IsAppSupportProcessCache_0100
|
||||
* @tc.name: CacheProcessManager_IsAppSupportProcessCache_0100
|
||||
* @tc.desc: Test the state of IsAppSupportProcessCache
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -258,9 +261,11 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_IsAppSupportProcessCache_0
|
||||
EXPECT_EQ(cacheProcMgr->IsAppSupportProcessCache(appRecord), false);
|
||||
// API earlier than 12 not allowed
|
||||
auto appRecord2 = MockAppRecord(11);
|
||||
EXPECT_NE(appRecord2, nullptr);
|
||||
EXPECT_EQ(cacheProcMgr->IsAppSupportProcessCache(appRecord2), false);
|
||||
// different supportState
|
||||
auto appRecord3 = MockAppRecord(12);
|
||||
EXPECT_NE(appRecord3, nullptr);
|
||||
EXPECT_EQ(cacheProcMgr->IsAppSupportProcessCache(appRecord3), true);
|
||||
appRecord3->SetSupportedProcessCache(true);
|
||||
EXPECT_EQ(cacheProcMgr->IsAppSupportProcessCache(appRecord3), true);
|
||||
@ -269,7 +274,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_IsAppSupportProcessCache_0
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_RefreshCacheNum_0100
|
||||
* @tc.name: CacheProcessManager_RefreshCacheNum_0100
|
||||
* @tc.desc: Test the state of RefreshCacheNum
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -282,7 +287,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_RefreshCacheNum_0100, Test
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_GetCurrentCachedProcNum_0100
|
||||
* @tc.name: CacheProcessManager_GetCurrentCachedProcNum_0100
|
||||
* @tc.desc: Test the state of GetCurrentCachedProcNum
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -302,7 +307,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_GetCurrentCachedProcNum_01
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_KillProcessByRecord_0100
|
||||
* @tc.name: CacheProcessManager_KillProcessByRecord_0100
|
||||
* @tc.desc: Test the state of KillProcessByRecord
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -317,7 +322,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_KillProcessByRecord_0100,
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_IsAppShouldCache_0100
|
||||
* @tc.name: CacheProcessManager_IsAppShouldCache_0100
|
||||
* @tc.desc: Test the state of IsAppShouldCache
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -347,7 +352,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_IsAppShouldCache_0100, Tes
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_IsAppAbilitiesEmpty_0100
|
||||
* @tc.name: CacheProcessManager_IsAppAbilitiesEmpty_0100
|
||||
* @tc.desc: Test the state of IsAppAbilitiesEmpty
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -379,7 +384,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_IsAppAbilitiesEmpty_0100,
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_ShrinkAndKillCache_0100
|
||||
* @tc.name: CacheProcessManager_ShrinkAndKillCache_0100
|
||||
* @tc.desc: Test the state of ShrinkAndKillCache
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -404,7 +409,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_ShrinkAndKillCache_0100, T
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppRunningManager_PrintCacheQueue_0100
|
||||
* @tc.name: CacheProcessManager_PrintCacheQueue_0100
|
||||
* @tc.desc: Test the state of PrintCacheQueue
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
@ -421,5 +426,53 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_PrintCacheQueue_0100, Test
|
||||
|
||||
EXPECT_NE(cacheProcMgr->PrintCacheQueue(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CacheProcessManager_AddToApplicationSet_0100
|
||||
* @tc.desc: Test the state of AddToApplicationSet
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(CacheProcessManagerTest, CacheProcessManager_AddToApplicationSet_0100, TestSize.Level1)
|
||||
{
|
||||
auto cacheProcMgr = std::make_shared<CacheProcessManager>();
|
||||
EXPECT_NE(cacheProcMgr, nullptr);
|
||||
cacheProcMgr->maxProcCacheNum_ = 2;
|
||||
|
||||
auto appRecord1 = MockAppRecord();
|
||||
EXPECT_NE(appRecord1, nullptr);
|
||||
auto appRecord2 = MockAppRecord();
|
||||
EXPECT_NE(appRecord2, nullptr);
|
||||
|
||||
cacheProcMgr->AddToApplicationSet(appRecord1);
|
||||
cacheProcMgr->AddToApplicationSet(appRecord2);
|
||||
|
||||
EXPECT_TRUE(cacheProcMgr->sameAppSet.find(DEFAULT_BUNDLE_NAME) != cacheProcMgr->sameAppSet.end());
|
||||
EXPECT_TRUE(cacheProcMgr->sameAppSet[DEFAULT_BUNDLE_NAME].find(DEFAULT_UID) !=
|
||||
cacheProcMgr->sameAppSet[DEFAULT_BUNDLE_NAME].end());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CacheProcessManager_RemoveFromApplicationSet_0100
|
||||
* @tc.desc: Test the state of RemoveFromApplicationSet
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(CacheProcessManagerTest, CacheProcessManager_RemoveFromApplicationSet_0100, TestSize.Level1)
|
||||
{
|
||||
auto cacheProcMgr = std::make_shared<CacheProcessManager>();
|
||||
EXPECT_NE(cacheProcMgr, nullptr);
|
||||
cacheProcMgr->maxProcCacheNum_ = 2;
|
||||
|
||||
auto appRecord1 = MockAppRecord();
|
||||
EXPECT_NE(appRecord1, nullptr);
|
||||
auto appRecord2 = MockAppRecord();
|
||||
EXPECT_NE(appRecord2, nullptr);
|
||||
|
||||
cacheProcMgr->AddToApplicationSet(appRecord1);
|
||||
cacheProcMgr->RemoveFromApplicationSet(appRecord2);
|
||||
EXPECT_TRUE(cacheProcMgr->sameAppSet.find(DEFAULT_BUNDLE_NAME) != cacheProcMgr->sameAppSet.end());
|
||||
|
||||
cacheProcMgr->RemoveFromApplicationSet(appRecord1);
|
||||
EXPECT_TRUE(cacheProcMgr->sameAppSet.find(DEFAULT_BUNDLE_NAME) == cacheProcMgr->sameAppSet.end());
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -2770,6 +2770,42 @@ ohos_unittest("js_ui_extension_Callback_test") {
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("dialog_request_callback_test") {
|
||||
module_out_path = module_output_path
|
||||
defines = []
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime",
|
||||
"${ability_runtime_path}/frameworks/simulator/common/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/dialog_request_callback",
|
||||
]
|
||||
|
||||
sources = [ "dialog_request_callback_test.cpp" ]
|
||||
|
||||
configs = [ ":module_private_config" ]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
"${ability_runtime_native_path}/ability/native:dialog_request_callback",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
defines += [
|
||||
"SUPPORT_SCREEN",
|
||||
"SUPPORT_GRAPHICS",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
||||
group("unittest") {
|
||||
@ -2809,6 +2845,7 @@ group("unittest") {
|
||||
":data_ability_operation_test",
|
||||
":data_ability_result_test",
|
||||
":data_uri_utils_test",
|
||||
":dialog_request_callback_test",
|
||||
":distributed_client_test",
|
||||
":embedded_ui_extension_module_loader_test",
|
||||
":embedded_ui_extension_test",
|
||||
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "dialog_request_callback_proxy.h"
|
||||
#include "dialog_request_callback_stub.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#undef SUPPORT_GRAPHICS
|
||||
#include "dialog_request_callback_impl.h"
|
||||
#endif
|
||||
#include "idialog_request_callback.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class DialogRequestCallbackTest : public testing::Test {
|
||||
public:
|
||||
DialogRequestCallbackTest()
|
||||
{}
|
||||
~DialogRequestCallbackTest()
|
||||
{}
|
||||
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
class MockDialogRequestCallbackStub : public AbilityRuntime::DialogRequestCallbackStub {
|
||||
public:
|
||||
MockDialogRequestCallbackStub() = default;
|
||||
virtual ~MockDialogRequestCallbackStub() = default;
|
||||
MOCK_METHOD4(OnRemoteRequest, int(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option));
|
||||
MOCK_METHOD2(SendResult, void(int32_t resultCode, const AAFwk::Want &want));
|
||||
};
|
||||
|
||||
void DialogRequestCallbackTest::SetUpTestCase(void)
|
||||
{}
|
||||
|
||||
void DialogRequestCallbackTest::TearDownTestCase(void)
|
||||
{}
|
||||
|
||||
void DialogRequestCallbackTest::SetUp(void)
|
||||
{}
|
||||
|
||||
void DialogRequestCallbackTest::TearDown(void)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @tc.number:
|
||||
* @tc.name:
|
||||
* @tc.desc:
|
||||
*/
|
||||
HWTEST_F(DialogRequestCallbackTest, AppExecFwk_DialogRequestCallbackTest0100, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_DialogRequestCallbackTest0100 start";
|
||||
auto mockDialogRequestCallbackStub = new MockDialogRequestCallbackStub();
|
||||
AbilityRuntime::DialogRequestCallbackProxy dialogRequestCallbackProxy(mockDialogRequestCallbackStub);
|
||||
EXPECT_CALL(*mockDialogRequestCallbackStub, OnRemoteRequest(testing::_, testing::_, testing::_, testing::_))
|
||||
.Times(1);
|
||||
AAFwk::Want want;
|
||||
int32_t resultCode = 0;
|
||||
dialogRequestCallbackProxy.SendResult(resultCode, want);
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_DialogRequestCallbackTest0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number:
|
||||
* @tc.name:
|
||||
* @tc.desc:
|
||||
*/
|
||||
HWTEST_F(DialogRequestCallbackTest, AppExecFwk_DialogRequestCallbackTest0200, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_DialogRequestCallbackTest0200 start";
|
||||
AbilityRuntime::RequestDialogResultTask task =
|
||||
[](int32_t resultCode, const AAFwk::Want &resultWant) {
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_DialogRequestCallbackTest0200 fuction is called.";
|
||||
};
|
||||
AbilityRuntime::DialogRequestCallbackImpl dialogRequestCallbackImpl(std::move(task));
|
||||
int32_t resultCode = AbilityRuntime::IDialogRequestCallback::CODE_SEND_RESULT;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
data.WriteInterfaceToken(AbilityRuntime::DialogRequestCallbackStub::GetDescriptor());
|
||||
data.WriteInt32(resultCode);
|
||||
AAFwk::Want want = {};
|
||||
want.SetParam("debugApp", false);
|
||||
data.WriteParcelable(&want);
|
||||
dialogRequestCallbackImpl.OnRemoteRequest(resultCode, data, reply, option);
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_DialogRequestCallbackTest0200 end";
|
||||
}
|
||||
|
||||
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -21,9 +21,13 @@
|
||||
|
||||
#include "form_extension_context_mock_test.h"
|
||||
#include "form_mgr_errors.h"
|
||||
#include "errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "ability_manager_errors.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
@ -242,5 +246,36 @@ HWTEST_F(FormExtensionContextTest, formExtensionContext_GetAbilityInfoType_0200,
|
||||
EXPECT_EQ(abilityInfo->type, formextension_->GetAbilityInfoType());
|
||||
GTEST_LOG_(INFO) << "formExtensionContext_GetAbilityInfoType_0200 end";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.number: formExtensionContext_ConnectAbility_001
|
||||
* @tc.name: GetAbilityInfoType
|
||||
* @tc.desc: ConnectAbility
|
||||
*/
|
||||
HWTEST_F(FormExtensionContextTest, formExtensionContext_ConnectAbility_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "formExtensionContext_ConnectAbility_001 start";
|
||||
Want want;
|
||||
sptr<AbilityRuntime::AbilityConnectCallback> connectCallback;
|
||||
ErrCode result = formextension_->ConnectAbility(want, connectCallback);
|
||||
EXPECT_EQ(AAFwk::ERR_INVALID_CALLER, result);
|
||||
GTEST_LOG_(INFO) << "formExtensionContext_ConnectAbility_001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: formExtensionContext_DisconnectAbility_001
|
||||
* @tc.name: GetAbilityInfoType
|
||||
* @tc.desc: DisconnectAbility
|
||||
*/
|
||||
HWTEST_F(FormExtensionContextTest, formExtensionContext_DisconnectAbility_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "formExtensionContext_DisconnectAbility_001 start";
|
||||
Want want;
|
||||
sptr<AbilityRuntime::AbilityConnectCallback> connectCallback;
|
||||
ErrCode result = formextension_->DisconnectAbility(want, connectCallback);
|
||||
EXPECT_EQ(AAFwk::ERR_INVALID_CALLER, result);
|
||||
GTEST_LOG_(INFO) << "formExtensionContext_DisconnectAbility_001 end";
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -17,6 +17,12 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
module_output_path = "ability_runtime/abilitymgr"
|
||||
|
||||
ohos_unittest("pending_want_manager_test") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
module_out_path = module_output_path
|
||||
|
||||
include_dirs = [
|
||||
|
@ -78,6 +78,41 @@ HWTEST_F(ServiceExtensionContextTest, service_extension_context_startAbility_002
|
||||
EXPECT_EQ(ERR_IMPLICIT_START_ABILITY_FAIL, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: ServiceExtensionContextTest StartAbilityAsCaller
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify startAbility
|
||||
*/
|
||||
HWTEST_F(ServiceExtensionContextTest, service_extension_context_StartAbilityAsCaller_001, TestSize.Level1)
|
||||
{
|
||||
ServiceExtensionContext serviceExtensionContextTest;
|
||||
Want want;
|
||||
ErrCode result = serviceExtensionContextTest.StartAbilityAsCaller(want);
|
||||
GTEST_LOG_(INFO) <<result;
|
||||
EXPECT_EQ(ERR_IMPLICIT_START_ABILITY_FAIL, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: ServiceExtensionContextTest StartAbilityAsCaller
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify startAbility
|
||||
*/
|
||||
HWTEST_F(ServiceExtensionContextTest, service_extension_context_StartAbilityAsCaller_002, TestSize.Level1)
|
||||
{
|
||||
ServiceExtensionContext serviceExtensionContextTest;
|
||||
Want want;
|
||||
StartOptions startOptions;
|
||||
ErrCode result = serviceExtensionContextTest.StartAbilityAsCaller(want, startOptions);
|
||||
GTEST_LOG_(INFO) <<result;
|
||||
EXPECT_EQ(ERR_IMPLICIT_START_ABILITY_FAIL, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
@ -217,6 +252,25 @@ HWTEST_F(ServiceExtensionContextTest, service_extension_context_ConnectAbilityWi
|
||||
EXPECT_EQ(AAFwk::ERR_INVALID_CALLER, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: ServiceExtensionContextTest ConnectAbilityWithAccount
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify startAbility
|
||||
*/
|
||||
HWTEST_F(ServiceExtensionContextTest, service_extension_context_DisconnectAbility_001, TestSize.Level1)
|
||||
{
|
||||
ServiceExtensionContext serviceExtensionContextTest;
|
||||
Want want;
|
||||
int32_t accountId = 1;
|
||||
sptr<AbilityConnectCallback> connectCallback;
|
||||
ErrCode result = serviceExtensionContextTest.DisconnectAbility(want, connectCallback, accountId);
|
||||
GTEST_LOG_(INFO) <<result;
|
||||
EXPECT_EQ(AAFwk::ERR_INVALID_CALLER, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
@ -232,6 +286,23 @@ HWTEST_F(ServiceExtensionContextTest, service_extension_context_TerminateAbility
|
||||
EXPECT_EQ(ERR_INVALID_VALUE, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: ServiceExtensionContextTest RequestModalUIExtension
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify startAbility
|
||||
*/
|
||||
HWTEST_F(ServiceExtensionContextTest, service_extension_context_RequestModalUIExtension_001, TestSize.Level1)
|
||||
{
|
||||
ServiceExtensionContext serviceExtensionContextTest;
|
||||
Want want;
|
||||
ErrCode result = serviceExtensionContextTest.RequestModalUIExtension(want);
|
||||
GTEST_LOG_(INFO) <<result;
|
||||
EXPECT_EQ(AAFwk::INNER_ERR, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: ServiceExtensionContext
|
||||
* Function: startAbility
|
||||
@ -371,4 +442,4 @@ HWTEST_F(ServiceExtensionContextTest, service_extension_context_ClearFailedCallC
|
||||
GTEST_LOG_(INFO) << "service_extension_context_ClearFailedCallConnection_001 end";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ ohos_unittest("ui_ability_lifecycle_manager_test") {
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
|
@ -3257,5 +3257,477 @@ HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_004, TestSize.Level1)
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord);
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_IsAbilityStarted_0100
|
||||
* @tc.desc: IsAbilityStarted
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, IsAbilityStarted_001, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
ASSERT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
Rosen::SessionInfo info;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->sessionToken = new Rosen::Session(info);
|
||||
sessionInfo->persistentId = 0;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, targetRecord);
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->IsAbilityStarted(abilityRequest, targetRecord), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_IsAbilityStarted_0200
|
||||
* @tc.desc: IsAbilityStarted
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, IsAbilityStarted_002, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
ASSERT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
Rosen::SessionInfo info;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->sessionToken = new Rosen::Session(info);
|
||||
sessionInfo->persistentId = 1;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, targetRecord);
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->IsAbilityStarted(abilityRequest, targetRecord), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_KillProcessWithPrepareTerminate_0100
|
||||
* @tc.desc: KillProcessWithPrepareTerminate
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, KillProcessWithPrepareTerminate_001, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
ASSERT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
std::vector<int32_t> pids;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->KillProcessWithPrepareTerminate(pids), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0200
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_002, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0300
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_003, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = 100;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_NATIVE_NOT_SELF_APPLICATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0400
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_004, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
abilityRequest.sessionInfo = nullptr;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0500
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_005, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->processOptions = nullptr;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_START_OPTIONS_CHECK_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0600
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_006, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->processOptions = std::make_shared<ProcessOptions>();
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_START_OPTIONS_CHECK_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0700
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_007, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->sessionToken = nullptr;
|
||||
sessionInfo->processOptions = std::make_shared<ProcessOptions>();
|
||||
sessionInfo->processOptions->processMode = ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0800
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_008, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
Rosen::SessionInfo info;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->sessionToken = new Rosen::Session(info);
|
||||
sessionInfo->processOptions = std::make_shared<ProcessOptions>();
|
||||
sessionInfo->processOptions->processMode = ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeAbilityVisibility_0900
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeAbilityVisibility_009, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
Rosen::SessionInfo info;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->sessionToken = new Rosen::Session(info);
|
||||
sessionInfo->processOptions = std::make_shared<ProcessOptions>();
|
||||
sessionInfo->processOptions->processMode = ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
sptr<IRemoteObject> token = abilityRecord->GetToken()->AsObject();
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeAbilityVisibility(token, isShow), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0200
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_002, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
sptr<SessionInfo> sessionInfo = nullptr;
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0300
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_003, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->persistentId = 100;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord);
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow),
|
||||
ERR_NATIVE_ABILITY_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0400
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_004, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->persistentId = 100;
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, nullptr);
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow),
|
||||
ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0500
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_005, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->persistentId = 100;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
abilityRecord->SetAbilityVisibilityState(AbilityVisibilityState::INITIAL);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow),
|
||||
ERR_NATIVE_ABILITY_STATE_CHECK_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0600
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_006, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->persistentId = 100;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
abilityRecord->SetAbilityVisibilityState(AbilityVisibilityState::UNSPECIFIED);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow),
|
||||
ERR_NATIVE_ABILITY_STATE_CHECK_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0700
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_007, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->persistentId = 100;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
abilityRecord->SetAbilityVisibilityState(AbilityVisibilityState::FOREGROUND_SHOW);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
|
||||
bool isShow = true;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_ChangeUIAbilityVisibilityBySCB_0800
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_008, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
sptr<SessionInfo> sessionInfo(new SessionInfo());
|
||||
sessionInfo->persistentId = 100;
|
||||
abilityRequest.sessionInfo = sessionInfo;
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
abilityRecord->SetAbilityVisibilityState(AbilityVisibilityState::FOREGROUND_HIDE);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord);
|
||||
bool isShow = false;
|
||||
EXPECT_EQ(uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow), ERR_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsByName_0100
|
||||
* @tc.desc: GetAbilityRecordsByName
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsByName_001, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.abilityInfo.bundleName = "com.example.unittest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.deviceId = "100";
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
|
||||
AppExecFwk::ElementName element;
|
||||
auto ret = uiAbilityLifecycleManager->GetAbilityRecordsByName(element);
|
||||
EXPECT_EQ(ret.empty(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsByName_0200
|
||||
* @tc.desc: GetAbilityRecordsByName
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsByName_002, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.abilityInfo.deviceId = "100";
|
||||
abilityRequest.abilityInfo.bundleName = "com.example.unittest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
|
||||
AppExecFwk::ElementName element("100", "com.example.unittest", "MainAbility");
|
||||
auto ret = uiAbilityLifecycleManager->GetAbilityRecordsByName(element);
|
||||
EXPECT_EQ(ret.empty(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsByName_0300
|
||||
* @tc.desc: GetAbilityRecordsByName
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsByName_003, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.abilityInfo.deviceId = "100";
|
||||
abilityRequest.abilityInfo.bundleName = "com.example.unittest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.moduleName = "entry";
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
|
||||
AppExecFwk::ElementName element("100", "com.example.unittest", "MainAbility", "entry");
|
||||
auto ret = uiAbilityLifecycleManager->GetAbilityRecordsByName(element);
|
||||
EXPECT_EQ(ret.empty(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsByNameInner_0100
|
||||
* @tc.desc: GetAbilityRecordsByNameInner
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsByNameInner_001, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.abilityInfo.bundleName = "com.example.unittest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.deviceId = "100";
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
|
||||
AppExecFwk::ElementName element;
|
||||
auto ret = uiAbilityLifecycleManager->GetAbilityRecordsByNameInner(element);
|
||||
EXPECT_EQ(ret.empty(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsByNameInner_0200
|
||||
* @tc.desc: GetAbilityRecordsByNameInner
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsByNameInner_002, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.abilityInfo.deviceId = "100";
|
||||
abilityRequest.abilityInfo.bundleName = "com.example.unittest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
|
||||
AppExecFwk::ElementName element("100", "com.example.unittest", "MainAbility");
|
||||
auto ret = uiAbilityLifecycleManager->GetAbilityRecordsByNameInner(element);
|
||||
EXPECT_EQ(ret.empty(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsByNameInner_0300
|
||||
* @tc.desc: GetAbilityRecordsByNameInner
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsByNameInner_003, TestSize.Level1)
|
||||
{
|
||||
auto uiAbilityLifecycleManager = std::make_unique<UIAbilityLifecycleManager>();
|
||||
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.abilityInfo.deviceId = "100";
|
||||
abilityRequest.abilityInfo.bundleName = "com.example.unittest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.moduleName = "entry";
|
||||
auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord);
|
||||
AppExecFwk::ElementName element("100", "com.example.unittest", "MainAbility", "entry");
|
||||
auto ret = uiAbilityLifecycleManager->GetAbilityRecordsByNameInner(element);
|
||||
EXPECT_EQ(ret.empty(), false);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user