support dump ace trees

Signed-off-by: zcdqs <junfeng.lijunfeng@huawei.com>
Change-Id: I35235c54f2e53a5e1798de2b05694949f062f59b
This commit is contained in:
zcdqs 2022-02-12 00:17:40 +08:00
parent f4c82beda4
commit a92a700e43
23 changed files with 112 additions and 43 deletions

View File

@ -671,6 +671,14 @@ public:
*/
virtual void Dump(const std::string &extra);
/**
* @brief dump ability info
*
* @param params dump params that indicate different dump targets
* @param info dump ability info
*/
virtual void Dump(const std::vector<std::string> &params, std::vector<std::string> &info);
/**
* @brief Keeps this Service ability in the background and displays a notification bar.
* To use this method, you need to request the ohos.permission.KEEP_BACKGROUND_RUNNING permission from the system.

View File

@ -400,7 +400,7 @@ public:
*
* @param runnerInfo ability runner info.
*/
void DumpAbilityInfo(std::vector<std::string> &info);
void DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info);
sptr<IRemoteObject> CallRequest();

View File

@ -1222,6 +1222,15 @@ void Ability::Dump(const std::string &extra)
}
}
/**
* @brief dump ability info
*
* @param params dump params that indicate different dump targets
* @param info dump ability info
*/
void Ability::Dump(const std::vector<std::string> &params, std::vector<std::string> &info)
{}
/**
* @brief Keeps this Service ability in the background and displays a notification bar.
* To use this method, you need to request the ohos.permission.KEEP_BACKGROUND_RUNNING permission from the system.

View File

@ -1559,9 +1559,23 @@ std::shared_ptr<AbilityRuntime::AbilityContext> AbilityThread::BuildAbilityConte
return abilityContextImpl;
}
void AbilityThread::DumpAbilityInfo(std::vector<std::string> &info)
void AbilityThread::DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info)
{
APP_LOGI("%{public}s begin.", __func__);
if (!params.empty()) {
if (abilityImpl_->IsStageBasedModel()) {
auto window = currentAbility_->GetWindow();
if (window == nullptr) {
APP_LOGE("DumpAbilityInfo window == nullptr");
return;
}
window->DumpInfo(params, info);
} else {
currentAbility_->Dump(params, info);
}
return;
}
std::string dumpInfo = " event:";
info.push_back(dumpInfo);

View File

@ -127,7 +127,7 @@ public:
};
virtual void NotifyContinuationResult(const int32_t result) {};
virtual void ContinueAbility(const std::string& deviceId) {};
virtual void DumpAbilityInfo(std::vector<std::string> &info) {};
virtual void DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info) {};
virtual sptr<IRemoteObject> CallRequest()
{
return sptr<IRemoteObject>(nullptr);

View File

@ -60,7 +60,7 @@ public:
MOCK_METHOD1(ExecuteBatch, std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>>(const std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> &operation));
MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result));
MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId));
MOCK_METHOD1(DumpAbilityInfo, void(std::vector<std::string> &info));
MOCK_METHOD2(DumpAbilityInfo, void(const std::vector<std::string> &params, std::vector<std::string> &info));
virtual sptr<IRemoteObject> CallRequest()
{

View File

@ -275,7 +275,7 @@ public:
virtual void ContinueAbility(const std::string& deviceId) = 0;
virtual void NotifyContinuationResult(const int32_t result) = 0;
virtual void DumpAbilityInfo(std::vector<std::string>& info) = 0;
virtual void DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info) = 0;
virtual sptr<IRemoteObject> CallRequest() = 0;

View File

@ -670,7 +670,7 @@ public:
* dump ability state info.
*
*/
void DumpAbilityState(std::vector<std::string> &info, bool isClient);
void DumpAbilityState(std::vector<std::string> &info, bool isClient, const std::vector<std::string> &params);
void SetStartTime();

View File

@ -305,7 +305,7 @@ public:
* @param
* @return Ability Runner info.
*/
void DumpAbilityInfo(std::vector<std::string> &info) override;
void DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info) override;
sptr<IRemoteObject> CallRequest() override;
private:

View File

@ -174,7 +174,9 @@ public:
* @param info dump result.
*/
void DumpList(std::vector<std::string> &info, bool isClient);
void DumpStateByRecordId(std::vector<std::string> &info, bool isClient, int32_t abilityRecordId);
void DumpStateByRecordId(
std::vector<std::string> &info, bool isClient, int32_t abilityRecordId, const std::vector<std::string> &params);
std::shared_ptr<Mission> GetMissionBySpecifiedFlag(const std::string &flag) const;
private:

View File

@ -262,7 +262,14 @@ public:
*/
void DumpMissionList(std::vector<std::string> &info, bool isClient, const std::string &args = "");
void DumpMissionListByRecordId(std::vector<std::string> &info, bool isClient, int32_t abilityRecordId);
/**
* @brief dump mission list by id with params
*
* @param info dump result.
* @param params dump params.
*/
void DumpMissionListByRecordId(
std::vector<std::string>& info, bool isClient, int32_t abilityRecordId, const std::vector<std::string>& params);
/**
* @brief dump mission by id

View File

@ -1699,9 +1699,10 @@ void AbilityManagerService::DumpSysAbilityInner(
if (argList.empty()) {
return;
}
if (argList.size() == MIN_DUMP_ARGUMENT_NUM) {
if (argList.size() >= MIN_DUMP_ARGUMENT_NUM) {
HILOG_INFO("argList = %{public}s", argList[1].c_str());
targetManager->DumpMissionListByRecordId(info, isClient, std::stoi(argList[1]));
std::vector<std::string> params(argList.begin() + MIN_DUMP_ARGUMENT_NUM, argList.end());
targetManager->DumpMissionListByRecordId(info, isClient, std::stoi(argList[1]), params);
} else {
info.emplace_back("error: invalid argument, please see 'ability dumpsys -h'.");
}

View File

@ -922,7 +922,8 @@ void AbilityRecord::Dump(std::vector<std::string> &info)
}
}
void AbilityRecord::DumpAbilityState(std::vector<std::string> &info, bool isClient)
void AbilityRecord::DumpAbilityState(
std::vector<std::string> &info, bool isClient, const std::vector<std::string> &params)
{
HILOG_INFO("%{public}s begin.", __func__);
std::string dumpInfo = " AbilityRecord ID #" + std::to_string(recordId_);
@ -954,7 +955,10 @@ void AbilityRecord::DumpAbilityState(std::vector<std::string> &info, bool isClie
// add dump client info
if (isClient && scheduler_ && isReady_) {
scheduler_->DumpAbilityInfo(info);
scheduler_->DumpAbilityInfo(params, info);
if (!params.empty()) {
return;
}
AppExecFwk::Configuration config;
if (DelayedSingleton<AppScheduler>::GetInstance()->GetConfiguration(config) == ERR_OK) {
info.emplace_back(" configuration: " + config.GetName());
@ -992,7 +996,8 @@ void AbilityRecord::DumpService(std::vector<std::string> &info, bool isClient) c
}
// add dump client info
if (isClient && scheduler_ && isReady_) {
scheduler_->DumpAbilityInfo(info);
std::vector<std::string> params;
scheduler_->DumpAbilityInfo(params, info);
AppExecFwk::Configuration config;
if (DelayedSingleton<AppScheduler>::GetInstance()->GetConfiguration(config) == ERR_OK) {
info.emplace_back(" configuration: " + config.GetName());

View File

@ -981,7 +981,7 @@ void AbilitySchedulerProxy::NotifyContinuationResult(int32_t result)
}
}
void AbilitySchedulerProxy::DumpAbilityInfo(std::vector<std::string> &info)
void AbilitySchedulerProxy::DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info)
{
MessageParcel data;
MessageParcel reply;
@ -991,6 +991,11 @@ void AbilitySchedulerProxy::DumpAbilityInfo(std::vector<std::string> &info)
return;
}
if (!data.WriteStringVector(params)) {
HILOG_ERROR("DumpAbilityRunner fail to write params");
return;
}
int32_t err = Remote()->SendRequest(IAbilityScheduler::DUMP_ABILITY_RUNNER_INNER, data, reply, option);
if (err != NO_ERROR) {
HILOG_ERROR("DumpAbilityRunner fail to SendRequest. err: %d", err);

View File

@ -580,10 +580,13 @@ int AbilitySchedulerStub::NotifyContinuationResultInner(MessageParcel &data, Mes
int AbilitySchedulerStub::DumpAbilityInfoInner(MessageParcel &data, MessageParcel &reply)
{
std::vector<std::string> infos;
DumpAbilityInfo(infos);
std::vector<std::string> params;
if (!data.ReadStringVector(&params)) {
HILOG_INFO("DumpAbilityInfoInner read params error");
return NO_ERROR;
}
DumpAbilityInfo(params, infos);
for (const auto & infostep:infos) {
HILOG_INFO("DumpAbilityInfoInner infos = %{public}s", infostep.c_str());

View File

@ -264,7 +264,8 @@ void MissionList::Dump(std::vector<std::string>& info)
}
}
void MissionList::DumpStateByRecordId(std::vector<std::string> &info, bool isClient, int32_t abilityRecordId)
void MissionList::DumpStateByRecordId(
std::vector<std::string> &info, bool isClient, int32_t abilityRecordId, const std::vector<std::string> &params)
{
for (const auto& mission : missions_) {
if (mission) {
@ -272,7 +273,7 @@ void MissionList::DumpStateByRecordId(std::vector<std::string> &info, bool isCli
if (abilityRecord) {
if (abilityRecord->GetRecordId() == abilityRecordId) {
HILOG_INFO("record begain to call DumpAbilityState %{public}s", __func__);
abilityRecord->DumpAbilityState(info, isClient);
abilityRecord->DumpAbilityState(info, isClient, params);
return;
}
}
@ -294,7 +295,8 @@ void MissionList::DumpList(std::vector<std::string> &info, bool isClient)
auto abilityRecord = mission->GetAbilityRecord();
if (abilityRecord) {
HILOG_INFO("record begain to call DumpAbilityState %{public}s", __func__);
abilityRecord->DumpAbilityState(info, isClient);
std::vector<std::string> params;
abilityRecord->DumpAbilityState(info, isClient, params);
}
}
}

View File

@ -1574,7 +1574,7 @@ void MissionListManager::Dump(std::vector<std::string> &info)
}
void MissionListManager::DumpMissionListByRecordId(
std::vector<std::string> &info, bool isClient, int32_t abilityRecordId)
std::vector<std::string> &info, bool isClient, int32_t abilityRecordId, const std::vector<std::string> &params)
{
std::lock_guard<std::recursive_mutex> guard(managerLock_);
std::string dumpInfo = "User ID #" + std::to_string(userId_);
@ -1582,23 +1582,23 @@ void MissionListManager::DumpMissionListByRecordId(
for (const auto& missionList : currentMissionLists_) {
if (missionList && missionList != launcherList_) {
HILOG_INFO("missionList begain to call DumpMissionListByRecordId %{public}s", __func__);
missionList->DumpStateByRecordId(info, isClient, abilityRecordId);
missionList->DumpStateByRecordId(info, isClient, abilityRecordId, params);
}
}
if (defaultStandardList_) {
HILOG_INFO("defaultStandardList begain to call DumpMissionListByRecordId %{public}s", __func__);
defaultStandardList_->DumpStateByRecordId(info, isClient, abilityRecordId);
defaultStandardList_->DumpStateByRecordId(info, isClient, abilityRecordId, params);
}
if (defaultSingleList_) {
HILOG_INFO("defaultSingleList begain to call DumpMissionListByRecordId %{public}s", __func__);
defaultSingleList_->DumpStateByRecordId(info, isClient, abilityRecordId);
defaultSingleList_->DumpStateByRecordId(info, isClient, abilityRecordId, params);
}
if (launcherList_) {
HILOG_INFO("launcherList begain to call DumpMissionListByRecordId %{public}s", __func__);
launcherList_->DumpStateByRecordId(info, isClient, abilityRecordId);
launcherList_->DumpStateByRecordId(info, isClient, abilityRecordId, params);
}
}
void MissionListManager::DumpMissionList(std::vector<std::string> &info, bool isClient, const std::string &args)

View File

@ -101,7 +101,7 @@ public:
{};
virtual void ContinueAbility(const std::string& deviceId) override
{};
virtual void DumpAbilityInfo(std::vector<std::string> &info) override
virtual void DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info) override
{};
virtual sptr<IRemoteObject> CallRequest() override
{

View File

@ -43,7 +43,7 @@ public:
MOCK_METHOD2(NotifyMultiWinModeChanged, void(int32_t winModeKey, bool flag));
MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result));
MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId));
MOCK_METHOD1(DumpAbilityInfo, void(std::vector<std::string> &info));
MOCK_METHOD2(DumpAbilityInfo, void(const std::vector<std::string> &params, std::vector<std::string> &info));
int InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{

View File

@ -133,7 +133,7 @@ public:
{}
virtual void ContinueAbility(const std::string& deviceId) override
{}
virtual void DumpAbilityInfo(std::vector<std::string> &info) override
virtual void DumpAbilityInfo(const std::vector<std::string> &params, std::vector<std::string> &info) override
{}
virtual sptr<IRemoteObject> CallRequest() override
{

View File

@ -44,7 +44,7 @@ public:
MOCK_METHOD1(ExecuteBatch, std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>>(const std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> &operations));
MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result));
MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId));
MOCK_METHOD1(DumpAbilityInfo, void(std::vector<std::string> &info));
MOCK_METHOD2(DumpAbilityInfo, void(const std::vector<std::string> &params, std::vector<std::string> &info));
std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
{
std::vector<std::string> types;

View File

@ -53,7 +53,7 @@ public:
const std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> &operations));
MOCK_METHOD1(NotifyContinuationResult, void(const int32_t result));
MOCK_METHOD1(ContinueAbility, void(const std::string& deviceId));
MOCK_METHOD1(DumpAbilityInfo, void(std::vector<std::string> &info));
MOCK_METHOD2(DumpAbilityInfo, void(const std::vector<std::string> &params, std::vector<std::string> &info));
virtual sptr<IRemoteObject> CallRequest()
{

View File

@ -629,9 +629,13 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
if (isfirstCommand == false) {
isfirstCommand = true;
} else {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
// 'aa dumpsys -i 10 -element -lastpage'
// 'aa dumpsys -i 10 -render -lastpage'
if (strcmp(optarg, "astpage")) {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
}
}
// 'aa dumpsys -l'
// 'aa dumpsys --mission-list'
@ -648,9 +652,12 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
return result;
}
} else {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
// 'aa dumpsys -i 10 -inspector'
if (strcmp(optarg, "nspector")) {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
}
}
// 'aa dumpsys -i'
// 'aa dumpsys --ability'
@ -660,9 +667,12 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
if (isfirstCommand == false) {
isfirstCommand = true;
} else {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
// 'aa dumpsys -i 10 -element'
if (strcmp(optarg, "lement")) {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
}
}
// 'aa dumpsys -e'
// 'aa dumpsys --extension'
@ -684,9 +694,12 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
if (isfirstCommand == false) {
isfirstCommand = true;
} else {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
// 'aa dumpsys -i 10 -render'
if (strcmp(optarg, "ender")) {
result = OHOS::ERR_INVALID_VALUE;
resultReceiver_.append(HELP_MSG_DUMPSYS);
return result;
}
}
// 'aa dumpsys -r'
// 'aa dumpsys --process'