Merge pull request !9058 from 杨旭光/refactor/cfi
This commit is contained in:
openharmony_ci
2024-06-21 13:24:37 +00:00
committed by Gitee
21 changed files with 1170 additions and 709 deletions
@@ -23,10 +23,7 @@
namespace OHOS {
namespace AbilityRuntime {
DialogRequestCallbackStub::DialogRequestCallbackStub()
{
vecMemberFunc_.resize(IDialogRequestCallback::CODE_MAX);
vecMemberFunc_[CODE_SEND_RESULT] = &DialogRequestCallbackStub::SendResultInner;
}
{}
int DialogRequestCallbackStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
@@ -38,9 +35,8 @@ int DialogRequestCallbackStub::OnRemoteRequest(
return ERR_INVALID_STATE;
}
if (code < IDialogRequestCallback::CODE_MAX) {
auto memberFunc = vecMemberFunc_[code];
return (this->*memberFunc)(data, reply);
if (code == CODE_SEND_RESULT) {
return SendResultInner(data, reply);
}
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@@ -23,15 +23,10 @@
namespace OHOS {
namespace AbilityRuntime {
FreeInstallObserverStub::FreeInstallObserverStub()
{
memberFuncMap_[IFreeInstallObserver::ON_INSTALL_FINISHED] =
&FreeInstallObserverStub::OnInstallFinishedInner;
}
{}
FreeInstallObserverStub::~FreeInstallObserverStub()
{
memberFuncMap_.clear();
}
{}
int FreeInstallObserverStub::OnInstallFinishedInner(MessageParcel &data, MessageParcel &reply)
{
@@ -54,12 +49,8 @@ int FreeInstallObserverStub::OnRemoteRequest(
return ERR_INVALID_STATE;
}
auto itFunc = memberFuncMap_.find(code);
if (itFunc != memberFuncMap_.end()) {
auto memberFunc = itFunc->second;
if (memberFunc != nullptr) {
return (this->*memberFunc)(data, reply);
}
if (code == IFreeInstallObserver::ON_INSTALL_FINISHED) {
return OnInstallFinishedInner(data, reply);
}
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@@ -549,6 +549,11 @@ enum {
* Native error(2097258) for target bundle not exist.
*/
ERR_BUNDLE_NOT_EXIST,
/**
* Native error(3000000) for target bundle not exist.
*/
ERR_CODE_NOT_EXIST = 3000000,
};
enum {
@@ -41,9 +41,6 @@ private:
DISALLOW_COPY_AND_MOVE(DialogRequestCallbackStub);
int SendResultInner(MessageParcel &data, MessageParcel &reply);
using StubFunc = int (DialogRequestCallbackStub::*)(MessageParcel &data, MessageParcel &reply);
std::vector<StubFunc> vecMemberFunc_;
};
} // namespace AbilityRuntime
} // namespace OHOS
@@ -35,8 +35,6 @@ public:
private:
DISALLOW_COPY_AND_MOVE(FreeInstallObserverStub);
int OnInstallFinishedInner(MessageParcel &data, MessageParcel &reply);
using FreeInstallObserverFunc = int32_t (FreeInstallObserverStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, FreeInstallObserverFunc> memberFuncMap_;
};
} // namespace AbilityRuntime
} // namespace OHOS
@@ -1836,14 +1836,12 @@ private:
void DataDumpStateInner(const std::string &args, std::vector<std::string> &info);
void DumpMissionListInner(const std::string &args, std::vector<std::string> &info);
void DumpMissionInfosInner(const std::string &args, std::vector<std::string> &info);
void DumpFuncInit();
bool JudgeMultiUserConcurrency(const int32_t userId);
/**
* dumpsys info
*
*/
void DumpSysFuncInit();
void DumpSysInner(
const std::string &args, std::vector<std::string> &info, bool isClient, bool isUserID, int userId);
void DumpSysMissionListInner(
@@ -1919,13 +1917,6 @@ private:
int VerifyAccountPermission(int32_t userId);
using DumpFuncType = void (AbilityManagerService::*)(const std::string &args, std::vector<std::string> &info);
std::map<uint32_t, DumpFuncType> dumpFuncMap_;
using DumpSysFuncType = void (AbilityManagerService::*)(
const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserID, int UserID);
std::map<uint32_t, DumpSysFuncType> dumpsysFuncMap_;
int CheckStaticCfgPermissionForAbility(const AppExecFwk::AbilityInfo &abilityInfo, uint32_t tokenId);
int CheckStaticCfgPermissionForSkill(const AppExecFwk::AbilityRequest &abilityRequest, uint32_t tokenId);
@@ -66,11 +66,6 @@ public:
virtual int GetConnectionData(std::vector<AbilityRuntime::ConnectionData> &connectionData);
private:
void FirstStepInit();
void SecondStepInit();
void ThirdStepInit();
void FourthStepInit();
void FifthStepInit();
int TerminateAbilityInner(MessageParcel &data, MessageParcel &reply);
int TerminateUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply);
int CloseUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply);
@@ -218,9 +213,6 @@ private:
int FreeInstallAbilityFromRemoteInner(MessageParcel &data, MessageParcel &reply);
int AddFreeInstallObserverInner(MessageParcel &data, MessageParcel &reply);
using RequestFuncType = int (AbilityManagerStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, RequestFuncType> requestFuncMap_;
#ifdef ABILITY_COMMAND_FOR_TEST
int BlockAmsServiceInner(MessageParcel &data, MessageParcel &reply);
int BlockAbilityInner(MessageParcel &data, MessageParcel &reply);
@@ -302,6 +294,50 @@ private:
int32_t GetAbilityStateByPersistentIdInner(MessageParcel &data, MessageParcel &reply);
int32_t TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply);
int32_t NotifyFrozenProcessByRSSInner(MessageParcel &data, MessageParcel &reply);
int OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerFifth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerSixth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerEighth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerNinth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerTenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerEleventh(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInner(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerTwelveth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerThirteenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerFourteenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerFifteenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerSixteenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerSeventeenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerEighteenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerNineteenth(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int HandleOnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
int HandleOnRemoteRequestInnerSecond(uint32_t code, MessageParcel &data,
MessageParcel &reply, MessageOption &option);
};
} // namespace AAFwk
} // namespace OHOS
@@ -75,8 +75,14 @@ private:
int ShareDataInner(MessageParcel &data, MessageParcel &reply);
int CreateModalUIExtensionInner(MessageParcel &data, MessageParcel &reply);
int UpdateSessionTokenInner(MessageParcel &data, MessageParcel &reply);
using RequestFuncType = int (AbilitySchedulerStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, RequestFuncType> requestFuncMap_;
int OnRemoteRequestInner(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerFirst(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerSecond(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
int OnRemoteRequestInnerThird(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
};
/**
@@ -340,10 +340,7 @@ AbilityManagerService::AbilityManagerService()
: SystemAbility(ABILITY_MGR_SERVICE_ID, true),
state_(ServiceRunningState::STATE_NOT_START),
bundleMgrHelper_(nullptr)
{
DumpFuncInit();
DumpSysFuncInit();
}
{}
AbilityManagerService::~AbilityManagerService()
{}
@@ -4776,29 +4773,6 @@ int AbilityManagerService::AttachAbilityThread(
}
}
void AbilityManagerService::DumpFuncInit()
{
dumpFuncMap_[KEY_DUMP_SERVICE] = &AbilityManagerService::DumpStateInner;
dumpFuncMap_[KEY_DUMP_DATA] = &AbilityManagerService::DataDumpStateInner;
dumpFuncMap_[KEY_DUMP_ALL] = &AbilityManagerService::DumpInner;
dumpFuncMap_[KEY_DUMP_MISSION] = &AbilityManagerService::DumpMissionInner;
dumpFuncMap_[KEY_DUMP_MISSION_LIST] = &AbilityManagerService::DumpMissionListInner;
dumpFuncMap_[KEY_DUMP_MISSION_INFOS] = &AbilityManagerService::DumpMissionInfosInner;
}
void AbilityManagerService::DumpSysFuncInit()
{
dumpsysFuncMap_[KEY_DUMPSYS_ALL] = &AbilityManagerService::DumpSysInner;
dumpsysFuncMap_[KEY_DUMPSYS_SERVICE] = &AbilityManagerService::DumpSysStateInner;
dumpsysFuncMap_[KEY_DUMPSYS_PENDING] = &AbilityManagerService::DumpSysPendingInner;
dumpsysFuncMap_[KEY_DUMPSYS_PROCESS] = &AbilityManagerService::DumpSysProcess;
dumpsysFuncMap_[KEY_DUMPSYS_DATA] = &AbilityManagerService::DataDumpSysStateInner;
dumpsysFuncMap_[KEY_DUMPSYS_MISSION_LIST] = &AbilityManagerService::DumpSysMissionListInner;
dumpsysFuncMap_[KEY_DUMPSYS_ABILITY] = &AbilityManagerService::DumpSysAbilityInner;
}
void AbilityManagerService::DumpSysInner(
const std::string& args, std::vector<std::string>& info, bool isClient, bool isUserID, int userId)
{
@@ -5271,15 +5245,29 @@ void AbilityManagerService::DumpState(const std::string &args, std::vector<std::
return;
}
DumpKey key = it->second;
auto itFunc = dumpFuncMap_.find(key);
if (itFunc != dumpFuncMap_.end()) {
auto dumpFunc = itFunc->second;
if (dumpFunc != nullptr) {
(this->*dumpFunc)(args, info);
return;
}
switch (key) {
case KEY_DUMP_SERVICE:
DumpStateInner(args, info);
break;
case KEY_DUMP_DATA:
DataDumpStateInner(args, info);
break;
case KEY_DUMP_ALL:
DumpInner(args, info);
break;
case KEY_DUMP_MISSION:
DumpMissionInner(args, info);
break;
case KEY_DUMP_MISSION_LIST:
DumpMissionListInner(args, info);
break;
case KEY_DUMP_MISSION_INFOS:
DumpMissionInfosInner(args, info);
break;
default:
info.push_back("error: invalid argument, please see 'ability dump -h'.");
break;
}
info.push_back("error: invalid argument, please see 'ability dump -h'.");
}
void AbilityManagerService::DumpSysState(
@@ -5302,15 +5290,32 @@ void AbilityManagerService::DumpSysState(
return;
}
DumpsysKey key = it->second;
auto itFunc = dumpsysFuncMap_.find(key);
if (itFunc != dumpsysFuncMap_.end()) {
auto dumpsysFunc = itFunc->second;
if (dumpsysFunc != nullptr) {
(this->*dumpsysFunc)(args, info, isClient, isUserID, userId);
return;
}
switch (key) {
case KEY_DUMPSYS_ALL:
DumpSysInner(args, info, isClient, isUserID, userId);
break;
case KEY_DUMPSYS_SERVICE:
DumpSysStateInner(args, info, isClient, isUserID, userId);
break;
case KEY_DUMPSYS_PENDING:
DumpSysPendingInner(args, info, isClient, isUserID, userId);
break;
case KEY_DUMPSYS_PROCESS:
DumpSysProcess(args, info, isClient, isUserID, userId);
break;
case KEY_DUMPSYS_DATA:
DataDumpSysStateInner(args, info, isClient, isUserID, userId);
break;
case KEY_DUMPSYS_MISSION_LIST:
DumpSysMissionListInner(args, info, isClient, isUserID, userId);
break;
case KEY_DUMPSYS_ABILITY:
DumpSysAbilityInner(args, info, isClient, isUserID, userId);
break;
default:
info.push_back("error: invalid argument, please see 'ability dump -h'.");
break;
}
info.push_back("error: invalid argument, please see 'ability dump -h'.");
}
int AbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
File diff suppressed because it is too large Load Diff
@@ -15,6 +15,7 @@
#include "ability_scheduler_stub.h"
#include "ability_manager_errors.h"
#include "abs_shared_result_set.h"
#include "data_ability_observer_interface.h"
#include "data_ability_operation.h"
@@ -33,51 +34,10 @@ namespace OHOS {
namespace AAFwk {
constexpr int CYCLE_LIMIT = 2000;
AbilitySchedulerStub::AbilitySchedulerStub()
{
requestFuncMap_[SCHEDULE_ABILITY_TRANSACTION] = &AbilitySchedulerStub::AbilityTransactionInner;
requestFuncMap_[SEND_RESULT] = &AbilitySchedulerStub::SendResultInner;
requestFuncMap_[SCHEDULE_ABILITY_CONNECT] = &AbilitySchedulerStub::ConnectAbilityInner;
requestFuncMap_[SCHEDULE_ABILITY_DISCONNECT] = &AbilitySchedulerStub::DisconnectAbilityInner;
requestFuncMap_[SCHEDULE_ABILITY_COMMAND] = &AbilitySchedulerStub::CommandAbilityInner;
requestFuncMap_[SCHEDULE_ABILITY_PREPARE_TERMINATE] = &AbilitySchedulerStub::PrepareTerminateAbilityInner;
requestFuncMap_[SCHEDULE_ABILITY_COMMAND_WINDOW] = &AbilitySchedulerStub::CommandAbilityWindowInner;
requestFuncMap_[SCHEDULE_SAVE_ABILITY_STATE] = &AbilitySchedulerStub::SaveAbilityStateInner;
requestFuncMap_[SCHEDULE_RESTORE_ABILITY_STATE] = &AbilitySchedulerStub::RestoreAbilityStateInner;
requestFuncMap_[SCHEDULE_GETFILETYPES] = &AbilitySchedulerStub::GetFileTypesInner;
requestFuncMap_[SCHEDULE_OPENFILE] = &AbilitySchedulerStub::OpenFileInner;
requestFuncMap_[SCHEDULE_OPENRAWFILE] = &AbilitySchedulerStub::OpenRawFileInner;
requestFuncMap_[SCHEDULE_INSERT] = &AbilitySchedulerStub::InsertInner;
requestFuncMap_[SCHEDULE_UPDATE] = &AbilitySchedulerStub::UpdatetInner;
requestFuncMap_[SCHEDULE_DELETE] = &AbilitySchedulerStub::DeleteInner;
requestFuncMap_[SCHEDULE_QUERY] = &AbilitySchedulerStub::QueryInner;
requestFuncMap_[SCHEDULE_CALL] = &AbilitySchedulerStub::CallInner;
requestFuncMap_[SCHEDULE_GETTYPE] = &AbilitySchedulerStub::GetTypeInner;
requestFuncMap_[SCHEDULE_RELOAD] = &AbilitySchedulerStub::ReloadInner;
requestFuncMap_[SCHEDULE_BATCHINSERT] = &AbilitySchedulerStub::BatchInsertInner;
requestFuncMap_[SCHEDULE_REGISTEROBSERVER] = &AbilitySchedulerStub::RegisterObserverInner;
requestFuncMap_[SCHEDULE_UNREGISTEROBSERVER] = &AbilitySchedulerStub::UnregisterObserverInner;
requestFuncMap_[SCHEDULE_NOTIFYCHANGE] = &AbilitySchedulerStub::NotifyChangeInner;
requestFuncMap_[SCHEDULE_NORMALIZEURI] = &AbilitySchedulerStub::NormalizeUriInner;
requestFuncMap_[SCHEDULE_DENORMALIZEURI] = &AbilitySchedulerStub::DenormalizeUriInner;
requestFuncMap_[SCHEDULE_EXECUTEBATCH] = &AbilitySchedulerStub::ExecuteBatchInner;
requestFuncMap_[NOTIFY_CONTINUATION_RESULT] = &AbilitySchedulerStub::NotifyContinuationResultInner;
requestFuncMap_[REQUEST_CALL_REMOTE] = &AbilitySchedulerStub::CallRequestInner;
requestFuncMap_[CONTINUE_ABILITY] = &AbilitySchedulerStub::ContinueAbilityInner;
requestFuncMap_[DUMP_ABILITY_RUNNER_INNER] = &AbilitySchedulerStub::DumpAbilityInfoInner;
requestFuncMap_[SCHEDULE_SHARE_DATA] = &AbilitySchedulerStub::ShareDataInner;
requestFuncMap_[SCHEDULE_ONEXECUTE_INTENT] = &AbilitySchedulerStub::OnExecuteIntentInner;
requestFuncMap_[CREATE_MODAL_UI_EXTENSION] = &AbilitySchedulerStub::CreateModalUIExtensionInner;
requestFuncMap_[UPDATE_SESSION_TOKEN] = &AbilitySchedulerStub::UpdateSessionTokenInner;
#ifdef ABILITY_COMMAND_FOR_TEST
requestFuncMap_[BLOCK_ABILITY_INNER] = &AbilitySchedulerStub::BlockAbilityInner;
#endif
}
{}
AbilitySchedulerStub::~AbilitySchedulerStub()
{
requestFuncMap_.clear();
}
{}
int AbilitySchedulerStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
@@ -88,18 +48,125 @@ int AbilitySchedulerStub::OnRemoteRequest(
TAG_LOGE(AAFwkTag::ABILITYMGR, "local descriptor is not equal to remote");
return ERR_INVALID_STATE;
}
return OnRemoteRequestInner(code, data, reply, option);
}
auto itFunc = requestFuncMap_.find(code);
if (itFunc != requestFuncMap_.end()) {
auto requestFunc = itFunc->second;
if (requestFunc != nullptr) {
return (this->*requestFunc)(data, reply);
}
int AbilitySchedulerStub::OnRemoteRequestInner(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
int retCode = ERR_OK;
retCode = OnRemoteRequestInnerFirst(code, data, reply, option);
if (retCode != ERR_CODE_NOT_EXIST) {
return retCode;
}
retCode = OnRemoteRequestInnerSecond(code, data, reply, option);
if (retCode != ERR_CODE_NOT_EXIST) {
return retCode;
}
retCode = OnRemoteRequestInnerThird(code, data, reply, option);
if (retCode != ERR_CODE_NOT_EXIST) {
return retCode;
}
TAG_LOGW(AAFwkTag::ABILITYMGR, "AbilitySchedulerStub::OnRemoteRequest, default case, need check.");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
int AbilitySchedulerStub::OnRemoteRequestInnerFirst(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
switch (code) {
case SCHEDULE_ABILITY_TRANSACTION:
return AbilityTransactionInner(data, reply);
case SEND_RESULT:
return SendResultInner(data, reply);
case SCHEDULE_ABILITY_CONNECT:
return ConnectAbilityInner(data, reply);
case SCHEDULE_ABILITY_DISCONNECT:
return DisconnectAbilityInner(data, reply);
case SCHEDULE_ABILITY_COMMAND:
return CommandAbilityInner(data, reply);
case SCHEDULE_ABILITY_PREPARE_TERMINATE:
return PrepareTerminateAbilityInner(data, reply);
case SCHEDULE_ABILITY_COMMAND_WINDOW:
return CommandAbilityWindowInner(data, reply);
case SCHEDULE_SAVE_ABILITY_STATE:
return SaveAbilityStateInner(data, reply);
case SCHEDULE_RESTORE_ABILITY_STATE:
return RestoreAbilityStateInner(data, reply);
case SCHEDULE_GETFILETYPES:
return GetFileTypesInner(data, reply);
case SCHEDULE_OPENFILE:
return OpenFileInner(data, reply);
case SCHEDULE_OPENRAWFILE:
return OpenRawFileInner(data, reply);
case SCHEDULE_INSERT:
return InsertInner(data, reply);
case SCHEDULE_UPDATE:
return UpdatetInner(data, reply);
case SCHEDULE_DELETE:
return DeleteInner(data, reply);
}
return ERR_CODE_NOT_EXIST;
}
int AbilitySchedulerStub::OnRemoteRequestInnerSecond(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
switch (code) {
case SCHEDULE_QUERY:
return QueryInner(data, reply);
case SCHEDULE_CALL:
return CallInner(data, reply);
case SCHEDULE_GETTYPE:
return GetTypeInner(data, reply);
case SCHEDULE_RELOAD:
return ReloadInner(data, reply);
case SCHEDULE_BATCHINSERT:
return BatchInsertInner(data, reply);
case SCHEDULE_REGISTEROBSERVER:
return RegisterObserverInner(data, reply);
case SCHEDULE_UNREGISTEROBSERVER:
return UnregisterObserverInner(data, reply);
case SCHEDULE_NOTIFYCHANGE:
return NotifyChangeInner(data, reply);
case SCHEDULE_NORMALIZEURI:
return NormalizeUriInner(data, reply);
case SCHEDULE_DENORMALIZEURI:
return DenormalizeUriInner(data, reply);
case SCHEDULE_EXECUTEBATCH:
return ExecuteBatchInner(data, reply);
case NOTIFY_CONTINUATION_RESULT:
return NotifyContinuationResultInner(data, reply);
case REQUEST_CALL_REMOTE:
return CallRequestInner(data, reply);
case CONTINUE_ABILITY:
return ContinueAbilityInner(data, reply);
case DUMP_ABILITY_RUNNER_INNER:
return DumpAbilityInfoInner(data, reply);
}
return ERR_CODE_NOT_EXIST;
}
int AbilitySchedulerStub::OnRemoteRequestInnerThird(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
switch (code) {
case SCHEDULE_SHARE_DATA:
return ShareDataInner(data, reply);
case SCHEDULE_ONEXECUTE_INTENT:
return OnExecuteIntentInner(data, reply);
case CREATE_MODAL_UI_EXTENSION:
return CreateModalUIExtensionInner(data, reply);
case UPDATE_SESSION_TOKEN:
return UpdateSessionTokenInner(data, reply);
#ifdef ABILITY_COMMAND_FOR_TEST
case BLOCK_ABILITY_INNER:
return BlockAbilityInner(data, reply);
#endif
}
return ERR_CODE_NOT_EXIST;
}
int AbilitySchedulerStub::AbilityTransactionInner(MessageParcel &data, MessageParcel &reply)
{
std::shared_ptr<Want> want(data.ReadParcelable<Want>());
@@ -180,8 +180,9 @@ int32_t ResidentProcessManager::SetResidentProcessEnabled(
IN_PROCESS_CALL_WITHOUT_RET(appMgrClient->SetKeepAliveEnableState(bundleName, updateEnable));
}
ffrt::submit(std::bind(&ResidentProcessManager::UpdateResidentProcessesStatus, shared_from_this(), bundleName,
localEnable, updateEnable));
ffrt::submit([self = shared_from_this(), bundleName, localEnable, updateEnable]() {
self->UpdateResidentProcessesStatus(bundleName, localEnable, updateEnable);
});
return ERR_OK;
}
@@ -698,15 +698,6 @@ private:
bool GetDumpIpcKeyByOption(const std::string &option, DumpIpcKey &key);
using DumpFuncType = int (AppMgrService::*)(const std::vector<std::u16string>& args, std::string& result);
bool GetDumpFunc(const std::string &optionKey, DumpFuncType &func);
using DumpIpcAllFuncType = int (AppMgrService::*)(std::string& result);
DumpIpcAllFuncType GetDumpIpcAllFuncByKey(uint32_t key);
using DumpIpcFuncType = int (AppMgrService::*)(const int32_t pid, std::string& result);
DumpIpcFuncType GetDumpIpcFuncByKey(uint32_t key);
DISALLOW_COPY_AND_MOVE(AppMgrService);
};
} // namespace AppExecFwk
+39 -24
View File
@@ -82,9 +82,10 @@ void AmsMgrScheduler::LoadAbility(const sptr<IRemoteObject> &token, const sptr<I
PerfProfile::GetInstance().SetAbilityLoadStartTime(GetTickCount());
TAG_LOGI(AAFwkTag::APPMGR, "SubmitLoadTask: %{public}s-%{public}s", abilityInfo->bundleName.c_str(),
abilityInfo->name.c_str());
std::function<void()> loadAbilityFunc =
std::bind(&AppMgrServiceInner::LoadAbility, amsMgrServiceInner_, token, preToken, abilityInfo,
appInfo, want, abilityRecordId);
std::function<void()> loadAbilityFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, preToken,
abilityInfo, appInfo, want, abilityRecordId]() {
amsMgrServiceInner->LoadAbility(token, preToken, abilityInfo, appInfo, want, abilityRecordId);
};
// cache other application load ability task before scene board attach
if (!amsMgrServiceInner_->GetSceneBoardAttachFlag() && abilityInfo->bundleName != SCENE_BOARD_BUNDLE_NAME) {
@@ -117,8 +118,9 @@ void AmsMgrScheduler::UpdateAbilityState(const sptr<IRemoteObject> &token, const
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
return;
}
std::function<void()> updateAbilityStateFunc =
std::bind(&AppMgrServiceInner::UpdateAbilityState, amsMgrServiceInner_, token, state);
std::function<void()> updateAbilityStateFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, state] () {
amsMgrServiceInner->UpdateAbilityState(token, state);
};
amsHandler_->SubmitTask(updateAbilityStateFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_UPDATE_ABILITY_STATE,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -135,8 +137,9 @@ void AmsMgrScheduler::UpdateExtensionState(const sptr<IRemoteObject> &token, con
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
return;
}
std::function<void()> updateExtensionStateFunc =
std::bind(&AppMgrServiceInner::UpdateExtensionState, amsMgrServiceInner_, token, state);
std::function<void()> updateExtensionStateFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, state]() {
amsMgrServiceInner->UpdateExtensionState(token, state);
};
amsHandler_->SubmitTask(updateExtensionStateFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_UPDATE_EXTENSION_STATE,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -153,8 +156,9 @@ void AmsMgrScheduler::TerminateAbility(const sptr<IRemoteObject> &token, bool cl
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
return;
}
std::function<void()> terminateAbilityFunc =
std::bind(&AppMgrServiceInner::TerminateAbility, amsMgrServiceInner_, token, clearMissionFlag);
std::function<void()> terminateAbilityFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, clearMissionFlag]() {
amsMgrServiceInner->TerminateAbility(token, clearMissionFlag);
};
amsHandler_->SubmitTask(terminateAbilityFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_TERMINATE_ABILITY,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -166,8 +170,9 @@ void AmsMgrScheduler::RegisterAppStateCallback(const sptr<IAppStateCallback> &ca
if (!IsReady()) {
return;
}
std::function<void()> registerAppStateCallbackFunc =
std::bind(&AppMgrServiceInner::RegisterAppStateCallback, amsMgrServiceInner_, callback);
std::function<void()> registerAppStateCallbackFunc = [amsMgrServiceInner = amsMgrServiceInner_, callback]() {
amsMgrServiceInner->RegisterAppStateCallback(callback);
};
amsHandler_->SubmitTask(registerAppStateCallbackFunc, TASK_REGISTER_APP_STATE_CALLBACK);
}
@@ -182,8 +187,11 @@ void AmsMgrScheduler::AbilityBehaviorAnalysis(const sptr<IRemoteObject> &token,
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
return;
}
std::function<void()> abilityBehaviorAnalysisFunc = std::bind(&AppMgrServiceInner::AbilityBehaviorAnalysis,
amsMgrServiceInner_, token, preToken, visibility, perceptibility, connectionState);
std::function<void()> abilityBehaviorAnalysisFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, preToken,
visibility, perceptibility, connectionState]() {
amsMgrServiceInner->AbilityBehaviorAnalysis(token, preToken,
visibility, perceptibility, connectionState);
};
amsHandler_->SubmitTask(abilityBehaviorAnalysisFunc, TASK_ABILITY_BEHAVIOR_ANALYSIS);
}
@@ -198,8 +206,9 @@ void AmsMgrScheduler::KillProcessByAbilityToken(const sptr<IRemoteObject> &token
return;
}
std::function<void()> killProcessByAbilityTokenFunc =
std::bind(&AppMgrServiceInner::KillProcessByAbilityToken, amsMgrServiceInner_, token);
std::function<void()> killProcessByAbilityTokenFunc = [amsMgrServiceInner = amsMgrServiceInner_, token]() {
amsMgrServiceInner->KillProcessByAbilityToken(token);
};
amsHandler_->SubmitTask(killProcessByAbilityTokenFunc, TASK_KILL_PROCESS_BY_ABILITY_TOKEN);
}
@@ -223,8 +232,9 @@ void AmsMgrScheduler::KillProcessesByUserId(int32_t userId)
return;
}
std::function<void()> killProcessesByUserIdFunc =
std::bind(&AppMgrServiceInner::KillProcessesByUserId, amsMgrServiceInner_, userId);
std::function<void()> killProcessesByUserIdFunc = [amsMgrServiceInner = amsMgrServiceInner_, userId]() {
amsMgrServiceInner->KillProcessesByUserId(userId);
};
amsHandler_->SubmitTask(killProcessesByUserIdFunc, TASK_KILL_PROCESSES_BY_USERID);
}
@@ -241,8 +251,9 @@ void AmsMgrScheduler::KillProcessesByPids(std::vector<int32_t> &pids)
return;
}
std::function<void()> killProcessesByPidsFunc =
std::bind(&AppMgrServiceInner::KillProcessesByPids, amsMgrServiceInner_, pids);
std::function<void()> killProcessesByPidsFunc = [amsMgrServiceInner = amsMgrServiceInner_, &pids]() {
amsMgrServiceInner->KillProcessesByPids(pids);
};
amsHandler_->SubmitTask(killProcessesByPidsFunc, TASK_KILL_PROCESSES_BY_PIDS);
}
@@ -259,8 +270,9 @@ void AmsMgrScheduler::AttachPidToParent(const sptr<IRemoteObject> &token, const
return;
}
std::function<void()> attachPidToParentFunc =
std::bind(&AppMgrServiceInner::AttachPidToParent, amsMgrServiceInner_, token, callerToken);
std::function<void()> attachPidToParentFunc = [amsMgrServiceInner = amsMgrServiceInner_, token, callerToken]() {
amsMgrServiceInner->AttachPidToParent(token, callerToken);
};
amsHandler_->SubmitTask(attachPidToParentFunc, TASK_ATTACH_PID_TO_PARENT);
}
@@ -286,7 +298,9 @@ void AmsMgrScheduler::AbilityAttachTimeOut(const sptr<IRemoteObject> &token)
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
return;
}
auto task = [=]() { amsMgrServiceInner_->HandleAbilityAttachTimeOut(token); };
auto task = [amsMgrServiceInner = amsMgrServiceInner_, token]() {
amsMgrServiceInner->HandleAbilityAttachTimeOut(token);
};
amsHandler_->SubmitTask(task);
}
@@ -567,8 +581,9 @@ void AmsMgrScheduler::ClearProcessByToken(sptr<IRemoteObject> token)
return;
}
std::function<void()> clearProcessByTokenFunc =
std::bind(&AppMgrServiceInner::ClearProcessByToken, amsMgrServiceInner_, token);
std::function<void()> clearProcessByTokenFunc = [amsMgrServiceInner = amsMgrServiceInner_, token]() {
amsMgrServiceInner->ClearProcessByToken(token);
};
amsHandler_->SubmitTask(clearProcessByTokenFunc, TASK_CLEAR_PROCESS_BY_ABILITY_TOKEN);
}
+5 -2
View File
@@ -41,8 +41,11 @@ void AppDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
return;
}
auto onRemoteDiedFunc = std::bind(&AppMgrServiceInner::OnRemoteDied, serviceInner, remote, isRenderProcess_,
isChildProcess_);
auto onRemoteDiedFunc = [serviceInner, remote,
isRenderProcess = isRenderProcess_,
isChildProcess = isChildProcess_]() {
serviceInner->OnRemoteDied(remote, isRenderProcess, isChildProcess);
};
handler->SubmitTask(onRemoteDiedFunc, TASK_ON_REMOTE_DIED);
}
+84 -100
View File
@@ -154,8 +154,9 @@ ErrCode AppMgrService::Init()
appMgrServiceInner_->SetTaskHandler(taskHandler_);
appMgrServiceInner_->SetEventHandler(eventHandler_);
DelayedSingleton<CacheProcessManager>::GetInstance()->SetAppMgr(appMgrServiceInner_);
std::function<void()> initAppMgrServiceInnerTask =
std::bind(&AppMgrServiceInner::Init, appMgrServiceInner_);
std::function<void()> initAppMgrServiceInnerTask = [appMgrServiceInner = appMgrServiceInner_]() {
appMgrServiceInner->Init();
};
taskHandler_->SubmitTask(initAppMgrServiceInnerTask, TASK_INIT_APPMGRSERVICEINNER);
ErrCode openErr = appMgrServiceInner_->OpenAppSpawnConnection();
@@ -184,8 +185,9 @@ void AppMgrService::AttachApplication(const sptr<IRemoteObject> &app)
}
pid_t pid = IPCSkeleton::GetCallingPid();
std::function<void()> attachApplicationFunc =
std::bind(&AppMgrServiceInner::AttachApplication, appMgrServiceInner_, pid, iface_cast<IAppScheduler>(app));
std::function<void()> attachApplicationFunc = [appMgrServiceInner = appMgrServiceInner_, pid, app]() {
appMgrServiceInner->AttachApplication(pid, iface_cast<IAppScheduler>(app));
};
taskHandler_->SubmitTask(attachApplicationFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_ATTACH_APPLICATION,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -211,8 +213,9 @@ void AppMgrService::ApplicationForegrounded(const int32_t recordId)
if (!JudgeAppSelfCalled(recordId)) {
return;
}
std::function<void()> applicationForegroundedFunc =
std::bind(&AppMgrServiceInner::ApplicationForegrounded, appMgrServiceInner_, recordId);
std::function<void()> applicationForegroundedFunc = [appMgrServiceInner = appMgrServiceInner_, recordId]() {
appMgrServiceInner->ApplicationForegrounded(recordId);
};
taskHandler_->SubmitTask(applicationForegroundedFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_APPLICATION_FOREGROUNDED,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -228,8 +231,9 @@ void AppMgrService::ApplicationBackgrounded(const int32_t recordId)
return;
}
taskHandler_->CancelTask("appbackground_" + std::to_string(recordId));
std::function<void()> applicationBackgroundedFunc =
std::bind(&AppMgrServiceInner::ApplicationBackgrounded, appMgrServiceInner_, recordId);
std::function<void()> applicationBackgroundedFunc = [appMgrServiceInner = appMgrServiceInner_, recordId]() {
appMgrServiceInner->ApplicationBackgrounded(recordId);
};
taskHandler_->SubmitTask(applicationBackgroundedFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_APPLICATION_BACKGROUNDED,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -244,8 +248,9 @@ void AppMgrService::ApplicationTerminated(const int32_t recordId)
if (!JudgeAppSelfCalled(recordId)) {
return;
}
std::function<void()> applicationTerminatedFunc =
std::bind(&AppMgrServiceInner::ApplicationTerminated, appMgrServiceInner_, recordId);
std::function<void()> applicationTerminatedFunc = [appMgrServiceInner = appMgrServiceInner_, recordId]() {
appMgrServiceInner->ApplicationTerminated(recordId);
};
taskHandler_->SubmitTask(applicationTerminatedFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_APPLICATION_TERMINATED,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -265,8 +270,9 @@ void AppMgrService::AbilityCleaned(const sptr<IRemoteObject> &token)
return;
}
std::function<void()> abilityCleanedFunc =
std::bind(&AppMgrServiceInner::AbilityTerminated, appMgrServiceInner_, token);
std::function<void()> abilityCleanedFunc = [appMgrServiceInner = appMgrServiceInner_, token]() {
appMgrServiceInner->AbilityTerminated(token);
};
taskHandler_->SubmitTask(abilityCleanedFunc, AAFwk::TaskAttribute{
.taskName_ = TASK_ABILITY_CLEANED,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -295,8 +301,9 @@ void AppMgrService::StartupResidentProcess(const std::vector<AppExecFwk::BundleI
return;
}
TAG_LOGI(AAFwkTag::APPMGR, "Notify start resident process");
std::function <void()> startupResidentProcess =
std::bind(&AppMgrServiceInner::LoadResidentProcess, appMgrServiceInner_, bundleInfos);
std::function <void()> startupResidentProcess = [appMgrServiceInner = appMgrServiceInner_, bundleInfos]() {
appMgrServiceInner->LoadResidentProcess(bundleInfos);
};
taskHandler_->SubmitTask(startupResidentProcess, AAFwk::TaskAttribute{
.taskName_ = TASK_STARTUP_RESIDENT_PROCESS,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -482,8 +489,9 @@ void AppMgrService::AddAbilityStageDone(const int32_t recordId)
if (!JudgeAppSelfCalled(recordId)) {
return;
}
std::function <void()> addAbilityStageDone =
std::bind(&AppMgrServiceInner::AddAbilityStageDone, appMgrServiceInner_, recordId);
std::function <void()> addAbilityStageDone = [appMgrServiceInner = appMgrServiceInner_, recordId]() {
appMgrServiceInner->AddAbilityStageDone(recordId);
};
taskHandler_->SubmitTask(addAbilityStageDone, AAFwk::TaskAttribute{
.taskName_ = TASK_ADD_ABILITY_STAGE_DONE,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -553,8 +561,10 @@ int AppMgrService::StartUserTestProcess(const AAFwk::Want &want, const sptr<IRem
TAG_LOGE(AAFwkTag::APPMGR, "StartUserTestProcess is not shell call.");
return ERR_INVALID_OPERATION;
}
std::function<void()> startUserTestProcessFunc =
std::bind(&AppMgrServiceInner::StartUserTestProcess, appMgrServiceInner_, want, observer, bundleInfo, userId);
std::function<void()> startUserTestProcessFunc = [appMgrServiceInner = appMgrServiceInner_,
want, observer, bundleInfo, userId]() {
appMgrServiceInner->StartUserTestProcess(want, observer, bundleInfo, userId);
};
taskHandler_->SubmitTask(startUserTestProcessFunc, TASK_START_USER_TEST_PROCESS);
return ERR_OK;
}
@@ -589,8 +599,10 @@ int AppMgrService::FinishUserTest(const std::string &msg, const int64_t &resultC
return ERR_INVALID_OPERATION;
}
pid_t callingPid = IPCSkeleton::GetCallingPid();
std::function<void()> finishUserTestProcessFunc =
std::bind(&AppMgrServiceInner::FinishUserTest, appMgrServiceInner_, msg, resultCode, bundleName, callingPid);
std::function<void()> finishUserTestProcessFunc = [appMgrServiceInner = appMgrServiceInner_, msg,
resultCode, bundleName, callingPid]() {
appMgrServiceInner->FinishUserTest(msg, resultCode, bundleName, callingPid);
};
taskHandler_->SubmitTask(finishUserTestProcessFunc, TASK_FINISH_USER_TEST);
return ERR_OK;
}
@@ -613,23 +625,6 @@ int AppMgrService::Dump(int fd, const std::vector<std::u16string>& args)
return errCode;
}
bool AppMgrService::GetDumpFunc(const std::string &optionKey, DumpFuncType &func)
{
if (optionKey == OPTION_KEY_HELP) {
func = &AppMgrService::ShowHelp;
return true;
}
if (optionKey == OPTION_KEY_DUMP_IPC) {
func = &AppMgrService::DumpIpc;
return true;
}
if (optionKey == OPTION_KEY_DUMP_FFRT) {
func = &AppMgrService::DumpFfrt;
return true;
}
return false;
}
int AppMgrService::Dump(const std::vector<std::u16string>& args, std::string& result)
{
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
@@ -639,19 +634,18 @@ int AppMgrService::Dump(const std::vector<std::u16string>& args, std::string& re
}
std::string optionKey = Str16ToStr8(args[0]);
DumpFuncType dumpFunc;
if (!GetDumpFunc(optionKey, dumpFunc)) {
result.append("error: unkown option.\n");
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}s does not exist", optionKey.c_str());
return DumpErrorCode::ERR_UNKNOWN_OPTION_ERROR;
if (optionKey == OPTION_KEY_HELP) {
return ShowHelp(args, result);
}
if (dumpFunc == nullptr) {
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
TAG_LOGE(AAFwkTag::APPMGR, "dump ffrt function does not exist");
return DumpErrorCode::ERR_INTERNAL_ERROR;
if (optionKey == OPTION_KEY_DUMP_IPC) {
return DumpIpc(args, result);
}
return (this->*dumpFunc)(args, result);
if (optionKey == OPTION_KEY_DUMP_FFRT) {
return DumpFfrt(args, result);
}
result.append("error: unkown option.\n");
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}s does not exist", optionKey.c_str());
return DumpErrorCode::ERR_UNKNOWN_OPTION_ERROR;
}
int AppMgrService::ShowHelp(const std::vector<std::u16string>& args, std::string& result)
@@ -665,47 +659,23 @@ int AppMgrService::ShowHelp(const std::vector<std::u16string>& args, std::string
return ERR_OK;
}
AppMgrService::DumpIpcAllFuncType AppMgrService::GetDumpIpcAllFuncByKey(uint32_t key)
{
if (key == KEY_DUMP_IPC_START) {
return &AppMgrService::DumpIpcAllStart;
}
if (key == KEY_DUMP_IPC_STOP) {
return &AppMgrService::DumpIpcAllStop;
}
if (key == KEY_DUMP_IPC_STAT) {
return &AppMgrService::DumpIpcAllStat;
}
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
return nullptr;
}
int AppMgrService::DumpIpcAllInner(const AppMgrService::DumpIpcKey key, std::string& result)
{
TAG_LOGI(AAFwkTag::APPMGR, "Called.");
auto dumpFunc = GetDumpIpcAllFuncByKey(key);
if (dumpFunc == nullptr) {
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
TAG_LOGE(AAFwkTag::APPMGR, "dump ipc all function does not exist");
return DumpErrorCode::ERR_INTERNAL_ERROR;
switch (key) {
case KEY_DUMP_IPC_START:
return DumpIpcAllStart(result);
case KEY_DUMP_IPC_STOP:
return DumpIpcAllStop(result);
case KEY_DUMP_IPC_STAT:
return DumpIpcAllStat(result);
default: {
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
TAG_LOGE(AAFwkTag::APPMGR, "dump ipc all function does not exist");
return DumpErrorCode::ERR_INTERNAL_ERROR;
}
}
return (this->*dumpFunc)(result);
}
AppMgrService::DumpIpcFuncType AppMgrService::GetDumpIpcFuncByKey(uint32_t key)
{
if (key == KEY_DUMP_IPC_START) {
return &AppMgrService::DumpIpcStart;
}
if (key == KEY_DUMP_IPC_STOP) {
return &AppMgrService::DumpIpcStop;
}
if (key == KEY_DUMP_IPC_STAT) {
return &AppMgrService::DumpIpcStat;
}
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
return nullptr;
}
int AppMgrService::DumpIpcWithPidInner(const AppMgrService::DumpIpcKey key,
@@ -728,14 +698,21 @@ int AppMgrService::DumpIpcWithPidInner(const AppMgrService::DumpIpcKey key,
return DumpErrorCode::ERR_INVALID_PID_ERROR;
}
auto dumpFunc = GetDumpIpcFuncByKey(key);
if (dumpFunc == nullptr) {
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
TAG_LOGE(AAFwkTag::APPMGR, "dump ipc function does not exist");
return DumpErrorCode::ERR_INTERNAL_ERROR;
switch (key) {
case KEY_DUMP_IPC_START:
return DumpIpcStart(pid, result);
case KEY_DUMP_IPC_STOP:
return DumpIpcStop(pid, result);
case KEY_DUMP_IPC_STAT:
return DumpIpcStat(pid, result);
default: {
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
TAG_LOGE(AAFwkTag::APPMGR, "dump ipc function does not exist");
return DumpErrorCode::ERR_INTERNAL_ERROR;
}
}
return (this->*dumpFunc)(pid, result);
}
int AppMgrService::DumpFfrtInner(const std::string& pidsRaw, std::string& result)
@@ -895,7 +872,9 @@ void AppMgrService::ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::
if (!JudgeAppSelfCalled(recordId)) {
return;
}
auto task = [=]() { appMgrServiceInner_->ScheduleAcceptWantDone(recordId, want, flag); };
auto task = [appMgrServiceInner = appMgrServiceInner_, recordId, want, flag]() {
appMgrServiceInner->ScheduleAcceptWantDone(recordId, want, flag);
};
taskHandler_->SubmitTask(task);
}
@@ -909,7 +888,9 @@ void AppMgrService::ScheduleNewProcessRequestDone(const int32_t recordId, const
if (!JudgeAppSelfCalled(recordId)) {
return;
}
auto task = [=]() { appMgrServiceInner_->ScheduleNewProcessRequestDone(recordId, want, flag); };
auto task = [appMgrServiceInner = appMgrServiceInner_, recordId, want, flag]() {
appMgrServiceInner->ScheduleNewProcessRequestDone(recordId, want, flag);
};
taskHandler_->SubmitTask(task, AAFwk::TaskQoS::USER_INTERACTIVE);
}
@@ -959,8 +940,9 @@ void AppMgrService::AttachRenderProcess(const sptr<IRemoteObject> &scheduler)
}
auto pid = IPCSkeleton::GetCallingPid();
auto fun = std::bind(&AppMgrServiceInner::AttachRenderProcess,
appMgrServiceInner_, pid, iface_cast<IRenderScheduler>(scheduler));
auto fun = [appMgrServiceInner = appMgrServiceInner_, pid, scheduler]() {
appMgrServiceInner->AttachRenderProcess(pid, iface_cast<IRenderScheduler>(scheduler));
};
taskHandler_->SubmitTask(fun, AAFwk::TaskAttribute{
.taskName_ = TASK_ATTACH_RENDER_PROCESS,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -1370,8 +1352,9 @@ void AppMgrService::AttachChildProcess(const sptr<IRemoteObject> &childScheduler
return;
}
pid_t pid = IPCSkeleton::GetCallingPid();
std::function<void()> task = std::bind(&AppMgrServiceInner::AttachChildProcess,
appMgrServiceInner_, pid, iface_cast<IChildScheduler>(childScheduler));
std::function<void()> task = [appMgrServiceInner = appMgrServiceInner_, pid, childScheduler]() {
appMgrServiceInner->AttachChildProcess(pid, iface_cast<IChildScheduler>(childScheduler));
};
taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{
.taskName_ = TASK_ATTACH_CHILD_PROCESS,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -1389,8 +1372,9 @@ void AppMgrService::ExitChildProcessSafely()
return;
}
pid_t pid = IPCSkeleton::GetCallingPid();
std::function<void()> task = std::bind(&AppMgrServiceInner::ExitChildProcessSafelyByChildPid,
appMgrServiceInner_, pid);
std::function<void()> task = [appMgrServiceInner = appMgrServiceInner_, pid]() {
appMgrServiceInner->ExitChildProcessSafelyByChildPid(pid);
};
taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{
.taskName_ = TASK_EXIT_CHILD_PROCESS_SAFELY,
.taskQos_ = AAFwk::TaskQoS::USER_INTERACTIVE
@@ -5291,19 +5291,19 @@ int32_t AppMgrServiceInner::NotifyAppFaultBySA(const AppFaultDataBySA &faultData
if (!AppExecFwk::AppfreezeManager::GetInstance()->IsHandleAppfreeze(bundleName) || record->IsDebugging()) {
return ERR_OK;
}
auto timeoutNotifyApp = std::bind(&AppMgrServiceInner::TimeoutNotifyApp, this,
pid, uid, bundleName, transformedFaultData);
auto timeoutNotifyApp = [this, pid, uid, bundleName, transformedFaultData]() {
this->TimeoutNotifyApp(pid, uid, bundleName, transformedFaultData);
};
taskHandler_->SubmitTask(timeoutNotifyApp, transformedFaultData.timeoutMarkers, timeout);
}
record->NotifyAppFault(transformedFaultData);
TAG_LOGW(AAFwkTag::APPMGR, "FaultDataBySA is: name: %{public}s, faultType: %{public}s, uid: %{public}d,"
"pid: %{public}d, bundleName: %{public}s", faultData.errorObject.name.c_str(),
FaultTypeToString(faultData.faultType).c_str(), uid, pid, bundleName.c_str());
} else {
TAG_LOGD(AAFwkTag::APPMGR, "this is not called by SA.");
return AAFwk::CHECK_PERMISSION_FAILED;
return ERR_OK;
}
return ERR_OK;
TAG_LOGD(AAFwkTag::APPMGR, "this is not called by SA.");
return AAFwk::CHECK_PERMISSION_FAILED;
}
FaultData AppMgrServiceInner::ConvertDataTypes(const AppFaultDataBySA &faultData)
@@ -115,8 +115,6 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
sptr<IAbilityScheduler> dataAbilityScheduler;
abilityms->ReleaseDataAbility(dataAbilityScheduler, token);
abilityms->AttachAbilityThread(dataAbilityScheduler, token);
abilityms->DumpFuncInit();
abilityms->DumpSysFuncInit();
std::vector<std::string> info;
abilityms->DumpSysInner(stringParam, info, boolParam, boolParam, intParam);
abilityms->DumpSysMissionListInner(stringParam, info, boolParam, boolParam, intParam);
@@ -69,19 +69,6 @@ HWTEST_F(AbilityManagerServiceDumpTest, AbilityManagerService_GetProcessRunningI
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
}
/**
* @tc.name: AbilityManagerService_DumpSysFuncInit_0100
* @tc.desc: DumpSysFuncInit
* @tc.type: FUNC
* @tc.require: SR000GH1GO
*/
HWTEST_F(AbilityManagerServiceDumpTest, AbilityManagerService_DumpSysFuncInit_0100, TestSize.Level1)
{
auto abilityMs_ = std::make_shared<AbilityManagerService>();
abilityMs_->DumpSysFuncInit();
EXPECT_GT(abilityMs_->dumpsysFuncMap_.size(), SIZE_ZERO);
}
/**
* @tc.name: AbilityManagerService_DumpSysInner_0100
* @tc.desc: DumpSysInner
+17 -17
View File
@@ -157,26 +157,26 @@ AbilityManagerShellCommand::AbilityManagerShellCommand(int argc, char* argv[]) :
ErrCode AbilityManagerShellCommand::CreateCommandMap()
{
commandMap_ = {
{"help", std::bind(&AbilityManagerShellCommand::RunAsHelpCommand, this)},
{"screen", std::bind(&AbilityManagerShellCommand::RunAsScreenCommand, this)},
{"start", std::bind(&AbilityManagerShellCommand::RunAsStartAbility, this)},
{"stop-service", std::bind(&AbilityManagerShellCommand::RunAsStopService, this)},
{"dump", std::bind(&AbilityManagerShellCommand::RunAsDumpsysCommand, this)},
{"force-stop", std::bind(&AbilityManagerShellCommand::RunAsForceStop, this)},
{"test", std::bind(&AbilityManagerShellCommand::RunAsTestCommand, this)},
{"process", std::bind(&AbilityManagerShellCommand::RunAsProcessCommand, this)},
{"attach", std::bind(&AbilityManagerShellCommand::RunAsAttachDebugCommand, this)},
{"detach", std::bind(&AbilityManagerShellCommand::RunAsDetachDebugCommand, this)},
{"appdebug", std::bind(&AbilityManagerShellCommand::RunAsAppDebugDebugCommand, this)},
{"help", [this]() { return this->RunAsHelpCommand(); }},
{"screen", [this]() { return this->RunAsScreenCommand(); }},
{"start", [this]() { return this->RunAsStartAbility(); }},
{"stop-service", [this]() { return this->RunAsStopService(); }},
{"dump", [this]() { return this->RunAsDumpsysCommand(); }},
{"force-stop", [this]() { return this->RunAsForceStop(); }},
{"test", [this]() { return this->RunAsTestCommand(); }},
{"process", [this]() { return this->RunAsProcessCommand(); }},
{"attach", [this]() { return this->RunAsAttachDebugCommand(); }},
{"detach", [this]() { return this->RunAsDetachDebugCommand(); }},
{"appdebug", [this]() { return this->RunAsAppDebugDebugCommand(); }},
#ifdef ABILITY_COMMAND_FOR_TEST
{"force-timeout", std::bind(&AbilityManagerShellCommand::RunForceTimeoutForTest, this)},
{"block-ability", std::bind(&AbilityManagerShellCommand::RunAsBlockAbilityCommand, this)},
{"block-ams-service", std::bind(&AbilityManagerShellCommand::RunAsBlockAmsServiceCommand, this)},
{"block-app-service", std::bind(&AbilityManagerShellCommand::RunAsBlockAppServiceCommand, this)},
{"force-timeout", [this]() { return this->RunForceTimeoutForTest(); }},
{"block-ability", [this]() { return this->RunAsBlockAbilityCommand(); }},
{"block-ams-service", [this]() { return this->RunAsBlockAmsServiceCommand(); }},
{"block-app-service", [this]() { return this->RunAsBlockAppServiceCommand(); }},
#endif
#ifdef ABILITY_FAULT_AND_EXIT_TEST
{"forceexitapp", std::bind(&AbilityManagerShellCommand::RunAsForceExitAppCommand, this)},
{"notifyappfault", std::bind(&AbilityManagerShellCommand::RunAsNotifyAppFaultCommand, this)},
{"forceexitapp", [this]() { return this->RunAsForceExitAppCommand(); }},
{"notifyappfault", [this]() { return this->RunAsNotifyAppFaultCommand(); }},
#endif
};
+5 -5
View File
@@ -116,11 +116,11 @@ AbilityToolCommand::AbilityToolCommand(int argc, char* argv[]) : ShellCommand(ar
ErrCode AbilityToolCommand::CreateCommandMap()
{
commandMap_ = {
{"help", std::bind(&AbilityToolCommand::RunAsHelpCommand, this)},
{"start", std::bind(&AbilityToolCommand::RunAsStartAbility, this)},
{"stop-service", std::bind(&AbilityToolCommand::RunAsStopService, this)},
{"force-stop", std::bind(&AbilityToolCommand::RunAsForceStop, this)},
{"test", std::bind(&AbilityToolCommand::RunAsTestCommand, this)},
{"help", [this]() { return this->RunAsHelpCommand(); }},
{"start", [this]() { return this->RunAsStartAbility(); }},
{"stop-service", [this]() { return this->RunAsStopService(); }},
{"force-stop", [this]() { return this->RunAsForceStop(); }},
{"test", [this]() { return this->RunAsTestCommand(); }},
};
return OHOS::ERR_OK;