新增进程预加载接口

Signed-off-by: zhangyuhang72 <zhangyuhang72@huawei.com>
Change-Id: I908de9ee5283a9f67eb7b0c2593e0afde903a1ee
This commit is contained in:
zhangyuhang72
2024-04-19 11:16:23 +08:00
parent 014ed0aaf6
commit 024c2ad9c2
48 changed files with 1025 additions and 41 deletions
@@ -18,6 +18,7 @@
#include <cstdint>
#include <mutex>
#include "ability_manager_client.h"
#include "ability_manager_interface.h"
#include "ability_runtime_error_util.h"
#include "app_mgr_interface.h"
@@ -189,6 +190,11 @@ public:
return true;
}
static napi_value PreloadApplication(napi_env env, napi_callback_info info)
{
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnPreloadApplication);
}
private:
sptr<OHOS::AppExecFwk::IAppMgr> appManager_ = nullptr;
sptr<OHOS::AAFwk::IAbilityManager> abilityManager_ = nullptr;
@@ -990,6 +996,48 @@ private:
return result;
}
napi_value OnPreloadApplication(napi_env env, size_t argc, napi_value *argv)
{
TAG_LOGD(AAFwkTag::APPMGR, "OnPreloadApplication called.");
if (argc < ARGC_THREE) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication Invalid param count.");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
PreloadApplicationParam param;
std::string errorMsg;
if (!ConvertPreloadApplicationParam(env, argc, argv, param, errorMsg)) {
ThrowInvalidParamError(env, errorMsg);
return CreateJsUndefined(env);
}
wptr<OHOS::AppExecFwk::IAppMgr> weak = appManager_;
auto innerErrorCode = std::make_shared<int32_t>(ERR_OK);
NapiAsyncTask::ExecuteCallback execute =
[param, innerErrorCode, weak]() {
sptr<OHOS::AppExecFwk::IAppMgr> appMgr = weak.promote();
if (appMgr == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication appMgr is nullptr.");
*innerErrorCode = static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
return;
}
*innerErrorCode = appMgr->PreloadApplication(param.bundleName, param.userId, param.preloadMode,
param.appIndex);
};
NapiAsyncTask::CompleteCallback complete =
[innerErrorCode](napi_env env, NapiAsyncTask &task, int32_t status) {
if (*innerErrorCode == ERR_OK) {
task.ResolveWithNoError(env, CreateJsUndefined(env));
} else {
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode));
}
};
napi_value result = nullptr;
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnPreloadApplication",
env, CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), &result));
return result;
}
bool CheckOnOffType(napi_env env, size_t argc, napi_value* argv)
{
if (argc < ARGC_ONE) {
@@ -1056,6 +1104,7 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj)
napi_set_named_property(env, exportObj, "ApplicationState", ApplicationStateInit(env));
napi_set_named_property(env, exportObj, "ProcessState", ProcessStateInit(env));
napi_set_named_property(env, exportObj, "PreloadMode", PreloadModeInit(env));
const char *moduleName = "AppManager";
BindNativeFunction(env, exportObj, "on", moduleName, JsAppManager::On);
@@ -1088,6 +1137,8 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj)
JsAppManager::GetRunningProcessInfoByBundleName);
BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName,
JsAppManager::IsApplicationRunning);
BindNativeFunction(env, exportObj, "preloadApplication", moduleName,
JsAppManager::PreloadApplication);
TAG_LOGD(AAFwkTag::APPMGR, "end");
return CreateJsUndefined(env);
}
@@ -25,6 +25,12 @@
namespace OHOS {
namespace AbilityRuntime {
namespace {
constexpr const int32_t ARG_INDEX_0 = 0;
constexpr const int32_t ARG_INDEX_1 = 1;
constexpr const int32_t ARG_INDEX_2 = 2;
constexpr const int32_t ARG_INDEX_3 = 3;
}
napi_value CreateJsAppStateData(napi_env env, const AppStateData &appStateData)
{
TAG_LOGD(AAFwkTag::APPMGR, "called.");
@@ -201,6 +207,49 @@ napi_value ProcessStateInit(napi_env env)
return object;
}
napi_value PreloadModeInit(napi_env env)
{
TAG_LOGD(AAFwkTag::APPMGR, "PreloadModeInit enter.");
if (env == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadModeInit, env is nullptr.");
return nullptr;
}
napi_value objValue = nullptr;
napi_create_object(env, &objValue);
napi_set_named_property(env, objValue, "PRESS_DOWN",
CreateJsValue(env, static_cast<int32_t>(AppExecFwk::PreloadMode::PRESS_DOWN)));
return objValue;
}
bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, PreloadApplicationParam &param,
std::string &errorMsg)
{
if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], param.bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param bundleName failed.");
errorMsg = "Param bundleName must be a valid string.";
return false;
}
if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], param.userId)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param userId failed.");
errorMsg = "Param userId must be a valid number.";
return false;
}
if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], param.preloadMode)
|| param.preloadMode != AppExecFwk::PreloadMode::PRESS_DOWN) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param preloadMode failed.");
errorMsg = "Unsupported preloadMode, must be PreloadMode.PRESS_DOWN.";
return false;
}
if (argc > ARG_INDEX_3 && !ConvertFromJsValue(env, argv[ARG_INDEX_3], param.appIndex)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param appIndex failed.");
errorMsg = "Param appIndex must be a valid number.";
return false;
}
return true;
}
JsAppProcessState ConvertToJsAppProcessState(
const AppExecFwk::AppProcessState &appProcessState, const bool &isFocused)
{
@@ -39,6 +39,13 @@ enum JsAppProcessState {
STATE_BACKGROUND,
STATE_DESTROY
};
struct PreloadApplicationParam {
std::string bundleName;
int32_t userId;
AppExecFwk::PreloadMode preloadMode;
int32_t appIndex;
};
napi_value CreateJsAppStateData(napi_env env, const AppStateData &appStateData);
napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilityStateData);
#ifdef SUPPORT_GRAPHICS
@@ -51,6 +58,9 @@ napi_value CreateJsRunningProcessInfoArray(napi_env env, const std::vector<Runni
napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &info);
napi_value ApplicationStateInit(napi_env env);
napi_value ProcessStateInit(napi_env env);
napi_value PreloadModeInit(napi_env env);
bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, PreloadApplicationParam &param,
std::string &errorMsg);
JsAppProcessState ConvertToJsAppProcessState(
const AppExecFwk::AppProcessState &appProcessState, const bool &isFocused);
} // namespace AbilityRuntime
@@ -74,6 +74,7 @@ constexpr const char* ERROR_MSG_ABILITY_ALREADY_RUNNING = "Ability already runni
constexpr const char* ERROR_MSG_NOT_SUPPORT_CROSS_APP_START =
"The application is not allow jumping to other applications when api version is above 11.";
constexpr const char* ERROR_MSG_CANNOT_MATCH_ANY_COMPONENT = "Can not match any component.";
constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle does not exist.";
// follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework
constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220;
@@ -124,6 +125,7 @@ static std::unordered_map<AbilityErrorCode, const char*> ERR_CODE_MAP = {
{ AbilityErrorCode::ERROR_ABILITY_ALREADY_RUNNING, ERROR_MSG_ABILITY_ALREADY_RUNNING },
{ AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_CROSS_APP_START, ERROR_MSG_NOT_SUPPORT_CROSS_APP_START },
{ AbilityErrorCode::ERROR_CODE_CANNOT_MATCH_ANY_COMPONENT, ERROR_MSG_CANNOT_MATCH_ANY_COMPONENT },
{ AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST },
};
static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP {
@@ -176,7 +178,8 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
{ERR_WUKONG_MODE_CANT_MOVE_STATE, AbilityErrorCode::ERROR_CODE_WUKONG_MODE_CANT_MOVE_STATE},
{ERR_OPERATION_NOT_SUPPORTED_ON_CURRENT_DEVICE, AbilityErrorCode::ERROR_CODE_OPERATION_NOT_SUPPORTED},
{ERR_IMPLICIT_START_ABILITY_FAIL, AbilityErrorCode::ERROR_CODE_CANNOT_MATCH_ANY_COMPONENT},
{ERR_START_OTHER_APP_FAILED, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_CROSS_APP_START}
{ERR_START_OTHER_APP_FAILED, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_CROSS_APP_START},
{ERR_TARGET_BUNDLE_NOT_EXIST, AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST},
};
}
+1 -1
View File
@@ -1218,7 +1218,7 @@ bool GetBundleForLaunchApplication(std::shared_ptr<BundleMgrHelper> bundleMgrHel
void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, const Configuration &config)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPKIT, "called");
TAG_LOGI(AAFwkTag::APPKIT, "HandleLaunchApplication called.");
if (!CheckForHandleLaunchApplication(appLaunchData)) {
TAG_LOGE(AAFwkTag::APPKIT, "CheckForHandleLaunchApplication failed.");
return;
@@ -462,6 +462,21 @@ enum {
* Native error(2097240) for memory size state unchanged.
*/
ERR_NATIVE_MEMORY_SIZE_STATE_UNCHANGED,
/**
* Native error(2097241) for target bundle not exist.
*/
ERR_TARGET_BUNDLE_NOT_EXIST,
/**
* Native error(2097242) for get launch ability info failed.
*/
ERR_GET_LAUNCH_ABILITY_INFO_FAILED,
/**
* Native error(2097243) for check preload conditions failed.
*/
ERR_CHECK_PRELOAD_CONDITIONS_FAILED,
};
enum {
@@ -721,6 +721,18 @@ public:
*/
bool IsMemorySizeSufficent() const;
/**
* Preload application.
*
* @param bundleName The bundle name of the application to preload.
* @param userId Indicates the user identification.
* @param preloadMode Preload application mode.
* @param appIndex The index of application clone.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0);
private:
void SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr);
/**
@@ -85,6 +85,17 @@ enum class AppStartType {
HOT,
MULTI_INSTANCE,
};
enum class PreloadMode {
PRESS_DOWN = 0,
PRE_MAKE = 1,
};
enum class PreloadState {
NONE = 0,
PRELOADING = 1,
PRELOADED = 2,
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_APP_MGR_CONSTANTS_H
@@ -57,6 +57,21 @@ public:
*/
virtual void AttachApplication(const sptr<IRemoteObject> &app) = 0;
/**
* Preload application.
*
* @param bundleName The bundle name of the application to preload.
* @param userId Indicates the user identification.
* @param preloadMode Preload application mode.
* @param appIndex The index of application clone.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0)
{
return 0;
}
/**
* ApplicationForegrounded, call ApplicationForegrounded() through proxy object,
* set the application to Foreground State.
@@ -96,6 +96,7 @@ enum class AppMgrInterfaceCode {
GET_ALL_UI_EXTENSION_PROVIDER_PID = 70,
UPDATE_CONFIGURATION_BY_BUNDLE_NAME = 71,
NOTIFY_MEMORY_SIZE_STATE_CHANGED = 72,
PRELOAD_APPLICATION = 73,
};
} // AppExecFwk
} // OHOS
@@ -40,6 +40,18 @@ public:
*/
virtual void AttachApplication(const sptr<IRemoteObject> &obj) override;
/**
* Preload application.
*
* @param bundleName The bundle name of the application to preload.
* @param userId Indicates the user identification.
* @param preloadMode Preload application mode.
* @param appIndex The index of application clone.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0) override;
/**
* ApplicationForegrounded, call ApplicationForegrounded() through proxy object,
* set the application to Foreground State.
@@ -57,6 +57,7 @@ public:
private:
int32_t HandleAttachApplication(MessageParcel &data, MessageParcel &reply);
int32_t HandlePreloadApplication(MessageParcel &data, MessageParcel &reply);
int32_t HandleApplicationForegrounded(MessageParcel &data, MessageParcel &reply);
int32_t HandleApplicationBackgrounded(MessageParcel &data, MessageParcel &reply);
int32_t HandleApplicationTerminated(MessageParcel &data, MessageParcel &reply);
@@ -1145,5 +1145,15 @@ bool AppMgrClient::IsMemorySizeSufficent() const
}
return amsService->IsMemorySizeSufficent();
}
int32_t AppMgrClient::PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex)
{
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
if (service == nullptr) {
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
}
return service->PreloadApplication(bundleName, userId, preloadMode, appIndex);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -24,6 +24,16 @@
namespace OHOS {
namespace AppExecFwk {
namespace {
#define PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(messageParcel, type, value) \
do { \
if (!(messageParcel).Write##type(value)) { \
TAG_LOGE(AAFwkTag::APPMGR, \
"failed to write %{public}s", #value); \
return IPC_PROXY_ERR; \
} \
} while (0)
}
constexpr int32_t CYCLE_LIMIT = 1000;
AppMgrProxy::AppMgrProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAppMgr>(impl)
{}
@@ -55,6 +65,31 @@ void AppMgrProxy::AttachApplication(const sptr<IRemoteObject> &obj)
}
}
int32_t AppMgrProxy::PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex)
{
TAG_LOGD(AAFwkTag::APPMGR, "PreloadApplication called.");
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!WriteInterfaceToken(data)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication Write interface token failed.");
return IPC_PROXY_ERR;
}
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, String16, Str8ToStr16(bundleName));
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, static_cast<int32_t>(preloadMode));
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, appIndex);
int32_t error = SendRequest(AppMgrInterfaceCode::PRELOAD_APPLICATION, data, reply, option);
if (error != NO_ERROR) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication Send request error: %{public}d.", error);
return error;
}
return reply.ReadInt32();
}
void AppMgrProxy::ApplicationForegrounded(const int32_t recordId)
{
MessageParcel data;
@@ -39,6 +39,8 @@ AppMgrStub::AppMgrStub()
{
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::APP_ATTACH_APPLICATION)] =
&AppMgrStub::HandleAttachApplication;
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::PRELOAD_APPLICATION)] =
&AppMgrStub::HandlePreloadApplication;
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::APP_APPLICATION_FOREGROUNDED)] =
&AppMgrStub::HandleApplicationForegrounded;
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::APP_APPLICATION_BACKGROUNDED)] =
@@ -221,6 +223,22 @@ int32_t AppMgrStub::HandleAttachApplication(MessageParcel &data, MessageParcel &
return NO_ERROR;
}
int32_t AppMgrStub::HandlePreloadApplication(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
TAG_LOGD(AAFwkTag::APPMGR, "Stub HandlePreloadApplication called.");
std::string bundleName = Str16ToStr8(data.ReadString16());
int32_t userId = data.ReadInt32();
int32_t preloadMode = data.ReadInt32();
int32_t appIndex = data.ReadInt32();
auto result = PreloadApplication(bundleName, userId, static_cast<AppExecFwk::PreloadMode>(preloadMode), appIndex);
if (!reply.WriteInt32(result)) {
TAG_LOGE(AAFwkTag::APPMGR, "Stub HandlePreloadApplication Write result failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return NO_ERROR;
}
int32_t AppMgrStub::HandleApplicationForegrounded(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
@@ -155,6 +155,9 @@ enum class AbilityErrorCode {
// observer not found.
ERROR_CODE_OBSERVER_NOT_FOUND = 16300004,
// target bundle not exist.
ERROR_CODE_TARGET_BUNDLE_NOT_EXIST = 16300005,
};
std::string GetErrorMsg(const AbilityErrorCode& errCode);
+1
View File
@@ -50,6 +50,7 @@ ohos_shared_library("libappms") {
"src/app_mgr_service.cpp",
"src/app_mgr_service_event_handler.cpp",
"src/app_mgr_service_inner.cpp",
"src/app_preloader.cpp",
"src/app_process_manager.cpp",
"src/app_running_manager.cpp",
"src/app_running_record.cpp",
+12
View File
@@ -70,6 +70,18 @@ public:
*/
virtual void AttachApplication(const sptr<IRemoteObject> &app) override;
/**
* Preload application.
*
* @param bundleName The bundle name of the application to preload.
* @param userId Indicates the user identification.
* @param preloadMode Preload application mode.
* @param appIndex The index of application clone.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex) override;
// notify the ams update the state of an app, when it entered foreground.
/**
@@ -33,6 +33,7 @@
#include "app_foreground_state_observer_interface.h"
#include "app_malloc_info.h"
#include "app_mgr_constants.h"
#include "app_preloader.h"
#include "app_process_manager.h"
#include "app_record_id.h"
#include "app_running_manager.h"
@@ -185,6 +186,18 @@ public:
*/
virtual void AttachApplication(const pid_t pid, const sptr<IAppScheduler> &appScheduler);
/**
* Preload application.
*
* @param bundleName The bundle name of the application to preload.
* @param userId Indicates the user identification.
* @param preloadMode Preload application mode.
* @param appIndex The index of application clone.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex);
/**
* ApplicationForegrounded, set the application to Foreground State.
*
@@ -1087,7 +1100,8 @@ private:
*/
void StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags,
std::shared_ptr<AppRunningRecord> appRecord, const int uid, const BundleInfo &bundleInfo,
const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag = true);
const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag = true,
bool isPreload = false);
/**
* PushAppFront, Adjust the latest application record to the top level.
@@ -1330,6 +1344,22 @@ private:
*/
bool NotifyMemMgrPriorityChanged(const std::shared_ptr<AppRunningRecord> appRecord);
void HandlePreloadApplication(const PreloadRequest &request);
std::string GetSpecifiedProcessFlag(std::shared_ptr<AbilityInfo> abilityInfo, std::shared_ptr<AAFwk::Want> want);
void LoadAbilityNoAppRecord(const std::shared_ptr<AppRunningRecord> appRecord,
sptr<IRemoteObject> preToken,
std::shared_ptr<ApplicationInfo> appInfo,
std::shared_ptr<AbilityInfo> abilityInfo,
const std::string &processName,
const std::string &specifiedProcessFlag,
const BundleInfo &bundleInfo,
const HapModuleInfo &hapModuleInfo,
std::shared_ptr<AAFwk::Want> want,
bool appExistFlag,
bool isPreload);
private:
/**
* Notify application status.
@@ -1392,6 +1422,7 @@ private:
std::vector<std::string> serviceExtensionWhiteList_;
std::shared_ptr<AdvancedSecurityModeManager> securityModeManager_;
std::shared_ptr<AAFwk::TaskHandlerWrap> dfxTaskHandler_;
std::shared_ptr<AppPreloader> appPreloader_;
};
} // namespace AppExecFwk
} // namespace OHOS
+60
View File
@@ -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.
*/
#ifndef OHOS_ABILITY_RUNTIME_APP_PRELOADER_H
#define OHOS_ABILITY_RUNTIME_APP_PRELOADER_H
#include <string>
#include "ability_info.h"
#include "remote_client_manager.h"
#include "want.h"
namespace OHOS {
namespace AppExecFwk {
struct PreloadRequest {
std::shared_ptr<AbilityInfo> abilityInfo = nullptr;
std::shared_ptr<ApplicationInfo> appInfo = nullptr;
std::shared_ptr<AAFwk::Want> want = nullptr;
BundleInfo bundleInfo;
HapModuleInfo hapModuleInfo;
int32_t appIndex = 0; // not used
};
class AppPreloader {
public:
AppPreloader(std::shared_ptr<RemoteClientManager> remoteClientManager);
~AppPreloader() = default;
int32_t GeneratePreloadRequest(const std::string &bundleName, int32_t userId, int32_t appIndex,
PreloadRequest &request);
private:
bool GetLaunchWant(const std::string &bundleName, int32_t userId, AAFwk::Want &want);
bool GetLaunchAbilityInfo(const AAFwk::Want &want, int32_t userId, AbilityInfo &abilityInfo);
bool GetBundleAndHapInfo(const std::string &bundleName, int32_t userId,
const AbilityInfo &abilityInfo, BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo);
bool CheckPreloadConditions(const AbilityInfo &abilityInfo);
std::shared_ptr<BundleMgrHelper> GetBundleManagerHelper();
std::shared_ptr<RemoteClientManager> remoteClientManager_;
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_APP_PRELOADER_H
@@ -712,6 +712,12 @@ public:
std::shared_ptr<ChildProcessRecord> GetChildProcessRecordByPid(const pid_t pid);
std::map<pid_t, std::shared_ptr<ChildProcessRecord>> GetChildProcessRecordMap();
void SetPreloadState(PreloadState state);
bool IsPreloading() const;
bool IsPreloaded() const;
/**
* @brief Obtains the app record assign tokenId.
*
@@ -862,6 +868,7 @@ private:
int64_t startTimeMillis_ = 0; // The time of app start(CLOCK_MONOTONIC)
int64_t restartTimeMillis_ = 0; // The time of last trying app restart
bool jitEnabled_ = false;
PreloadState preloadState_ = PreloadState::NONE;
std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr;
+11
View File
@@ -206,6 +206,17 @@ void AppMgrService::AttachApplication(const sptr<IRemoteObject> &app)
});
}
int32_t AppMgrService::PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex)
{
TAG_LOGD(AAFwkTag::APPMGR, "PreloadApplication called");
if (!IsReady()) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication failed, appMgr not ready.");
return ERR_INVALID_OPERATION;
}
return appMgrServiceInner_->PreloadApplication(bundleName, userId, preloadMode, appIndex);
}
void AppMgrService::ApplicationForegrounded(const int32_t recordId)
{
if (!IsReady()) {
+162 -38
View File
@@ -178,6 +178,7 @@ const std::string SYSTEM_CORE = "system_core";
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
const std::string PROCESS_EXIT_EVENT_TASK = "Send Process Exit Event Task";
const std::string KILL_PROCESS_REASON_PREFIX = "Kill Reason:";
const std::string PRELOAD_APPLIATION_TASK = "PreloadApplicactionTask";
constexpr int32_t ROOT_UID = 0;
constexpr int32_t FOUNDATION_UID = 5523;
@@ -191,6 +192,7 @@ constexpr int32_t NETSYS_SOCKET_GROUPID = 1097;
#endif
constexpr int32_t DEFAULT_INVAL_VALUE = -1;
constexpr int32_t NO_ABILITY_RECORD_ID = -1;
int32_t GetUserIdByUid(int32_t uid)
{
@@ -237,7 +239,8 @@ AppMgrServiceInner::AppMgrServiceInner()
configuration_(std::make_shared<Configuration>()),
appDebugManager_(std::make_shared<AppDebugManager>()),
appRunningStatusModule_(std::make_shared<AbilityRuntime::AppRunningStatusModule>()),
securityModeManager_(std::make_shared<AdvancedSecurityModeManager>())
securityModeManager_(std::make_shared<AdvancedSecurityModeManager>()),
appPreloader_(std::make_shared<AppPreloader>(remoteClientManager_))
{}
void AppMgrServiceInner::Init()
@@ -297,6 +300,93 @@ void AppMgrServiceInner::StartSpecifiedProcess(const AAFwk::Want &want, const Ap
}
}
int32_t AppMgrServiceInner::PreloadApplication(const std::string &bundleName, int32_t userId,
AppExecFwk::PreloadMode preloadMode, int32_t appIndex)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPMGR,
"PreloadApplication, bundleName:%{public}s, userId:%{public}d, preloadMode:%{public}d, appIndex:%{public}d",
bundleName.c_str(), userId, preloadMode, appIndex);
CHECK_CALLER_IS_SYSTEM_APP;
auto isPerm = AAFwk::PermissionVerification::GetInstance()->VerifyPreloadApplicationPermission();
if (!isPerm) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication %{public}s: Permission verification failed", __func__);
return ERR_PERMISSION_DENIED;
}
if (!appPreloader_) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication appPreloader is nullptr.");
return ERR_INVALID_VALUE;
}
// todo RSS preCheck
PreloadRequest request;
auto ret = appPreloader_->GeneratePreloadRequest(bundleName, userId, appIndex, request);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GeneratePreloadRequest failed.");
return ret;
}
auto task = [inner = shared_from_this(), request] () {
if (!inner) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication appMgrServiceInner is nullptr.");
return;
}
inner->HandlePreloadApplication(request);
};
if (!taskHandler_) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication taskHandler_ is nullptr.");
return ERR_INVALID_VALUE;
}
TAG_LOGI(AAFwkTag::APPMGR, "PreloadApplication Submit task, bundleName:%{public}s, userId:%{public}d.",
bundleName.c_str(), userId);
taskHandler_->SubmitTask(task, PRELOAD_APPLIATION_TASK);
return ERR_OK;
}
void AppMgrServiceInner::HandlePreloadApplication(const PreloadRequest &request)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
auto abilityInfo = request.abilityInfo;
if (!abilityInfo) {
TAG_LOGE(AAFwkTag::APPMGR, "HandlePreloadApplication request.abilityInfo is nullptr.");
return;
}
auto bundleInfo = request.bundleInfo;
TAG_LOGI(AAFwkTag::APPMGR, "HandlePreloadApplication, bundleName:%{public}s, abilityName:%{public}s, \
appIndex:%{public}d", bundleInfo.name.c_str(), abilityInfo->name.c_str(), request.appIndex);
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::shared_ptr<AppRunningRecord> appRecord = appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name,
processName, appInfo->uid, bundleInfo, specifiedProcessFlag);
if (appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "HandlePreloadApplication AppRecord already exists, no need to preload.");
return;
}
if (!appRunningManager_) {
TAG_LOGE(AAFwkTag::APPMGR, "HandlePreloadApplication failed, appRunningManager_ is nullptr");
return;
}
bool appExistFlag = appRunningManager_->CheckAppRunningRecordIsExistByBundleName(bundleInfo.name);
if (!appExistFlag) {
NotifyAppRunningStatusEvent(
bundleInfo.name, appInfo->uid, AbilityRuntime::RunningStatus::APP_RUNNING_START);
}
appRecord = CreateAppRunningRecord(nullptr, nullptr, appInfo, abilityInfo, processName, bundleInfo,
hapModuleInfo, want, NO_ABILITY_RECORD_ID);
appRecord->SetPreloadState(PreloadState::PRELOADING);
LoadAbilityNoAppRecord(appRecord, nullptr, appInfo, abilityInfo, processName, specifiedProcessFlag, bundleInfo,
hapModuleInfo, want, appExistFlag, true);
}
void AppMgrServiceInner::LoadAbility(sptr<IRemoteObject> token, sptr<IRemoteObject> preToken,
std::shared_ptr<AbilityInfo> abilityInfo, std::shared_ptr<ApplicationInfo> appInfo,
std::shared_ptr<AAFwk::Want> want, int32_t abilityRecordId)
@@ -333,14 +423,8 @@ void AppMgrServiceInner::LoadAbility(sptr<IRemoteObject> token, sptr<IRemoteObje
std::shared_ptr<AppRunningRecord> appRecord;
// for isolation process
std::string specifiedProcessFlag = "";
std::string specifiedProcessFlag = GetSpecifiedProcessFlag(abilityInfo, want);
bool isUIAbility = (abilityInfo->type == AppExecFwk::AbilityType::PAGE && abilityInfo->isStageBasedModel);
bool isSpecifiedProcess = abilityInfo->isolationProcess &&
AAFwk::AppUtils::GetInstance().IsStartSpecifiedProcess() && isUIAbility;
if (isSpecifiedProcess) {
specifiedProcessFlag = want->GetStringParam(PARAM_SPECIFIED_PROCESS_FLAG);
TAG_LOGI(AAFwkTag::APPMGR, "specifiedProcessFlag = %{public}s", specifiedProcessFlag.c_str());
}
appRecord = appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name,
processName, appInfo->uid, bundleInfo, specifiedProcessFlag);
if (appRecord && isUIAbility) {
@@ -356,32 +440,8 @@ void AppMgrServiceInner::LoadAbility(sptr<IRemoteObject> token, sptr<IRemoteObje
}
appRecord = CreateAppRunningRecord(token, preToken, appInfo, abilityInfo,
processName, bundleInfo, hapModuleInfo, want, abilityRecordId);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "CreateAppRunningRecord failed, appRecord is nullptr");
return;
}
if (isSpecifiedProcess && !specifiedProcessFlag.empty()) {
appRecord->SetSpecifiedProcessFlag(specifiedProcessFlag);
}
if (hapModuleInfo.isStageBasedModel && !IsMainProcess(appInfo, hapModuleInfo)) {
appRecord->SetKeepAliveAppState(false, false);
TAG_LOGI(AAFwkTag::APPMGR, "The process %{public}s will not keepalive", hapModuleInfo.process.c_str());
}
OnAppStateChanged(appRecord, ApplicationState::APP_STATE_SET_COLD_START, false, false);
SendAppStartupTypeEvent(appRecord, abilityInfo, AppStartType::COLD);
auto callRecord = GetAppRunningRecordByAbilityToken(preToken);
if (callRecord != nullptr) {
auto launchReson = (want == nullptr) ? 0 : want->GetIntParam("ohos.ability.launch.reason", 0);
TAG_LOGD(AAFwkTag::APPMGR, "req: %{public}d, proc: %{public}s, call:%{public}d,%{public}s", launchReson,
appInfo->name.c_str(), appRecord->GetCallerPid(), callRecord->GetBundleName().c_str());
}
uint32_t startFlags = (want == nullptr) ? 0 : AppspawnUtil::BuildStartFlags(*want, *abilityInfo);
int32_t bundleIndex = (want == nullptr) ? 0 : want->GetIntParam(DLP_PARAMS_INDEX, 0);
StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord,
appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag);
std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD);
bool isSandboxApp = (want == nullptr) ? false : want->GetBoolParam(ENTER_SANDBOX, false);
(void)StartPerfProcess(appRecord, perfCmd, "", isSandboxApp);
LoadAbilityNoAppRecord(appRecord, preToken, appInfo, abilityInfo, processName, specifiedProcessFlag,
bundleInfo, hapModuleInfo, want, appExistFlag, false);
} else {
TAG_LOGI(AAFwkTag::APPMGR, "have apprecord");
SendAppStartupTypeEvent(appRecord, abilityInfo, AppStartType::MULTI_INSTANCE);
@@ -526,6 +586,67 @@ void AppMgrServiceInner::MakeProcessName(
processName = appInfo->bundleName;
}
void AppMgrServiceInner::LoadAbilityNoAppRecord(const std::shared_ptr<AppRunningRecord> appRecord,
sptr<IRemoteObject> preToken, std::shared_ptr<ApplicationInfo> appInfo,
std::shared_ptr<AbilityInfo> abilityInfo, const std::string &processName,
const std::string &specifiedProcessFlag, const BundleInfo &bundleInfo, const HapModuleInfo &hapModuleInfo,
std::shared_ptr<AAFwk::Want> want, bool appExistFlag, bool isPreload)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::APPMGR, "LoadAbilityNoAppRecord, processName:%{public}s, isPreload:%{public}d",
processName.c_str(), isPreload);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "CreateAppRunningRecord failed, appRecord is nullptr");
return;
}
if (!specifiedProcessFlag.empty()) {
appRecord->SetSpecifiedProcessFlag(specifiedProcessFlag);
}
if (hapModuleInfo.isStageBasedModel && !IsMainProcess(appInfo, hapModuleInfo)) {
appRecord->SetKeepAliveAppState(false, false);
TAG_LOGI(AAFwkTag::APPMGR, "The process %{public}s will not keepalive", hapModuleInfo.process.c_str());
}
OnAppStateChanged(appRecord, ApplicationState::APP_STATE_SET_COLD_START, false, false);
SendAppStartupTypeEvent(appRecord, abilityInfo, AppStartType::COLD);
if (preToken) {
auto callRecord = GetAppRunningRecordByAbilityToken(preToken);
if (callRecord != nullptr) {
auto launchReson = (want == nullptr) ? 0 : want->GetIntParam("ohos.ability.launch.reason", 0);
TAG_LOGD(AAFwkTag::APPMGR, "req: %{public}d, proc: %{public}s, call:%{public}d,%{public}s", launchReson,
appInfo->name.c_str(), appRecord->GetCallerPid(), callRecord->GetBundleName().c_str());
}
}
uint32_t startFlags = (want == nullptr) ? 0 : AppspawnUtil::BuildStartFlags(*want, *abilityInfo);
int32_t bundleIndex = (want == nullptr) ? 0 : want->GetIntParam(DLP_PARAMS_INDEX, 0);
StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord,
appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload);
std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD);
bool isSandboxApp = (want == nullptr) ? false : want->GetBoolParam(ENTER_SANDBOX, false);
(void)StartPerfProcess(appRecord, perfCmd, "", isSandboxApp);
}
std::string AppMgrServiceInner::GetSpecifiedProcessFlag(std::shared_ptr<AbilityInfo> abilityInfo,
std::shared_ptr<AAFwk::Want> want)
{
if (!abilityInfo) {
TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo is nullptr.");
return "";
}
if (!want) {
TAG_LOGE(AAFwkTag::APPMGR, "want is nullptr.");
return "";
}
std::string specifiedProcessFlag = "";
bool isUIAbility = (abilityInfo->type == AppExecFwk::AbilityType::PAGE && abilityInfo->isStageBasedModel);
bool isSpecifiedProcess = abilityInfo->isolationProcess &&
AAFwk::AppUtils::GetInstance().IsStartSpecifiedProcess() && isUIAbility;
if (isSpecifiedProcess) {
specifiedProcessFlag = want->GetStringParam(PARAM_SPECIFIED_PROCESS_FLAG);
TAG_LOGI(AAFwkTag::APPMGR, "specifiedProcessFlag = %{public}s", specifiedProcessFlag.c_str());
}
return specifiedProcessFlag;
}
bool AppMgrServiceInner::IsMainProcess(const std::shared_ptr<ApplicationInfo> &appInfo,
const HapModuleInfo &hapModuleInfo) const
{
@@ -699,6 +820,7 @@ void AppMgrServiceInner::LaunchApplication(const std::shared_ptr<AppRunningRecor
return;
}
appRecord->LaunchPendingAbilities();
appRecord->SetPreloadState(PreloadState::PRELOADED);
SendAppLaunchEvent(appRecord);
}
@@ -1938,7 +2060,8 @@ void AppMgrServiceInner::StartAbility(sptr<IRemoteObject> token, sptr<IRemoteObj
ApplicationState appState = appRecord->GetState();
if (appState == ApplicationState::APP_STATE_CREATE) {
TAG_LOGE(AAFwkTag::APPMGR, "in create state, don't launch ability");
TAG_LOGE(AAFwkTag::APPMGR, "in create state, don't launch ability, bundleName:%{public}s, ability:%{public}s",
appInfo->bundleName.c_str(), abilityInfo->name.c_str());
return;
}
appRecord->LaunchAbility(ability);
@@ -2249,7 +2372,7 @@ void AppMgrServiceInner::StartProcessVerifyPermission(const BundleInfo &bundleIn
void AppMgrServiceInner::StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags,
std::shared_ptr<AppRunningRecord> appRecord, const int uid, const BundleInfo &bundleInfo,
const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag)
const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag, bool isPreload)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
if (!appRecord) {
@@ -2321,8 +2444,9 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
SetOverlayInfo(bundleName, userId, startMsg);
SetAppEnvInfo(bundleInfo, startMsg);
TAG_LOGI(AAFwkTag::APPMGR, "apl is %{public}s, bundleName is %{public}s, startFlags is %{public}d.",
startMsg.apl.c_str(), bundleName.c_str(), startFlags);
TAG_LOGI(AAFwkTag::APPMGR,
"apl is %{public}s, bundleName is %{public}s, startFlags is %{public}d, isPreload:%{public}d",
startMsg.apl.c_str(), bundleName.c_str(), startFlags, isPreload);
bool bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleGidsByUid(bundleName, uid, startMsg.gids));
if (!bundleMgrResult) {
+160
View File
@@ -0,0 +1,160 @@
/*
* 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 "app_preloader.h"
#include <string>
#include "ability_manager_errors.h"
#include "in_process_call_wrapper.h"
#include "hilog_tag_wrapper.h"
#include "hitrace_meter.h"
namespace OHOS {
namespace AppExecFwk {
AppPreloader::AppPreloader(std::shared_ptr<RemoteClientManager> remoteClientManager)
{
remoteClientManager_ = remoteClientManager;
}
int32_t AppPreloader::GeneratePreloadRequest(const std::string &bundleName, int32_t userId, int32_t appIndex,
PreloadRequest &request)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::APPMGR, "PreloadApplication GeneratePreloadRequest");
AAFwk::Want launchWant;
if (!GetLaunchWant(bundleName, userId, launchWant)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetLaunchWant failed");
return AAFwk::ERR_TARGET_BUNDLE_NOT_EXIST;
}
AbilityInfo abilityInfo;
if (!GetLaunchAbilityInfo(launchWant, userId, abilityInfo)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetLaunchAbilityInfo failed");
return AAFwk::ERR_GET_LAUNCH_ABILITY_INFO_FAILED;
}
if (!CheckPreloadConditions(abilityInfo)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication CheckPreloadConditions failed.");
return AAFwk::ERR_CHECK_PRELOAD_CONDITIONS_FAILED;
}
BundleInfo bundleInfo;
HapModuleInfo hapModuleInfo;
if (!GetBundleAndHapInfo(bundleName, userId, abilityInfo, bundleInfo, hapModuleInfo)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetBundleAndHapInfo failed");
return AAFwk::GET_BUNDLE_INFO_FAILED;
}
request.abilityInfo = std::make_shared<AbilityInfo>(abilityInfo);
request.appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo);
request.want = std::make_shared<AAFwk::Want>(launchWant);
request.bundleInfo = bundleInfo;
request.hapModuleInfo = hapModuleInfo;
request.appIndex = appIndex;
return ERR_OK;
}
bool AppPreloader::GetLaunchWant(const std::string &bundleName, int32_t userId, AAFwk::Want &launchWant)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
auto bundleMgrHelper = GetBundleManagerHelper();
if (!bundleMgrHelper) {
TAG_LOGE(AAFwkTag::APPMGR, "bundleMgrHelper is nullptr.");
return false;
}
auto errCode = IN_PROCESS_CALL(bundleMgrHelper->GetLaunchWantForBundle(bundleName, launchWant, userId));
if (errCode != ERR_OK) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetLaunchWantForBundle failed, errCode: %{public}d.", errCode);
return false;
}
return true;
}
bool AppPreloader::GetLaunchAbilityInfo(const AAFwk::Want &want, int32_t userId, AbilityInfo &abilityInfo)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
auto bundleMgrHelper = GetBundleManagerHelper();
if (!bundleMgrHelper) {
TAG_LOGE(AAFwkTag::APPMGR, "bundleMgrHelper is nullptr.");
return false;
}
auto abilityInfoFlag = (AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION |
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION |
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_METADATA);
if (!IN_PROCESS_CALL(bundleMgrHelper->QueryAbilityInfo(want, abilityInfoFlag, userId, abilityInfo))) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetLaunchAbilityInfo failed.");
return false;
}
return true;
}
bool AppPreloader::GetBundleAndHapInfo(const std::string &bundleName, int32_t userId,
const AbilityInfo &abilityInfo, BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
auto bundleMgrHelper = GetBundleManagerHelper();
if (!bundleMgrHelper) {
TAG_LOGE(AAFwkTag::APPMGR, "bundleMgrHelper is nullptr.");
return false;
}
if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo,
userId))) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetBundleInfo failed.");
return false;
}
if (!IN_PROCESS_CALL(bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo))) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetHapModuleInfo failed.");
return false;
}
return true;
}
bool AppPreloader::CheckPreloadConditions(const AbilityInfo &abilityInfo)
{
if (abilityInfo.type != AppExecFwk::AbilityType::PAGE || !abilityInfo.isStageBasedModel) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication Launch Ability type is not UIAbility");
return false;
}
ApplicationInfo appInfo = abilityInfo.applicationInfo;
if (abilityInfo.name.empty() || appInfo.name.empty()) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication abilityInfo or appInfo name is empty");
return false;
}
if (abilityInfo.applicationName != appInfo.name) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication abilityInfo and appInfo have different appName, \
don't load for it");
return false;
}
return true;
}
std::shared_ptr<BundleMgrHelper> AppPreloader::GetBundleManagerHelper()
{
if (!remoteClientManager_) {
TAG_LOGE(AAFwkTag::APPMGR, "remoteClientManager_ is nullptr.");
return nullptr;
}
return remoteClientManager_->GetBundleManagerHelper();
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -1995,6 +1995,21 @@ bool AppRunningRecord::IsJITEnabled() const
return jitEnabled_;
}
void AppRunningRecord::SetPreloadState(PreloadState state)
{
preloadState_ = state;
}
bool AppRunningRecord::IsPreloading() const
{
return preloadState_ == PreloadState::PRELOADING;
}
bool AppRunningRecord::IsPreloaded() const
{
return preloadState_ == PreloadState::PRELOADED;
}
int32_t AppRunningRecord::GetAssignTokenId() const
{
return assignTokenId_;
@@ -46,6 +46,7 @@ constexpr const char* PERMISSION_CONNECT_UI_EXTENSION_ABILITY = "ohos.permission
constexpr const char* PERMISSION_START_RECENT_ABILITY = "ohos.permission.START_RECENT_ABILITY";
constexpr const char* PERMISSION_NOTIFY_DEBUG_ASSERT_RESULT = "ohos.permission.NOTIFY_DEBUG_ASSERT_RESULT";
constexpr const char* PERMISSION_START_SHORTCUT = "ohos.permission.START_SHORTCUT";
constexpr const char* PERMISSION_PRELOAD_APPLICATION = "ohos.permission.PRELOAD_APPLICATION";
} // namespace PermissionConstants
} // namespace AAFwk
} // namespace OHOS
@@ -95,6 +95,8 @@ struct VerificationInfo {
bool VerifyShellStartExtensionType(int32_t type) const;
bool VerifyPreloadApplicationPermission() const;
private:
DISALLOW_COPY_AND_MOVE(PermissionVerification);
@@ -435,5 +435,15 @@ bool PermissionVerification::VerifyShellStartExtensionType(int32_t type) const
HILOG_DEBUG("VerifyShellStartExtensionType, reject start.");
return false;
}
bool PermissionVerification::VerifyPreloadApplicationPermission() const
{
if (VerifyCallingPermission(PermissionConstants::PERMISSION_PRELOAD_APPLICATION)) {
HILOG_DEBUG("Verify permission %{public}s succeed.", PermissionConstants::PERMISSION_PRELOAD_APPLICATION);
return true;
}
HILOG_ERROR("Verify permission %{public}s failed.", PermissionConstants::PERMISSION_PRELOAD_APPLICATION);
return false;
}
} // namespace AAFwk
} // namespace OHOS
@@ -63,6 +63,7 @@ public:
MOCK_METHOD3(GetBundleNameByPid, int32_t(const int pid, std::string &bundleName, int32_t &uid));
MOCK_METHOD3(StartChildProcess, int32_t(const pid_t hostPid, const std::string &srcEntry, pid_t &childPid));
MOCK_METHOD1(GetChildProcessInfoForSelf, int32_t(ChildProcessInfo &info));
MOCK_METHOD4(PreloadApplication, int32_t(const std::string&, int32_t, AppExecFwk::PreloadMode, int32_t));
void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo)
{}
+1
View File
@@ -391,6 +391,7 @@ group("unittest") {
"app_mgr_service_inner_test:unittest",
"app_mgr_service_test:unittest",
"app_mgr_stub_test:unittest",
"app_preloader_test:unittest",
"app_recovery_test:unittest",
"app_running_manager_test:unittest",
"app_running_processes_info_test:unittest",
@@ -33,6 +33,7 @@ ohos_unittest("AmsAbilityRunningRecordTest") {
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp",
"${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp",
@@ -32,6 +32,7 @@ ohos_unittest("AmsAppLifeCycleTest") {
"${ability_runtime_services_path}/appmgr/src/app_lifecycle_deal.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_process_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
@@ -33,6 +33,7 @@ ohos_unittest("AmsWorkFlowTest") {
"${ability_runtime_services_path}/appmgr/src/app_lifecycle_deal.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_process_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
@@ -33,6 +33,7 @@ ohos_unittest("AmsRecentAppListTest") {
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_lifecycle_deal.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_process_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
@@ -38,6 +38,7 @@ ohos_unittest("AmsServiceAppSpawnClientTest") {
"${ability_runtime_services_path}/appmgr/src/app_mgr_service.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp",
"${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp",
@@ -39,6 +39,7 @@ ohos_unittest("AmsServiceEventDriveTest") {
"${ability_runtime_services_path}/appmgr/src/app_mgr_service.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp",
"${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp",
@@ -33,6 +33,7 @@ ohos_unittest("AmsServiceLoadAbilityProcessTest") {
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_lifecycle_deal.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_process_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
@@ -36,6 +36,7 @@ ohos_unittest("AmsServiceStartupTest") {
"${ability_runtime_services_path}/appmgr/src/app_mgr_service.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp",
"${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp",
@@ -1010,5 +1010,26 @@ HWTEST_F(AppMgrClientTest, GetAllUIExtensionProviderPid_001, TestSize.Level0)
EXPECT_NE(ret, AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED);
EXPECT_EQ(providerPids.size(), 0);
}
/**
* @tc.name: PreloadApplication_001
* @tc.desc: Preload application.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrClientTest, PreloadApplication_001, TestSize.Level0)
{
auto appMgrClient = std::make_unique<AppMgrClient>();
EXPECT_NE(appMgrClient, nullptr);
auto result = appMgrClient->ConnectAppMgrService();
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
std::string bundleName = "com.acts.preloadtest";
int32_t userId = 100;
PreloadMode preloadMode = PreloadMode::PRE_MAKE;
int32_t appIndex = 0;
int32_t ret = appMgrClient->PreloadApplication(bundleName, userId, preloadMode, appIndex);
EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -539,5 +539,26 @@ HWTEST_F(AppMgrProxyTest, GetAllUIExtensionProviderPid_0100, TestSize.Level1)
EXPECT_EQ(mockAppMgrService_->code_,
static_cast<uint32_t>(AppMgrInterfaceCode::GET_ALL_UI_EXTENSION_PROVIDER_PID));
}
/**
* @tc.name: PreloadApplication_0100
* @tc.desc: Preload application.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrProxyTest, PreloadApplication_0100, TestSize.Level1)
{
EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _))
.Times(1)
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
std::string bundleName = "com.acts.preloadtest";
int32_t userId = 100;
PreloadMode preloadMode = PreloadMode::PRE_MAKE;
int32_t appIndex = 0;
auto ret = appMgrProxy_->PreloadApplication(bundleName, userId, preloadMode, appIndex);
EXPECT_EQ(ret, NO_ERROR);
EXPECT_EQ(mockAppMgrService_->code_,
static_cast<uint32_t>(AppMgrInterfaceCode::PRELOAD_APPLICATION));
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -30,6 +30,7 @@ ohos_unittest("AMSEventHandlerTest") {
"${ability_runtime_services_path}/appmgr/src/app_lifecycle_deal.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_process_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
@@ -4152,5 +4152,23 @@ HWTEST_F(AppMgrServiceInnerTest, AddUIExtensionLauncherItem_0100, TestSize.Level
EXPECT_EQ(want->HasParameter("ability.want.params.uiExtensionAbilityId"), false);
EXPECT_EQ(want->HasParameter("ability.want.params.uiExtensionRootHostPid"), false);
}
/**
* @tc.name: PreloadApplication_0100
* @tc.desc: Preload Application.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceInnerTest, PreloadApplication_0100, TestSize.Level1)
{
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
ASSERT_NE(appMgrServiceInner, nullptr);
std::string bundleName = "com.acts.preloadtest";
int32_t userId = 100;
PreloadMode preloadMode = PreloadMode::PRE_MAKE;
int32_t appIndex = 0;
int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex);
EXPECT_EQ(ret, ERR_PERMISSION_DENIED);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -19,6 +19,7 @@
#include "app_mgr_service.h"
#include "app_utils.h"
#undef private
#include "ability_manager_errors.h"
#include "child_main_thread.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
@@ -1624,5 +1625,31 @@ HWTEST_F(AppMgrServiceTest, GetAllUIExtensionProviderPid_0100, TestSize.Level1)
appMgrService->eventHandler_ = eventHandler_;
EXPECT_EQ(appMgrService->GetAllUIExtensionProviderPid(hostPid, providerPids), ERR_OK);
}
/**
* @tc.name: PreloadApplication_0100
* @tc.desc: Preload application.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrServiceTest, PreloadApplication_0100, TestSize.Level1)
{
auto appMgrService = std::make_shared<AppMgrService>();
ASSERT_NE(appMgrService, nullptr);
appMgrService->SetInnerService(mockAppMgrServiceInner_);
appMgrService->taskHandler_ = taskHandler_;
appMgrService->eventHandler_ = eventHandler_;
std::string bundleName = "com.acts.preloadtest";
int32_t userId = 100;
PreloadMode preloadMode = PreloadMode::PRE_MAKE;
int32_t appIndex = 0;
EXPECT_CALL(*mockAppMgrServiceInner_, PreloadApplication(_, _, _, _))
.Times(1)
.WillOnce(Return(ERR_OK));
int32_t ret = appMgrService->PreloadApplication(bundleName, userId, preloadMode, appIndex);
EXPECT_EQ(ret, ERR_OK);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -24,6 +24,7 @@
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "ipc_types.h"
#include "mock_app_mgr_service.h"
#include "render_state_observer_stub.h"
@@ -547,5 +548,32 @@ HWTEST_F(AppMgrStubTest, HandleGetAllUIExtensionProviderPid_0100, TestSize.Level
int32_t size = reply.ReadInt32();
EXPECT_EQ(size, 0);
}
/**
* @tc.name: PreloadApplication_0100
* @tc.desc: Preload application.
* @tc.type: FUNC
*/
HWTEST_F(AppMgrStubTest, PreloadApplication_0100, TestSize.Level1)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
WriteInterfaceToken(data);
std::string bundleName = "com.acts.preloadtest";
int32_t userId = 100;
PreloadMode preloadMode = PreloadMode::PRE_MAKE;
int32_t appIndex = 0;
data.WriteString16(Str8ToStr16(bundleName));
data.WriteInt32(userId);
data.WriteInt32(static_cast<int32_t>(preloadMode));
data.WriteInt32(appIndex);
auto result = mockAppMgrService_->OnRemoteRequest(
static_cast<uint32_t>(AppMgrInterfaceCode::PRELOAD_APPLICATION), data, reply, option);
EXPECT_EQ(result, NO_ERROR);
}
} // namespace AppExecFwk
} // namespace OHOS
+55
View File
@@ -0,0 +1,55 @@
# 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.
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/appmgrservice"
ohos_unittest("app_preloader_test") {
module_out_path = module_output_path
configs = [ "${ability_runtime_services_path}/common:common_config" ]
include_dirs = [
"${ability_runtime_services_path}/appmgr/include",
"include",
]
sources = [
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"app_preloader_test.cpp",
]
deps = [
"${ability_runtime_services_path}/appmgr:libappms",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:want",
"appspawn:appspawn_client",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"hilog:libhilog",
"hitrace:hitrace_meter",
"ipc:ipc_core",
]
}
group("unittest") {
testonly = true
deps = [ ":app_preloader_test" ]
}
+64
View File
@@ -0,0 +1,64 @@
/*
* 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 <gtest/gtest.h>
#include "app_preloader.h"
#include "hilog_tag_wrapper.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class AppPreloaderTest : public testing::Test {
public:
void SetUp();
void TearDown();
protected:
std::shared_ptr<RemoteClientManager> remoteClientManager_ = nullptr;
};
void AppPreloaderTest::SetUp()
{
remoteClientManager_ = std::make_shared<RemoteClientManager>();
auto bundleMgrHelper = std::make_shared<BundleMgrHelper>();
remoteClientManager_->SetBundleManagerHelper(bundleMgrHelper);
}
void AppPreloaderTest::TearDown()
{}
/**
* @tc.number: AppPreloaderTest_GeneratePreloadRequest_0100
* @tc.desc: Test Init works
* @tc.type: FUNC
*/
HWTEST_F(AppPreloaderTest, AppPreloaderTest_GeneratePreloadRequest_0100, TestSize.Level0)
{
TAG_LOGD(AAFwkTag::TEST, "AppPreloaderTest_GeneratePreloadRequest_0100 start.");
auto manager = std::make_shared<AppPreloader>(remoteClientManager_);
EXPECT_NE(manager, nullptr);
std::string bundleName = "com.acts.preloadtest";
int32_t userId = 100;
int32_t appIndex = 0;
PreloadRequest request;
auto ret = manager->GeneratePreloadRequest(bundleName, userId, appIndex, request);
EXPECT_EQ(ret, ERR_OK);
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023 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_BUNDLE_MGR_HELPER_H
#define OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H
#include "bundle_mgr_interface.h"
#include "want.h"
namespace OHOS {
namespace AppExecFwk {
using Want = OHOS::AAFwk::Want;
class BundleMgrHelper : public std::enable_shared_from_this<BundleMgrHelper> {
public:
BundleMgrHelper() = default;;
~BundleMgrHelper() = default;
ErrCode GetLaunchWantForBundle(const std::string &bundleName, Want &want, int32_t userId)
{
return ERR_OK;
}
bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo)
{
abilityInfo.type = AppExecFwk::AbilityType::PAGE;
abilityInfo.isStageBasedModel = true;
abilityInfo.name = "MainAbility";
abilityInfo.applicationName = "com.acts.preloadtest";
abilityInfo.applicationInfo.name = abilityInfo.applicationName;
return true;
}
bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId)
{
return true;
}
bool GetHapModuleInfo(const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo)
{
return true;
}
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H
@@ -32,6 +32,7 @@ ohos_unittest("AppRunningProcessesInfoTest") {
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
"${ability_runtime_services_path}/appmgr/src/app_preloader.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_record.cpp",
"${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp",
"${ability_runtime_services_path}/appmgr/src/app_spawn_client.cpp",