mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
Add load and foreground report to rss
Signed-off-by: wangzhen <wangzhen346@huawei.com> Change-Id: I2764028054b48fe23fc450238c4e683139621e46
This commit is contained in:
@@ -330,7 +330,6 @@ public:
|
||||
std::shared_ptr<AAFwk::AbilityRecord> GetUIExtensionRootHostInfo(const sptr<IRemoteObject> token);
|
||||
|
||||
// MSG 0 - 20 represents timeout message
|
||||
static constexpr uint32_t LOAD_TIMEOUT_MSG = 0;
|
||||
static constexpr uint32_t CONNECT_TIMEOUT_MSG = 1;
|
||||
|
||||
private:
|
||||
@@ -629,7 +628,7 @@ private:
|
||||
std::string GetServiceKey(const std::shared_ptr<AbilityRecord> &service);
|
||||
|
||||
int32_t ReportXiaoYiToRSSIfNeeded(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
int32_t ReportAbilitStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
int32_t ReportAbilityStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
|
||||
private:
|
||||
const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask";
|
||||
|
||||
@@ -1795,16 +1795,6 @@ public:
|
||||
static constexpr uint32_t LOAD_HALF_TIMEOUT_MSG = 8;
|
||||
static constexpr uint32_t FOREGROUND_HALF_TIMEOUT_MSG = 9;
|
||||
|
||||
#ifdef SUPPORT_ASAN
|
||||
static constexpr uint32_t LOAD_TIMEOUT = 150000; // ms
|
||||
static constexpr uint32_t ACTIVE_TIMEOUT = 75000; // ms
|
||||
static constexpr uint32_t INACTIVE_TIMEOUT = 7500; // ms
|
||||
#else
|
||||
static constexpr uint32_t LOAD_TIMEOUT = 10000; // ms
|
||||
static constexpr uint32_t ACTIVE_TIMEOUT = 5000; // ms
|
||||
static constexpr uint32_t INACTIVE_TIMEOUT = 500; // ms
|
||||
#endif
|
||||
|
||||
static constexpr uint32_t MIN_DUMP_ARGUMENT_NUM = 2;
|
||||
static constexpr uint32_t MAX_WAIT_SYSTEM_UI_NUM = 600;
|
||||
static constexpr uint32_t MAX_WAIT_SETTINGS_DATA_NUM = 300;
|
||||
@@ -2034,9 +2024,9 @@ private:
|
||||
|
||||
void UnsubscribeBundleEventCallback();
|
||||
|
||||
void ReportAbilitStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
void ReportAbilityStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
|
||||
void ReportAbilitAssociatedStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo, int64_t type,
|
||||
void ReportAbilityAssociatedStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo, int64_t type,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
void ReportEventToRSS(const AppExecFwk::AbilityInfo &abilityInfo, sptr<IRemoteObject> callerToken);
|
||||
|
||||
@@ -3254,7 +3254,7 @@ int32_t AbilityConnectManager::ReportXiaoYiToRSSIfNeeded(const AppExecFwk::Abili
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR,
|
||||
"bundleName is extension, abilityName:%{public}s",
|
||||
abilityInfo.name.c_str());
|
||||
auto ret = ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
auto ret = ReportAbilityStartInfoToRSS(abilityInfo);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@@ -3262,7 +3262,7 @@ int32_t AbilityConnectManager::ReportXiaoYiToRSSIfNeeded(const AppExecFwk::Abili
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AbilityConnectManager::ReportAbilitStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
int32_t AbilityConnectManager::ReportAbilityStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::vector<AppExecFwk::RunningProcessInfo> runningProcessInfos;
|
||||
@@ -3280,8 +3280,8 @@ int32_t AbilityConnectManager::ReportAbilitStartInfoToRSS(const AppExecFwk::Abil
|
||||
break;
|
||||
}
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "ReportAbilitStartInfoToRSS, abilityName:%{public}s", abilityInfo.name.c_str());
|
||||
ResSchedUtil::GetInstance().ReportAbilitStartInfoToRSS(abilityInfo, pid, isColdStart);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "ReportAbilityStartInfoToRSS, abilityName:%{public}s", abilityInfo.name.c_str());
|
||||
ResSchedUtil::GetInstance().ReportAbilityStartInfoToRSS(abilityInfo, pid, isColdStart);
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -1284,7 +1284,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
ReportAbilityStartInfoToRSS(abilityInfo);
|
||||
ReportEventToRSS(abilityInfo, callerToken);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Start ability, name is %{public}s.", abilityInfo.name.c_str());
|
||||
return missionListManager->StartAbility(abilityRequest);
|
||||
@@ -2230,8 +2230,8 @@ int32_t AbilityManagerService::StartUIAbilityBySCBDefaultCommon(AbilityRequest &
|
||||
}
|
||||
}
|
||||
|
||||
ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
ReportAbilitAssociatedStartInfoToRSS(abilityInfo, RES_TYPE_SCB_START_ABILITY, sessionInfo->callerToken);
|
||||
ReportAbilityStartInfoToRSS(abilityInfo);
|
||||
ReportAbilityAssociatedStartInfoToRSS(abilityInfo, RES_TYPE_SCB_START_ABILITY, sessionInfo->callerToken);
|
||||
auto uiAbilityManager = GetUIAbilityManagerByUid(IPCSkeleton::GetCallingUid());
|
||||
CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_INVALID_VALUE);
|
||||
// here we don't need want param "IS_CALL_BY_SCB" any more, remove it.
|
||||
@@ -2565,7 +2565,7 @@ void AbilityManagerService::UnsubscribeBundleEventCallback()
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "UnsubscribeBundleEventCallback success.");
|
||||
}
|
||||
|
||||
void AbilityManagerService::ReportAbilitStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
void AbilityManagerService::ReportAbilityStartInfoToRSS(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (abilityInfo.type == AppExecFwk::AbilityType::PAGE &&
|
||||
@@ -2583,11 +2583,11 @@ void AbilityManagerService::ReportAbilitStartInfoToRSS(const AppExecFwk::Ability
|
||||
break;
|
||||
}
|
||||
}
|
||||
ResSchedUtil::GetInstance().ReportAbilitStartInfoToRSS(abilityInfo, pid, isColdStart);
|
||||
ResSchedUtil::GetInstance().ReportAbilityStartInfoToRSS(abilityInfo, pid, isColdStart);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityManagerService::ReportAbilitAssociatedStartInfoToRSS(
|
||||
void AbilityManagerService::ReportAbilityAssociatedStartInfoToRSS(
|
||||
const AppExecFwk::AbilityInfo &abilityInfo, int64_t type, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
CHECK_POINTER_LOG(callerToken, "null callerToken");
|
||||
@@ -2595,7 +2595,7 @@ void AbilityManagerService::ReportAbilitAssociatedStartInfoToRSS(
|
||||
CHECK_POINTER_LOG(callerAbility, "null callerAbility");
|
||||
int32_t callerUid = callerAbility->GetUid();
|
||||
int32_t callerPid = callerAbility->GetPid();
|
||||
ResSchedUtil::GetInstance().ReportAbilitAssociatedStartInfoToRSS(abilityInfo, type, callerUid, callerPid);
|
||||
ResSchedUtil::GetInstance().ReportAbilityAssociatedStartInfoToRSS(abilityInfo, type, callerUid, callerPid);
|
||||
}
|
||||
|
||||
void AbilityManagerService::ReportEventToRSS(const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
@@ -2897,7 +2897,7 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp
|
||||
if (eventInfo.errCode != ERR_OK) {
|
||||
EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
}
|
||||
ReportAbilitAssociatedStartInfoToRSS(abilityRequest.abilityInfo, RES_TYPE_EXTENSION_START_ABILITY, callerToken);
|
||||
ReportAbilityAssociatedStartInfoToRSS(abilityRequest.abilityInfo, RES_TYPE_EXTENSION_START_ABILITY, callerToken);
|
||||
return eventInfo.errCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ using AbilityRuntime::FreezeUtil;
|
||||
namespace AAFwk {
|
||||
using namespace OHOS::Security;
|
||||
using namespace OHOS::AAFwk::PermissionConstants;
|
||||
using namespace OHOS::AbilityRuntime::GlobalConstant;
|
||||
const std::string DEBUG_APP = "debugApp";
|
||||
const std::string NATIVE_DEBUG = "nativeDebug";
|
||||
const std::string PERF_CMD = "perfCmd";
|
||||
@@ -94,29 +95,6 @@ const int TERMINATE_TIMEOUT_ASANENABLED = 150;
|
||||
const int HALF_TIMEOUT = 2;
|
||||
const int MAX_URI_COUNT = 500;
|
||||
const int RESTART_SCENEBOARD_DELAY = 500;
|
||||
#ifdef SUPPORT_ASAN
|
||||
const int COLDSTART_TIMEOUT_MULTIPLE = 15000;
|
||||
const int LOAD_TIMEOUT_MULTIPLE = 15000;
|
||||
const int FOREGROUND_TIMEOUT_MULTIPLE = 7500;
|
||||
const int BACKGROUND_TIMEOUT_MULTIPLE = 4500;
|
||||
const int ACTIVE_TIMEOUT_MULTIPLE = 7500;
|
||||
const int TERMINATE_TIMEOUT_MULTIPLE = 15000;
|
||||
const int INACTIVE_TIMEOUT_MULTIPLE = 800;
|
||||
const int DUMP_TIMEOUT_MULTIPLE = 1500;
|
||||
const int SHAREDATA_TIMEOUT_MULTIPLE = 7500;
|
||||
#else
|
||||
const int COLDSTART_TIMEOUT_MULTIPLE = 10;
|
||||
const int LOAD_TIMEOUT_MULTIPLE = 10;
|
||||
const int FOREGROUND_TIMEOUT_MULTIPLE = 5;
|
||||
const int BACKGROUND_TIMEOUT_MULTIPLE = 3;
|
||||
const int ACTIVE_TIMEOUT_MULTIPLE = 5;
|
||||
const int TERMINATE_TIMEOUT_MULTIPLE = 10;
|
||||
const int INACTIVE_TIMEOUT_MULTIPLE = 1;
|
||||
const int DUMP_TIMEOUT_MULTIPLE = 1000;
|
||||
const int SHAREDATA_TIMEOUT_MULTIPLE = 5;
|
||||
const int32_t TYPE_RESERVE = 1;
|
||||
const int32_t TYPE_OTHERS = 2;
|
||||
#endif
|
||||
|
||||
auto g_addLifecycleEventTask = [](sptr<Token> token, FreezeUtil::TimeoutState state, std::string &methodName) {
|
||||
CHECK_POINTER_LOG(token, "token is nullptr");
|
||||
@@ -497,6 +475,8 @@ void AbilityRecord::PostForegroundTimeoutTask()
|
||||
SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout);
|
||||
std::string methodName = "ForegroundAbility";
|
||||
g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
||||
ResSchedUtil::GetInstance().ReportLoadingEventToRss(LoadingStage::FOREGROUND_BEGIN, GetPid(), GetUid(),
|
||||
foregroundTimeout);
|
||||
}
|
||||
|
||||
void AbilityRecord::RemoveForegroundTimeoutTask()
|
||||
@@ -535,6 +515,8 @@ void AbilityRecord::PostUIExtensionAbilityTimeoutTask(uint32_t messageId)
|
||||
static_cast<uint32_t>(FOREGROUND_TIMEOUT_MULTIPLE);
|
||||
SendEvent(AbilityManagerService::FOREGROUND_HALF_TIMEOUT_MSG, timeout / HALF_TIMEOUT, recordId_, true);
|
||||
SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, timeout, recordId_, true);
|
||||
ResSchedUtil::GetInstance().ReportLoadingEventToRss(LoadingStage::FOREGROUND_BEGIN, GetPid(), GetUid(),
|
||||
timeout);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -1442,6 +1424,9 @@ void AbilityRecord::SetAbilityState(AbilityState state)
|
||||
if (state == AbilityState::FOREGROUND || state == AbilityState::ACTIVE || state == AbilityState::BACKGROUND) {
|
||||
SetRestarting(false);
|
||||
}
|
||||
if (state == AbilityState::FOREGROUND) {
|
||||
ResSchedUtil::GetInstance().ReportLoadingEventToRss(LoadingStage::FOREGROUND_END, GetPid(), GetUid());
|
||||
}
|
||||
}
|
||||
#endif // SUPPORT_SCREEN
|
||||
void AbilityRecord::SetScheduler(const sptr<IAbilityScheduler> &scheduler)
|
||||
@@ -1457,9 +1442,8 @@ void AbilityRecord::SetScheduler(const sptr<IAbilityScheduler> &scheduler)
|
||||
}
|
||||
}
|
||||
if (schedulerDeathRecipient_ == nullptr) {
|
||||
std::weak_ptr<AbilityRecord> thisWeakPtr(shared_from_this());
|
||||
schedulerDeathRecipient_ =
|
||||
new AbilitySchedulerRecipient([thisWeakPtr](const wptr<IRemoteObject> &remote) {
|
||||
new AbilitySchedulerRecipient([thisWeakPtr = weak_from_this()](const wptr<IRemoteObject> &remote) {
|
||||
auto abilityRecord = thisWeakPtr.lock();
|
||||
if (abilityRecord) {
|
||||
abilityRecord->OnSchedulerDied(remote);
|
||||
@@ -1477,6 +1461,7 @@ void AbilityRecord::SetScheduler(const sptr<IAbilityScheduler> &scheduler)
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Sceneboard DeathRecipient Added");
|
||||
}
|
||||
pid_ = static_cast<int32_t>(IPCSkeleton::GetCallingPid()); // set pid when ability attach to service.
|
||||
ResSchedUtil::GetInstance().ReportLoadingEventToRss(LoadingStage::LOAD_END, GetPid(), GetUid());
|
||||
// add collaborator mission bind pid
|
||||
NotifyMissionBindPid();
|
||||
#ifdef WITH_DLP
|
||||
|
||||
@@ -194,7 +194,7 @@ int MissionListManager::StartAbility(AbilityRequest &abilityRequest)
|
||||
}
|
||||
NotifyStartAbilityResult(abilityRequest, ret);
|
||||
if (callerAbility != nullptr) {
|
||||
ResSchedUtil::GetInstance().ReportAbilitAssociatedStartInfoToRSS(abilityRequest.abilityInfo,
|
||||
ResSchedUtil::GetInstance().ReportAbilityAssociatedStartInfoToRSS(abilityRequest.abilityInfo,
|
||||
RES_TYPE_MISSION_LIST_START_ABILITY, callerAbility->GetUid(), callerAbility->GetPid());
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -1389,6 +1389,9 @@ private:
|
||||
|
||||
void PresetMaxChildProcess(const std::shared_ptr<AbilityInfo> &abilityInfo, int32_t &maxChildProcess);
|
||||
|
||||
void AfterLoadAbility(std::shared_ptr<AppRunningRecord> appRecord, std::shared_ptr<AbilityInfo> abilityInfo,
|
||||
std::shared_ptr<AbilityRuntime::LoadParam> loadParam);
|
||||
|
||||
private:
|
||||
/**
|
||||
* ClearUpApplicationData, clear the application data.
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "permission_constants.h"
|
||||
#include "permission_verification.h"
|
||||
#include "render_state_observer_manager.h"
|
||||
#include "res_sched_util.h"
|
||||
#include "startup_util.h"
|
||||
#include "string_ex.h"
|
||||
#ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER
|
||||
@@ -559,13 +560,36 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s
|
||||
abilityRunningRecord->SetUIExtensionAbilityId(uiExtensionAbilityId);
|
||||
}
|
||||
}
|
||||
AfterLoadAbility(appRecord, abilityInfo, loadParam);
|
||||
}
|
||||
|
||||
if (abilityInfo->type == AppExecFwk::AbilityType::PAGE && appRecord != nullptr) {
|
||||
void AppMgrServiceInner::AfterLoadAbility(std::shared_ptr<AppRunningRecord> appRecord,
|
||||
std::shared_ptr<AbilityInfo> abilityInfo, std::shared_ptr<AbilityRuntime::LoadParam> loadParam)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!appRecord || !abilityInfo || !loadParam) {
|
||||
return;
|
||||
}
|
||||
if (abilityInfo->type == AppExecFwk::AbilityType::PAGE) {
|
||||
appRecord->SetUIAbilityLaunched(true);
|
||||
}
|
||||
PerfProfile::GetInstance().SetAbilityLoadEndTime(GetTickCount());
|
||||
PerfProfile::GetInstance().Dump();
|
||||
PerfProfile::GetInstance().Reset();
|
||||
|
||||
auto reportLoadTask = [appRecord]() {
|
||||
auto priorityObj = appRecord->GetPriorityObject();
|
||||
if (priorityObj) {
|
||||
auto timeOut = AbilityRuntime::GlobalConstant::GetLoadTimeOutBase() *
|
||||
AAFwk::AppUtils::GetInstance().GetTimeoutUnitTimeRatio();
|
||||
AAFwk::ResSchedUtil::GetInstance().ReportLoadingEventToRss(AAFwk::LoadingStage::LOAD_BEGIN,
|
||||
priorityObj->GetPid(), appRecord->GetUid(), timeOut);
|
||||
}
|
||||
};
|
||||
if (taskHandler_) {
|
||||
taskHandler_->SubmitTask(reportLoadTask);
|
||||
}
|
||||
|
||||
appRecord->UpdateAbilityState(loadParam->token, AbilityState::ABILITY_STATE_CREATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,16 +29,25 @@ using AbilityInfo = AppExecFwk::AbilityInfo;
|
||||
constexpr int64_t RES_TYPE_SCB_START_ABILITY = 0;
|
||||
constexpr int64_t RES_TYPE_EXTENSION_START_ABILITY = 1;
|
||||
constexpr int64_t RES_TYPE_MISSION_LIST_START_ABILITY = 2;
|
||||
|
||||
enum class LoadingStage : int32_t {
|
||||
LOAD_BEGIN = 1,
|
||||
LOAD_END,
|
||||
FOREGROUND_BEGIN,
|
||||
FOREGROUND_END
|
||||
};
|
||||
|
||||
class ResSchedUtil final {
|
||||
public:
|
||||
static ResSchedUtil &GetInstance();
|
||||
void ReportAbilitStartInfoToRSS(const AbilityInfo &abilityInfo, int32_t pid, bool isColdStart);
|
||||
void ReportAbilitAssociatedStartInfoToRSS(
|
||||
void ReportAbilityStartInfoToRSS(const AbilityInfo &abilityInfo, int32_t pid, bool isColdStart);
|
||||
void ReportAbilityAssociatedStartInfoToRSS(
|
||||
const AbilityInfo &abilityInfo, int64_t resSchedType, int32_t callerUid, int32_t callerPid);
|
||||
void ReportEventToRSS(const int32_t uid, const std::string &bundleName, const std::string &reason,
|
||||
const int32_t callerPid = -1);
|
||||
void GetAllFrozenPidsFromRSS(std::unordered_set<int32_t> &frozenPids);
|
||||
bool CheckShouldForceKillProcess(int32_t pid);
|
||||
void ReportLoadingEventToRss(LoadingStage stage, int32_t pid, int32_t uid, int64_t timeDuration = 0);
|
||||
private:
|
||||
ResSchedUtil() = default;
|
||||
~ResSchedUtil() = default;
|
||||
|
||||
@@ -48,7 +48,7 @@ int64_t ResSchedUtil::convertType(int64_t resSchedType)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ResSchedUtil::ReportAbilitStartInfoToRSS(const AbilityInfo &abilityInfo, int32_t pid, bool isColdStart)
|
||||
void ResSchedUtil::ReportAbilityStartInfoToRSS(const AbilityInfo &abilityInfo, int32_t pid, bool isColdStart)
|
||||
{
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
uint32_t resType = ResourceSchedule::ResType::RES_TYPE_APP_ABILITY_START;
|
||||
@@ -64,7 +64,7 @@ void ResSchedUtil::ReportAbilitStartInfoToRSS(const AbilityInfo &abilityInfo, in
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResSchedUtil::ReportAbilitAssociatedStartInfoToRSS(
|
||||
void ResSchedUtil::ReportAbilityAssociatedStartInfoToRSS(
|
||||
const AbilityInfo &abilityInfo, int64_t resSchedType, int32_t callerUid, int32_t callerPid)
|
||||
{
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
@@ -152,5 +152,23 @@ bool ResSchedUtil::CheckShouldForceKillProcess(int32_t pid)
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResSchedUtil::ReportLoadingEventToRss(LoadingStage stage, int32_t pid, int32_t uid, int64_t timeDuration)
|
||||
{
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
uint32_t resType = ResourceSchedule::ResType::RES_TYPE_KEY_PERF_SCENE;
|
||||
std::unordered_map<std::string, std::string> eventParams {
|
||||
{ "extType", "10015"},
|
||||
{ "pid", std::to_string(pid) },
|
||||
{ "uid", std::to_string(uid) },
|
||||
};
|
||||
if (timeDuration > 0) { // millisecond
|
||||
eventParams.emplace("timeoutDuration", std::to_string(timeDuration));
|
||||
}
|
||||
int64_t type = static_cast<int64_t>(stage);
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "call");
|
||||
ResourceSchedule::ResSchedClient::GetInstance().ReportData(resType, type, eventParams);
|
||||
#endif
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
+1
-1
@@ -95,7 +95,7 @@ void DoSomethingInterestingWithMyAPI1(AbilityManagerService &abilityms, Want& wa
|
||||
AppExecFwk::ExtensionAbilityType extensionType = ExtensionAbilityType::SERVICE;
|
||||
abilityms.CheckOptExtensionAbility(want, abilityRequest, int32Param, extensionType);
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
abilityms.ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
abilityms.ReportAbilityStartInfoToRSS(abilityInfo);
|
||||
abilityms.ReportEventToRSS(abilityInfo, token);
|
||||
abilityms.StartExtensionAbility(want, token, int32Param, extensionType);
|
||||
abilityms.StopExtensionAbility(want, token, int32Param, extensionType);
|
||||
|
||||
+13
-13
@@ -240,38 +240,38 @@ HWTEST_F(AbilityManagerServiceFourthTest, GetConfiguration_001, TestSize.Level1)
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ReportAbilitStartInfoToRSS
|
||||
* FunctionPoints: AbilityManagerService ReportAbilitStartInfoToRSS
|
||||
* Function: ReportAbilityStartInfoToRSS
|
||||
* FunctionPoints: AbilityManagerService ReportAbilityStartInfoToRSS
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceFourthTest, ReportAbilitStartInfoToRSS_001, TestSize.Level1)
|
||||
HWTEST_F(AbilityManagerServiceFourthTest, ReportAbilityStartInfoToRSS_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilitStartInfoToRSS start");
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilityStartInfoToRSS start");
|
||||
auto abilityMs = std::make_shared<AbilityManagerService>();
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
abilityInfo.type = AppExecFwk::AbilityType::PAGE;
|
||||
abilityMs->ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
abilityMs->ReportAbilityStartInfoToRSS(abilityInfo);
|
||||
EXPECT_EQ(abilityInfo.type, AppExecFwk::AbilityType::PAGE);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilitStartInfoToRSS end");
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilityStartInfoToRSS end");
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ReportAbilitAssociatedStartInfoToRSS
|
||||
* FunctionPoints: AbilityManagerService ReportAbilitAssociatedStartInfoToRSS
|
||||
* Function: ReportAbilityAssociatedStartInfoToRSS
|
||||
* FunctionPoints: AbilityManagerService ReportAbilityAssociatedStartInfoToRSS
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceFourthTest, ReportAbilitAssociatedStartInfoToRSS_001, TestSize.Level1)
|
||||
HWTEST_F(AbilityManagerServiceFourthTest, ReportAbilityAssociatedStartInfoToRSS_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilitAssociatedStartInfoToRSS start");
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilityAssociatedStartInfoToRSS start");
|
||||
auto abilityMs = std::make_shared<AbilityManagerService>();
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
abilityInfo.type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> callerToken = nullptr;
|
||||
int64_t type = 0;
|
||||
abilityMs->ReportAbilitAssociatedStartInfoToRSS(abilityInfo, type, callerToken);
|
||||
abilityMs->ReportAbilityAssociatedStartInfoToRSS(abilityInfo, type, callerToken);
|
||||
callerToken = MockToken(AbilityType::PAGE);
|
||||
abilityMs->ReportAbilitAssociatedStartInfoToRSS(abilityInfo, type, callerToken);
|
||||
abilityMs->ReportAbilityAssociatedStartInfoToRSS(abilityInfo, type, callerToken);
|
||||
EXPECT_EQ(abilityInfo.type, AppExecFwk::AbilityType::PAGE);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilitAssociatedStartInfoToRSS end");
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ReportAbilityAssociatedStartInfoToRSS end");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -64,6 +64,7 @@ ohos_unittest("AmsAbilityRunningRecordTest") {
|
||||
"${ability_runtime_services_path}/common:app_util",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
"${ability_runtime_services_path}/common:res_sched_util",
|
||||
"${ability_runtime_services_path}/common:task_handler_wrap",
|
||||
"${ability_runtime_test_path}/unittest:appmgr_test_source",
|
||||
]
|
||||
|
||||
@@ -68,6 +68,7 @@ ohos_unittest("AmsServiceAppSpawnClientTest") {
|
||||
"${ability_runtime_services_path}/common:app_util",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
"${ability_runtime_services_path}/common:res_sched_util",
|
||||
"${ability_runtime_services_path}/common:task_handler_wrap",
|
||||
"${ability_runtime_test_path}/unittest:appmgr_test_source",
|
||||
"${distributedschedule_path}/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
|
||||
@@ -68,6 +68,7 @@ ohos_unittest("AmsServiceEventDriveTest") {
|
||||
"${ability_runtime_services_path}/common:app_util",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
"${ability_runtime_services_path}/common:res_sched_util",
|
||||
"${ability_runtime_services_path}/common:task_handler_wrap",
|
||||
"${ability_runtime_test_path}/unittest:appmgr_test_source",
|
||||
"${distributedschedule_path}/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
|
||||
@@ -66,6 +66,7 @@ ohos_unittest("AmsServiceStartupTest") {
|
||||
"${ability_runtime_services_path}/common:app_util",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
"${ability_runtime_services_path}/common:res_sched_util",
|
||||
"${ability_runtime_services_path}/common:task_handler_wrap",
|
||||
"${ability_runtime_test_path}/unittest:appmgr_test_source",
|
||||
"${distributedschedule_path}/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
|
||||
@@ -22,6 +22,7 @@ ohos_unittest("lifecycle_test") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/include",
|
||||
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/include",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
]
|
||||
|
||||
sources = [ "lifecycle_test.cpp" ]
|
||||
|
||||
@@ -30,6 +30,15 @@ using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
#ifdef SUPPORT_ASAN
|
||||
constexpr uint32_t LOAD_TIMEOUT = 150000; // ms
|
||||
constexpr uint32_t ACTIVE_TIMEOUT = 75000; // ms
|
||||
constexpr uint32_t INACTIVE_TIMEOUT = 7500; // ms
|
||||
#else
|
||||
constexpr uint32_t LOAD_TIMEOUT = 10000; // ms
|
||||
constexpr uint32_t ACTIVE_TIMEOUT = 5000; // ms
|
||||
constexpr uint32_t INACTIVE_TIMEOUT = 500; // ms
|
||||
#endif
|
||||
class LifecycleTest : public testing::Test, public LifecycleTestBase {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -145,7 +154,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_StartLauncherAbilityLifeCycle_003, TestS
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret =
|
||||
LifecycleTest::SemTimedWaitMillis(AbilityManagerService::LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
LifecycleTest::SemTimedWaitMillis(LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
EXPECT_NE(ret, 0);
|
||||
// check timeout handler
|
||||
EXPECT_EQ(launcherAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
@@ -175,7 +184,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_StartLauncherAbilityLifeCycle_004, TestS
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret =
|
||||
LifecycleTest::SemTimedWaitMillis(AbilityManagerService::LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
LifecycleTest::SemTimedWaitMillis(LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
if (ret != 0) {
|
||||
// check timeout handler
|
||||
GTEST_LOG_(INFO) << "timeout. It shouldn't happen.";
|
||||
@@ -209,7 +218,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_StartLauncherAbilityLifeCycle_005, TestS
|
||||
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret =
|
||||
LifecycleTest::SemTimedWaitMillis(AbilityManagerService::LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
LifecycleTest::SemTimedWaitMillis(LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
if (ret != 0) {
|
||||
// check timeout handler. It won't happen normally.
|
||||
GTEST_LOG_(INFO) << "timeout. It shouldn't happen.";
|
||||
@@ -243,7 +252,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_StartLauncherAbilityLifeCycle_006, TestS
|
||||
command_->state_ = OHOS::AAFwk::AbilityState::INITIAL;
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(AbilityManagerService::ACTIVE_TIMEOUT, command_->sem_);
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(ACTIVE_TIMEOUT, command_->sem_);
|
||||
EXPECT_NE(ret, 0);
|
||||
// check AttachAbilityThread timeout handler
|
||||
EXPECT_EQ(launcherAbilityRecord_->IsReady(), false);
|
||||
@@ -272,7 +281,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_001, TestSize.Leve
|
||||
launcherAbilityRecord_->SetAbilityState(OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(AbilityManagerService::INACTIVE_TIMEOUT, command_->sem_);
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(INACTIVE_TIMEOUT, command_->sem_);
|
||||
EXPECT_NE(ret, 0);
|
||||
// check AbilityTransitionDone timeout handler
|
||||
EXPECT_NE(nextAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
@@ -328,7 +337,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_003, TestSize.Leve
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(
|
||||
AbilityManagerService::INACTIVE_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
INACTIVE_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
EXPECT_NE(ret, 0);
|
||||
// check timeout handler
|
||||
EXPECT_EQ(nextAbilityRecord_->GetAbilityState(), OHOS::AAFwk::AbilityState::ACTIVATING);
|
||||
@@ -391,7 +400,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_005, TestSize.Leve
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret =
|
||||
LifecycleTest::SemTimedWaitMillis(AbilityManagerService::LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
LifecycleTest::SemTimedWaitMillis(LOAD_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
if (ret != 0) {
|
||||
// check timeout handler
|
||||
pthread_join(tid, nullptr);
|
||||
@@ -424,7 +433,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_006, TestSize.Leve
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret =
|
||||
LifecycleTest::SemTimedWaitMillis(AbilityManagerService::ACTIVE_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
LifecycleTest::SemTimedWaitMillis(ACTIVE_TIMEOUT + DELAY_TEST_TIME, command_->sem_);
|
||||
EXPECT_NE(ret, 0);
|
||||
pthread_join(tid, nullptr);
|
||||
return;
|
||||
@@ -459,7 +468,7 @@ HWTEST_F(LifecycleTest, AAFWK_AbilityMS_startAbilityLifeCycle_007, TestSize.Leve
|
||||
EXPECT_EQ(AttachAbility(nextScheduler_, nextToken_), 0);
|
||||
pthread_t tid = 0;
|
||||
pthread_create(&tid, nullptr, LifecycleTest::AbilityStartThread, command_.get());
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(AbilityManagerService::ACTIVE_TIMEOUT * 2, command_->sem_);
|
||||
int ret = LifecycleTest::SemTimedWaitMillis(ACTIVE_TIMEOUT * 2, command_->sem_);
|
||||
if (ret != 0) {
|
||||
// check timeout handler
|
||||
pthread_join(tid, nullptr);
|
||||
|
||||
@@ -50,7 +50,7 @@ void ResSchedUtilTest::TearDown()
|
||||
|
||||
/**
|
||||
* @tc.number: ResSchedUtilTest_0100
|
||||
* @tc.desc: Test ReportAbilitStartInfoToRSS works
|
||||
* @tc.desc: Test ReportAbilityStartInfoToRSS works
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ResSchedUtilTest, ResSchedUtilTest_0100, TestSize.Level0)
|
||||
@@ -58,15 +58,15 @@ HWTEST_F(ResSchedUtilTest, ResSchedUtilTest_0100, TestSize.Level0)
|
||||
TAG_LOGI(AAFwkTag::TEST, "ResSchedUtilTest_0100 called.");
|
||||
AbilityInfo abilityInfo;
|
||||
int64_t resSchedType = -1;
|
||||
AAFwk::ResSchedUtil::GetInstance().ReportAbilitStartInfoToRSS(abilityInfo, -1, false);
|
||||
AAFwk::ResSchedUtil::GetInstance().ReportAbilitAssociatedStartInfoToRSS(abilityInfo, resSchedType, 0, 0);
|
||||
AAFwk::ResSchedUtil::GetInstance().ReportAbilityStartInfoToRSS(abilityInfo, -1, false);
|
||||
AAFwk::ResSchedUtil::GetInstance().ReportAbilityAssociatedStartInfoToRSS(abilityInfo, resSchedType, 0, 0);
|
||||
int64_t ret = AAFwk::ResSchedUtil::GetInstance().convertType(resSchedType);
|
||||
EXPECT_EQ(resSchedType, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ResSchedUtilTest_0200
|
||||
* @tc.desc: Test ReportAbilitStartInfoToRSS works
|
||||
* @tc.desc: Test ReportAbilityStartInfoToRSS works
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ResSchedUtilTest, ResSchedUtilTest_0200, TestSize.Level0)
|
||||
@@ -80,5 +80,20 @@ HWTEST_F(ResSchedUtilTest, ResSchedUtilTest_0200, TestSize.Level0)
|
||||
int64_t ret = AAFwk::ResSchedUtil::GetInstance().convertType(resSchedType);
|
||||
EXPECT_EQ(resSchedType, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: ResSchedUtilTest_0300
|
||||
* @tc.desc: Test ReportLoadingEventToRss works
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ResSchedUtilTest, ResSchedUtilTest_0300, TestSize.Level0)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "ResSchedUtilTest_0300 called.");
|
||||
AAFwk::ResSchedUtil::GetInstance().ReportLoadingEventToRss(AAFwk::LoadingStage::LOAD_BEGIN,
|
||||
0, 0, 0);
|
||||
int64_t resSchedType = AAFwk::RES_TYPE_SCB_START_ABILITY;
|
||||
int64_t ret = AAFwk::ResSchedUtil::GetInstance().convertType(resSchedType);
|
||||
EXPECT_EQ(resSchedType, ret);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -19,6 +19,37 @@
|
||||
namespace OHOS::AbilityRuntime {
|
||||
namespace GlobalConstant {
|
||||
constexpr int32_t MAX_APP_CLONE_INDEX = 1000;
|
||||
|
||||
constexpr int32_t TIMEOUT_UNIT_TIME = 1000;
|
||||
|
||||
#ifdef SUPPORT_ASAN
|
||||
constexpr int32_t COLDSTART_TIMEOUT_MULTIPLE = 15000;
|
||||
constexpr int32_t LOAD_TIMEOUT_MULTIPLE = 15000;
|
||||
constexpr int32_t FOREGROUND_TIMEOUT_MULTIPLE = 7500;
|
||||
constexpr int32_t BACKGROUND_TIMEOUT_MULTIPLE = 4500;
|
||||
constexpr int32_t ACTIVE_TIMEOUT_MULTIPLE = 7500;
|
||||
constexpr int32_t TERMINATE_TIMEOUT_MULTIPLE = 15000;
|
||||
constexpr int32_t INACTIVE_TIMEOUT_MULTIPLE = 800;
|
||||
constexpr int32_t DUMP_TIMEOUT_MULTIPLE = 1500;
|
||||
constexpr int32_t SHAREDATA_TIMEOUT_MULTIPLE = 7500;
|
||||
#else
|
||||
constexpr int32_t COLDSTART_TIMEOUT_MULTIPLE = 10;
|
||||
constexpr int32_t LOAD_TIMEOUT_MULTIPLE = 10;
|
||||
constexpr int32_t FOREGROUND_TIMEOUT_MULTIPLE = 5;
|
||||
constexpr int32_t BACKGROUND_TIMEOUT_MULTIPLE = 3;
|
||||
constexpr int32_t ACTIVE_TIMEOUT_MULTIPLE = 5;
|
||||
constexpr int32_t TERMINATE_TIMEOUT_MULTIPLE = 10;
|
||||
constexpr int32_t INACTIVE_TIMEOUT_MULTIPLE = 1;
|
||||
constexpr int32_t DUMP_TIMEOUT_MULTIPLE = 1000;
|
||||
constexpr int32_t SHAREDATA_TIMEOUT_MULTIPLE = 5;
|
||||
constexpr int32_t TYPE_RESERVE = 1;
|
||||
constexpr int32_t TYPE_OTHERS = 2;
|
||||
#endif
|
||||
|
||||
constexpr int32_t GetLoadTimeOutBase()
|
||||
{
|
||||
return TIMEOUT_UNIT_TIME * LOAD_TIMEOUT_MULTIPLE;
|
||||
}
|
||||
} // namespace GlobalConstant
|
||||
} // namespace OHOS::AbilityRuntime
|
||||
#endif // OHOS_ABILITY_RUNTIME_GLOBAL_CONSTANT_H
|
||||
Reference in New Issue
Block a user