mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into master
This commit is contained in:
commit
86cb2344bf
25
aafwk.gni
25
aafwk.gni
@ -12,27 +12,30 @@
|
||||
# limitations under the License.
|
||||
|
||||
aafwk_path = "//foundation/ability/ability_runtime"
|
||||
aafwk_napi_path = "${aafwk_path}/interfaces/kits/napi/aafwk"
|
||||
ability_base_path = "${aafwk_path}/ability_base"
|
||||
form_runtime_path = "${aafwk_path}/form_runtime"
|
||||
innerkits_path = "${aafwk_path}/interfaces/innerkits"
|
||||
kits_path = "${aafwk_path}/frameworks/kits"
|
||||
services_path = "${aafwk_path}/services"
|
||||
system_test_app_path =
|
||||
"${aafwk_path}/test/resource/amssystemtestability/abilitySrc"
|
||||
|
||||
bundlefwk_path = "//foundation/bundlemanager/bundle_framework"
|
||||
bundlefwk_innerkits_path = "${bundlefwk_path}/interfaces/innerkits"
|
||||
bundlefwk_inner_api_path = "${bundlefwk_path}/interfaces/inner_api"
|
||||
|
||||
multimedia_path = "//foundation/multimedia/image_standard"
|
||||
services_path = "//foundation/ability/ability_runtime/services"
|
||||
multimodalinput_path = "//foundation/multimodalinput/input"
|
||||
windowmanager_path = "//foundation/windowmanager"
|
||||
graphic_path = "//foundation/graphic/graphic_2d"
|
||||
global_path = "//base/global"
|
||||
distributedschedule_path = "//foundation/distributedschedule"
|
||||
notification_path = "//base/notification"
|
||||
distributeddatamgr_path = "//foundation/distributeddatamgr"
|
||||
kits_path = "//foundation/ability/ability_runtime/frameworks/kits"
|
||||
innerkits_path = "//foundation/ability/ability_runtime/interfaces/innerkits"
|
||||
bundlefwk_innerkits_path = "${bundlefwk_path}/interfaces/innerkits"
|
||||
bundlefwk_inner_api_path = "${bundlefwk_path}/interfaces/inner_api"
|
||||
ans_core_path =
|
||||
"//base/notification/distributed_notification_service/frameworks/core"
|
||||
system_test_app_path = "//foundation/ability/ability_runtime/test/resource/amssystemtestability/abilitySrc"
|
||||
form_runtime_path = "//foundation/ability/ability_runtime/form_runtime"
|
||||
"${notification_path}/distributed_notification_service/frameworks/core"
|
||||
distributeddatamgr_path = "//foundation/distributeddatamgr"
|
||||
form_runtime_napi_path = "${form_runtime_path}/frameworks/js/napi"
|
||||
|
||||
ability_base_path = "//foundation/ability/ability_runtime/ability_base"
|
||||
ability_base_innerapi_path = "${ability_base_path}/interfaces/inner_api"
|
||||
ability_base_native_path = "${ability_base_path}/frameworks/native"
|
||||
|
||||
|
@ -1228,37 +1228,38 @@ Want *Want::ParseUri(const std::string &uri)
|
||||
if (want == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
Want *baseWant = want;
|
||||
bool inPicker = false;
|
||||
pos = uri.find_first_of(";", begin);
|
||||
do {
|
||||
if (pos != std::string::npos) {
|
||||
while (pos != std::string::npos) {
|
||||
content = uri.substr(begin, pos - begin);
|
||||
if (content.compare("PICK") == 0) {
|
||||
inPicker = true;
|
||||
begin = pos + 1;
|
||||
pos = uri.find(";", begin);
|
||||
break;
|
||||
}
|
||||
ret = ParseUriInternal(content, element, *want);
|
||||
if (!ret) {
|
||||
break;
|
||||
}
|
||||
begin = pos + 1;
|
||||
pos = uri.find(";", begin);
|
||||
}
|
||||
if (inPicker) {
|
||||
sptr<Want> pickerWant = new (std::nothrow) Want();
|
||||
ElementName pickerElement;
|
||||
while (pos != std::string::npos) {
|
||||
content = uri.substr(begin, pos - begin);
|
||||
if (content.compare("PICK") == 0) {
|
||||
want = new (std::nothrow) Want();
|
||||
if (want == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
inPicker = true;
|
||||
continue;
|
||||
}
|
||||
ret = ParseUriInternal(content, element, *want);
|
||||
ret = ParseUriInternal(content, pickerElement, *pickerWant);
|
||||
if (!ret) {
|
||||
break;
|
||||
}
|
||||
begin = pos + 1;
|
||||
pos = uri.find(";", begin);
|
||||
if (pos == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
if (inPicker) {
|
||||
if (baseWant->GetBundle().empty()) {
|
||||
pickerWant->SetElement(pickerElement);
|
||||
if (want->GetBundle().empty()) {
|
||||
}
|
||||
want = baseWant;
|
||||
}
|
||||
if (ret) {
|
||||
want->SetElement(element);
|
||||
|
@ -96,7 +96,7 @@ int FormMgrService::AddForm(const int64_t formId, const Want &want,
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.userId = formId;
|
||||
eventInfo.bundleName = want.GetElement().GetBundleName();
|
||||
eventInfo.moduleName = want.GetElement().GetModuleName();
|
||||
eventInfo.moduleName = want.GetStringParam(AppExecFwk::Constants::PARAM_MODULE_NAME_KEY);
|
||||
eventInfo.abilityName = want.GetElement().GetAbilityName();
|
||||
AAFWK::EventReport::SendFormEvent(AAFWK::ADD_FORM, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
if (ret != ERR_OK) {
|
||||
@ -190,7 +190,7 @@ int FormMgrService::RequestForm(const int64_t formId, const sptr<IRemoteObject>
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.userId = formId;
|
||||
eventInfo.bundleName = want.GetElement().GetBundleName();
|
||||
eventInfo.moduleName = want.GetElement().GetModuleName();
|
||||
eventInfo.moduleName = want.GetStringParam(AppExecFwk::Constants::PARAM_MODULE_NAME_KEY);
|
||||
eventInfo.abilityName = want.GetElement().GetAbilityName();
|
||||
AAFWK::EventReport::SendFormEvent(AAFWK::REQUEST_FORM, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
|
||||
@ -378,7 +378,7 @@ int FormMgrService::MessageEvent(const int64_t formId, const Want &want, const s
|
||||
}
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.bundleName = want.GetElement().GetBundleName();
|
||||
eventInfo.moduleName = want.GetElement().GetModuleName();
|
||||
eventInfo.moduleName = want.GetStringParam(AppExecFwk::Constants::PARAM_MODULE_NAME_KEY);
|
||||
eventInfo.abilityName = want.GetElement().GetAbilityName();
|
||||
AAFWK::EventReport::SendFormEvent(AAFWK::MESSAGE_EVENT_FORM,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
@ -402,7 +402,7 @@ int FormMgrService::RouterEvent(const int64_t formId, Want &want)
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.userId = formId;
|
||||
eventInfo.bundleName = want.GetElement().GetBundleName();
|
||||
eventInfo.moduleName = want.GetElement().GetModuleName();
|
||||
eventInfo.moduleName = want.GetStringParam(AppExecFwk::Constants::PARAM_MODULE_NAME_KEY);
|
||||
eventInfo.abilityName = want.GetElement().GetAbilityName();
|
||||
AAFWK::EventReport::SendFormEvent(AAFWK::ROUTE_EVENT_FORM,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
@ -600,7 +600,7 @@ int FormMgrService::AcquireFormState(const Want &want, const sptr<IRemoteObject>
|
||||
}
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.bundleName = want.GetElement().GetBundleName();
|
||||
eventInfo.moduleName = want.GetElement().GetModuleName();
|
||||
eventInfo.moduleName = want.GetStringParam(AppExecFwk::Constants::PARAM_MODULE_NAME_KEY);
|
||||
eventInfo.abilityName = want.GetElement().GetAbilityName();
|
||||
AAFWK::EventReport::SendFormEvent(AAFWK::ACQUIREFORMSTATE_FORM,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
|
@ -1623,6 +1623,12 @@ protected:
|
||||
*/
|
||||
sptr<Rosen::WindowOption> GetWindowOption(const Want &want);
|
||||
|
||||
/**
|
||||
* @brief Restore window stage data and scene in ability continuation.
|
||||
*
|
||||
*/
|
||||
virtual void ContinuationRestore(const Want &want);
|
||||
|
||||
std::shared_ptr<Rosen::WindowScene> scene_ = nullptr;
|
||||
sptr<Rosen::IWindowLifeCycle> sceneListener_ = nullptr;
|
||||
sptr<AbilityDisplayListener> abilityDisplayListener_ = nullptr;
|
||||
|
@ -457,6 +457,7 @@ public:
|
||||
void AfterBackground() override;
|
||||
void AfterFocused() override;
|
||||
void AfterUnfocused() override;
|
||||
void ForegroundFailed() override;
|
||||
private:
|
||||
sptr<IRemoteObject> token_ = nullptr;
|
||||
std::weak_ptr<AbilityImpl> owner_;
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
protected:
|
||||
void DoOnForeground(const Want &want) override;
|
||||
void RequsetFocus(const Want &want) override;
|
||||
void ContinuationRestore(const Want &want) override;
|
||||
|
||||
private:
|
||||
void GetPageStackFromWant(const Want &want, std::string &pageStack);
|
||||
|
@ -413,14 +413,19 @@ bool Ability::IsRestoredInContinuation() const
|
||||
HILOG_ERROR("abilityContext_ is null");
|
||||
return false;
|
||||
}
|
||||
if (launchParam_.launchReason == LaunchReason::LAUNCHREASON_CONTINUATION
|
||||
&& abilityInfo_->launchMode == LaunchMode::STANDARD
|
||||
&& abilityContext_->GetContentStorage() != nullptr) {
|
||||
HILOG_INFO("Is Restored In Continuation");
|
||||
return true;
|
||||
|
||||
if (launchParam_.launchReason != LaunchReason::LAUNCHREASON_CONTINUATION) {
|
||||
HILOG_INFO("launchReason is %{public}d", launchParam_.launchReason);
|
||||
return false;
|
||||
}
|
||||
HILOG_INFO("not Restored In Continuation");
|
||||
return false;
|
||||
|
||||
if (abilityContext_->GetContentStorage() == nullptr) {
|
||||
HILOG_INFO("not Restored In Continuation");
|
||||
return false;
|
||||
}
|
||||
|
||||
HILOG_INFO("Is Restored In Continuation");
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ability::WaitingDistributedObjectSyncComplete(const Want& want)
|
||||
@ -3799,6 +3804,11 @@ int Ability::GetDisplayOrientation()
|
||||
HILOG_DEBUG("%{public}s, get window orientation: UNSPECIFIED", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ability::ContinuationRestore(const Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
}
|
||||
#endif
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -347,6 +347,9 @@ void AbilityImpl::NewWant(const Want &want)
|
||||
}
|
||||
ability_->SetWant(want);
|
||||
ability_->OnNewWant(want);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
ability_->ContinuationRestore(want);
|
||||
#endif
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
@ -808,6 +811,20 @@ void AbilityImpl::WindowLifeCycleImpl::AfterUnfocused()
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::ForegroundFailed()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("The ability is stage mode, schedule foreground failed.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_FAILED, restoreData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
|
@ -366,7 +366,7 @@ void JsAbility::DoOnForeground(const Want &want)
|
||||
}
|
||||
|
||||
// multi-instance ability continuation
|
||||
HILOG_INFO("lauch reason = %{public}d", launchParam_.launchReason);
|
||||
HILOG_INFO("launch reason = %{public}d", launchParam_.launchReason);
|
||||
if (IsRestoredInContinuation()) {
|
||||
std::string pageStack;
|
||||
GetPageStackFromWant(want, pageStack);
|
||||
@ -421,6 +421,26 @@ void JsAbility::RequsetFocus(const Want &want)
|
||||
}
|
||||
scene_->GoForeground(Ability::sceneFlag_);
|
||||
}
|
||||
|
||||
void JsAbility::ContinuationRestore(const Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
if (!IsRestoredInContinuation() || scene_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string pageStack;
|
||||
GetPageStackFromWant(want, pageStack);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto &engine = jsRuntime_.GetNativeEngine();
|
||||
if (abilityContext_->GetContentStorage()) {
|
||||
scene_->GetMainWindow()->SetUIContent(pageStack, &engine, abilityContext_->GetContentStorage()->Get(), true);
|
||||
} else {
|
||||
HILOG_ERROR("restore: content storage is nullptr");
|
||||
}
|
||||
OnSceneRestored();
|
||||
WaitingDistributedObjectSyncComplete(want);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t JsAbility::OnContinue(WantParams &wantParams)
|
||||
@ -516,7 +536,12 @@ void JsAbility::OnNewWant(const Want &want)
|
||||
|
||||
obj->SetProperty("lastRequestWant", jsWant);
|
||||
|
||||
CallObjectMethod("onNewWant", &jsWant, 1);
|
||||
NativeValue *argv[] = {
|
||||
jsWant,
|
||||
CreateJsLaunchParam(nativeEngine, GetLaunchParam()),
|
||||
};
|
||||
CallObjectMethod("onNewWant", argv, ArraySize(argv));
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,6 @@ DataAbilityHelper::DataAbilityHelper(const sptr<IRemoteObject> &token, const std
|
||||
tryBind_ = false;
|
||||
dataAbilityProxy_ = dataAbilityProxy;
|
||||
isSystemCaller_ = true;
|
||||
if (isSystemCaller_ && dataAbilityProxy_) {
|
||||
AddDataAbilityDeathRecipient(dataAbilityProxy_->AsObject());
|
||||
}
|
||||
HILOG_INFO("DataAbilityHelper::DataAbilityHelper end");
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Lif
|
||||
#endif
|
||||
SetLifeCycleStateInfo(targetState);
|
||||
|
||||
ability_->SetLaunchParam(targetState.launchParam);
|
||||
if (ability_ && lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL) {
|
||||
ability_->SetStartAbilitySetting(targetState.setting);
|
||||
ability_->SetLaunchParam(targetState.launchParam);
|
||||
Start(want);
|
||||
CheckAndRestore();
|
||||
}
|
||||
|
@ -166,8 +166,15 @@ public:
|
||||
OnConfigurationUpdated_++;
|
||||
}
|
||||
|
||||
void ContinuationRestore(const Want &want)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock Ability::ContinuationRestore called";
|
||||
continueRestoreCalled_ = true;
|
||||
}
|
||||
|
||||
MockPageAbility::Event state_ = UNDEFINED;
|
||||
bool onNewWantCalled_ = false;
|
||||
bool continueRestoreCalled_ = false;
|
||||
int OnConfigurationUpdated_ = 0;
|
||||
std::vector<std::string> value;
|
||||
};
|
||||
|
@ -1309,6 +1309,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NewWant_001, TestSize.Level1)
|
||||
Want want;
|
||||
mockAbilityimpl->NewWant(want);
|
||||
EXPECT_EQ(1, pMocKPageAbility->onNewWantCalled_);
|
||||
EXPECT_EQ(1, pMocKPageAbility->continueRestoreCalled_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +89,15 @@ private:
|
||||
{
|
||||
panda::RuntimeOption pandaOption;
|
||||
int arkProperties = OHOS::system::GetIntParameter<int>("persist.ark.properties", -1);
|
||||
size_t gcThreadNum = OHOS::system::GetUintParameter<size_t>("persist.ark.gcthreads", 7);
|
||||
size_t longPauseTime = OHOS::system::GetUintParameter<size_t>("persist.ark.longpausetime", 40);
|
||||
pandaOption.SetArkProperties(arkProperties);
|
||||
pandaOption.SetGcThreadNum(gcThreadNum);
|
||||
pandaOption.SetLongPauseTime(longPauseTime);
|
||||
HILOG_INFO("ArkJSRuntime::Initialize ark properties = %{public}d", arkProperties);
|
||||
pandaOption.SetGcType(panda::RuntimeOption::GC_TYPE::GEN_GC);
|
||||
pandaOption.SetGcPoolSize(DEFAULT_GC_POOL_SIZE);
|
||||
pandaOption.SetLogLevel(panda::RuntimeOption::LOG_LEVEL::ERROR);
|
||||
pandaOption.SetLogLevel(panda::RuntimeOption::LOG_LEVEL::INFO);
|
||||
pandaOption.SetLogBufPrint(PrintVmLog);
|
||||
vm_ = panda::JSNApi::CreateJSVM(pandaOption);
|
||||
if (vm_ == nullptr) {
|
||||
|
@ -50,6 +50,10 @@ THREAD_BLOCK_6S:
|
||||
|
||||
START_ABILITY_ERROR:
|
||||
__BASE: {type: FAULT, level: MINOR, tag: ability, desc: start ability error}
|
||||
USER_ID: {type: INT32, desc: userId}
|
||||
ERROR_CODE: {type: INT32, desc: error code}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
MODULE_NAME: {type: STRING, desc: module name}
|
||||
ABILITY_NAME: {type: STRING, desc: ability name}
|
||||
|
||||
TERMINATE_ABILITY_ERROR:
|
||||
@ -101,14 +105,6 @@ START_ABILITY:
|
||||
MODULE_NAME: {type: STRING, desc: module name}
|
||||
ABILITY_NAME: {type: STRING, desc: ability name}
|
||||
|
||||
DO_FOREGROUND_ABILITY:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: ability, desc: foreground ability}
|
||||
SCENE_FLAG: {type: STRING, desc: scene flag}
|
||||
|
||||
DO_BACKGROUND_ABILITY:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: ability, desc: background ability}
|
||||
SCENE_FLAG: {type: STRING, desc: scene flag}
|
||||
|
||||
CLOSE_ABILITY:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: ability, desc: close ability}
|
||||
|
||||
@ -147,40 +143,40 @@ DISCONNECT_SERVICE:
|
||||
|
||||
APP_ATTACH:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: attach app}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
PID: {type: INT32, desc: pid}
|
||||
TIME_STAMP: {type: INT32, desc: time stamp}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
PROCESS_NAME: {type: STRING, desc: process name}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
|
||||
APP_LAUNCH:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: launch app}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
PID: {type: INT32, desc: pid}
|
||||
TIME_STAMP: {type: INT32, desc: time stamp}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
PROCESS_NAME: {type: STRING, desc: process name}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
|
||||
APP_FOREGROUND:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: foreground app}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
PID: {type: INT32, desc: pid}
|
||||
TIME_STAMP: {type: INT32, desc: time stamp}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
PROCESS_NAME: {type: STRING, desc: process name}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
|
||||
APP_BACKGROUND:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: background app}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
PID: {type: INT32, desc: pid}
|
||||
TIME_STAMP: {type: INT32, desc: time stamp}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
PROCESS_NAME: {type: STRING, desc: process name}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
|
||||
APP_TERMINATE:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: terminate app}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
PID: {type: INT32, desc: pid}
|
||||
TIME_STAMP: {type: INT32, desc: time stamp}
|
||||
VERSION_CODE: {type: INT32, desc: version code}
|
||||
VERSION_NAME: {type: STRING, desc: version name}
|
||||
PROCESS_NAME: {type: STRING, desc: process name}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
@ -79,6 +79,7 @@ ohos_shared_library("ability_manager") {
|
||||
"${services_path}/abilitymgr/src/start_options.cpp",
|
||||
"${services_path}/abilitymgr/src/stop_user_callback_proxy.cpp",
|
||||
"${services_path}/abilitymgr/src/stop_user_callback_stub.cpp",
|
||||
"${services_path}/abilitymgr/src/system_ability_token_callback_stub.cpp",
|
||||
"${services_path}/abilitymgr/src/want_receiver_stub.cpp",
|
||||
"${services_path}/abilitymgr/src/want_sender_info.cpp",
|
||||
"${services_path}/abilitymgr/src/want_sender_proxy.cpp",
|
||||
|
@ -184,6 +184,16 @@ public:
|
||||
*/
|
||||
ErrCode TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant);
|
||||
|
||||
/**
|
||||
* SendResultToAbility with want, return resultWant from ability manager service.
|
||||
*
|
||||
* @param requestCode requestCode.
|
||||
* @param resultCode resultCode.
|
||||
* @param resultWant Ability want returned.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode SendResultToAbility(int requestCode, int resultCode, Want& resultWant);
|
||||
|
||||
/**
|
||||
* CloseAbility with want, return want from ability manager service.
|
||||
*
|
||||
|
@ -185,6 +185,19 @@ public:
|
||||
virtual int TerminateAbility(
|
||||
const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) = 0;
|
||||
|
||||
/**
|
||||
* SendResultToAbility, send the result to ability.
|
||||
*
|
||||
* @param requestCode, the requestCode of the ability to terminate.
|
||||
* @param resultCode, the resultCode of the ability to terminate.
|
||||
* @param resultWant, the Want of the ability to return.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int SendResultToAbility(int requestCode, int resultCode, Want &resultWant)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* TerminateAbility, terminate the special ability.
|
||||
*
|
||||
@ -915,6 +928,8 @@ public:
|
||||
|
||||
CONTINUE_MISSION = 1105,
|
||||
|
||||
SEND_RESULT_TO_ABILITY = 1106,
|
||||
|
||||
// ipc id for mission manager(1110)
|
||||
REGISTER_REMOTE_MISSION_LISTENER = 1110,
|
||||
UNREGISTER_REMOTE_MISSION_LISTENER = 1111,
|
||||
|
@ -41,6 +41,7 @@ enum AbilityState {
|
||||
BACKGROUND,
|
||||
FOREGROUNDING,
|
||||
BACKGROUNDING,
|
||||
FOREGROUND_FAILED,
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -37,7 +37,8 @@ enum AbilityLifeCycleState {
|
||||
ABILITY_STATE_STARTED_NEW,
|
||||
ABILITY_STATE_FOREGROUND_NEW,
|
||||
ABILITY_STATE_BACKGROUND_NEW,
|
||||
ABILITY_STATE_STOPED_NEW
|
||||
ABILITY_STATE_STOPED_NEW,
|
||||
ABILITY_STATE_FOREGROUND_FAILED,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_H
|
||||
#define OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class ISystemAbilityTokenCallback : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.ISystemAbilityTokenCallback");
|
||||
|
||||
/**
|
||||
* @brief When the remote device send result back to system ability, AbilityMs notify the listener.
|
||||
*
|
||||
* @param want, want of caller.
|
||||
* @param callerUid, uid of caller.
|
||||
* @param deviceId, requestCode of caller.
|
||||
* @param deviceId, accessToken of caller .
|
||||
* @param deviceId, resultCode of caller.
|
||||
*/
|
||||
virtual int32_t SendResult(OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
|
||||
uint32_t accessToken, int32_t resultCode) = 0;
|
||||
|
||||
enum {
|
||||
SEND_RESULT = 1,
|
||||
};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_H
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_PROXY_H
|
||||
#define OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_PROXY_H
|
||||
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class SystemAbilityTokenCallbackProxy : public IRemoteProxy<ISystemAbilityTokenCallback> {
|
||||
public:
|
||||
explicit SystemAbilityTokenCallbackProxy(const sptr<IRemoteObject> &impl)
|
||||
: IRemoteProxy<ISystemAbilityTokenCallback>(impl)
|
||||
{}
|
||||
virtual ~SystemAbilityTokenCallbackProxy() {}
|
||||
|
||||
/**
|
||||
* @brief When the remote device send result back to system ability, AbilityMs notify the listener.
|
||||
*
|
||||
* @param want, want of caller.
|
||||
* @param callerUid, uid of caller.
|
||||
* @param deviceId, requestCode of caller.
|
||||
* @param deviceId, accessToken of caller .
|
||||
* @param deviceId, resultCode of caller.
|
||||
*/
|
||||
virtual int32_t SendResult(OHOS::AAFwk::Want& want, int32_t callerUid, int32_t requestCode,
|
||||
uint32_t accessToken, int32_t resultCode) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SystemAbilityTokenCallbackProxy> delegator_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_PROXY_H
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_STUB_H
|
||||
#define OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_STUB_H
|
||||
|
||||
#include "iremote_object.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "system_ability_token_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class SystemAbilityTokenCallbackStub : public IRemoteStub<ISystemAbilityTokenCallback> {
|
||||
public:
|
||||
SystemAbilityTokenCallbackStub() = default;
|
||||
~SystemAbilityTokenCallbackStub() = default;
|
||||
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(SystemAbilityTokenCallbackStub);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_AAFWK_SYSTEM_ABILITY_TOKEN_CALLBACK_STUB_H
|
@ -16,36 +16,36 @@ import("//foundation/ability/ability_runtime/aafwk.gni")
|
||||
|
||||
group("napi_packages") {
|
||||
deps = [
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/ability:ability_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/abilityManager:abilitymanager",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/ability_constant:abilityconstant_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/ability_context:abilitycontext_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/ability_manager:abilitymanager_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/ability_delegator:abilitydelegatorregistry",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/ability_stage:abilitystage_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/ability_stage_context:abilitystagecontext_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/appMgr:napi_app_mgr",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/app_manager:appmanager_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/application_context:applicationcontext_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/context:context_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/app/test_runner:testrunner_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/callee:callee_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/caller:caller_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/configuration_constant:configurationconstant_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/dataUriUtils:datauriutils",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/extensioncontext:extensioncontext_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/featureAbility:featureability",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/feature_ability:featureability_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/inner/napi_common:napi_common",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/mission_manager:distributedmissionmanager",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/mission_manager:missionmanager_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/particleAbility:particleability",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/service_extension_ability:serviceextensionability_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/service_extension_context:serviceextensioncontext_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/static_subscriber_extension:staticsubscriberextensionability_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/static_subscriber_extension_context:staticsubscriberextensioncontext_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/uri_permission:uripermissionmanager_napi",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/wantConstant:wantconstant",
|
||||
"${aafwk_path}/interfaces/kits/napi/aafwk/wantagent:wantagent",
|
||||
"${aafwk_napi_path}/ability:ability_napi",
|
||||
"${aafwk_napi_path}/abilityManager:abilitymanager",
|
||||
"${aafwk_napi_path}/ability_constant:abilityconstant_napi",
|
||||
"${aafwk_napi_path}/ability_context:abilitycontext_napi",
|
||||
"${aafwk_napi_path}/ability_manager:abilitymanager_napi",
|
||||
"${aafwk_napi_path}/app/ability_delegator:abilitydelegatorregistry",
|
||||
"${aafwk_napi_path}/app/ability_stage:abilitystage_napi",
|
||||
"${aafwk_napi_path}/app/ability_stage_context:abilitystagecontext_napi",
|
||||
"${aafwk_napi_path}/app/appMgr:napi_app_mgr",
|
||||
"${aafwk_napi_path}/app/app_manager:appmanager_napi",
|
||||
"${aafwk_napi_path}/app/application_context:applicationcontext_napi",
|
||||
"${aafwk_napi_path}/app/context:context_napi",
|
||||
"${aafwk_napi_path}/app/test_runner:testrunner_napi",
|
||||
"${aafwk_napi_path}/callee:callee_napi",
|
||||
"${aafwk_napi_path}/caller:caller_napi",
|
||||
"${aafwk_napi_path}/configuration_constant:configurationconstant_napi",
|
||||
"${aafwk_napi_path}/dataUriUtils:datauriutils",
|
||||
"${aafwk_napi_path}/extensioncontext:extensioncontext_napi",
|
||||
"${aafwk_napi_path}/featureAbility:featureability",
|
||||
"${aafwk_napi_path}/feature_ability:featureability_napi",
|
||||
"${aafwk_napi_path}/inner/napi_common:napi_common",
|
||||
"${aafwk_napi_path}/mission_manager:distributedmissionmanager",
|
||||
"${aafwk_napi_path}/mission_manager:missionmanager_napi",
|
||||
"${aafwk_napi_path}/particleAbility:particleability",
|
||||
"${aafwk_napi_path}/service_extension_ability:serviceextensionability_napi",
|
||||
"${aafwk_napi_path}/service_extension_context:serviceextensioncontext_napi",
|
||||
"${aafwk_napi_path}/static_subscriber_extension:staticsubscriberextensionability_napi",
|
||||
"${aafwk_napi_path}/static_subscriber_extension_context:staticsubscriberextensioncontext_napi",
|
||||
"${aafwk_napi_path}/uri_permission:uripermissionmanager_napi",
|
||||
"${aafwk_napi_path}/wantConstant:wantconstant",
|
||||
"${aafwk_napi_path}/wantagent:wantagent",
|
||||
]
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class Ability {
|
||||
}
|
||||
onContinue(wantParams) {}
|
||||
onConfigurationUpdated(config) {}
|
||||
onNewWant(want) {}
|
||||
onNewWant(want, param) {}
|
||||
dump(params) {}
|
||||
}
|
||||
|
||||
|
@ -737,7 +737,7 @@ NativeValue *JSAbilityDelegator::ParseTimeoutCallbackPara(
|
||||
|
||||
if (info.argc >= ARGC_TWO) {
|
||||
if (!ConvertFromJsValue(engine, info.argv[INDEX_ONE], timeout)) {
|
||||
if (info.argv[INDEX_ONE]->TypeOf() != NativeValueType::NATIVE_FUNCTION) {
|
||||
if (info.argv[INDEX_ONE] == nullptr || info.argv[INDEX_ONE]->TypeOf() != NativeValueType::NATIVE_FUNCTION) {
|
||||
HILOG_ERROR("Parse parameter argv[1] failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ abilityms_files = [
|
||||
"src/remote_mission_listener_stub.cpp",
|
||||
"src/mission_list_manager.cpp",
|
||||
"src/mission_list.cpp",
|
||||
"src/system_ability_token_callback_proxy.cpp",
|
||||
|
||||
#multi user
|
||||
"src/user_controller.cpp",
|
||||
|
@ -135,6 +135,16 @@ public:
|
||||
virtual int TerminateAbility(
|
||||
const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override;
|
||||
|
||||
/**
|
||||
* SendResultToAbility with want, return want from ability manager service.(Only used for dms)
|
||||
*
|
||||
* @param requestCode, request code.
|
||||
* @param resultCode, resultCode to return.
|
||||
* @param resultWant, the Want of the ability to return.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant) override;
|
||||
|
||||
/**
|
||||
* TerminateAbility, terminate the special ability.
|
||||
*
|
||||
|
@ -164,6 +164,16 @@ public:
|
||||
virtual int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE,
|
||||
const Want *resultWant = nullptr) override;
|
||||
|
||||
/**
|
||||
* SendResultToAbility with want, return want from ability manager service.
|
||||
*
|
||||
* @param requestCode, request code.
|
||||
* @param resultCode, resultCode to return.
|
||||
* @param resultWant, the Want of the ability to return.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant) override;
|
||||
|
||||
/**
|
||||
* TerminateAbility, terminate the special ability.
|
||||
*
|
||||
@ -788,7 +798,7 @@ public:
|
||||
static constexpr uint32_t RESTART_ABILITY_TIMEOUT = 500; // ms
|
||||
static constexpr uint32_t FOREGROUNDNEW_TIMEOUT = 5000; // ms
|
||||
static constexpr uint32_t BACKGROUNDNEW_TIMEOUT = 3000; // ms
|
||||
static constexpr uint32_t DUMP_TIMEOUT = 5000; // ms
|
||||
static constexpr uint32_t DUMP_TIMEOUT = 1000; // ms
|
||||
|
||||
static constexpr uint32_t MIN_DUMP_ARGUMENT_NUM = 2;
|
||||
static constexpr uint32_t MAX_WAIT_SYSTEM_UI_NUM = 600;
|
||||
|
@ -58,6 +58,7 @@ private:
|
||||
void SecondStepInit();
|
||||
void ThirdStepInit();
|
||||
int TerminateAbilityInner(MessageParcel &data, MessageParcel &reply);
|
||||
int SendResultToAbilityInner(MessageParcel &data, MessageParcel &reply);
|
||||
int TerminateAbilityByCallerInner(MessageParcel &data, MessageParcel &reply);
|
||||
int MinimizeAbilityInner(MessageParcel &data, MessageParcel &reply);
|
||||
int AttachAbilityThreadInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -86,6 +86,59 @@ public:
|
||||
Want resultWant_; // for-result start mode ability will send the result to caller
|
||||
};
|
||||
|
||||
/**
|
||||
* @class SystemAbilityCallerRecord
|
||||
* Record system caller ability of for-result start mode and result.
|
||||
*/
|
||||
class SystemAbilityCallerRecord {
|
||||
public:
|
||||
SystemAbilityCallerRecord(std::string &srcAbilityId, const sptr<IRemoteObject> &callerToken)
|
||||
: srcAbilityId_(srcAbilityId), callerToken_(callerToken)
|
||||
{}
|
||||
virtual ~SystemAbilityCallerRecord()
|
||||
{}
|
||||
|
||||
std::string GetSrcAbilityId()
|
||||
{
|
||||
return srcAbilityId_;
|
||||
}
|
||||
const sptr<IRemoteObject> GetCallerToken()
|
||||
{
|
||||
return callerToken_;
|
||||
}
|
||||
void SetResult(Want &want, int resultCode)
|
||||
{
|
||||
resultWant_ = want;
|
||||
resultCode_ = resultCode;
|
||||
}
|
||||
Want &GetResultWant()
|
||||
{
|
||||
return resultWant_;
|
||||
}
|
||||
int &GetResultCode()
|
||||
{
|
||||
return resultCode_;
|
||||
}
|
||||
/**
|
||||
* Set result to system ability.
|
||||
*
|
||||
*/
|
||||
void SetResultToSystemAbility(std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord,
|
||||
Want &resultWant, int resultCode);
|
||||
/**
|
||||
* Send result to system ability.
|
||||
*
|
||||
*/
|
||||
void SendResultToSystemAbility(int requestCode, int resultCode, Want &resultWant,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
private:
|
||||
std::string srcAbilityId_;
|
||||
sptr<IRemoteObject> callerToken_;
|
||||
Want resultWant_;
|
||||
int resultCode_ = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class CallerRecord
|
||||
* Record caller ability of for-result start mode and result.
|
||||
@ -95,6 +148,9 @@ public:
|
||||
CallerRecord() = default;
|
||||
CallerRecord(int requestCode, std::weak_ptr<AbilityRecord> caller) : requestCode_(requestCode), caller_(caller)
|
||||
{}
|
||||
CallerRecord(int requestCode, std::shared_ptr<SystemAbilityCallerRecord> saCaller) : requestCode_(requestCode),
|
||||
saCaller_(saCaller)
|
||||
{}
|
||||
virtual ~CallerRecord()
|
||||
{}
|
||||
|
||||
@ -106,10 +162,15 @@ public:
|
||||
{
|
||||
return caller_.lock();
|
||||
}
|
||||
std::shared_ptr<SystemAbilityCallerRecord> GetSaCaller()
|
||||
{
|
||||
return saCaller_;
|
||||
}
|
||||
|
||||
private:
|
||||
int requestCode_ = -1; // requestCode of for-result start mode
|
||||
std::weak_ptr<AbilityRecord> caller_;
|
||||
std::shared_ptr<SystemAbilityCallerRecord> saCaller_ = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -208,13 +269,13 @@ public:
|
||||
* foreground the ability.
|
||||
*
|
||||
*/
|
||||
void ForegroundAbility(uint32_t sceneFlag = 0);
|
||||
void ForegroundAbility(const Closure &task, uint32_t sceneFlag = 0);
|
||||
|
||||
/**
|
||||
* process request of foregrounding the ability.
|
||||
*
|
||||
*/
|
||||
void ProcessForegroundAbility(uint32_t sceneFlag = 0);
|
||||
void ProcessForegroundAbility(const Closure &task, uint32_t sceneFlag = 0);
|
||||
|
||||
/**
|
||||
* move the ability to back ground.
|
||||
@ -492,6 +553,12 @@ public:
|
||||
*/
|
||||
void SaveResultToCallers(const int resultCode, const Want *resultWant);
|
||||
|
||||
/**
|
||||
* save result to caller ability.
|
||||
*
|
||||
*/
|
||||
void SaveResult(int resultCode, const Want *resultWant, std::shared_ptr<CallerRecord> caller);
|
||||
|
||||
/**
|
||||
* add connect record to the list.
|
||||
*
|
||||
@ -526,7 +593,14 @@ public:
|
||||
* add caller record
|
||||
*
|
||||
*/
|
||||
void AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode);
|
||||
void AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode, std::string srcAbilityId = "");
|
||||
|
||||
/**
|
||||
* add system ability caller record
|
||||
*
|
||||
*/
|
||||
void AddSystemAbilityCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode,
|
||||
std::string srcAbilityId);
|
||||
|
||||
/**
|
||||
* get caller record to list.
|
||||
@ -775,9 +849,10 @@ private:
|
||||
int32_t restratMax_ = -1;
|
||||
std::string specifiedFlag_;
|
||||
std::mutex lock_;
|
||||
mutable std::mutex dumpInfoLock_;
|
||||
mutable std::mutex dumpLock_;
|
||||
mutable std::condition_variable dumpCondition_;
|
||||
mutable bool isDumpWaiting_ = false;
|
||||
mutable bool isDumpTimeout_ = false;
|
||||
std::vector<std::string> dumpInfos_;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
@ -396,6 +396,7 @@ private:
|
||||
const std::shared_ptr<AbilityRecord> &callerAbility);
|
||||
void NotifyStartingWindow(bool isCold, const std::shared_ptr<AbilityRecord> &targetAbilityRecord,
|
||||
std::shared_ptr<StartOptions> &startOptions, int32_t missionId);
|
||||
void ProcessForeground(std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
#endif
|
||||
|
||||
private:
|
||||
@ -421,10 +422,10 @@ private:
|
||||
void PrintTimeOutLog(const std::shared_ptr<AbilityRecord> &ability, uint32_t msgId);
|
||||
|
||||
int DispatchState(const std::shared_ptr<AbilityRecord> &abilityRecord, int state);
|
||||
int DispatchForegroundNew(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
int DispatchForeground(const std::shared_ptr<AbilityRecord> &abilityRecord, bool success);
|
||||
int DispatchTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
int DispatchBackground(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
void CompleteForegroundNew(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
void CompleteForegroundSuccess(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
void CompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
void CompleteBackground(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
void CompleteTerminateAndUpdateMission(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
@ -457,6 +458,7 @@ private:
|
||||
void BackToCaller(const std::shared_ptr<AbilityRecord> &callerAbility);
|
||||
|
||||
// new version for call inner function.
|
||||
void CompleteForegroundFailed(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
int ResolveAbility(const std::shared_ptr<AbilityRecord> &targetAbility, const AbilityRequest &abilityRequest);
|
||||
std::shared_ptr<AbilityRecord> GetAbilityRecordByName(const AppExecFwk::ElementName &element);
|
||||
int CallAbilityLocked(const AbilityRequest &abilityRequest);
|
||||
|
@ -893,9 +893,10 @@ void AbilityConnectManager::RemoveServiceAbility(const std::shared_ptr<AbilityRe
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
const AppExecFwk::AbilityInfo &abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
std::string element = abilityInfo.deviceId + "/" + abilityInfo.bundleName + "/" + abilityInfo.name;
|
||||
HILOG_INFO("Remove service(%{public}s) from map.", abilityInfo.name.c_str());
|
||||
auto it = serviceMap_.find(element);
|
||||
AppExecFwk::ElementName element(abilityInfo.deviceId, abilityInfo.bundleName,
|
||||
abilityInfo.name, abilityInfo.moduleName);
|
||||
HILOG_INFO("Remove service(%{public}s) from map.", element.GetURI().c_str());
|
||||
auto it = serviceMap_.find(element.GetURI());
|
||||
if (it != serviceMap_.end()) {
|
||||
HILOG_INFO("Remove service(%{public}s) from map.", abilityInfo.name.c_str());
|
||||
serviceMap_.erase(it);
|
||||
|
@ -135,6 +135,14 @@ ErrCode AbilityManagerClient::StartAbility(const Want &want, const StartOptions
|
||||
return abms->StartAbility(want, startOptions, callerToken, userId, requestCode);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::SendResultToAbility(int requestCode, int resultCode, Want& resultWant)
|
||||
{
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
HILOG_INFO("startSendResultToAbility come.");
|
||||
return abms->SendResultToAbility(requestCode, resultCode, resultWant);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::StartExtensionAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
|
||||
{
|
||||
|
@ -357,6 +357,32 @@ int AbilityManagerProxy::TerminateAbility(const sptr<IRemoteObject> &token,
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant)
|
||||
{
|
||||
int error;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(requestCode)) {
|
||||
HILOG_ERROR("requestCode write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(resultCode) || !data.WriteParcelable(&resultWant)) {
|
||||
HILOG_ERROR("data write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
error = Remote()->SendRequest(IAbilityManager::SEND_RESULT_TO_ABILITY, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::TerminateAbilityByCaller(const sptr<IRemoteObject> &callerToken, int requestCode)
|
||||
{
|
||||
int error;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "permission_constants.h"
|
||||
#include "permission_verification.h"
|
||||
#include "sa_mgr_client.h"
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "softbus_bus_center.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -112,6 +113,10 @@ const std::string DM_PKG_NAME = "ohos.distributedhardware.devicemanager";
|
||||
const std::string ACTION_CHOOSE = "ohos.want.action.select";
|
||||
const std::string HIGHEST_PRIORITY_ABILITY_ENTITY = "flag.home.intent.from.system";
|
||||
const std::string FREE_INSTALL_TYPE_KEY = "freeInstallType";
|
||||
const std::string DMS_PROCESS_NAME = "distributedsched";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const int DEFAULT_DMS_MISSION_ID = -1;
|
||||
const int DEFAULT_REQUEST_CODE = -1;
|
||||
const std::map<std::string, AbilityManagerService::DumpKey> AbilityManagerService::dumpMap = {
|
||||
std::map<std::string, AbilityManagerService::DumpKey>::value_type("--all", KEY_DUMP_ALL),
|
||||
std::map<std::string, AbilityManagerService::DumpKey>::value_type("-a", KEY_DUMP_ALL),
|
||||
@ -314,8 +319,18 @@ int AbilityManagerService::StartAbility(const Want &want, const sptr<IRemoteObje
|
||||
HILOG_INFO("Start ability come, ability is %{public}s, userId is %{public}d",
|
||||
want.GetElement().GetAbilityName().c_str(), userId);
|
||||
if (CheckIfOperateRemote(want)) {
|
||||
HILOG_INFO("AbilityManagerService::StartAbility. try to StartRemoteAbility");
|
||||
eventInfo.errCode = StartRemoteAbility(want, requestCode);
|
||||
if (requestCode == DEFAULT_REQUEST_CODE) {
|
||||
HILOG_INFO("AbilityManagerService::StartAbility. try to StartRemoteAbility");
|
||||
eventInfo.errCode = StartRemoteAbility(want, requestCode);
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR,
|
||||
HiSysEventType::FAULT, eventInfo);
|
||||
return eventInfo.errCode;
|
||||
}
|
||||
int32_t missionId = GetMissionIdByAbilityToken(callerToken);
|
||||
Want newWant = want;
|
||||
newWant.SetParam(DMS_MISSION_ID, missionId);
|
||||
HILOG_INFO("AbilityManagerService::StartAbility. try to StartAbilityForResult");
|
||||
eventInfo.errCode = StartRemoteAbility(newWant, requestCode);
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR,
|
||||
HiSysEventType::FAULT, eventInfo);
|
||||
return eventInfo.errCode;
|
||||
@ -340,8 +355,13 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
}
|
||||
|
||||
if (callerToken != nullptr && !VerificationAllToken(callerToken)) {
|
||||
HILOG_ERROR("%{public}s VerificationAllToken failed.", __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(IPCSkeleton::GetCallingTokenID());
|
||||
if (tokenType != Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE ||
|
||||
iface_cast<ISystemAbilityTokenCallback>(callerToken) == nullptr) {
|
||||
HILOG_ERROR("%{public}s VerificationAllToken failed.", __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
HILOG_INFO("%{public}s: Caller is system ability.", __func__);
|
||||
}
|
||||
int32_t oriValidUserId = GetValidUserId(userId);
|
||||
int32_t validUserId = oriValidUserId;
|
||||
@ -818,7 +838,7 @@ int AbilityManagerService::StopExtensionAbility(const Want &want, const sptr<IRe
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("CheckOptExtensionAbility error.");
|
||||
eventInfo.errCode = result;
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::STOP_EXTENSION_ERROR,
|
||||
AAFWK::EventReport::SendExtensionEvent(AAFWK::STOP_EXTENSION_ERROR,
|
||||
HiSysEventType::FAULT,
|
||||
eventInfo);
|
||||
return result;
|
||||
@ -835,9 +855,11 @@ int AbilityManagerService::StopExtensionAbility(const Want &want, const sptr<IRe
|
||||
}
|
||||
HILOG_INFO("Stop extension begin, name is %{public}s.", abilityInfo.name.c_str());
|
||||
eventInfo.errCode = connectManager->StopServiceAbility(abilityRequest);
|
||||
AAFWK::EventReport::SendExtensionEvent(AAFWK::STOP_EXTENSION_ERROR,
|
||||
HiSysEventType::FAULT,
|
||||
eventInfo);
|
||||
if (eventInfo.errCode != ERR_OK) {
|
||||
AAFWK::EventReport::SendExtensionEvent(AAFWK::STOP_EXTENSION_ERROR,
|
||||
HiSysEventType::FAULT,
|
||||
eventInfo);
|
||||
}
|
||||
return eventInfo.errCode;
|
||||
}
|
||||
|
||||
@ -967,10 +989,38 @@ int AbilityManagerService::TerminateAbilityWithFlag(const sptr<IRemoteObject> &t
|
||||
return missionListManager->TerminateAbility(abilityRecord, resultCode, resultWant, flag);
|
||||
}
|
||||
|
||||
int AbilityManagerService::SendResultToAbility(int requestCode, int resultCode, Want &resultWant)
|
||||
{
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
Security::AccessToken::NativeTokenInfo nativeTokenInfo;
|
||||
uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(accessToken);
|
||||
int32_t result = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(accessToken, nativeTokenInfo);
|
||||
if (tokenType != Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE ||
|
||||
result != ERR_OK || nativeTokenInfo.processName != DMS_PROCESS_NAME) {
|
||||
HILOG_ERROR("Check processName failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int missionId = resultWant.GetIntParam(DMS_MISSION_ID, DEFAULT_DMS_MISSION_ID);
|
||||
resultWant.RemoveParam(DMS_MISSION_ID);
|
||||
if (missionId == DEFAULT_DMS_MISSION_ID) {
|
||||
HILOG_ERROR("MissionId is empty");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
sptr<IRemoteObject> abilityToken = GetAbilityTokenByMissionId(missionId);
|
||||
CHECK_POINTER_AND_RETURN(abilityToken, ERR_INVALID_VALUE);
|
||||
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(abilityToken);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
abilityRecord->SetResult(std::make_shared<AbilityResult>(requestCode, resultCode, resultWant));
|
||||
abilityRecord->SendResult();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AbilityManagerService::StartRemoteAbility(const Want &want, int requestCode)
|
||||
{
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
want.DumpInfo(0);
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
|
||||
DistributedClient dmsClient;
|
||||
@ -2775,7 +2825,7 @@ int AbilityManagerService::GenerateExtensionAbilityRequest(
|
||||
request.appInfo.name.c_str(), request.appInfo.bundleName.c_str(), request.uid);
|
||||
|
||||
HILOG_INFO("GenerateExtensionAbilityRequest, moduleName: %{public}s.", request.abilityInfo.moduleName.c_str());
|
||||
request.want.SetModuleName(request.abilityInfo.moduleName);
|
||||
request.want.SetModuleName(request.abilityInfo.moduleName);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -4152,11 +4202,7 @@ int AbilityManagerService::DoAbilityForeground(const sptr<IRemoteObject> &token,
|
||||
return ERR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
abilityRecord->ProcessForegroundAbility(flag);
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.sceneFlag = flag;
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::DO_FOREGROUND_ABILITY,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
abilityRecord->ProcessForegroundAbility(nullptr, flag);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -4171,10 +4217,6 @@ int AbilityManagerService::DoAbilityBackground(const sptr<IRemoteObject> &token,
|
||||
abilityRecord->lifeCycleStateInfo_.sceneFlag = flag;
|
||||
int ret = MinimizeAbility(token);
|
||||
abilityRecord->lifeCycleStateInfo_.sceneFlag = SCENE_FLAG_NORMAL;
|
||||
AAFWK::EventInfo eventInfo;
|
||||
eventInfo.sceneFlag = flag;
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::DO_FOREGROUND_ABILITY,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ void AbilityManagerStub::FirstStepInit()
|
||||
requestFuncMap_[START_CONTINUATION] = &AbilityManagerStub::StartContinuationInner;
|
||||
requestFuncMap_[NOTIFY_COMPLETE_CONTINUATION] = &AbilityManagerStub::NotifyCompleteContinuationInner;
|
||||
requestFuncMap_[NOTIFY_CONTINUATION_RESULT] = &AbilityManagerStub::NotifyContinuationResultInner;
|
||||
requestFuncMap_[SEND_RESULT_TO_ABILITY] = &AbilityManagerStub::SendResultToAbilityInner;
|
||||
requestFuncMap_[REGISTER_REMOTE_MISSION_LISTENER] = &AbilityManagerStub::RegisterRemoteMissionListenerInner;
|
||||
requestFuncMap_[UNREGISTER_REMOTE_MISSION_LISTENER] = &AbilityManagerStub::UnRegisterRemoteMissionListenerInner;
|
||||
requestFuncMap_[START_ABILITY_FOR_OPTIONS] = &AbilityManagerStub::StartAbilityForOptionsInner;
|
||||
@ -199,6 +200,23 @@ int AbilityManagerStub::TerminateAbilityInner(MessageParcel &data, MessageParcel
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::SendResultToAbilityInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int requestCode = data.ReadInt32();
|
||||
int resultCode = data.ReadInt32();
|
||||
Want *resultWant = data.ReadParcelable<Want>();
|
||||
if (resultWant == nullptr) {
|
||||
HILOG_ERROR("resultWant is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t result = SendResultToAbility(requestCode, resultCode, *resultWant);
|
||||
reply.WriteInt32(result);
|
||||
if (resultWant != nullptr) {
|
||||
delete resultWant;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::TerminateAbilityByCallerInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IRemoteObject> callerToken = nullptr;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_scheduler_stub.h"
|
||||
#include "ability_util.h"
|
||||
#include "accesstoken_kit.h"
|
||||
#include "bundle_mgr_client.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "errors.h"
|
||||
@ -29,15 +30,24 @@
|
||||
#ifdef OS_ACCOUNT_PART_ENABLED
|
||||
#include "os_account_manager.h"
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "system_ability_token_callback_proxy.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
using namespace OHOS::Security;
|
||||
const std::string DEBUG_APP = "debugApp";
|
||||
const std::string DMS_PROCESS_NAME = "distributedsched";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
int64_t AbilityRecord::abilityRecordId = 0;
|
||||
int64_t AbilityRecord::g_abilityRecordEventId_ = 0;
|
||||
const int32_t DEFAULT_USER_ID = 0;
|
||||
const int32_t SEND_RESULT_CANCELED = -1;
|
||||
const int DEFAULT_REQUEST_CODE = -1;
|
||||
const int VECTOR_SIZE = 2;
|
||||
const std::map<AbilityState, std::string> AbilityRecord::stateToStrMap = {
|
||||
std::map<AbilityState, std::string>::value_type(INITIAL, "INITIAL"),
|
||||
std::map<AbilityState, std::string>::value_type(INACTIVE, "INACTIVE"),
|
||||
@ -49,6 +59,7 @@ const std::map<AbilityState, std::string> AbilityRecord::stateToStrMap = {
|
||||
std::map<AbilityState, std::string>::value_type(BACKGROUND, "BACKGROUND"),
|
||||
std::map<AbilityState, std::string>::value_type(FOREGROUNDING, "FOREGROUNDING"),
|
||||
std::map<AbilityState, std::string>::value_type(BACKGROUNDING, "BACKGROUNDING"),
|
||||
std::map<AbilityState, std::string>::value_type(FOREGROUND_FAILED, "FOREGROUND_FAILED"),
|
||||
};
|
||||
const std::map<AppState, std::string> AbilityRecord::appStateToStrMap_ = {
|
||||
std::map<AppState, std::string>::value_type(AppState::BEGIN, "BEGIN"),
|
||||
@ -65,6 +76,7 @@ const std::map<AbilityLifeCycleState, AbilityState> AbilityRecord::convertStateM
|
||||
std::map<AbilityLifeCycleState, AbilityState>::value_type(ABILITY_STATE_ACTIVE, ACTIVE),
|
||||
std::map<AbilityLifeCycleState, AbilityState>::value_type(ABILITY_STATE_FOREGROUND_NEW, FOREGROUND),
|
||||
std::map<AbilityLifeCycleState, AbilityState>::value_type(ABILITY_STATE_BACKGROUND_NEW, BACKGROUND),
|
||||
std::map<AbilityLifeCycleState, AbilityState>::value_type(ABILITY_STATE_FOREGROUND_FAILED, FOREGROUND_FAILED),
|
||||
};
|
||||
#ifndef OS_ACCOUNT_PART_ENABLED
|
||||
const int32_t DEFAULT_OS_ACCOUNT_ID = 0; // 0 is the default id when there is no os_account part
|
||||
@ -200,13 +212,21 @@ bool AbilityRecord::CanRestartRootLauncher()
|
||||
return true;
|
||||
}
|
||||
|
||||
void AbilityRecord::ForegroundAbility(uint32_t sceneFlag)
|
||||
void AbilityRecord::ForegroundAbility(const Closure &task, uint32_t sceneFlag)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("Start to foreground ability, name is %{public}s.", abilityInfo_.name.c_str());
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
|
||||
SendEvent(AbilityManagerService::FOREGROUNDNEW_TIMEOUT_MSG, AbilityManagerService::FOREGROUNDNEW_TIMEOUT);
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
if (handler && task) {
|
||||
if (!want_.GetBoolParam(DEBUG_APP, false)) {
|
||||
handler->PostTask(task, "CancelStartingWindow", AbilityManagerService::FOREGROUNDNEW_TIMEOUT);
|
||||
} else {
|
||||
HILOG_INFO("Is debug mode, no need to handle time out.");
|
||||
}
|
||||
}
|
||||
|
||||
// schedule active after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
@ -226,7 +246,7 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag)
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityRecord::ProcessForegroundAbility(uint32_t sceneFlag)
|
||||
void AbilityRecord::ProcessForegroundAbility(const Closure &task, uint32_t sceneFlag)
|
||||
{
|
||||
std::string element = GetWant().GetElement().GetURI();
|
||||
HILOG_DEBUG("ability record: %{public}s", element.c_str());
|
||||
@ -239,7 +259,7 @@ void AbilityRecord::ProcessForegroundAbility(uint32_t sceneFlag)
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->MoveToForground(token_);
|
||||
} else {
|
||||
HILOG_DEBUG("Activate %{public}s", element.c_str());
|
||||
ForegroundAbility(sceneFlag);
|
||||
ForegroundAbility(task, sceneFlag);
|
||||
}
|
||||
} else {
|
||||
lifeCycleStateInfo_.sceneFlagBak = sceneFlag;
|
||||
@ -581,22 +601,97 @@ void AbilityRecord::SendResultToCallers()
|
||||
std::shared_ptr<AbilityRecord> callerAbilityRecord = caller->GetCaller();
|
||||
if (callerAbilityRecord != nullptr && callerAbilityRecord->GetResult() != nullptr) {
|
||||
callerAbilityRecord->SendResult();
|
||||
} else {
|
||||
std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord = caller->GetSaCaller();
|
||||
if (callerSystemAbilityRecord != nullptr) {
|
||||
HILOG_INFO("Send result to system ability.");
|
||||
callerSystemAbilityRecord->SendResultToSystemAbility(caller->GetRequestCode(),
|
||||
callerSystemAbilityRecord->GetResultCode(), callerSystemAbilityRecord->GetResultWant(),
|
||||
callerSystemAbilityRecord->GetCallerToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityRecord::SaveResultToCallers(const int resultCode, const Want *resultWant)
|
||||
{
|
||||
for (auto caller : GetCallerRecordList()) {
|
||||
auto callerRecordList = GetCallerRecordList();
|
||||
if (callerRecordList.empty()) {
|
||||
HILOG_WARN("callerRecordList is empty.");
|
||||
return;
|
||||
}
|
||||
auto lastestCaller = callerRecordList.back();
|
||||
for (auto caller : callerRecordList) {
|
||||
if (caller == nullptr) {
|
||||
HILOG_WARN("Caller record is nullptr.");
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<AbilityRecord> callerAbilityRecord = caller->GetCaller();
|
||||
if (callerAbilityRecord != nullptr) {
|
||||
callerAbilityRecord->SetResult(
|
||||
std::make_shared<AbilityResult>(caller->GetRequestCode(), resultCode, *resultWant));
|
||||
if (caller == lastestCaller) {
|
||||
HILOG_INFO("Caller record is the latest.");
|
||||
SaveResult(resultCode, resultWant, caller);
|
||||
continue;
|
||||
}
|
||||
SaveResult(SEND_RESULT_CANCELED, resultWant, caller);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityRecord::SaveResult(int resultCode, const Want *resultWant, std::shared_ptr<CallerRecord> caller)
|
||||
{
|
||||
std::shared_ptr<AbilityRecord> callerAbilityRecord = caller->GetCaller();
|
||||
if (callerAbilityRecord != nullptr) {
|
||||
callerAbilityRecord->SetResult(
|
||||
std::make_shared<AbilityResult>(caller->GetRequestCode(), resultCode, *resultWant));
|
||||
} else {
|
||||
std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord = caller->GetSaCaller();
|
||||
if (callerSystemAbilityRecord != nullptr) {
|
||||
HILOG_INFO("Caller is system ability.");
|
||||
Want* newWant = const_cast<Want*>(resultWant);
|
||||
callerSystemAbilityRecord->SetResultToSystemAbility(callerSystemAbilityRecord, *newWant,
|
||||
resultCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SystemAbilityCallerRecord::SetResultToSystemAbility(
|
||||
std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord,
|
||||
Want &resultWant, int resultCode)
|
||||
{
|
||||
std::vector<std::string> data;
|
||||
std::string srcAbilityId = callerSystemAbilityRecord->GetSrcAbilityId();
|
||||
SplitStr(srcAbilityId, "_", data);
|
||||
if (data.size() != VECTOR_SIZE) {
|
||||
HILOG_ERROR("Check data size failed");
|
||||
return;
|
||||
}
|
||||
std::string srcDeviceId = data[0];
|
||||
HILOG_INFO("Get srcDeviceId = %{public}s", srcDeviceId.c_str());
|
||||
int missionId = atoi(data[1].c_str());
|
||||
HILOG_INFO("Get missionId = %{public}d", missionId);
|
||||
resultWant.SetParam(DMS_SRC_NETWORK_ID, srcDeviceId);
|
||||
resultWant.SetParam(DMS_MISSION_ID, missionId);
|
||||
callerSystemAbilityRecord->SetResult(resultWant, resultCode);
|
||||
}
|
||||
|
||||
void SystemAbilityCallerRecord::SendResultToSystemAbility(int requestCode, int resultCode, Want &resultWant,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
|
||||
HILOG_INFO("Try to SendResult, callerUid = %{public}d, AccessTokenId = %{public}u",
|
||||
callerUid, accessToken);
|
||||
if (callerToken == nullptr) {
|
||||
HILOG_ERROR("CallerToken is nullptr");
|
||||
return;
|
||||
}
|
||||
auto object = iface_cast<ISystemAbilityTokenCallback>(callerToken);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Remote object is nullptr");
|
||||
return;
|
||||
}
|
||||
int result = object->SendResult(resultWant, callerUid, requestCode, accessToken, resultCode);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("SendResultToSystemAbility error = %{public}d", result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,11 +720,15 @@ void AbilityRecord::RemoveConnectRecordFromList(const std::shared_ptr<Connection
|
||||
connRecordList_.remove(connRecord);
|
||||
}
|
||||
|
||||
void AbilityRecord::AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode)
|
||||
void AbilityRecord::AddCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode, std::string srcAbilityId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("Add caller record.");
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (requestCode != DEFAULT_REQUEST_CODE && callerToken != nullptr && abilityRecord == nullptr) {
|
||||
AddSystemAbilityCallerRecord(callerToken, requestCode, srcAbilityId);
|
||||
return;
|
||||
}
|
||||
CHECK_POINTER(abilityRecord);
|
||||
|
||||
auto isExist = [&abilityRecord](const std::shared_ptr<CallerRecord> &callerRecord) {
|
||||
@ -652,6 +751,29 @@ void AbilityRecord::AddCallerRecord(const sptr<IRemoteObject> &callerToken, int
|
||||
abilityRecord->GetAbilityInfo().name.c_str());
|
||||
}
|
||||
|
||||
void AbilityRecord::AddSystemAbilityCallerRecord(const sptr<IRemoteObject> &callerToken, int requestCode,
|
||||
std::string srcAbilityId)
|
||||
{
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(IPCSkeleton::GetCallingTokenID());
|
||||
if (tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE &&
|
||||
iface_cast<ISystemAbilityTokenCallback>(callerToken) != nullptr) {
|
||||
HILOG_INFO("Add system ability caller record.");
|
||||
std::shared_ptr<SystemAbilityCallerRecord> systemAbilityRecord =
|
||||
std::make_shared<SystemAbilityCallerRecord>(srcAbilityId, callerToken);
|
||||
auto isExist = [&srcAbilityId](const std::shared_ptr<CallerRecord> &callerRecord) {
|
||||
std::shared_ptr<SystemAbilityCallerRecord> saCaller = callerRecord->GetSaCaller();
|
||||
return (saCaller != nullptr && saCaller->GetSrcAbilityId() == srcAbilityId);
|
||||
};
|
||||
auto record = std::find_if(callerList_.begin(), callerList_.end(), isExist);
|
||||
if (record != callerList_.end()) {
|
||||
HILOG_INFO("Find same system ability caller record.");
|
||||
callerList_.erase(record);
|
||||
}
|
||||
callerList_.emplace_back(std::make_shared<CallerRecord>(requestCode, systemAbilityRecord));
|
||||
HILOG_INFO("Add system ability record end.");
|
||||
}
|
||||
}
|
||||
|
||||
std::list<std::shared_ptr<CallerRecord>> AbilityRecord::GetCallerRecordList() const
|
||||
{
|
||||
return callerList_;
|
||||
@ -1312,27 +1434,20 @@ void AbilityRecord::DumpClientInfo(std::vector<std::string> &info, const std::ve
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(dumpLock_);
|
||||
isDumpWaiting_ = true;
|
||||
scheduler_->DumpAbilityInfo(params, info);
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
if (handler) {
|
||||
handler->PostTask([condition = &dumpCondition_, isWaiting = &isDumpWaiting_]() mutable {
|
||||
HILOG_INFO("Dump time out, isWaiting:%{public}d.", *isWaiting);
|
||||
if (*isWaiting && condition != nullptr) {
|
||||
*isWaiting = false;
|
||||
condition->notify_all();
|
||||
}
|
||||
}, std::string("Dump") + std::to_string(recordId_), AbilityManagerService::DUMP_TIMEOUT);
|
||||
}
|
||||
|
||||
HILOG_INFO("Dump begin wait.");
|
||||
while (isDumpWaiting_) {
|
||||
dumpCondition_.wait(lock);
|
||||
isDumpTimeout_ = false;
|
||||
std::chrono::milliseconds timeout { AbilityManagerService::DUMP_TIMEOUT };
|
||||
if (dumpCondition_.wait_for(lock, timeout) == std::cv_status::timeout) {
|
||||
isDumpTimeout_ = true;
|
||||
}
|
||||
HILOG_INFO("Dump done and begin parse.");
|
||||
for (auto one : dumpInfos_) {
|
||||
info.emplace_back(one);
|
||||
if (!isDumpTimeout_) {
|
||||
std::lock_guard<std::mutex> infoLock(dumpInfoLock_);
|
||||
for (auto one : dumpInfos_) {
|
||||
info.emplace_back(one);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dumpConfig) {
|
||||
@ -1348,19 +1463,17 @@ void AbilityRecord::DumpClientInfo(std::vector<std::string> &info, const std::ve
|
||||
void AbilityRecord::DumpAbilityInfoDone(std::vector<std::string> &infos)
|
||||
{
|
||||
HILOG_INFO("DumpAbilityInfoDone begin.");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
if (handler) {
|
||||
handler->RemoveTask(std::string("Dump") + std::to_string(recordId_));
|
||||
}
|
||||
if (!isDumpWaiting_) {
|
||||
HILOG_ERROR("not waiting.");
|
||||
if (isDumpTimeout_) {
|
||||
HILOG_WARN("%{public}s, dump time out.", __func__);
|
||||
return;
|
||||
}
|
||||
dumpInfos_.clear();
|
||||
for (auto info : infos) {
|
||||
dumpInfos_.emplace_back(info);
|
||||
{
|
||||
std::lock_guard<std::mutex> infoLock(dumpInfoLock_);
|
||||
dumpInfos_.clear();
|
||||
for (auto info : infos) {
|
||||
dumpInfos_.emplace_back(info);
|
||||
}
|
||||
}
|
||||
isDumpWaiting_ = false;
|
||||
dumpCondition_.notify_all();
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,8 @@ std::shared_ptr<CallRecord> CallContainer::GetCallRecord(const sptr<IAbilityConn
|
||||
bool CallContainer::RemoveCallRecord(const sptr<IAbilityConnection> & connect)
|
||||
{
|
||||
HILOG_DEBUG("call container release call record by callback.");
|
||||
CHECK_POINTER_AND_RETURN(connect, nullptr);
|
||||
CHECK_POINTER_AND_RETURN(connect->AsObject(), nullptr);
|
||||
CHECK_POINTER_AND_RETURN(connect, false);
|
||||
CHECK_POINTER_AND_RETURN(connect->AsObject(), false);
|
||||
|
||||
auto iter = callRecordMap_.find(connect->AsObject());
|
||||
if (iter != callRecordMap_.end()) {
|
||||
|
@ -41,6 +41,9 @@ constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME";
|
||||
constexpr uint32_t NEXTABILITY_TIMEOUT = 1000; // ms
|
||||
constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns
|
||||
const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen";
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const int DEFAULT_DMS_MISSION_ID = -1;
|
||||
std::string GetCurrentTime()
|
||||
{
|
||||
struct timespec tn;
|
||||
@ -193,10 +196,12 @@ int MissionListManager::MoveMissionToFront(int32_t missionId, bool isCallerFromL
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
NotifyStartingWindow(isCold, targetAbilityRecord, startOptions, missionId);
|
||||
#endif
|
||||
|
||||
// schedule target ability to foreground.
|
||||
targetAbilityRecord->ProcessForegroundAbility();
|
||||
ProcessForeground(targetAbilityRecord);
|
||||
#else
|
||||
targetAbilityRecord->ProcessForegroundAbility(nullptr);
|
||||
#endif
|
||||
HILOG_DEBUG("SetMovingState, missionId: %{public}d", missionId);
|
||||
mission->SetMovingState(true);
|
||||
return ERR_OK;
|
||||
@ -223,6 +228,7 @@ void MissionListManager::EnqueueWaittingAbilityToFront(const AbilityRequest &abi
|
||||
|
||||
void MissionListManager::StartWaittingAbility()
|
||||
{
|
||||
HILOG_INFO("%{public}s was called.", __func__);
|
||||
std::lock_guard<std::recursive_mutex> guard(managerLock_);
|
||||
auto topAbility = GetCurrentTopAbilityLocked();
|
||||
CHECK_POINTER(topAbility);
|
||||
@ -234,6 +240,7 @@ void MissionListManager::StartWaittingAbility()
|
||||
|
||||
if (!waittingAbilityQueue_.empty()) {
|
||||
AbilityRequest abilityRequest = waittingAbilityQueue_.front();
|
||||
HILOG_INFO("%{public}s. ability name: %{public}s", __func__, abilityRequest.abilityInfo.name.c_str());
|
||||
waittingAbilityQueue_.pop();
|
||||
auto callerAbility = GetAbilityRecordByToken(abilityRequest.callerToken);
|
||||
StartAbility(topAbility, callerAbility, abilityRequest);
|
||||
@ -265,7 +272,18 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord>
|
||||
} else {
|
||||
targetAbilityRecord->SetLaunchReason(LaunchReason::LAUNCHREASON_START_ABILITY);
|
||||
}
|
||||
targetAbilityRecord->AddCallerRecord(abilityRequest.callerToken, abilityRequest.requestCode);
|
||||
|
||||
std::string srcDeviceId = abilityRequest.want.GetStringParam(DMS_SRC_NETWORK_ID);
|
||||
HILOG_INFO("Get srcNetWorkId = %{public}s", srcDeviceId.c_str());
|
||||
int missionId = abilityRequest.want.GetIntParam(DMS_MISSION_ID, DEFAULT_DMS_MISSION_ID);
|
||||
HILOG_INFO("Get missionId = %{public}d", missionId);
|
||||
if (!srcDeviceId.empty() && missionId != DEFAULT_DMS_MISSION_ID) {
|
||||
Want* newWant = const_cast<Want*>(&abilityRequest.want);
|
||||
newWant->RemoveParam(DMS_SRC_NETWORK_ID);
|
||||
newWant->RemoveParam(DMS_MISSION_ID);
|
||||
}
|
||||
std::string srcAbilityId = srcDeviceId + "_" + std::to_string(missionId);
|
||||
targetAbilityRecord->AddCallerRecord(abilityRequest.callerToken, abilityRequest.requestCode, srcAbilityId);
|
||||
|
||||
// 3. move mission to target list
|
||||
bool isCallerFromLauncher = (callerAbility && callerAbility->IsLauncherAbility());
|
||||
@ -287,7 +305,11 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord>
|
||||
return targetAbilityRecord->LoadAbility();
|
||||
} else {
|
||||
// schedule target ability to foreground.
|
||||
targetAbilityRecord->ProcessForegroundAbility();
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
ProcessForeground(targetAbilityRecord);
|
||||
#else
|
||||
targetAbilityRecord->ProcessForegroundAbility(nullptr);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -635,9 +657,6 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
handler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecord->GetEventId());
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
abilityRecord->SetStartingWindow(false);
|
||||
#endif
|
||||
|
||||
abilityRecord->SetScheduler(scheduler);
|
||||
|
||||
@ -667,7 +686,7 @@ void MissionListManager::OnAbilityRequestDone(const sptr<IRemoteObject> &token,
|
||||
CHECK_POINTER(abilityRecord);
|
||||
std::string element = abilityRecord->GetWant().GetElement().GetURI();
|
||||
HILOG_DEBUG("Ability is %{public}s, start to foreground.", element.c_str());
|
||||
abilityRecord->ForegroundAbility(abilityRecord->lifeCycleStateInfo_.sceneFlagBak);
|
||||
abilityRecord->ForegroundAbility(nullptr, abilityRecord->lifeCycleStateInfo_.sceneFlagBak);
|
||||
}
|
||||
}
|
||||
|
||||
@ -811,7 +830,10 @@ int MissionListManager::DispatchState(const std::shared_ptr<AbilityRecord> &abil
|
||||
return DispatchBackground(abilityRecord);
|
||||
}
|
||||
case AbilityState::FOREGROUND: {
|
||||
return DispatchForegroundNew(abilityRecord);
|
||||
return DispatchForeground(abilityRecord, true);
|
||||
}
|
||||
case AbilityState::FOREGROUND_FAILED: {
|
||||
return DispatchForeground(abilityRecord, false);
|
||||
}
|
||||
default: {
|
||||
HILOG_WARN("Don't support transiting state: %{public}d", state);
|
||||
@ -820,36 +842,40 @@ int MissionListManager::DispatchState(const std::shared_ptr<AbilityRecord> &abil
|
||||
}
|
||||
}
|
||||
|
||||
int MissionListManager::DispatchForegroundNew(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord> &abilityRecord, bool success)
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
if (!abilityRecord->IsAbilityState(AbilityState::FOREGROUNDING)) {
|
||||
HILOG_ERROR("DispatchForegroundNew Ability transition life state error. expect %{public}d, actual %{public}d",
|
||||
HILOG_ERROR("DispatchForeground Ability transition life state error. expect %{public}d, actual %{public}d",
|
||||
AbilityState::FOREGROUNDING,
|
||||
abilityRecord->GetAbilityState());
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
handler->RemoveEvent(AbilityManagerService::FOREGROUNDNEW_TIMEOUT_MSG, abilityRecord->GetEventId());
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
abilityRecord->SetStartingWindow(false);
|
||||
#endif
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteForegroundNew(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
|
||||
if (success) {
|
||||
auto task = [self, abilityRecord]() { self->CompleteForegroundSuccess(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
} else {
|
||||
auto task = [self, abilityRecord]() { self->CompleteForegroundFailed(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void MissionListManager::CompleteForegroundNew(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
void MissionListManager::CompleteForegroundSuccess(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::recursive_mutex> guard(managerLock_);
|
||||
|
||||
CHECK_POINTER(abilityRecord);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
abilityRecord->SetStartingWindow(false);
|
||||
#endif
|
||||
// ability do not save window mode
|
||||
abilityRecord->RemoveWindowMode();
|
||||
std::string element = abilityRecord->GetWant().GetElement().GetURI();
|
||||
@ -1026,7 +1052,7 @@ int MissionListManager::TerminateAbilityLocked(const std::shared_ptr<AbilityReco
|
||||
if (abilityRecord->IsAbilityState(FOREGROUND) || abilityRecord->IsAbilityState(FOREGROUNDING)) {
|
||||
HILOG_DEBUG("current ability is active");
|
||||
if (abilityRecord->GetNextAbilityRecord()) {
|
||||
abilityRecord->GetNextAbilityRecord()->ProcessForegroundAbility();
|
||||
abilityRecord->GetNextAbilityRecord()->ProcessForegroundAbility(nullptr);
|
||||
} else {
|
||||
MoveToBackgroundTask(abilityRecord);
|
||||
}
|
||||
@ -1488,6 +1514,24 @@ void MissionListManager::HandleForgroundNewTimeout(const std::shared_ptr<Ability
|
||||
HandleTimeoutAndResumeAbility(ability);
|
||||
}
|
||||
|
||||
void MissionListManager::CompleteForegroundFailed(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
HILOG_DEBUG("CompleteForegroundFailed come.");
|
||||
std::lock_guard<std::recursive_mutex> guard(managerLock_);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("CompleteForegroundFailed, ability is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (abilityRecord->IsStartingWindow()) {
|
||||
CancelStartingWindow(abilityRecord->GetToken(), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
HandleForgroundNewTimeout(abilityRecord);
|
||||
}
|
||||
|
||||
void MissionListManager::HandleTimeoutAndResumeAbility(const std::shared_ptr<AbilityRecord> &timeOutAbilityRecord)
|
||||
{
|
||||
HILOG_DEBUG("HandleTimeoutAndResumeTopAbility start");
|
||||
@ -1917,7 +1961,7 @@ void MissionListManager::BackToLauncher()
|
||||
|
||||
launcherList_->AddMissionToTop(launcherRootMission);
|
||||
MoveMissionListToTop(launcherList_);
|
||||
launcherRootAbility->ProcessForegroundAbility();
|
||||
launcherRootAbility->ProcessForegroundAbility(nullptr);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@ -2314,7 +2358,7 @@ void MissionListManager::StartingWindowHot(const std::shared_ptr<AbilityRecord>
|
||||
|
||||
void MissionListManager::CancelStartingWindow(const sptr<IRemoteObject> abilityToken, bool isDelay) const
|
||||
{
|
||||
HILOG_DEBUG("%{public}s, call CancelStartingWindow.", __func__);
|
||||
HILOG_INFO("%{public}s, call CancelStartingWindow.", __func__);
|
||||
auto windowHandler = GetWMSHandler();
|
||||
if (!windowHandler) {
|
||||
HILOG_ERROR("%{public}s, Get WMS handler failed.", __func__);
|
||||
@ -2329,7 +2373,11 @@ void MissionListManager::CancelStartingWindow(const sptr<IRemoteObject> abilityT
|
||||
|
||||
auto task = [windowHandler, abilityToken] {
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(abilityToken);
|
||||
if (!abilityRecord) {
|
||||
HILOG_INFO("%{public}s, abilityRecord is nullptr.", __func__);
|
||||
}
|
||||
if (windowHandler && abilityRecord && abilityRecord->IsStartingWindow()) {
|
||||
HILOG_INFO("%{public}s, call windowHandler CancelStartingWindow.", __func__);
|
||||
windowHandler->CancelStartingWindow(abilityToken);
|
||||
abilityRecord->SetStartingWindow(false);
|
||||
}
|
||||
@ -2342,6 +2390,24 @@ void MissionListManager::CancelStartingWindow(const sptr<IRemoteObject> abilityT
|
||||
}
|
||||
}
|
||||
|
||||
void MissionListManager::ProcessForeground(std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
auto windowHandler = GetWMSHandler();
|
||||
if (!windowHandler) {
|
||||
HILOG_ERROR("%{public}s, Get WMS handler failed.", __func__);
|
||||
abilityRecord->ProcessForegroundAbility(nullptr);
|
||||
return;
|
||||
}
|
||||
auto task = [windowHandler, abilityRecord] {
|
||||
if (windowHandler && abilityRecord && abilityRecord->IsStartingWindow()) {
|
||||
HILOG_INFO("%{public}s, call windowHandler CancelStartingWindow.", __func__);
|
||||
windowHandler->CancelStartingWindow(abilityRecord->GetToken());
|
||||
abilityRecord->SetStartingWindow(false);
|
||||
}
|
||||
};
|
||||
abilityRecord->ProcessForegroundAbility(task);
|
||||
}
|
||||
|
||||
void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) const
|
||||
{
|
||||
if (!abilityToken) {
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "system_ability_token_callback_proxy.h"
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "message_parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
const std::u16string SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_TOKEN = u"ohos.aafwk.ISystemAbilityTokenCallback";
|
||||
|
||||
int32_t SystemAbilityTokenCallbackProxy::SendResult(OHOS::AAFwk::Want& want, int32_t callerUid,
|
||||
int32_t requestCode, uint32_t accessToken, int32_t resultCode)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_TOKEN)) {
|
||||
HILOG_ERROR("SendResult Write interface token failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
HILOG_ERROR("fail to WriteParcelable");
|
||||
return INNER_ERR;
|
||||
}
|
||||
data.WriteInt32(callerUid);
|
||||
data.WriteInt32(requestCode);
|
||||
data.WriteUint32(accessToken);
|
||||
data.WriteInt32(resultCode);
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
int result = Remote()->SendRequest(ISystemAbilityTokenCallback::SEND_RESULT, data, reply, option);
|
||||
if (result != NO_ERROR) {
|
||||
HILOG_ERROR("SendResult SendRequest fail, error: %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "system_ability_token_callback_stub.h"
|
||||
|
||||
#include "errors.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
const std::u16string SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_TOKEN = u"ohos.aafwk.ISystemAbilityTokenCallback";
|
||||
}
|
||||
int32_t SystemAbilityTokenCallbackStub::OnRemoteRequest(uint32_t code,
|
||||
MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
if (data.ReadInterfaceToken() != SYSTEM_ABILITY_TOKEN_CALLBACK_INTERFACE_TOKEN) {
|
||||
HILOG_ERROR("OnRemoteRequest::ReadInterfaceToken error");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
switch (code) {
|
||||
case SEND_RESULT: {
|
||||
std::shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
|
||||
if (want == nullptr) {
|
||||
HILOG_ERROR("SEND_RESULT want readParcelable failed!");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
int32_t callerUid = data.ReadInt32();
|
||||
int32_t requestCode = data.ReadInt32();
|
||||
uint32_t accessToken = data.ReadUint32();
|
||||
int32_t resultCode = data.ReadInt32();
|
||||
return SendResult(*want, callerUid, requestCode, accessToken, resultCode);
|
||||
}
|
||||
default: {
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -57,6 +57,20 @@ void AbilityManagerClientTest::SetUp()
|
||||
client_->proxy_ = mock_;
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: SendResultToAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerClient SendResultToAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the SendResultToAbility call normal
|
||||
*/
|
||||
HWTEST_F(AbilityManagerClientTest, SendResultToAbility_001, TestSize.Level1)
|
||||
{
|
||||
Want want;
|
||||
EXPECT_EQ(client_->SendResultToAbility(-1, -1, want), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerClient
|
||||
* Function: StartAbilityByCall
|
||||
|
@ -298,6 +298,11 @@ public:
|
||||
MOCK_METHOD1(BlockAbility, int(int32_t abilityRecordId));
|
||||
#endif
|
||||
|
||||
virtual int SendResultToAbility(int requestCode, int resultCode, Want &resultWant) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int StartAbilityByCall(
|
||||
const Want &want, const sptr<IAbilityConnection> &connect, const sptr<IRemoteObject> &callerToken) override
|
||||
{
|
||||
|
@ -163,6 +163,45 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_004, TestSize.Level1)
|
||||
EXPECT_NE(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SendResultToAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SendResultToAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the normal conditions of SendResultToAbility
|
||||
*/
|
||||
HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_SendResultToAbility_001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*mock_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest));
|
||||
Want want;
|
||||
int res1 = proxy_->SendResultToAbility(-1, -1, want);
|
||||
EXPECT_EQ(res1, NO_ERROR);
|
||||
EXPECT_EQ(IAbilityManager::SEND_RESULT_TO_ABILITY, mock_->code_);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: SendResultToAbility
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService SendResultToAbility
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify the abnormal conditions of SendResultToAbility
|
||||
*/
|
||||
HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_SendResult_002, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*mock_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeErrorSendRequest));
|
||||
Want want;
|
||||
int res = proxy_->SendResultToAbility(-1, -1, want);
|
||||
|
||||
EXPECT_EQ(IAbilityManager::SEND_RESULT_TO_ABILITY, mock_->code_);
|
||||
EXPECT_NE(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: ConnectAbility
|
||||
|
@ -76,6 +76,12 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int SendResultToAbility(int requestCode, int resultCode, Want &resultWant)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int CloseAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE,
|
||||
const Want *resultWant = nullptr) override
|
||||
{
|
||||
|
@ -108,6 +108,12 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int SendResultToAbility(int requestCode, int resultCode, Want &resultWant)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int CloseAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE,
|
||||
const Want *resultWant = nullptr) override
|
||||
{
|
||||
|
@ -341,6 +341,32 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_011, TestSize.Level1)
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: OnRemoteRequest
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AbilityManagerService OnRemoteRequest
|
||||
* EnvConditions: code is SEND_RESULT_TO_ABILITY
|
||||
* CaseDescription: Verify that on remote request is normal
|
||||
*/
|
||||
HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_012, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
WriteInterfaceToken(data);
|
||||
int requestCode = -1;
|
||||
int resultCode = -1;
|
||||
Want want;
|
||||
data.WriteInt32(requestCode);
|
||||
data.WriteInt32(resultCode);
|
||||
data.WriteParcelable(&want);
|
||||
int res = stub_->OnRemoteRequest(IAbilityManager::SEND_RESULT_TO_ABILITY, data, reply, option);
|
||||
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AbilityManagerService
|
||||
* Function: OnRemoteRequest
|
||||
|
@ -29,6 +29,7 @@ ohos_unittest("app_scheduler_test") {
|
||||
|
||||
sources = [
|
||||
"${aafwk_path}/services/abilitymgr/src/app_scheduler.cpp",
|
||||
"${aafwk_path}/services/abilitymgr/src/system_ability_token_callback_proxy.cpp",
|
||||
"app_scheduler_test.cpp",
|
||||
]
|
||||
|
||||
|
@ -33,6 +33,7 @@ ohos_unittest("data_ability_manager_test") {
|
||||
|
||||
sources = [
|
||||
"${aafwk_path}/services/abilitymgr/src/app_scheduler.cpp",
|
||||
"${aafwk_path}/services/abilitymgr/src/system_ability_token_callback_proxy.cpp",
|
||||
"data_ability_manager_test.cpp", # add mock file
|
||||
]
|
||||
|
||||
|
@ -277,7 +277,7 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr<IAppSched
|
||||
eventInfo.bundleName = applicationInfo->name;
|
||||
eventInfo.versionName = applicationInfo->versionName;
|
||||
eventInfo.versionCode = applicationInfo->versionCode;
|
||||
eventInfo.processName = applicationInfo->process;
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
AAFWK::EventReport::SendAppEvent(AAFWK::APP_ATTACH, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ void AppMgrServiceInner::LaunchApplication(const std::shared_ptr<AppRunningRecor
|
||||
eventInfo.bundleName = applicationInfo->name;
|
||||
eventInfo.versionName = applicationInfo->versionName;
|
||||
eventInfo.versionCode = applicationInfo->versionCode;
|
||||
eventInfo.processName = applicationInfo->process;
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
AAFWK::EventReport::SendAppEvent(AAFWK::APP_LAUNCH, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ void AppMgrServiceInner::ApplicationForegrounded(const int32_t recordId)
|
||||
eventInfo.bundleName = applicationInfo->name;
|
||||
eventInfo.versionName = applicationInfo->versionName;
|
||||
eventInfo.versionCode = applicationInfo->versionCode;
|
||||
eventInfo.processName = applicationInfo->process;
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
AAFWK::EventReport::SendAppEvent(AAFWK::APP_FOREGROUND,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
}
|
||||
@ -391,7 +391,7 @@ void AppMgrServiceInner::ApplicationBackgrounded(const int32_t recordId)
|
||||
eventInfo.bundleName = applicationInfo->name;
|
||||
eventInfo.versionName = applicationInfo->versionName;
|
||||
eventInfo.versionCode = applicationInfo->versionCode;
|
||||
eventInfo.processName = applicationInfo->process;
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
AAFWK::EventReport::SendAppEvent(AAFWK::APP_BACKGROUND,
|
||||
HiSysEventType::BEHAVIOR, eventInfo);
|
||||
}
|
||||
@ -429,7 +429,7 @@ void AppMgrServiceInner::ApplicationTerminated(const int32_t recordId)
|
||||
eventInfo.bundleName = applicationInfo->name;
|
||||
eventInfo.versionName = applicationInfo->versionName;
|
||||
eventInfo.versionCode = applicationInfo->versionCode;
|
||||
eventInfo.processName = applicationInfo->process;
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
AAFWK::EventReport::SendAppEvent(AAFWK::APP_TERMINATE, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnProcessDied(appRecord);
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_AAFWK_SERVICES_ABILITYMGR_INCLUDE_INNER_EVENT_REPORT_H
|
||||
#define FOUNDATION_AAFWK_SERVICES_ABILITYMGR_INCLUDE_INNER_EVENT_REPORT_H
|
||||
#ifndef FOUNDATION_AAFWK_SERVICES_COMMON_INCLUDE_EVENT_REPORT_H
|
||||
#define FOUNDATION_AAFWK_SERVICES_COMMON_INCLUDE_EVENT_REPORT_H
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@ -40,8 +40,6 @@ const std::string DISCONNECT_SERVICE_ERROR = "DISCONNECT_SERVICE_ERROR";
|
||||
const std::string START_ABILITY = "START_ABILITY";
|
||||
const std::string TERMINATE_ABILITY = "TERMINATE_ABILITY";
|
||||
const std::string CLOSE_ABILITY = "CLOSE_ABILITY";
|
||||
const std::string DO_FOREGROUND_ABILITY = "DO_FOREGROUND_ABILITY";
|
||||
const std::string DO_BACKGROUND_ABILITY = "DO_BACKGROUND_ABILITY";
|
||||
// serviceExtensionAbility behavior event
|
||||
const std::string START_SERVICE = "START_SERVICE";
|
||||
const std::string STOP_SERVICE = "STOP_SERVICE";
|
||||
@ -72,7 +70,6 @@ struct EventInfo {
|
||||
int64_t formId = -1;
|
||||
int32_t extensionType = -1;
|
||||
uint32_t versionCode = 0;
|
||||
uint32_t sceneFlag = -1;
|
||||
std::string versionName;
|
||||
std::string bundleName;
|
||||
std::string moduleName;
|
||||
@ -88,7 +85,6 @@ struct EventInfo {
|
||||
userId = -1;
|
||||
formId =-1;
|
||||
versionCode = 0;
|
||||
sceneFlag = -1;
|
||||
versionName.clear();
|
||||
bundleName.clear();
|
||||
moduleName.clear();
|
||||
@ -111,4 +107,4 @@ public:
|
||||
};
|
||||
} // namespace AAFWK
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_AAFWK_SERVICES_ABILITYMGR_INCLUDE_INNER_EVENT_REPORT_H
|
||||
#endif // FOUNDATION_AAFWK_SERVICES_COMMON_INCLUDE_EVENT_REPORT_H
|
||||
|
@ -23,11 +23,10 @@ namespace AAFWK {
|
||||
namespace {
|
||||
// event params
|
||||
const std::string TYPE = "TYPE";
|
||||
const std::string EVENT_KEY_PID = "PID";
|
||||
const std::string EVENT_KEY_USERID = "USERID";
|
||||
const std::string EVENT_KEY_APP_PID = "APP_PID";
|
||||
const std::string EVENT_KEY_USERID = "USER_ID";
|
||||
const std::string EVENT_KEY_FORM_ID = "FORM_ID";
|
||||
const std::string EVENT_KEY_ERROR_CODE = "ERROR_CODE";
|
||||
const std::string EVENT_KEY_SCENE_FLAG = "SCENE_FLAG";
|
||||
const std::string EVENT_KEY_BUNDLE_NAME = "BUNDLE_NAME";
|
||||
const std::string EVENT_KEY_MODULE_NAME = "MODULE_NAME";
|
||||
const std::string EVENT_KEY_ABILITY_NAME = "ABILITY_NAME";
|
||||
@ -44,6 +43,7 @@ void EventReport::SendAppEvent(const std::string &eventName, HiSysEventType type
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
type,
|
||||
EVENT_KEY_APP_PID, eventInfo.pid,
|
||||
EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName,
|
||||
EVENT_KEY_VERSION_NAME, eventInfo.versionName,
|
||||
EVENT_KEY_VERSION_CODE, eventInfo.versionCode,
|
||||
@ -64,7 +64,7 @@ void EventReport::SendAbilityEvent(const std::string &eventName, HiSysEventType
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName,
|
||||
EVENT_KEY_ERROR_CODE, eventInfo.errCode);
|
||||
} else if (eventName == START_ABILITY_ERROR) {
|
||||
} else if (eventName == START_ABILITY) {
|
||||
HiSysEvent::Write(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
@ -73,13 +73,7 @@ void EventReport::SendAbilityEvent(const std::string &eventName, HiSysEventType
|
||||
EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName,
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName);
|
||||
} else if (eventName == DO_FOREGROUND_ABILITY || eventName == DO_BACKGROUND_ABILITY) {
|
||||
HiSysEvent::Write(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
type,
|
||||
EVENT_KEY_SCENE_FLAG, eventInfo.sceneFlag);
|
||||
} else {
|
||||
} else if (eventName == TERMINATE_ABILITY || eventName == CLOSE_ABILITY) {
|
||||
HiSysEvent::Write(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
@ -114,7 +108,8 @@ void EventReport::SendExtensionEvent(const std::string &eventName, HiSysEventTyp
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName,
|
||||
EVENT_KEY_EXTENSION_TYPE, eventInfo.extensionType);
|
||||
} else {
|
||||
} else if (eventName == START_EXTENSION_ERROR || eventName == STOP_EXTENSION_ERROR ||
|
||||
eventName == CONNECT_SERVICE_ERROR) {
|
||||
HiSysEvent::Write(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
@ -124,6 +119,12 @@ void EventReport::SendExtensionEvent(const std::string &eventName, HiSysEventTyp
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName,
|
||||
EVENT_KEY_ERROR_CODE, eventInfo.errCode);
|
||||
} else if (eventName == DISCONNECT_SERVICE_ERROR) {
|
||||
HiSysEvent::Write(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
type,
|
||||
EVENT_KEY_ERROR_CODE, eventInfo.errCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +153,8 @@ void EventReport::SendFormEvent(const std::string &eventName, HiSysEventType typ
|
||||
EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName,
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName);
|
||||
} else {
|
||||
} else if (eventName == DELETE_FORM || eventName == CASTTEMP_FORM || eventName == RELEASE_FORM ||
|
||||
eventName == SET_NEXT_REFRESH_TIME_FORM) {
|
||||
HiSysEvent::Write(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
eventName,
|
||||
|
Loading…
Reference in New Issue
Block a user