diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index 3f3cf0514d059135f6ffe853fb8cdd623bd9acf7..446e1cf296c748bedc449797938ff5c88c855a9d 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -332,6 +332,7 @@ ohos_shared_library("abilitykit_native") { public_configs = [ ":ability_public_config", "${ability_runtime_native_path}/ability:ability_context_public_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits_public_config", ] @@ -405,6 +406,8 @@ ohos_shared_library("abilitykit_native") { "jsoncpp:jsoncpp", "libuv:uv", "napi:ace_napi", + "relational_store:native_dataability", + "relational_store:native_rdb", ] defines = [] diff --git a/frameworks/native/ability/native/ability_impl.cpp b/frameworks/native/ability/native/ability_impl.cpp index 499d50e8d8b1e58f3d05ea5380ec2efef5bda8c5..6c9daee7df210056a3fa55b60753e4bfede7b90d 100644 --- a/frameworks/native/ability/native/ability_impl.cpp +++ b/frameworks/native/ability/native/ability_impl.cpp @@ -380,7 +380,7 @@ int AbilityImpl::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates & } std::shared_ptr AbilityImpl::Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) + const Uri &uri, const std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) { TAG_LOGD(AAFwkTag::ABILITY, "called"); return nullptr; diff --git a/frameworks/native/ability/native/ability_thread.cpp b/frameworks/native/ability/native/ability_thread.cpp index 4832062a6323bc27b98b33e9cd07049a12b0bce8..2e4e079dc8612d1c4b81152b4575fa01f14d555a 100644 --- a/frameworks/native/ability/native/ability_thread.cpp +++ b/frameworks/native/ability/native/ability_thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -88,218 +88,237 @@ void AbilityThread::AbilityThreadMain(const std::shared_ptr &ap TAG_LOGD(AAFwkTag::ABILITY, "end"); } -bool AbilityThread::ScheduleAbilityTransaction( - const Want &want, const LifeCycleStateInfo &targetState, sptr sessionInfo) +ErrCode AbilityThread::ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, + const sptr& sessionInfo) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return true; + return ERR_OK; } -void AbilityThread::ScheduleShareData(const int32_t &requestCode) +ErrCode AbilityThread::ScheduleShareData(int32_t requestCode) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleConnectAbility(const Want &want) +ErrCode AbilityThread::ScheduleConnectAbility(const Want &want) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleDisconnectAbility(const Want &want) +ErrCode AbilityThread::ScheduleDisconnectAbility(const Want &want) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int startId) +ErrCode AbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int startId) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleCommandAbilityWindow( - const Want &want, const sptr &sessionInfo, AAFwk::WindowCommand winCmd) +ErrCode AbilityThread::ScheduleCommandAbilityWindow( + const Want &want, const sptr &sessionInfo, int32_t winCmd) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -bool AbilityThread::SchedulePrepareTerminateAbility() +ErrCode AbilityThread::SchedulePrepareTerminateAbility() { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return false; + return ERR_OK; } -void AbilityThread::ScheduleSaveAbilityState() +ErrCode AbilityThread::ScheduleSaveAbilityState() { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleRestoreAbilityState(const PacMap &state) +ErrCode AbilityThread::ScheduleRestoreAbilityState(const PacMap &state) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::SendResult(int requestCode, int resultCode, const Want &resultData) +ErrCode AbilityThread::SendResult(int requestCode, int resultCode, const Want &resultData) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -std::vector AbilityThread::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) +ErrCode AbilityThread::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter, + std::vector& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - std::vector types; - return types; + return ERR_OK; } -int AbilityThread::OpenFile(const Uri &uri, const std::string &mode) +ErrCode AbilityThread::OpenFile(const Uri &uri, const std::string &mode, int& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -int AbilityThread::OpenRawFile(const Uri &uri, const std::string &mode) +ErrCode AbilityThread::OpenRawFile(const Uri &uri, const std::string &mode, int32_t& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -int AbilityThread::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) +ErrCode AbilityThread::Insert(const Uri &uri, const NativeRdb::AmValuesBucket &value, int32_t& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -std::shared_ptr AbilityThread::Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) +ErrCode AbilityThread::Call(const Uri &uri, const std::string &method, const std::string &arg, + const AppExecFwk::PacMap &pacMap, std::shared_ptr& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return nullptr; + return ERR_OK; } -int AbilityThread::Update( - const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates) +ErrCode AbilityThread::Update(const Uri &uri, const NativeRdb::AmValuesBucket &value, + const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -int AbilityThread::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) +ErrCode AbilityThread::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -std::shared_ptr AbilityThread::Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) +ErrCode AbilityThread::Query(const Uri &uri, const std::vector &columns, + const NativeRdb::DataAbilityPredicates &predicates, std::shared_ptr& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return nullptr; + return ERR_OK; } -std::string AbilityThread::GetType(const Uri &uri) +ErrCode AbilityThread::GetType(const Uri &uri, std::string& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ""; + return ERR_OK; } -bool AbilityThread::Reload(const Uri &uri, const PacMap &extras) +ErrCode AbilityThread::Reload(const Uri &uri, const PacMap &extras, bool& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return false; + return ERR_OK; } -int AbilityThread::BatchInsert(const Uri &uri, const std::vector &values) +ErrCode AbilityThread::BatchInsert(const Uri &uri, const std::vector &values, + int32_t& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -void AbilityThread::ContinueAbility(const std::string &deviceId, uint32_t versionCode) +ErrCode AbilityThread::ContinueAbility(const std::string &deviceId, uint32_t versionCode) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::NotifyContinuationResult(int32_t result) +ErrCode AbilityThread::NotifyContinuationResult(int32_t result) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -Uri AbilityThread::NormalizeUri(const Uri &uri) +ErrCode AbilityThread::NormalizeUri(const Uri &uri, AmUri& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return uri; + return ERR_OK; } -Uri AbilityThread::DenormalizeUri(const Uri &uri) +ErrCode AbilityThread::DenormalizeUri(const Uri &uri, AmUri& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return uri; + return ERR_OK; } -bool AbilityThread::ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) +ErrCode AbilityThread::ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return false; + return ERR_OK; } -bool AbilityThread::ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) +ErrCode AbilityThread::ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return false; + return ERR_OK; } -bool AbilityThread::ScheduleNotifyChange(const Uri &uri) +ErrCode AbilityThread::ScheduleNotifyChange(const Uri &uri) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return false; + return ERR_OK; } -void AbilityThread::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) +ErrCode AbilityThread::DumpAbilityInfo(const std::vector ¶ms) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::CallRequest() +ErrCode AbilityThread::CallRequest() { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::OnExecuteIntent(const Want &want) +ErrCode AbilityThread::OnExecuteIntent(const Want &want) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -std::vector> AbilityThread::ExecuteBatch( - const std::vector> &operations) +ErrCode AbilityThread::ExecuteBatch( + const std::vector> &operations, + std::vector>& funcResult) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - std::vector> results; - return results; + return ERR_OK; } -int AbilityThread::CreateModalUIExtension(const Want &want) +ErrCode AbilityThread::CreateModalUIExtension(const Want &want) { TAG_LOGD(AAFwkTag::ABILITY, "called"); - return ERR_INVALID_VALUE; + return ERR_OK; } -void AbilityThread::UpdateSessionToken(sptr sessionToken) +ErrCode AbilityThread::UpdateSessionToken(const sptr& sessionToken) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleCollaborate(const Want &want) +ErrCode AbilityThread::ScheduleCollaborate(const Want &want) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, +ErrCode AbilityThread::ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, const std::string &message) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } -void AbilityThread::ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) +ErrCode AbilityThread::ScheduleAbilityRequestSuccess(const std::string &requestId, + const AppExecFwk::ElementName &element) { TAG_LOGD(AAFwkTag::ABILITY, "called"); + return ERR_OK; } } // namespace AppExecFwk } // namespace OHOS diff --git a/frameworks/native/ability/native/continuation/distributed/reverse_continuation_scheduler_primary_stub.cpp b/frameworks/native/ability/native/continuation/distributed/reverse_continuation_scheduler_primary_stub.cpp index 46fb9293bf7d0980716b6dff2a034c9a9c1df88b..c7c6910726f39c3dad0f76eb53102f2914ffbe93 100644 --- a/frameworks/native/ability/native/continuation/distributed/reverse_continuation_scheduler_primary_stub.cpp +++ b/frameworks/native/ability/native/continuation/distributed/reverse_continuation_scheduler_primary_stub.cpp @@ -14,7 +14,7 @@ */ #include "reverse_continuation_scheduler_primary_stub.h" -#include "ability_scheduler_interface.h" +#include "iability_scheduler.h" #include "hilog_tag_wrapper.h" #include "string_ex.h" diff --git a/frameworks/native/ability/native/data_ability_helper_impl.cpp b/frameworks/native/ability/native/data_ability_helper_impl.cpp index ae8a96c12dee4ea4e56e3a1732973cf523d324db..ad360e41b3220272d5a77bfd1034badb3a17dd14 100644 --- a/frameworks/native/ability/native/data_ability_helper_impl.cpp +++ b/frameworks/native/ability/native/data_ability_helper_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -16,7 +16,7 @@ #include "data_ability_helper_impl.h" #include "ability_manager_client.h" -#include "ability_scheduler_interface.h" +#include "iability_scheduler.h" #include "ability_thread.h" #include "abs_shared_result_set.h" #include "hitrace_meter.h" @@ -304,7 +304,7 @@ std::vector DataAbilityHelperImpl::GetFileTypes(Uri &uri, const std return matchedMIMEs; } - matchedMIMEs = dataAbilityProxy->GetFileTypes(uri, mimeTypeFilter); + dataAbilityProxy->GetFileTypes(uri, mimeTypeFilter, matchedMIMEs); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "matchedMIMEs size: %{public}zu", matchedMIMEs.size()); @@ -331,7 +331,7 @@ int DataAbilityHelperImpl::OpenFile(Uri &uri, const std::string &mode) return fd; } - fd = dataAbilityProxy->OpenFile(uri, mode); + dataAbilityProxy->OpenFile(uri, mode, fd); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "fd: %{public}d", fd); @@ -358,8 +358,7 @@ int DataAbilityHelperImpl::OpenRawFile(Uri &uri, const std::string &mode) TAG_LOGE(AAFwkTag::DATA_ABILITY, "GetDataAbilityProxy failed"); return fd; } - - fd = dataAbilityProxy->OpenRawFile(uri, mode); + dataAbilityProxy->OpenRawFile(uri, mode, fd); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "fd: %{public}d", fd); @@ -383,7 +382,8 @@ int DataAbilityHelperImpl::Insert(Uri &uri, const NativeRdb::ValuesBucket &value return index; } - index = dataAbilityProxy->Insert(uri, value); + AmValuesBucket amValue(std::make_shared(value)); + dataAbilityProxy->Insert(uri, amValue, index); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "index: %{public}d", index); @@ -400,7 +400,7 @@ std::shared_ptr DataAbilityHelperImpl::Call( return result; } - result = dataAbilityProxy->Call(uri, method, arg, pacMap); + dataAbilityProxy->Call(uri, method, arg, pacMap, result); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "null result?: %{public}d", result == nullptr); @@ -426,7 +426,8 @@ int DataAbilityHelperImpl::Update( return index; } - index = dataAbilityProxy->Update(uri, value, predicates); + AmValuesBucket amValue(std::make_shared(value)); + dataAbilityProxy->Update(uri, amValue, predicates, index); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "index: %{public}d", index); @@ -450,7 +451,7 @@ int DataAbilityHelperImpl::Delete(Uri &uri, const NativeRdb::DataAbilityPredicat return index; } - index = dataAbilityProxy->Delete(uri, predicates); + dataAbilityProxy->Delete(uri, predicates, index); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "index: %{public}d", index); @@ -476,7 +477,11 @@ std::shared_ptr DataAbilityHelperImpl::Query( return resultset; } - resultset = dataAbilityProxy->Query(uri, columns, predicates); + std::shared_ptr amResultset = nullptr; + dataAbilityProxy->Query(uri, columns, predicates, amResultset); + if (amResultset != nullptr) { + resultset = amResultset->GetResultSet(); + } ReleaseDataAbility(dataAbilityProxy); TAG_LOGD(AAFwkTag::DATA_ABILITY, "null resultset?: %{public}d.", resultset == nullptr); @@ -500,7 +505,7 @@ std::string DataAbilityHelperImpl::GetType(Uri &uri) return type; } - type = dataAbilityProxy->GetType(uri); + dataAbilityProxy->GetType(uri, type); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "type: %{public}s", type.c_str()); @@ -526,7 +531,7 @@ bool DataAbilityHelperImpl::Reload(Uri &uri, const PacMap &extras) return ret; } - ret = dataAbilityProxy->Reload(uri, extras); + dataAbilityProxy->Reload(uri, extras, ret); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "ret: %{public}d", ret); @@ -550,7 +555,11 @@ int DataAbilityHelperImpl::BatchInsert(Uri &uri, const std::vectorBatchInsert(uri, values); + std::vector amValues; + for (auto &value : values) { + amValues.emplace_back(std::make_shared(value)); + } + dataAbilityProxy->BatchInsert(uri, amValues, ret); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "ret: %{public}d", ret); @@ -749,8 +758,9 @@ Uri DataAbilityHelperImpl::NormalizeUri(Uri &uri) return urivalue; } - urivalue = dataAbilityProxy->NormalizeUri(uri); - + AmUri amUri; + dataAbilityProxy->NormalizeUri(uri, amUri); + urivalue = amUri.uri; ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "uri: %{public}s", urivalue.ToString().c_str()); return urivalue; @@ -775,8 +785,9 @@ Uri DataAbilityHelperImpl::DenormalizeUri(Uri &uri) return urivalue; } - urivalue = dataAbilityProxy->DenormalizeUri(uri); - + AmUri amUri; + dataAbilityProxy->DenormalizeUri(uri, amUri); + urivalue = amUri.uri; ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "uri: %{public}s", urivalue.ToString().c_str()); return urivalue; @@ -792,7 +803,7 @@ std::vector> DataAbilityHelperImpl::ExecuteBa return results; } - results = dataAbilityProxy->ExecuteBatch(operations); + dataAbilityProxy->ExecuteBatch(operations, results); ReleaseDataAbility(dataAbilityProxy); TAG_LOGI(AAFwkTag::DATA_ABILITY, "results size: %{public}zu", results.size()); diff --git a/frameworks/native/ability/native/data_ability_impl.cpp b/frameworks/native/ability/native/data_ability_impl.cpp index d73a159db0a2fe85e86adb3f2682bbdfb28d563a..ac4af1fec2fca0e726da2bcdffc57ec18be93a07 100644 --- a/frameworks/native/ability/native/data_ability_impl.cpp +++ b/frameworks/native/ability/native/data_ability_impl.cpp @@ -224,7 +224,7 @@ int DataAbilityImpl::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicat * @return Returns the query result. */ std::shared_ptr DataAbilityImpl::Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) + const Uri &uri, const std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) { if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::DATA_ABILITY, "null ability_"); diff --git a/frameworks/native/ability/native/extension_ability_thread.cpp b/frameworks/native/ability/native/extension_ability_thread.cpp index f72fa0f4c2a0baf0747fcde775a4cb4ec02b887a..f5150882688de94c0553516a4f70453210028a36 100644 --- a/frameworks/native/ability/native/extension_ability_thread.cpp +++ b/frameworks/native/ability/native/extension_ability_thread.cpp @@ -388,19 +388,19 @@ void ExtensionAbilityThread::HandleExtensionUpdateConfiguration(const AppExecFwk TAG_LOGD(AAFwkTag::EXT, "End"); } -bool ExtensionAbilityThread::ScheduleAbilityTransaction( - const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, sptr sessionInfo) +ErrCode ExtensionAbilityThread::ScheduleAbilityTransaction( + const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, const sptr& sessionInfo) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::EXT, "Name: %{public}s, targeState: %{public}d, isNewWant: %{public}d", want.GetElement().GetAbilityName().c_str(), lifeCycleStateInfo.state, lifeCycleStateInfo.isNewWant); if (token_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null token_"); - return false; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want, lifeCycleStateInfo, sessionInfo]() { @@ -414,17 +414,17 @@ bool ExtensionAbilityThread::ScheduleAbilityTransaction( bool ret = abilityHandler_->PostTask(task, AppExecFwk::EventQueue::Priority::HIGH); if (!ret) { TAG_LOGE(AAFwkTag::EXT, "PostTask error"); - return false; + return ERR_INVALID_VALUE; } - return true; + return ERR_OK; } -void ExtensionAbilityThread::ScheduleConnectAbility(const Want &want) +ErrCode ExtensionAbilityThread::ScheduleConnectAbility(const Want &want) { TAG_LOGD(AAFwkTag::EXT, "called"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } FreezeUtil::GetInstance().AddLifecycleEvent(token_, "ExtensionAbilityThread::ScheduleConnectAbility"); @@ -441,15 +441,16 @@ void ExtensionAbilityThread::ScheduleConnectAbility(const Want &want) if (!ret) { TAG_LOGE(AAFwkTag::EXT, "PostTask error"); } + return ERR_OK; } -void ExtensionAbilityThread::ScheduleDisconnectAbility(const Want &want) +ErrCode ExtensionAbilityThread::ScheduleDisconnectAbility(const Want &want) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::EXT, "called"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want]() { @@ -464,20 +465,22 @@ void ExtensionAbilityThread::ScheduleDisconnectAbility(const Want &want) if (!ret) { TAG_LOGE(AAFwkTag::EXT, "PostTask error"); } + return ERR_OK; } -void ExtensionAbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int32_t startId) +ErrCode ExtensionAbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int32_t startId) { TAG_LOGD(AAFwkTag::EXT, "Begin startId: %{public}d", startId); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } ScheduleCommandAbilityInner(want, restart, startId); if (AppExecFwk::InsightIntentExecuteParam::IsInsightIntentExecute(want)) { ScheduleInsightIntentInner(want); } TAG_LOGD(AAFwkTag::EXT, "End"); + return ERR_OK; } void ExtensionAbilityThread::ScheduleCommandAbilityInner(const Want &want, bool restart, int32_t startId) @@ -514,13 +517,13 @@ void ExtensionAbilityThread::ScheduleInsightIntentInner(const Want &want) } } -void ExtensionAbilityThread::ScheduleCommandAbilityWindow( - const Want &want, const sptr &sessionInfo, AAFwk::WindowCommand winCmd) +ErrCode ExtensionAbilityThread::ScheduleCommandAbilityWindow( + const Want &want, const sptr &sessionInfo, int32_t winCmd) { TAG_LOGD(AAFwkTag::EXT, "Begin, winCmd: %{public}d", winCmd); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want, sessionInfo, winCmd]() { @@ -529,21 +532,22 @@ void ExtensionAbilityThread::ScheduleCommandAbilityWindow( TAG_LOGE(AAFwkTag::EXT, "null abilityThread"); return; } - abilityThread->HandleCommandExtensionWindow(want, sessionInfo, winCmd); + abilityThread->HandleCommandExtensionWindow(want, sessionInfo, static_cast(winCmd)); }; bool ret = abilityHandler_->PostTask(task, AppExecFwk::EventQueue::Priority::HIGH); if (!ret) { TAG_LOGE(AAFwkTag::EXT, "PostTask error"); } TAG_LOGD(AAFwkTag::EXT, "End"); + return ERR_OK; } -void ExtensionAbilityThread::SendResult(int requestCode, int resultCode, const Want &want) +ErrCode ExtensionAbilityThread::SendResult(int requestCode, int resultCode, const Want &want) { TAG_LOGD(AAFwkTag::EXT, "Begin"); if (abilityHandler_ == nullptr || requestCode == -1) { TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_ or requestCode -1"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; @@ -565,6 +569,7 @@ void ExtensionAbilityThread::SendResult(int requestCode, int resultCode, const W TAG_LOGE(AAFwkTag::EXT, "PostTask error"); } TAG_LOGD(AAFwkTag::EXT, "End"); + return ERR_OK; } void ExtensionAbilityThread::NotifyMemoryLevel(int32_t level) @@ -577,12 +582,12 @@ void ExtensionAbilityThread::NotifyMemoryLevel(int32_t level) extensionImpl_->NotifyMemoryLevel(level); } -void ExtensionAbilityThread::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) +ErrCode ExtensionAbilityThread::DumpAbilityInfo(const std::vector ¶ms) { TAG_LOGD(AAFwkTag::EXT, "Begin"); if (token_ == nullptr || abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null token_ or abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, params, token = token_]() { @@ -603,6 +608,7 @@ void ExtensionAbilityThread::DumpAbilityInfo(const std::vector &par TAG_LOGE(AAFwkTag::EXT, "PostTask error"); } TAG_LOGD(AAFwkTag::EXT, "End"); + return ERR_OK; } void ExtensionAbilityThread::DumpAbilityInfoInner( diff --git a/frameworks/native/ability/native/extension_impl.cpp b/frameworks/native/ability/native/extension_impl.cpp index ea559e946cdf73b21f258f608469de932edbc04b..16454f351e99c85235e75a96f479bfb003c32426 100644 --- a/frameworks/native/ability/native/extension_impl.cpp +++ b/frameworks/native/ability/native/extension_impl.cpp @@ -117,7 +117,7 @@ void ExtensionImpl::HandleExtensionTransaction(const Want &want, const AAFwk::Li } if (ret && !UIExtensionAbilityExecuteInsightIntent(want)) { TAG_LOGD(AAFwkTag::EXT, "call abilityms"); - AAFwk::PacMap restoreData; + PacMap restoreData; AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, restoreData); } } @@ -242,7 +242,7 @@ void ExtensionImpl::Stop(bool &isAsyncCallback, const Want &want, sptrAbilityTransitionDone(token_, state, restoreData); } diff --git a/frameworks/native/ability/native/fa_ability_thread.cpp b/frameworks/native/ability/native/fa_ability_thread.cpp index 86d32d4b1015df2a6872b4b6d2b2f6033715318a..82d3e38ae0f7ff7332234014a278a60cc8cc9171 100644 --- a/frameworks/native/ability/native/fa_ability_thread.cpp +++ b/frameworks/native/ability/native/fa_ability_thread.cpp @@ -642,25 +642,27 @@ void FAAbilityThread::HandleRestoreAbilityState(const AppExecFwk::PacMap &state) abilityImpl_->DispatchRestoreAbilityState(state); } -void FAAbilityThread::ScheduleSaveAbilityState() +ErrCode FAAbilityThread::ScheduleSaveAbilityState() { TAG_LOGD(AAFwkTag::FA, "begin"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->DispatchSaveAbilityState(); + return ERR_OK; } -void FAAbilityThread::ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) +ErrCode FAAbilityThread::ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) { TAG_LOGD(AAFwkTag::FA, "begin"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->DispatchRestoreAbilityState(state); + return ERR_OK; } void FAAbilityThread::ScheduleUpdateConfiguration(const AppExecFwk::Configuration &config) @@ -712,8 +714,8 @@ void FAAbilityThread::HandleExtensionUpdateConfiguration(const AppExecFwk::Confi extensionImpl_->ScheduleUpdateConfiguration(config); } -bool FAAbilityThread::ScheduleAbilityTransaction( - const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, sptr sessionInfo) +ErrCode FAAbilityThread::ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, + const sptr& sessionInfo) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::FA, "Lifecycle: name:%{public}s,targeState:%{public}d,isNewWant:%{public}d", @@ -725,11 +727,11 @@ bool FAAbilityThread::ScheduleAbilityTransaction( if (token_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null token_"); - return false; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want, lifeCycleStateInfo, sessionInfo]() { @@ -749,21 +751,21 @@ bool FAAbilityThread::ScheduleAbilityTransaction( bool ret = abilityHandler_->PostTask(task, "FAAbilityThread:AbilityTransaction"); if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); - return false; + return ERR_INVALID_VALUE; } - return true; + return ERR_OK; } -void FAAbilityThread::ScheduleShareData(const int32_t &uniqueId) +ErrCode FAAbilityThread::ScheduleShareData(int32_t uniqueId) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); if (token_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null token_"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, uniqueId]() { @@ -778,14 +780,15 @@ void FAAbilityThread::ScheduleShareData(const int32_t &uniqueId) if (!ret) { TAG_LOGE(AAFwkTag::FA, "postTask error"); } + return ERR_OK; } -void FAAbilityThread::ScheduleConnectAbility(const Want &want) +ErrCode FAAbilityThread::ScheduleConnectAbility(const Want &want) { TAG_LOGD(AAFwkTag::FA, "begin, isExtension_: %{public}d", isExtension_); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want]() { @@ -804,15 +807,16 @@ void FAAbilityThread::ScheduleConnectAbility(const Want &want) if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); } + return ERR_OK; } -void FAAbilityThread::ScheduleDisconnectAbility(const Want &want) +ErrCode FAAbilityThread::ScheduleDisconnectAbility(const Want &want) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::FA, "begin, isExtension: %{public}d", isExtension_); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want]() { @@ -831,14 +835,15 @@ void FAAbilityThread::ScheduleDisconnectAbility(const Want &want) if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); } + return ERR_OK; } -void FAAbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int startId) +ErrCode FAAbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int32_t startId) { TAG_LOGD(AAFwkTag::FA, "begin. startId: %{public}d", startId); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want, restart, startId]() { @@ -866,23 +871,24 @@ void FAAbilityThread::ScheduleCommandAbility(const Want &want, bool restart, int if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); } + return ERR_OK; } -bool FAAbilityThread::SchedulePrepareTerminateAbility() +ErrCode FAAbilityThread::SchedulePrepareTerminateAbility() { TAG_LOGD(AAFwkTag::FA, "begin"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return false; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } if (getpid() == gettid()) { bool ret = abilityImpl_->PrepareTerminateAbility(); TAG_LOGD(AAFwkTag::FA, "end, ret = %{public}d", ret); - return ret; + return ret ? ERR_OK : ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak]() { @@ -896,7 +902,7 @@ bool FAAbilityThread::SchedulePrepareTerminateAbility() bool ret = abilityHandler_->PostTask(task, "FAAbilityThread:PrepareTerminateAbility"); if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); - return false; + return ERR_INVALID_VALUE; } std::unique_lock lock(mutex_); @@ -912,16 +918,16 @@ bool FAAbilityThread::SchedulePrepareTerminateAbility() TAG_LOGW(AAFwkTag::FA, "Wait timeout"); } TAG_LOGD(AAFwkTag::FA, "end, ret = %{public}d", isPrepareTerminate_); - return isPrepareTerminate_; + return isPrepareTerminate_ ? ERR_OK : ERR_INVALID_VALUE; } -void FAAbilityThread::ScheduleCommandAbilityWindow( - const Want &want, const sptr &sessionInfo, AAFwk::WindowCommand winCmd) +ErrCode FAAbilityThread::ScheduleCommandAbilityWindow( + const Want &want, const sptr &sessionInfo, int32_t winCmd) { TAG_LOGD(AAFwkTag::FA, "begin"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want, sessionInfo, winCmd]() { @@ -930,20 +936,21 @@ void FAAbilityThread::ScheduleCommandAbilityWindow( TAG_LOGE(AAFwkTag::FA, "null abilityThread"); return; } - abilityThread->HandleCommandExtensionWindow(want, sessionInfo, winCmd); + abilityThread->HandleCommandExtensionWindow(want, sessionInfo, static_cast(winCmd)); }; bool ret = abilityHandler_->PostTask(task, "FAAbilityThread:CommandAbilityWindow"); if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); } + return ERR_OK; } -void FAAbilityThread::SendResult(int requestCode, int resultCode, const Want &want) +ErrCode FAAbilityThread::SendResult(int requestCode, int resultCode, const Want &want) { TAG_LOGD(AAFwkTag::FA, "begin"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, requestCode, resultCode, want]() { @@ -970,150 +977,176 @@ void FAAbilityThread::SendResult(int requestCode, int resultCode, const Want &wa if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); } + return ERR_OK; } -std::vector FAAbilityThread::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) +ErrCode FAAbilityThread::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter, + std::vector& funcResult) { TAG_LOGD(AAFwkTag::FA, "begin"); - std::vector types; if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return types; + return ERR_INVALID_VALUE; } - types = abilityImpl_->GetFileTypes(uri, mimeTypeFilter); - return types; + funcResult = abilityImpl_->GetFileTypes(uri, mimeTypeFilter); + return ERR_OK; } -int FAAbilityThread::OpenFile(const Uri &uri, const std::string &mode) +ErrCode FAAbilityThread::OpenFile(const Uri &uri, const std::string &mode, int& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return -1; + funcResult = -1; + return ERR_OK; } - return abilityImpl_->OpenFile(uri, mode); + funcResult = abilityImpl_->OpenFile(uri, mode); + return ERR_OK; } -int FAAbilityThread::OpenRawFile(const Uri &uri, const std::string &mode) +ErrCode FAAbilityThread::OpenRawFile(const Uri &uri, const std::string &mode, int& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return -1; + funcResult = -1; + return ERR_OK; } - return abilityImpl_->OpenRawFile(uri, mode); + funcResult = abilityImpl_->OpenRawFile(uri, mode); + return ERR_OK; } -int FAAbilityThread::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) +int FAAbilityThread::Insert(const Uri &uri, const NativeRdb::AmValuesBucket &value, int32_t& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return -1; + funcResult = -1; + return ERR_OK; } - - return abilityImpl_->Insert(uri, value); + funcResult = abilityImpl_->Insert(uri, *(value.GetValuesBucket())); + return ERR_OK; } -std::shared_ptr FAAbilityThread::Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) +ErrCode FAAbilityThread::FAAbilityThread::Call( + const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap, + std::shared_ptr& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return nullptr; + funcResult = nullptr; + return ERR_OK; } - - return abilityImpl_->Call(uri, method, arg, pacMap); + funcResult = abilityImpl_->Call(uri, method, arg, pacMap); + return ERR_OK; } -int FAAbilityThread::Update( - const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates) +ErrCode FAAbilityThread::Update(const Uri &uri, const NativeRdb::AmValuesBucket &value, + const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return -1; + funcResult = -1; + return ERR_OK; } - return abilityImpl_->Update(uri, value, predicates); + funcResult = abilityImpl_->Update(uri, *(value.GetValuesBucket()), predicates);; + return ERR_OK; } -int FAAbilityThread::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) +ErrCode FAAbilityThread::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return -1; + funcResult = -1; + return ERR_OK; } - return abilityImpl_->Delete(uri, predicates); + funcResult = abilityImpl_->Delete(uri, predicates); + return ERR_OK; } -std::shared_ptr FAAbilityThread::Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) +ErrCode FAAbilityThread::Query(const Uri &uri, const std::vector &columns, + const NativeRdb::DataAbilityPredicates &predicates, std::shared_ptr& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return nullptr; + funcResult = nullptr; + return ERR_OK; } - - return abilityImpl_->Query(uri, columns, predicates); + std::shared_ptr ret = abilityImpl_->Query(uri, columns, predicates); + funcResult = std::make_shared(ret); + return ERR_OK; } -std::string FAAbilityThread::GetType(const Uri &uri) +ErrCode FAAbilityThread::GetType(const Uri &uri, std::string& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); std::string type; if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return ""; + funcResult = ""; + return ERR_OK; } - return abilityImpl_->GetType(uri); + funcResult = abilityImpl_->GetType(uri); + return ERR_OK; } -bool FAAbilityThread::Reload(const Uri &uri, const AppExecFwk::PacMap &extras) +ErrCode FAAbilityThread::Reload(const Uri &uri, const AppExecFwk::PacMap &extras, bool& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return false; + funcResult = false; + return ERR_OK; } - return abilityImpl_->Reload(uri, extras); + funcResult = abilityImpl_->Reload(uri, extras); + return ERR_OK; } -int FAAbilityThread::BatchInsert(const Uri &uri, const std::vector &values) +ErrCode FAAbilityThread::BatchInsert(const Uri &uri, const std::vector &values, + int32_t& funcResult) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return -1; + funcResult = -1; + return ERR_OK; } - - return abilityImpl_->BatchInsert(uri, values); + std::vector tmpValues; + for(auto &value : values) { + tmpValues.push_back(*(value.GetValuesBucket())); + } + funcResult = abilityImpl_->BatchInsert(uri, tmpValues); + return ERR_OK; } -void FAAbilityThread::ContinueAbility(const std::string &deviceId, uint32_t versionCode) +ErrCode FAAbilityThread::ContinueAbility(const std::string &deviceId, uint32_t versionCode) { TAG_LOGD(AAFwkTag::FA, "begin"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->ContinueAbility(deviceId, versionCode); + return ERR_OK; } -void FAAbilityThread::NotifyContinuationResult(int32_t result) +ErrCode FAAbilityThread::NotifyContinuationResult(int32_t result) { TAG_LOGD(AAFwkTag::FA, "begin, result: %{public}d", result); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->NotifyContinuationResult(result); + return ERR_OK; } void FAAbilityThread::NotifyMemoryLevel(int32_t level) @@ -1158,30 +1191,34 @@ void FAAbilityThread::InitExtensionFlag(const std::shared_ptrNormalizeUri(uri); - return urivalue; + funcResult = AmUri(urivalue); + return ERR_OK; } -Uri FAAbilityThread::DenormalizeUri(const Uri &uri) +ErrCode FAAbilityThread::DenormalizeUri(const Uri &uri, AmUri& funcResult) { TAG_LOGD(AAFwkTag::FA, "begin"); Uri urivalue(""); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl"); - return urivalue; + funcResult = AmUri(urivalue); + return ERR_OK; } urivalue = abilityImpl_->DenormalizeUri(uri); - return urivalue; + funcResult = AmUri(urivalue); + return ERR_OK; } bool FAAbilityThread::HandleRegisterObserver(const Uri &uri, const sptr &dataObserver) @@ -1232,12 +1269,12 @@ bool FAAbilityThread::HandleNotifyChange(const Uri &uri) return true; } -bool FAAbilityThread::ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) +ErrCode FAAbilityThread::ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, uri, dataObserver]() { @@ -1251,16 +1288,18 @@ bool FAAbilityThread::ScheduleRegisterObserver(const Uri &uri, const sptrPostTask(task, "FAAbilityThread:RegisterObserver"); if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); + return ERR_INVALID_VALUE; } - return ret; + return ERR_OK; } -bool FAAbilityThread::ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) +ErrCode FAAbilityThread::ScheduleUnregisterObserver(const Uri &uri, + const sptr &dataObserver) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, uri, dataObserver]() { @@ -1274,16 +1313,17 @@ bool FAAbilityThread::ScheduleUnregisterObserver(const Uri &uri, const sptrPostSyncTask(task, "FAAbilityThread:UnregisterObserver"); if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); + return ERR_INVALID_VALUE; } - return ret; + return ERR_OK; } -bool FAAbilityThread::ScheduleNotifyChange(const Uri &uri) +ErrCode FAAbilityThread::ScheduleNotifyChange(const Uri &uri) { TAG_LOGD(AAFwkTag::FA, "called"); if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, uri]() { @@ -1297,22 +1337,23 @@ bool FAAbilityThread::ScheduleNotifyChange(const Uri &uri) bool ret = abilityHandler_->PostTask(task, "FAAbilityThread:NotifyChange"); if (!ret) { TAG_LOGE(AAFwkTag::FA, "PostTask error"); + return ERR_INVALID_VALUE; } - return ret; + return ERR_OK; } -std::vector> FAAbilityThread::ExecuteBatch( - const std::vector> &operations) +ErrCode FAAbilityThread::ExecuteBatch( + const std::vector> &operations, + std::vector>& funcResult) { TAG_LOGD(AAFwkTag::FA, "begin"); - std::vector> results; if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityImpl_"); - results.clear(); - return results; + funcResult.clear(); + return ERR_OK; } - results = abilityImpl_->ExecuteBatch(operations); - return results; + funcResult = abilityImpl_->ExecuteBatch(operations); + return ERR_OK; } std::shared_ptr FAAbilityThread::BuildAbilityContext( @@ -1332,16 +1373,16 @@ std::shared_ptr FAAbilityThread::BuildAbilityContext( return abilityContextImpl; } -void FAAbilityThread::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) +ErrCode FAAbilityThread::DumpAbilityInfo(const std::vector ¶ms) { TAG_LOGD(AAFwkTag::FA, "begin"); if (token_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null token_"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, params, token = token_]() { @@ -1358,6 +1399,7 @@ void FAAbilityThread::DumpAbilityInfo(const std::vector ¶ms, st } }; abilityHandler_->PostTask(task, "FAAbilityThread:DumpAbilityInfo"); + return ERR_OK; } #ifdef SUPPORT_SCREEN @@ -1438,16 +1480,16 @@ void FAAbilityThread::DumpOtherInfo(std::vector &info) } } -void FAAbilityThread::CallRequest() +ErrCode FAAbilityThread::CallRequest() { TAG_LOGD(AAFwkTag::FA, "begin"); if (currentAbility_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null ability"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } sptr retval = nullptr; @@ -1463,6 +1505,7 @@ void FAAbilityThread::CallRequest() }; abilityHandler_->PostSyncTask(syncTask, "FAAbilityThread:CallRequest"); AbilityManagerClient::GetInstance()->CallRequestDone(token_, retval); + return ERR_OK; } void FAAbilityThread::HandlePrepareTermianteAbility() @@ -1488,15 +1531,16 @@ int FAAbilityThread::CreateModalUIExtension(const Want &want) return currentAbility_->CreateModalUIExtension(want); } #endif //SUPPORT_SCREEN -void FAAbilityThread::UpdateSessionToken(sptr sessionToken) +ErrCode FAAbilityThread::UpdateSessionToken(const sptr& sessionToken) { if (currentAbility_ == nullptr) { TAG_LOGE(AAFwkTag::FA, "null current ability"); - return; + return ERR_INVALID_VALUE; } #ifdef SUPPORT_SCREEN currentAbility_->UpdateSessionToken(sessionToken); #endif //SUPPORT_SCREEN + return ERR_OK; } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/ability/native/ui_ability_thread.cpp b/frameworks/native/ability/native/ui_ability_thread.cpp index 1b2afe1743e957a21ec6501c16b92d09a7e5a549..e815c17257ce52369ad654a97696c3a88b78a62e 100644 --- a/frameworks/native/ability/native/ui_ability_thread.cpp +++ b/frameworks/native/ability/native/ui_ability_thread.cpp @@ -267,25 +267,27 @@ void UIAbilityThread::HandleShareData(const int32_t &uniqueId) abilityImpl_->HandleShareData(uniqueId); } -void UIAbilityThread::ScheduleSaveAbilityState() +ErrCode UIAbilityThread::ScheduleSaveAbilityState() { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->DispatchSaveAbilityState(); + return ERR_OK; } -void UIAbilityThread::ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) +ErrCode UIAbilityThread::ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->DispatchRestoreAbilityState(state); + return ERR_OK; } void UIAbilityThread::ScheduleUpdateConfiguration(const AppExecFwk::Configuration &config) @@ -305,8 +307,8 @@ void UIAbilityThread::HandleUpdateConfiguration(const AppExecFwk::Configuration abilityImpl_->ScheduleUpdateConfiguration(config); } -bool UIAbilityThread::ScheduleAbilityTransaction( - const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, sptr sessionInfo) +ErrCode UIAbilityThread::ScheduleAbilityTransaction( + const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, const sptr& sessionInfo) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::UIABILITY, "name:%{public}s,targeState:%{public}d,isNewWant:%{public}d", @@ -318,11 +320,11 @@ bool UIAbilityThread::ScheduleAbilityTransaction( if (token_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null token_"); - return false; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want, lifeCycleStateInfo, sessionInfo]() { @@ -337,21 +339,21 @@ bool UIAbilityThread::ScheduleAbilityTransaction( bool ret = abilityHandler_->PostTask(task, "UIAbilityThread:AbilityTransaction"); if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); - return false; + return ERR_INVALID_VALUE; } - return true; + return ERR_OK; } -void UIAbilityThread::ScheduleShareData(const int32_t &uniqueId) +ErrCode UIAbilityThread::ScheduleShareData(int32_t uniqueId) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); if (token_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null token_"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, uniqueId]() { @@ -365,18 +367,22 @@ void UIAbilityThread::ScheduleShareData(const int32_t &uniqueId) bool ret = abilityHandler_->PostTask(task, "UIAbilityThread:ShareData"); if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); + return ERR_INVALID_VALUE; } + return ERR_OK; } -bool UIAbilityThread::SchedulePrepareTerminateAbility() +ErrCode UIAbilityThread::SchedulePrepareTerminateAbility() { if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_"); - return false; + return ERR_INVALID_VALUE; } if (getpid() == gettid()) { TAG_LOGE(AAFwkTag::UIABILITY, "in app main thread"); - return HandlePrepareTermianteAbility(); + if (!HandlePrepareTermianteAbility()) { + return ERR_INVALID_VALUE; + } } wptr weak = this; auto task = [weak]() { @@ -391,9 +397,9 @@ bool UIAbilityThread::SchedulePrepareTerminateAbility() bool ret = abilityHandler_->PostTask(task, "UIAbilityThread:PrepareTerminateAbility"); if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); - return false; + return ERR_INVALID_VALUE; } - return true; + return ERR_OK; } bool UIAbilityThread::HandlePrepareTermianteAbility() @@ -425,12 +431,12 @@ bool UIAbilityThread::HandlePrepareTermianteAbility() return true; } -void UIAbilityThread::SendResult(int requestCode, int resultCode, const Want &want) +ErrCode UIAbilityThread::SendResult(int requestCode, int resultCode, const Want &want) { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (abilityHandler_ == nullptr || requestCode == -1) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_ or requestCode is -1"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; @@ -451,26 +457,29 @@ void UIAbilityThread::SendResult(int requestCode, int resultCode, const Want &wa if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); } + return ERR_OK; } -void UIAbilityThread::ContinueAbility(const std::string &deviceId, uint32_t versionCode) +ErrCode UIAbilityThread::ContinueAbility(const std::string &deviceId, uint32_t versionCode) { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->ContinueAbility(deviceId, versionCode); + return ERR_OK; } -void UIAbilityThread::NotifyContinuationResult(int32_t result) +ErrCode UIAbilityThread::NotifyContinuationResult(int32_t result) { TAG_LOGD(AAFwkTag::UIABILITY, "result: %{public}d", result); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } abilityImpl_->NotifyContinuationResult(result); + return ERR_OK; } void UIAbilityThread::NotifyMemoryLevel(int32_t level) @@ -501,16 +510,16 @@ std::shared_ptr UIAbilityThread::BuildAbilityContext( return abilityContextImpl; } -void UIAbilityThread::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) +ErrCode UIAbilityThread::DumpAbilityInfo(const std::vector ¶ms) { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (token_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null token_"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, params, token = token_]() { @@ -527,6 +536,7 @@ void UIAbilityThread::DumpAbilityInfo(const std::vector ¶ms, st } }; abilityHandler_->PostTask(task, "UIAbilityThread:DumpAbilityInfo"); + return ERR_OK; } #ifdef SUPPORT_SCREEN @@ -598,16 +608,16 @@ void UIAbilityThread::DumpOtherInfo(std::vector &info) } } -void UIAbilityThread::CallRequest() +ErrCode UIAbilityThread::CallRequest() { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (currentAbility_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null ability"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } sptr retval = nullptr; @@ -624,19 +634,20 @@ void UIAbilityThread::CallRequest() abilityHandler_->PostSyncTask(syncTask, "UIAbilityThread:CallRequest"); AbilityManagerClient::GetInstance()->CallRequestDone(token_, retval); TAG_LOGD(AAFwkTag::UIABILITY, "end"); + return ERR_OK; } -void UIAbilityThread::OnExecuteIntent(const Want &want) +ErrCode UIAbilityThread::OnExecuteIntent(const Want &want) { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } if (abilityHandler_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityHandler_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; @@ -652,6 +663,7 @@ void UIAbilityThread::OnExecuteIntent(const Want &want) } }; abilityHandler_->PostTask(task, "UIAbilityThread:OnExecuteIntent"); + return ERR_OK; } #ifdef SUPPORT_SCREEN @@ -665,23 +677,24 @@ int UIAbilityThread::CreateModalUIExtension(const Want &want) return currentAbility_->CreateModalUIExtension(want); } #endif //SUPPORT_SCREEN -void UIAbilityThread::UpdateSessionToken(sptr sessionToken) +ErrCode UIAbilityThread::UpdateSessionToken(const sptr& sessionToken) { if (currentAbility_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null current ability"); - return; + return ERR_INVALID_VALUE; } #ifdef SUPPORT_SCREEN currentAbility_->UpdateSessionToken(sessionToken); #endif //SUPPORT_SCREEN + return ERR_OK; } -void UIAbilityThread::ScheduleCollaborate(const Want &want) +ErrCode UIAbilityThread::ScheduleCollaborate(const Want &want) { TAG_LOGD(AAFwkTag::UIABILITY, "called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, want]() { @@ -698,17 +711,18 @@ void UIAbilityThread::ScheduleCollaborate(const Want &want) bool ret = abilityHandler_->PostTask(task, "UIAbilityThread:ScheduleCollaborate"); if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); - return; + return ERR_INVALID_VALUE; } + return ERR_OK; } -void UIAbilityThread::ScheduleAbilityRequestFailure(const std::string &requestId, +ErrCode UIAbilityThread::ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, const std::string &message) { TAG_LOGD(AAFwkTag::UIABILITY, "ScheduleAbilityRequestFailure called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, requestId, element, message]() { @@ -725,17 +739,18 @@ void UIAbilityThread::ScheduleAbilityRequestFailure(const std::string &requestId bool ret = abilityHandler_->PostTask(task, "UIAbilityThread:ScheduleAbilityRequestFailure"); if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); - return; + return ERR_INVALID_VALUE; } + return ERR_OK; } -void UIAbilityThread::ScheduleAbilityRequestSuccess(const std::string &requestId, +ErrCode UIAbilityThread::ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) { TAG_LOGD(AAFwkTag::UIABILITY, "ScheduleAbilityRequestSuccess called"); if (abilityImpl_ == nullptr) { TAG_LOGE(AAFwkTag::UIABILITY, "null abilityImpl_"); - return; + return ERR_INVALID_VALUE; } wptr weak = this; auto task = [weak, requestId, element]() { @@ -752,8 +767,9 @@ void UIAbilityThread::ScheduleAbilityRequestSuccess(const std::string &requestId bool ret = abilityHandler_->PostTask(task, "UIAbilityThread:ScheduleAbilityRequestSuccess"); if (!ret) { TAG_LOGE(AAFwkTag::UIABILITY, "postTask error"); - return; + return ERR_INVALID_VALUE; } + return ERR_OK; } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp index 6071ca92bfd750e6a87b86e67fb60f1f6539a24b..d210c23ef2c7ec909152bf4fdf700db7b46cba1d 100755 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp @@ -641,7 +641,7 @@ void JsUIExtension::PostInsightIntentExecuted(const sptr &se if (needForeground) { // If need foreground, that means triggered by onForeground. TAG_LOGI(AAFwkTag::UI_EXT, "call abilityms"); - AAFwk::PacMap restoreData; + PacMap restoreData; AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, AAFwk::ABILITY_STATE_FOREGROUND_NEW, restoreData); } else { diff --git a/frameworks/native/ability/native/ui_extension_base/cj_ui_extension_base.cpp b/frameworks/native/ability/native/ui_extension_base/cj_ui_extension_base.cpp index b71b78172bd12ed1138b856b8824e30f0554c029..f1999475fe0b7a75377653f1631dfb84544e1cc5 100644 --- a/frameworks/native/ability/native/ui_extension_base/cj_ui_extension_base.cpp +++ b/frameworks/native/ability/native/ui_extension_base/cj_ui_extension_base.cpp @@ -380,7 +380,7 @@ void CJUIExtensionBase::PostInsightIntentExecuted(const sptr if (needForeground) { // If need foreground, that means triggered by onForeground. TAG_LOGI(AAFwkTag::UI_EXT, "call abilityms"); - AAFwk::PacMap restoreData; + PacMap restoreData; AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, AAFwk::ABILITY_STATE_FOREGROUND_NEW, restoreData); } else { diff --git a/frameworks/native/ability/native/ui_extension_base/js_ui_extension_base.cpp b/frameworks/native/ability/native/ui_extension_base/js_ui_extension_base.cpp index f8f67de6ff92e3c324cbd27b43de985f982ac665..b65a0575a34ddeab41ce78cdafa353f41d38deaa 100644 --- a/frameworks/native/ability/native/ui_extension_base/js_ui_extension_base.cpp +++ b/frameworks/native/ability/native/ui_extension_base/js_ui_extension_base.cpp @@ -580,7 +580,7 @@ void JsUIExtensionBase::PostInsightIntentExecuted(const sptr if (needForeground) { // If need foreground, that means triggered by onForeground. TAG_LOGI(AAFwkTag::UI_EXT, "call abilityms"); - AAFwk::PacMap restoreData; + PacMap restoreData; AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, AAFwk::ABILITY_STATE_FOREGROUND_NEW, restoreData); } else { diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 8bb1055efa0185b2c06da59016a9a25776c4c803..612d8bcd7b89c5b6c026e20267fc4f9622bb92c7 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -11,9 +11,27 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") +idl_gen_interface("ability_manager_interface") { + sources = [ + "IAbilityScheduler.idl", + ] + log_domainid = "0xD001336" + log_tag = "AbilityMgr" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +config("ability_manager_idl_config") { + include_dirs = [ + "${ability_runtime_innerkits_path}/dataobs_manager/include", + "${target_gen_dir}", + ] +} + config("ability_manager_public_config") { visibility = [ ":*" ] visibility += [ @@ -40,6 +58,7 @@ config("ability_manager_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", "${ability_runtime_path}/interfaces/kits/native/appkit", "${ability_runtime_innerkits_path}/dataobs_manager/include", + "${target_gen_dir}", ] defines = [] @@ -62,7 +81,171 @@ config("ability_manager_public_config") { } } +ohos_source_set("ability_manager_proxy") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":ability_manager_interface") + source_values = [ + "*ability_scheduler_proxy.cpp", + ] + sources = filter_include(output_values, source_values) + public_configs = [ + ":ability_manager_idl_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + public_deps = [ ":ability_connect_callback_stub" ] + + deps = [ + ":ability_manager_interface", + ":ability_start_options", + ":ability_start_setting", + ":mission_info", + ":process_options", + ":start_window_option", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + ] + + external_deps = [ + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "samgr:samgr_proxy", + ] + + if (host_cpu != "arm64") { + external_deps += [ "relational_store:native_rdb" ] + } + + public_external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "init:libbegetutil", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", + ] + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "ability_base:session_info", + "image_framework:image_native", + "window_manager:libwsutils", + "window_manager:session_manager_lite", + ] + public_external_deps += [ "graphic_2d:color_manager" ] + } + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_source_set("ability_manager_stub") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":ability_manager_interface") + source_values = [ + "*ability_scheduler_stub.cpp", + ] + sources = filter_include(output_values, source_values) + + public_configs = [ + ":ability_manager_idl_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + + public_deps = [ ":ability_connect_callback_stub" ] + + deps = [ + ":ability_manager_interface", + ":ability_start_options", + ":ability_start_setting", + ":mission_info", + ":process_options", + ":start_window_option", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + ] + + external_deps = [ + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "samgr:samgr_proxy", + ] + + if (host_cpu != "arm64") { + external_deps += [ "relational_store:native_rdb" ] + } + + public_external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "background_task_mgr:bgtaskmgr_innerkits", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "init:libbegetutil", + "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", + ] + + if (ability_runtime_graphics) { + deps += [] + external_deps += [ + "ability_base:session_info", + "image_framework:image_native", + "window_manager:libwsutils", + "window_manager:session_manager_lite", + ] + public_external_deps += [ "graphic_2d:color_manager" ] + } + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("ability_manager") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } use_exceptions = true branch_protector_ret = "pac_ret" @@ -76,7 +259,7 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/ability_manager_client.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_manager_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_running_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_stub.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_recipient.cpp", "${ability_runtime_services_path}/abilitymgr/src/acquire_share_data_callback_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/acquire_share_data_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/auto_startup_info.cpp", @@ -111,6 +294,8 @@ ohos_shared_library("ability_manager") { "src/aa_tools/ability_start_with_wait_data.cpp", "src/aa_tools/ability_start_with_wait_observer_proxy.cpp", "src/aa_tools/ability_start_with_wait_observer_stub.cpp", + "src/am_abs_shared_result_set.cpp", + "src/am_values_bucket.cpp", "src/hidden_start_observer_proxy.cpp", "src/hidden_start_observer_stub.cpp", "src/status_bar_delegate/status_bar_delegate_proxy.cpp", @@ -129,12 +314,14 @@ ohos_shared_library("ability_manager") { public_configs = [ ":ability_manager_public_config", + ":ability_manager_idl_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", ] public_deps = [ ":ability_connect_callback_stub" ] deps = [ + ":ability_manager_stub", ":ability_start_options", ":ability_start_setting", ":mission_info", @@ -423,6 +610,8 @@ ohos_shared_library("ability_connect_callback_stub") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "jsoncpp:jsoncpp", + "relational_store:native_dataability", + "relational_store:native_rdb", ] if (ability_runtime_graphics) { external_deps += [ "graphic_2d:color_manager" ] diff --git a/interfaces/inner_api/ability_manager/IAbilityScheduler.idl b/interfaces/inner_api/ability_manager/IAbilityScheduler.idl new file mode 100644 index 0000000000000000000000000000000000000000..ab11ee3a2da88ab8c19e07dd44618f20a539dc20 --- /dev/null +++ b/interfaces/inner_api/ability_manager/IAbilityScheduler.idl @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2025 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. + */ + +sequenceable OHOS.IRemoteObject; +sequenceable want..OHOS.AAFwk.Want; +sequenceable lifecycle_state_info..OHOS.AAFwk.LifeCycleStateInfo; +sequenceable OHOS.AAFwk.SessionInfo; +sequenceable pac_map..OHOS.AppExecFwk.PacMap; +sequenceable uri..OHOS.Uri; +sequenceable data_ability_operation..OHOS.AppExecFwk.DataAbilityOperation; +sequenceable am_abs_shared_result_set..OHOS.NativeRdb.AmAbsSharedResultSet; +sequenceable am_values_bucket..OHOS.NativeRdb.AmValuesBucket; +sequenceable data_ability_predicates..OHOS.NativeRdb.DataAbilityPredicates; +sequenceable data_ability_result..OHOS.AppExecFwk.DataAbilityResult; +sequenceable element_name..OHOS.AppExecFwk.ElementName; +sequenceable am_uri..OHOS.AmUri; + +interface OHOS.AAFwk.IDataAbilityObserver; +interface OHOS.AAFwk.IAbilityScheduler { + [oneway,ipcincapacity 216] void ScheduleAbilityTransaction([in] Want want, [in] LifeCycleStateInfo targetState, + [in] null_sptr sessionInfo); + [oneway] void ScheduleShareData([in] int uniqueId); + [oneway] void SendResult([in] int requestCode, [in] int resultCode, [in] Want resultWant); + [oneway,ipcincapacity 216] void ScheduleConnectAbility([in] Want want); + [oneway,ipcincapacity 216] void ScheduleDisconnectAbility([in] Want want); + [oneway,ipcincapacity 216] void ScheduleCommandAbility([in] Want want, [in] boolean restart, [in] int startId); + [oneway,ipcincapacity 216] void ScheduleCommandAbilityWindow([in] Want want, [in] sptr sessionInfo, [in] int winCmd); + [oneway] void SchedulePrepareTerminateAbility(); + [oneway] void ScheduleSaveAbilityState(); + [oneway] void ScheduleRestoreAbilityState([in] PacMap inState); + String[] GetFileTypes([in] Uri uri, [in] String mimeTypeFilter); + FileDescriptor OpenFile([in] Uri uri, [in] String mode); + int OpenRawFile([in] Uri uri, [in] String mode); + int Insert([in] Uri uri, [in] AmValuesBucket value); + int Update([in] Uri uri, [in] AmValuesBucket value, [in] DataAbilityPredicates predicates); + int Delete([in] Uri uri, [in] DataAbilityPredicates predicates); + sharedptr Call([in] Uri uri, [in] String method, [in] String arg, [in] PacMap pacMap); + sharedptr Query([in] Uri uri, [in] String[] columns, + [in] DataAbilityPredicates predicates); + String GetType([in] Uri uri); + boolean Reload([in] Uri uri, [in] PacMap extras); + int BatchInsert([in] Uri uri, [in] AmValuesBucket[] values); + void ScheduleRegisterObserver([in] Uri uri, [in] IDataAbilityObserver dataObserver); + void ScheduleUnregisterObserver([in] Uri uri, [in] IDataAbilityObserver dataObserver); + void ScheduleNotifyChange([in] Uri uri); + AmUri NormalizeUri([in] Uri uri); + AmUri DenormalizeUri([in] Uri uri); + sharedptr[] ExecuteBatch([in] sharedptr[] operations); + [oneway] void ContinueAbility([in] String deviceId, [in] unsigned int versionCode); + [oneway] void NotifyContinuationResult([in] int resultParam); + [oneway] void DumpAbilityInfo([in] String[] params); + [oneway,ipcincapacity 216] void CreateModalUIExtension([in] Want want); + [oneway,ipcincapacity 216] void OnExecuteIntent([in] Want want); + [oneway] void CallRequest(); + [oneway] void UpdateSessionToken([in] IRemoteObject sessionToken); + [oneway] void ScheduleCollaborate([in] Want want); + [oneway] void ScheduleAbilityRequestFailure([in] String requestId, [in] ElementName element, [in] String message); + [oneway] void ScheduleAbilityRequestSuccess([in] String requestId, [in] ElementName element); +} \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/ability_manager_headers.gni b/interfaces/inner_api/ability_manager/ability_manager_headers.gni index ec72bedb4f51047b3d8068c4d87851d783303c74..06d4534e47f74ffcc8e52c2fc6605a26e971d873 100644 --- a/interfaces/inner_api/ability_manager/ability_manager_headers.gni +++ b/interfaces/inner_api/ability_manager/ability_manager_headers.gni @@ -19,8 +19,8 @@ ability_manager_headers = { "ability_manager_errors.h", "ability_manager_interface.h", "ability_running_info.h", - "ability_scheduler_interface.h", "extension_running_info.h", + "iability_scheduler.h", "lifecycle_state_info.h", "open_link_options.h", "ability_state.h", diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index 52bcb2d2f08217293331b7deb025f90d3451ec09..2a6561b40269444c8fb3711c775ef002641e554f 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -21,7 +21,7 @@ #include "ability_connect_callback_interface.h" #include "ability_manager_errors.h" #include "ability_manager_interface.h" -#include "ability_scheduler_interface.h" +#include "iability_scheduler.h" #include "auto_startup_info.h" #include "iremote_object.h" #include "mission_info.h" @@ -550,7 +550,7 @@ public: sptr connect, sptr callerToken, int32_t userId = DEFAULT_INVAL_VALUE); - + /** * ConnectAbilityWithExtensionType, connect session with specified extentionType ability. * @@ -1825,7 +1825,7 @@ public: const std::string &moduleName, const std::string &intentName, InsightIntentInfoForQuery &info); - + private: AbilityManagerClient(); DISALLOW_COPY_AND_MOVE(AbilityManagerClient); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 4d576a8f5043743b07fb52f0bf550a1b7e519d7d..83e1058b74b0d3053c531f18f59343823af2d3c8 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -25,7 +25,7 @@ #include "ability_connect_callback_interface.h" #include "ability_manager_ipc_interface_code.h" #include "ability_running_info.h" -#include "ability_scheduler_interface.h" +#include "iability_scheduler.h" #include "ability_start_setting.h" #include "ability_state.h" #include "ability_state_data.h" diff --git a/interfaces/inner_api/ability_manager/include/ability_scheduler_interface.h b/interfaces/inner_api/ability_manager/include/ability_scheduler_interface.h index a9365cf1c332831b6c8019ae705f275aa7a8eb42..903164b2e574b71e6ada729b4efa1dd29e80714d 100644 --- a/interfaces/inner_api/ability_manager/include/ability_scheduler_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_scheduler_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -16,406 +16,6 @@ #ifndef OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULER_INTERFACE_H #define OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULER_INTERFACE_H -#include -#include "lifecycle_state_info.h" -#include "pac_map.h" -#include "ui_extension_window_command.h" -#include "want.h" +#include "iability_scheduler.h" -namespace OHOS { -namespace NativeRdb { -class AbsSharedResultSet; -class DataAbilityPredicates; -class ValuesBucket; -} -namespace AppExecFwk { -class DataAbilityResult; -class DataAbilityOperation; -} -namespace AAFwk { -using OHOS::AppExecFwk::PacMap; -class IDataAbilityObserver; -class SessionInfo; - -/** - * @class IAbilityScheduler - * IAbilityScheduler is used to schedule ability kit lifecycle. - */ -class IAbilityScheduler : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.AbilityScheduler"); - - /* - * ScheduleAbilityTransaction, schedule ability to transform life state. - * - * @param Want, Special Want for service type's ability. - * @param targetState, The lifecycle state to be transformed - * @param sessionInfo, The session info - */ - virtual bool ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, - sptr sessionInfo = nullptr) = 0; - - /* - * ScheduleShareData, schedule ability to share data. - * - * @param uniqueId, Indicates the uniqueId returned after the ability is started. - */ - virtual void ScheduleShareData(const int32_t &uniqueId) = 0; - - /* - * SendResult, Send result to app when ability is terminated with result want. - * - * @param requestCode, the requestCode of the ability to start. - * @param resultCode, the resultCode of the ability to terminate. - * @param resultWant, the want of the ability to terminate. - */ - virtual void SendResult(int requestCode, int resultCode, const Want &resultWant) = 0; - - /* - * ScheduleConnectAbility, schedule service ability to connect. - * - * @param Want, Special Want for service type's ability. - */ - virtual void ScheduleConnectAbility(const Want &want) = 0; - - /* - * ScheduleDisconnectAbility, schedule service ability to disconnect. - */ - virtual void ScheduleDisconnectAbility(const Want &want) = 0; - - /* - * ScheduleCommandAbility, schedule service ability to command. - */ - virtual void ScheduleCommandAbility(const Want &want, bool restart, int startId) = 0; - - virtual void ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, - WindowCommand winCmd) = 0; - - /** - * SchedulePrepareTerminateAbility, schedule ability to prepare terminate. - */ - virtual bool SchedulePrepareTerminateAbility() = 0; - - /* - * ScheduleSaveAbilityState, scheduling save ability state. - */ - virtual void ScheduleSaveAbilityState() = 0; - - /* - * ScheduleRestoreAbilityState, scheduling restore ability state. - */ - virtual void ScheduleRestoreAbilityState(const PacMap &inState) = 0; - - /** - * @brief Obtains the MIME types of files supported. - * - * @param uri Indicates the path of the files to obtain. - * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. - * - * @return Returns the matched MIME types. If there is no match, null is returned. - */ - virtual std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) = 0; - - /** - * @brief Opens a file in a specified remote path. - * - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, - * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, - * or "rwt" for read and write access that truncates any existing file. - * - * @return Returns the file descriptor. - */ - virtual int OpenFile(const Uri &uri, const std::string &mode) = 0; - - /** - * @brief This is like openFile, open a file that need to be able to return sub-sections of files,often assets - * inside of their .hap. - * - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, - * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing - * data, or "rwt" for read and write access that truncates any existing file. - * - * @return Returns the RawFileDescriptor object containing file descriptor. - */ - virtual int OpenRawFile(const Uri &uri, const std::string &mode) = 0; - - /** - * @brief Inserts a single data record into the database. - * - * @param uri Indicates the path of the data to operate. - * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. - * - * @return Returns the index of the inserted data record. - */ - virtual int Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) = 0; - - /** - * @brief Updates data records in the database. - * - * @param uri Indicates the path of data to update. - * @param value Indicates the data to update. This parameter can be null. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the number of data records updated. - */ - virtual int Update(const Uri &uri, const NativeRdb::ValuesBucket &value, - const NativeRdb::DataAbilityPredicates &predicates) = 0; - - /** - * @brief Deletes one or more data records from the database. - * - * @param uri Indicates the path of the data to operate. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the number of data records deleted. - */ - virtual int Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) = 0; - - /** - * @brief Calls the method of the Data ability. - * - * @param uri Indicates the Data ability of the method to call. - * @param method Indicates the method to call. - * @param arg Indicates the parameter of the String type. - * @param pacMap Defines a PacMap object for storing a series of values. - * - * @return Returns the call result. - */ - virtual std::shared_ptr Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) = 0; - - /** - * @brief Deletes one or more data records from the database. - * - * @param uri Indicates the path of data to query. - * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the query result. - */ - virtual std::shared_ptr Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) = 0; - - /** - * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be - * implemented by a Data ability. Data abilities supports general data types, including text, HTML, and JPEG. - * - * @param uri Indicates the URI of the data. - * - * @return Returns the MIME type that matches the data specified by uri. - */ - virtual std::string GetType(const Uri &uri) = 0; - - /** - * @brief Reloads data in the database. - * - * @param uri Indicates the position where the data is to reload. This parameter is mandatory. - * @param extras Indicates the PacMap object containing the additional parameters to be passed in this call. This - * parameter can be null. If a custom Sequenceable object is put in the PacMap object and will be transferred across - * processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. - * - * @return Returns true if the data is successfully reloaded; returns false otherwise. - */ - virtual bool Reload(const Uri &uri, const PacMap &extras) = 0; - - /** - * @brief Inserts multiple data records into the database. - * - * @param uri Indicates the path of the data to operate. - * @param values Indicates the data records to insert. - * - * @return Returns the number of data records inserted. - */ - virtual int BatchInsert(const Uri &uri, const std::vector &values) = 0; - - /** - * @brief Registers an observer to DataObsMgr specified by the given Uri. - * - * @param uri, Indicates the path of the data to operate. - * @param dataObserver, Indicates the IDataAbilityObserver object. - * - * @return Return true if success. otherwise return false. - */ - virtual bool ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) = 0; - - /** - * @brief Deregisters an observer used for DataObsMgr specified by the given Uri. - * - * @param uri, Indicates the path of the data to operate. - * @param dataObserver, Indicates the IDataAbilityObserver object. - * - * @return Return true if success. otherwise return false. - */ - virtual bool ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) = 0; - - /** - * @brief Notifies the registered observers of a change to the data resource specified by Uri. - * - * @param uri, Indicates the path of the data to operate. - * - * @return Return true if success. otherwise return false. - */ - virtual bool ScheduleNotifyChange(const Uri &uri) = 0; - /** - * @brief Converts the given uri that refer to the Data ability into a normalized URI. A normalized URI can be used - * across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability even if the - * context has changed. If you implement URI normalization for a Data ability, you must also implement - * denormalizeUri(ohos.utils.net.Uri) to enable URI denormalization. After this feature is enabled, URIs passed to - * any method that is called on the Data ability must require normalization verification and denormalization. The - * default implementation of this method returns null, indicating that this Data ability does not support URI - * normalization. - * - * @param uri Indicates the Uri object to normalize. - * - * @return Returns the normalized Uri object if the Data ability supports URI normalization; returns null otherwise. - */ - virtual Uri NormalizeUri(const Uri &uri) = 0; - - /** - * @brief Converts the given normalized uri generated by normalizeUri(ohos.utils.net.Uri) into a denormalized one. - * The default implementation of this method returns the original URI passed to it. - * - * @param uri uri Indicates the Uri object to denormalize. - * - * @return Returns the denormalized Uri object if the denormalization is successful; returns the original Uri passed - * to this method if there is nothing to do; returns null if the data identified by the original Uri cannot be found - * in the current environment. - */ - virtual Uri DenormalizeUri(const Uri &uri) = 0; - virtual std::vector> ExecuteBatch( - const std::vector> &operations) = 0; - virtual void ContinueAbility(const std::string& deviceId, uint32_t versionCode) = 0; - virtual void NotifyContinuationResult(int32_t result) = 0; - - virtual void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) = 0; - virtual int CreateModalUIExtension(const Want &want) = 0; - - virtual void OnExecuteIntent(const Want &want) = 0; - - virtual void CallRequest() = 0; - - /** - * @brief Update sessionToken. - * @param sessionToken The token of session. - */ - virtual void UpdateSessionToken(sptr sessionToken) = 0; - - virtual void ScheduleCollaborate(const Want &want) = 0; - - virtual void ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, - const std::string &message) = 0; - - virtual void ScheduleAbilityRequestSuccess(const std::string &requestId, - const AppExecFwk::ElementName &element) = 0; - - enum { - // ipc id for scheduling ability to a state of life cycle - SCHEDULE_ABILITY_TRANSACTION = 0, - - // ipc id for sending result to caller - SEND_RESULT, - - // ipc id for scheduling service ability to connect - SCHEDULE_ABILITY_CONNECT, - - // ipc id for scheduling service ability to disconnect - SCHEDULE_ABILITY_DISCONNECT, - - // ipc id for scheduling service ability to command - SCHEDULE_ABILITY_COMMAND, - - SCHEDULE_ABILITY_COMMAND_WINDOW, - - // ipc id for scheduling save ability state - SCHEDULE_SAVE_ABILITY_STATE, - - // ipc id for scheduling restore ability state - SCHEDULE_RESTORE_ABILITY_STATE, - - // ipc id for scheduling getFileTypes - SCHEDULE_GETFILETYPES, - - // ipc id for scheduling openFile - SCHEDULE_OPENFILE, - - // ipc id for scheduling openRawFile - SCHEDULE_OPENRAWFILE, - - // ipc id for scheduling insert - SCHEDULE_INSERT, - - // ipc id for scheduling update - SCHEDULE_UPDATE, - - // ipc id for scheduling delete - SCHEDULE_DELETE, - - // ipc id for scheduling query - SCHEDULE_QUERY, - - // ipc id for scheduling getType - SCHEDULE_GETTYPE, - - // ipc id for scheduling Reload - SCHEDULE_RELOAD, - - // ipc id for scheduling BatchInsert​ - SCHEDULE_BATCHINSERT, - - // ipc id for dataAbilityObServer Register - SCHEDULE_REGISTEROBSERVER, - - // ipc id for dataAbilityObServer UnReguster - SCHEDULE_UNREGISTEROBSERVER, - - // ipc id for dataAbilityObServer change - SCHEDULE_NOTIFYCHANGE, - - // ipc id for scheduling NormalizeUri - SCHEDULE_NORMALIZEURI, - - // ipc id for scheduling DenormalizeUri - SCHEDULE_DENORMALIZEURI, - - // ipc id for scheduling ExecuteBatch - SCHEDULE_EXECUTEBATCH, - - // ipc id for notify continuation result - NOTIFY_CONTINUATION_RESULT, - - // ipc id for scheduling call request - REQUEST_CALL_REMOTE, - - // ipc id for continue ability - CONTINUE_ABILITY, - - // ipc id for dump ability runner - DUMP_ABILITY_RUNNER_INNER, - - SCHEDULE_CALL, - - SCHEDULE_SHARE_DATA, - - // ipc id for scheduling service ability to prepare terminate (30) - SCHEDULE_ABILITY_PREPARE_TERMINATE, - - SCHEDULE_ONEXECUTE_INTENT, - - CREATE_MODAL_UI_EXTENSION, - - UPDATE_SESSION_TOKEN, - - SCHEDULE_COLLABORATE_DATA, - - SCHEDULE_ABILITY_REQUEST_FAILURE, - - SCHEDULE_ABILITY_REQUEST_SUCCESS - }; -}; -} // namespace AAFwk -} // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULER_INTERFACE_H diff --git a/interfaces/inner_api/ability_manager/include/am_abs_shared_result_set.h b/interfaces/inner_api/ability_manager/include/am_abs_shared_result_set.h new file mode 100644 index 0000000000000000000000000000000000000000..1fa460dced5d98183f4ce63ecbbfe0b1d6d6a237 --- /dev/null +++ b/interfaces/inner_api/ability_manager/include/am_abs_shared_result_set.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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_NativeRdb_AM_ABS_SHARED_RESULT_SET_H +#define OHOS_NativeRdb_AM_ABS_SHARED_RESULT_SET_H + +#include +#include + +namespace OHOS::NativeRdb { +class AbsSharedResultSet; + +class AmAbsSharedResultSet : public Parcelable { +public: + AmAbsSharedResultSet() = default; + explicit AmAbsSharedResultSet(const std::shared_ptr& resultSet) : + resultSet_(resultSet) {} + ~AmAbsSharedResultSet() = default; + + bool Marshalling(Parcel& parcel) const override; + static AmAbsSharedResultSet* Unmarshalling(Parcel& parcel); + std::shared_ptr GetResultSet() const; + +private: + std::shared_ptr resultSet_; +}; +} // namespace OHOS::NativeRdb + +#endif // OHOS_NativeRdb_AM_ABS_SHARED_RESULT_SET_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/am_uri.h b/interfaces/inner_api/ability_manager/include/am_uri.h new file mode 100644 index 0000000000000000000000000000000000000000..fcf110675a7a055ae51ce430302f79ea8d135b14 --- /dev/null +++ b/interfaces/inner_api/ability_manager/include/am_uri.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_AM_URI_H +#define OHOS_ABILITY_RUNTIME_AM_URI_H + +#include "uri.h" +#include "parcel.h" + +namespace OHOS { +using Uri = OHOS::Uri; +struct AmUri : public Parcelable { + Uri uri; + AmUri() : uri("") {} + AmUri(const Uri &uri) : uri(uri) {} + + bool ReadFromParcel(Parcel &parcel) { + auto tempUri = parcel.ReadParcelable(); + if (tempUri == nullptr) { + return false; + } + uri = *tempUri; + delete tempUri; + tempUri = nullptr; + return true; + } + + virtual bool Marshalling(Parcel &parcel) const override { + if (!parcel.WriteParcelable(&uri)) { + return false; + } + return true; + } + + static AmUri *Unmarshalling(Parcel &parcel) { + AmUri *amUri = new (std::nothrow) AmUri(); + if (amUri == nullptr) { + return nullptr; + } + + if (!amUri->ReadFromParcel(parcel)) { + delete amUri; + amUri = nullptr; + } + return amUri; + } +}; +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_AM_URI_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/include/am_values_bucket.h b/interfaces/inner_api/ability_manager/include/am_values_bucket.h new file mode 100644 index 0000000000000000000000000000000000000000..ce9a5f0a5932dae1a3f07fd7a2a4af3f8f3621c7 --- /dev/null +++ b/interfaces/inner_api/ability_manager/include/am_values_bucket.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 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_NativeRdb_AM_VALUES_BUCKET_H +#define OHOS_NativeRdb_AM_VALUES_BUCKET_H + +#include +#include + +namespace OHOS::NativeRdb { +class ValuesBucket; + +class AmValuesBucket : public Parcelable { +public: + AmValuesBucket() = default; + explicit AmValuesBucket(const std::shared_ptr& valuesBucket) : valuesBucket_(valuesBucket) {} + ~AmValuesBucket() = default; + bool Marshalling(Parcel& parcel) const override; + static AmValuesBucket* Unmarshalling(Parcel& parcel); + std::shared_ptr GetValuesBucket() const; + +private: + std::shared_ptr valuesBucket_; +}; +} // namespace OHOS::NativeRdb + +#endif // OHOS_NativeRdb_AM_VALUES_BUCKET_H \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/src/am_abs_shared_result_set.cpp b/interfaces/inner_api/ability_manager/src/am_abs_shared_result_set.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3f477466e363e83eb53a5e55002e6f182957daff --- /dev/null +++ b/interfaces/inner_api/ability_manager/src/am_abs_shared_result_set.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 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 "am_abs_shared_result_set.h" + +#include "ishared_result_set.h" +namespace OHOS { +namespace NativeRdb { +bool AmAbsSharedResultSet::Marshalling(Parcel &parcel) const +{ + if (resultSet_ == nullptr) { + return false; + } + MessageParcel& data = static_cast(parcel); + auto result = NativeRdb::ISharedResultSet::WriteToParcel(std::move(resultSet_), data); + if (result == nullptr) { + return false; + } + return true; +} + +AmAbsSharedResultSet* AmAbsSharedResultSet::Unmarshalling(Parcel &parcel) +{ + MessageParcel& data = static_cast(parcel); + std::shared_ptr sharedPtr = NativeRdb::ISharedResultSet::ReadFromParcel(data); + return new (std::nothrow) AmAbsSharedResultSet(sharedPtr); +} + +std::shared_ptr AmAbsSharedResultSet::GetResultSet() const +{ + return resultSet_; +} +} // namespace NativeRdb +} // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/src/am_values_bucket.cpp b/interfaces/inner_api/ability_manager/src/am_values_bucket.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a311a6f1728b55d9451987736b841c57941351bb --- /dev/null +++ b/interfaces/inner_api/ability_manager/src/am_values_bucket.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 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 "am_values_bucket.h" + +#include "values_bucket.h" + +namespace OHOS { +namespace NativeRdb { +bool AmValuesBucket::Marshalling(Parcel& parcel) const +{ + if (valuesBucket_) { + return valuesBucket_->Marshalling(parcel); + } + return false; +} + +AmValuesBucket* AmValuesBucket::Unmarshalling(Parcel& parcel) +{ + ValuesBucket bucket = ValuesBucket::Unmarshalling(parcel); + std::shared_ptr valuesBucket = std::make_shared(bucket); + return new (std::nothrow) AmValuesBucket(valuesBucket); +} + +std::shared_ptr AmValuesBucket::GetValuesBucket() const +{ + return valuesBucket_; +} +} // namespace OHOS::NativeRdb +} // namespace NativeRdb + diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 39ea4c18d2406607ef95399cddcc6f7b36e5eaa3..46f8696fea61cc15ea12e32be0cf2475702a97c5 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -126,6 +126,7 @@ ohos_shared_library("app_manager") { public_configs = [ ":appmgr_core_config", ":appmgr_sdk_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", ] defines = [ "AMS_LOG_TAG = \"AppexecfwkCore\"" ] @@ -161,6 +162,7 @@ ohos_shared_library("app_manager") { "ability_base:want", "bundle_framework:appexecfwk_base", "image_framework:image_native", + "relational_store:native_dataability", "relational_store:native_rdb", ] if (ability_runtime_child_process) { diff --git a/interfaces/inner_api/dataobs_manager/include/idata_ability_observer.h b/interfaces/inner_api/dataobs_manager/include/idata_ability_observer.h new file mode 100644 index 0000000000000000000000000000000000000000..a7810564e1585b10c6f5b87086e95fbd25202ec3 --- /dev/null +++ b/interfaces/inner_api/dataobs_manager/include/idata_ability_observer.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_ABILITY_RUNTIME_IDATA_ABILITY_OBSERVER_H +#define OHOS_ABILITY_RUNTIME_IDATA_ABILITY_OBSERVER_H + +#include "data_ability_observer_interface.h" + +#endif // OHOS_ABILITY_RUNTIME_IDATA_ABILITY_OBSERVER_H diff --git a/interfaces/inner_api/extension_manager/BUILD.gn b/interfaces/inner_api/extension_manager/BUILD.gn index 2a0d85fb821d0fcbf9b261e096a6474f40bd6026..bb2caa0f8ff43ee3cc2d7a4dd8c95eb063de3321 100755 --- a/interfaces/inner_api/extension_manager/BUILD.gn +++ b/interfaces/inner_api/extension_manager/BUILD.gn @@ -44,7 +44,14 @@ ohos_shared_library("extension_manager") { ] configs = [ ":extension_manager_config" ] - public_configs = [ ":extension_manager_public_config" ] + public_configs = [ + ":extension_manager_public_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_interface", + ] public_deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub" ] @@ -55,6 +62,8 @@ ohos_shared_library("extension_manager") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_single", + "relational_store:native_dataability", + "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index a9f3008821ce8144f55e241721e9ab01b90077d1..0f39f91c107f2a8b7ffcd6b865ee0194bb2e44f4 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -64,9 +64,13 @@ ohos_shared_library("wantagent_innerkits") { "src/want_agent_info.cpp", ] - public_configs = [ ":wantagent_innerkits_public_config" ] + public_configs = [ + ":wantagent_innerkits_public_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_interface", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", @@ -92,6 +96,8 @@ ohos_shared_library("wantagent_innerkits") { "icu:shared_icuuc", "image_framework:image_native", "resource_management:global_resmgr", + "relational_store:native_dataability", + "relational_store:native_rdb", ] if (is_double_framework) { diff --git a/interfaces/kits/native/ability/native/ability_impl.h b/interfaces/kits/native/ability/native/ability_impl.h index 300bbea90cbf7da2e9e68947c71acfd22442ccc2..265c0d5d0681dde93ababa33613d84a5dfa60141 100644 --- a/interfaces/kits/native/ability/native/ability_impl.h +++ b/interfaces/kits/native/ability/native/ability_impl.h @@ -215,7 +215,7 @@ public: * @return Returns the query result. */ virtual std::shared_ptr Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates); + const Uri &uri, const std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates); /** * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should diff --git a/interfaces/kits/native/ability/native/ability_thread.h b/interfaces/kits/native/ability/native/ability_thread.h index 6dd0fe9cded36cb4507d255f700fb001d5556464..7940c9bc3943f89823a116b6058be85ffcf68fae 100644 --- a/interfaces/kits/native/ability/native/ability_thread.h +++ b/interfaces/kits/native/ability/native/ability_thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -94,26 +94,26 @@ public: * @param targetState Indicates the lifecycle state. * @param sessionInfo Indicates the session info. */ - bool ScheduleAbilityTransaction( - const Want &want, const LifeCycleStateInfo &targetState, sptr sessionInfo = nullptr) override; + ErrCode ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, + const sptr& sessionInfo) override; /** * @brief Provide operating system ShareData information to the observer * @param requestCode Indicates the Ability request code. */ - void ScheduleShareData(const int32_t &requestCode) override; + ErrCode ScheduleShareData(int32_t requestCode) override; /** * @brief Provide operating system ConnectAbility information to the observer * @param want Indicates the structure containing connect information about the ability. */ - void ScheduleConnectAbility(const Want &want) override; + ErrCode ScheduleConnectAbility(const Want &want) override; /** * @brief Provide operating system DisconnectAbility information to the observer * @param want Indicates the structure containing connect information about the ability. */ - void ScheduleDisconnectAbility(const Want &want) override; + ErrCode ScheduleDisconnectAbility(const Want &want) override; /** * @brief Provide operating system CommandAbility information to the observer @@ -124,7 +124,7 @@ public: * 1 every time the ability is started. For example, if the ability has been started for six times, the value of * startId is 6. */ - void ScheduleCommandAbility(const Want &want, bool restart, int startId) override; + ErrCode ScheduleCommandAbility(const Want &want, bool restart, int32_t startId) override; /** * @brief Schedule Command AbilityWindow @@ -132,24 +132,24 @@ public: * @param sessionInfo Indicates the session info. * @param winCmd Indicates the WindowCommand of winCmd */ - void ScheduleCommandAbilityWindow( - const Want &want, const sptr &sessionInfo, AAFwk::WindowCommand winCmd) override; + ErrCode ScheduleCommandAbilityWindow( + const Want &want, const sptr &sessionInfo, int32_t winCmd) override; /** * @brief Provide operating system PrepareTerminateAbility information to the observer */ - bool SchedulePrepareTerminateAbility() override; + ErrCode SchedulePrepareTerminateAbility() override; /** * @brief Provide operating system SaveabilityState information to the observer */ - void ScheduleSaveAbilityState() override; + ErrCode ScheduleSaveAbilityState() override; /** * @brief Provide operating system RestoreAbilityState information to the observer * @param state Indicates resotre ability state used to dispatchRestoreAbilityState. */ - void ScheduleRestoreAbilityState(const PacMap &state) override; + ErrCode ScheduleRestoreAbilityState(const PacMap &state) override; /** * @brief Send the result code and data to be returned by this Page ability to the caller. @@ -162,7 +162,7 @@ public: * @param resultData Indicates the data returned after the ability is destroyed. You can define the data returned. * This parameter can be null. */ - void SendResult(int requestCode, int resultCode, const Want &resultData) override; + ErrCode SendResult(int requestCode, int resultCode, const Want &resultData) override; /** * @brief Obtains the MIME types of files supported. @@ -170,7 +170,8 @@ public: * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. * @return Returns the matched MIME types. If there is no match, null is returned. */ - std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; + ErrCode GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter, + std::vector& funcResult) override; /** * @brief Opens a file in a specified remote path. @@ -181,7 +182,7 @@ public: * or "rwt" for read and write access that truncates any existing file. * @return Returns the file descriptor. */ - int OpenFile(const Uri &uri, const std::string &mode) override; + ErrCode OpenFile(const Uri &uri, const std::string &mode, int& funcResult) override; /** * @brief This is like openFile, open a file that need to be able to return sub-sections of files that often assets @@ -193,7 +194,7 @@ public: * data, or "rwt" for read and write access that truncates any existing file. * @return Returns the RawFileDescriptor object containing file descriptor. */ - int OpenRawFile(const Uri &uri, const std::string &mode) override; + ErrCode OpenRawFile(const Uri &uri, const std::string &mode, int32_t& funcResult) override; /** * @brief Inserts a single data record into the database. @@ -201,7 +202,7 @@ public: * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. * @return Returns the index of the inserted data record. */ - int Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) override; + ErrCode Insert(const Uri &uri, const NativeRdb::AmValuesBucket &value, int32_t& funcResult) override; /** * @brief Calls the method of the Data ability. @@ -211,8 +212,8 @@ public: * @param pacMap Defines a PacMap object for storing a series of values. * @return Returns the call result. */ - std::shared_ptr Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) override; + ErrCode Call(const Uri &uri, const std::string &method, const std::string &arg, + const AppExecFwk::PacMap &pacMap, std::shared_ptr& funcResult) override; /** * @brief Updates data records in the database. @@ -221,8 +222,8 @@ public: * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the number of data records updated. */ - int Update(const Uri &uri, const NativeRdb::ValuesBucket &value, - const NativeRdb::DataAbilityPredicates &predicates) override; + ErrCode Update(const Uri &uri, const NativeRdb::AmValuesBucket &value, + const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) override; /** * @brief Deletes one or more data records from the database. @@ -230,7 +231,7 @@ public: * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the number of data records deleted. */ - int Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) override; + ErrCode Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) override; /** * @brief Deletes one or more data records from the database. @@ -239,8 +240,8 @@ public: * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the query result. */ - std::shared_ptr Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) override; + ErrCode Query(const Uri &uri, const std::vector &columns, + const NativeRdb::DataAbilityPredicates &predicates, std::shared_ptr& funcResult) override; /** * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be @@ -248,7 +249,7 @@ public: * @param uri Indicates the URI of the data. * @return Returns the MIME type that matches the data specified by uri. */ - std::string GetType(const Uri &uri) override; + ErrCode GetType(const Uri &uri, std::string& funcResult) override; /** * @brief Reloads data in the database. @@ -258,7 +259,7 @@ public: * processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. * @return Returns true if the data is successfully reloaded; returns false otherwise. */ - bool Reload(const Uri &uri, const PacMap &extras) override; + ErrCode Reload(const Uri &uri, const PacMap &extras, bool& funcResult) override; /** * @brief Inserts multiple data records into the database. @@ -266,20 +267,21 @@ public: * @param values Indicates the data records to insert. * @return Returns the number of data records inserted. */ - int BatchInsert(const Uri &uri, const std::vector &values) override; + ErrCode BatchInsert(const Uri &uri, const std::vector &values, + int32_t& funcResult) override; /** * @brief continue ability to target device. * @param deviceId target deviceId * @param versionCode Target bundle version. */ - void ContinueAbility(const std::string &deviceId, uint32_t versionCode) override; + ErrCode ContinueAbility(const std::string &deviceId, uint32_t versionCode) override; /** * @brief notify this ability continuation result. * @param result: Continuation result */ - void NotifyContinuationResult(int32_t result) override; + ErrCode NotifyContinuationResult(int32_t result) override; /** * @brief Converts the given uri that refer to the Data ability into a normalized URI. A normalized URI can be used @@ -292,7 +294,7 @@ public: * @param uri Indicates the Uri object to normalize. * @return Returns the normalized Uri object if the Data ability supports URI normalization; returns null otherwise. */ - Uri NormalizeUri(const Uri &uri) override; + ErrCode NormalizeUri(const Uri &uri, AmUri& funcResult) override; /** * @brief Converts the given normalized uri generated by normalizeUri(ohos.utils.net.Uri) into a denormalized one. @@ -302,67 +304,68 @@ public: * to this method if there is nothing to do; returns null if the data identified by the original Uri cannot be found * in the current environment. */ - Uri DenormalizeUri(const Uri &uri) override; + ErrCode DenormalizeUri(const Uri &uri, AmUri& funcResult) override; /** * @brief Registers an observer to DataObsMgr specified by the given Uri. * @param uri Indicates the path of the data to operate. * @param dataObserver Indicates the IDataAbilityObserver object. */ - bool ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) override; + ErrCode ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) override; /** * @brief Deregisters an observer used for DataObsMgr specified by the given Uri. * @param uri Indicates the path of the data to operate. * @param dataObserver Indicates the IDataAbilityObserver object. */ - bool ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) override; + ErrCode ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) override; /** * @brief Notifies the registered observers of a change to the data resource specified by Uri. * @param uri Indicates the path of the data to operate. */ - bool ScheduleNotifyChange(const Uri &uri) override; + ErrCode ScheduleNotifyChange(const Uri &uri) override; /** * @brief Dump ability runner info. * @param params Indicates the params * @param info ability runner info. */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override; + ErrCode DumpAbilityInfo(const std::vector ¶ms) override; /** * @brief Call Request */ - void CallRequest() override; + ErrCode CallRequest() override; - void OnExecuteIntent(const Want &want) override; + ErrCode OnExecuteIntent(const Want &want) override; /** * @brief Execute Batch * @param operations Indicates the operations */ - std::vector> ExecuteBatch( - const std::vector> &operations) override; + ErrCode ExecuteBatch(const std::vector> &operations, + std::vector>& funcResult) override; /** * @brief Dump ability runner info. * @param want Create modalUIExtension with want object. */ - int CreateModalUIExtension(const Want &want) override; + ErrCode CreateModalUIExtension(const Want &want) override; /** * @brief Update sessionToken. * @param sessionToken The token of session. */ - void UpdateSessionToken(sptr sessionToken) override; + ErrCode UpdateSessionToken(const sptr& sessionToken) override; - void ScheduleCollaborate(const Want &want) override; + ErrCode ScheduleCollaborate(const Want &want) override; - void ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, + ErrCode ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, const std::string &message) override; - void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override; + ErrCode ScheduleAbilityRequestSuccess(const std::string &requestId, + const AppExecFwk::ElementName &element) override; sptr token_; std::shared_ptr abilityHandler_ = nullptr; diff --git a/interfaces/kits/native/ability/native/data_ability_impl.h b/interfaces/kits/native/ability/native/data_ability_impl.h index 2f4fe126621668f6d9577831f8121093dbf13027..d2d3804c53de80e30f8601030204560243ed599f 100644 --- a/interfaces/kits/native/ability/native/data_ability_impl.h +++ b/interfaces/kits/native/ability/native/data_ability_impl.h @@ -128,7 +128,7 @@ public: * @return Returns the query result. */ std::shared_ptr Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates); + const Uri &uri, const std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates); /** * @brief Calls the method of the Data ability. diff --git a/interfaces/kits/native/ability/native/extension_ability_thread.h b/interfaces/kits/native/ability/native/extension_ability_thread.h index b5eca2c8602f43572dc6d09b618d5ec172f31a69..66605c91c64fa2187a7657936045d7d298eaee35 100644 --- a/interfaces/kits/native/ability/native/extension_ability_thread.h +++ b/interfaces/kits/native/ability/native/extension_ability_thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -63,20 +63,20 @@ public: * @param targetState Indicates the lifecycle state. * @param sessionInfo Indicates the session info. */ - bool ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, - sptr sessionInfo = nullptr) override; + ErrCode ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, + const sptr& sessionInfo) override; /** * @brief Provide operating system ConnectAbility information to the observer * @param want Indicates the structure containing connect information about the ability. */ - void ScheduleConnectAbility(const Want &want) override; + ErrCode ScheduleConnectAbility(const Want &want) override; /** * @brief Provide operating system DisconnectAbility information to the observer * @param want Indicates the structure containing connect information about the ability. */ - void ScheduleDisconnectAbility(const Want &want) override; + ErrCode ScheduleDisconnectAbility(const Want &want) override; /** * @brief Provide operating system CommandAbility information to the observer @@ -87,7 +87,7 @@ public: * 1 every time the ability is started. For example, if the ability has been started for six times, the value of * startId is 6. */ - void ScheduleCommandAbility(const Want &want, bool restart, int startId) override; + ErrCode ScheduleCommandAbility(const Want &want, bool restart, int32_t startId) override; /** * @brief Schedule Command AbilityWindow @@ -95,8 +95,8 @@ public: * @param sessionInfo Indicates the session info. * @param winCmd Indicates the WindowCommand of winCmd */ - void ScheduleCommandAbilityWindow( - const Want &want, const sptr &sessionInfo, AAFwk::WindowCommand winCmd) override; + ErrCode ScheduleCommandAbilityWindow( + const Want &want, const sptr &sessionInfo, int32_t winCmd) override; /** * @brief ScheduleUpdateConfiguration, scheduling update configuration. @@ -115,7 +115,7 @@ public: * @param want Indicates the data returned after the ability is destroyed. You can define the data returned. This * parameter can be null. */ - void SendResult(int requestCode, int resultCode, const Want &resultData) override; + ErrCode SendResult(int requestCode, int resultCode, const Want &resultData) override; /** * @brief notify this ability current memory level. @@ -128,7 +128,7 @@ public: * @param params the params need to be Dumped * @param info ability runner info. */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override; + ErrCode DumpAbilityInfo(const std::vector ¶ms) override; private: /** diff --git a/interfaces/kits/native/ability/native/fa_ability_thread.h b/interfaces/kits/native/ability/native/fa_ability_thread.h index 91854f19be8e12547b417edecd0bb6b65ab2467c..1345127c5d1663d226748abbbf0785ff13ae172d 100644 --- a/interfaces/kits/native/ability/native/fa_ability_thread.h +++ b/interfaces/kits/native/ability/native/fa_ability_thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -71,26 +71,26 @@ public: * @param targetState Indicates the lifecycle state. * @param sessionInfo Indicates the session info. */ - bool ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, - sptr sessionInfo = nullptr) override; + ErrCode ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, + const sptr& sessionInfo) override; /** * @brief Provide operating system ShareData information to the observer * @param requestCode Indicates the Ability request code. */ - void ScheduleShareData(const int32_t &requestCode) override; + ErrCode ScheduleShareData(int32_t requestCode) override; /** * @brief Provide operating system ConnectAbility information to the observer * @param want Indicates the structure containing connect information about the ability. */ - void ScheduleConnectAbility(const Want &want) override; + ErrCode ScheduleConnectAbility(const Want &want) override; /** * @brief Provide operating system DisconnectAbility information to the observer * @param want Indicates the structure containing connect information about the ability. */ - void ScheduleDisconnectAbility(const Want &want) override; + ErrCode ScheduleDisconnectAbility(const Want &want) override; /** * @brief Provide operating system CommandAbility information to the observer @@ -101,7 +101,7 @@ public: * 1 every time the ability is started. For example, if the ability has been started for six times, the value of * startId is 6. */ - void ScheduleCommandAbility(const Want &want, bool restart, int startId) override; + ErrCode ScheduleCommandAbility(const Want &want, bool restart, int32_t startId) override; /** * @brief Schedule Command AbilityWindow @@ -109,24 +109,24 @@ public: * @param sessionInfo Indicates the session info. * @param winCmd Indicates the WindowCommand of winCmd */ - void ScheduleCommandAbilityWindow( - const Want &want, const sptr &sessionInfo, AAFwk::WindowCommand winCmd) override; + ErrCode ScheduleCommandAbilityWindow( + const Want &want, const sptr &sessionInfo, int32_t winCmd) override; /** * @brief Provide operating system PrepareTerminateAbility information to the observer */ - bool SchedulePrepareTerminateAbility() override; + ErrCode SchedulePrepareTerminateAbility() override; /** * @brief Provide operating system SaveabilityState information to the observer */ - void ScheduleSaveAbilityState() override; + ErrCode ScheduleSaveAbilityState() override; /** * @brief Provide operating system RestoreAbilityState information to the observer * @param state Indicates resotre ability state used to dispatchRestoreAbilityState. */ - void ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) override; + ErrCode ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) override; /** * @brief ScheduleUpdateConfiguration, scheduling update configuration. @@ -145,7 +145,7 @@ public: * @param want Indicates the data returned after the ability is destroyed. You can define the data returned. This * parameter can be null. */ - void SendResult(int requestCode, int resultCode, const Want &resultData) override; + ErrCode SendResult(int requestCode, int resultCode, const Want &resultData) override; /** * @brief Obtains the MIME types of files supported. @@ -153,7 +153,8 @@ public: * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. * @return Returns the matched MIME types. If there is no match, null is returned. */ - std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; + ErrCode GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter, + std::vector& funcResult) override; /** * @brief Opens a file in a specified remote path. @@ -164,7 +165,7 @@ public: * or "rwt" for read and write access that truncates any existing file. * @return Returns the file descriptor. */ - int OpenFile(const Uri &uri, const std::string &mode) override; + ErrCode OpenFile(const Uri &uri, const std::string &mode, int& funcResult) override; /** * @brief This is like openFile, open a file that need to be able to return sub-sections of files often assets @@ -176,7 +177,7 @@ public: * data, or "rwt" for read and write access that truncates any existing file. * @return Returns the RawFileDescriptor object containing file descriptor. */ - int OpenRawFile(const Uri &uri, const std::string &mode) override; + ErrCode OpenRawFile(const Uri &uri, const std::string &mode, int& funcResult) override; /** * @brief Inserts a single data record into the database. @@ -184,7 +185,7 @@ public: * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. * @return Returns the index of the inserted data record. */ - int Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) override; + ErrCode Insert(const Uri &uri, const NativeRdb::AmValuesBucket &value, int32_t& funcResult) override; /** * @brief Calls the method of the Data ability. @@ -193,8 +194,8 @@ public: * @param pacMap Defines a PacMap object for storing a series of values. * @return Returns the call result. */ - std::shared_ptr Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) override; + ErrCode Call(const Uri &uri, const std::string &method, const std::string &arg, + const AppExecFwk::PacMap &pacMap, std::shared_ptr& funcResult) override; /** * @brief Updates data records in the database. @@ -203,8 +204,8 @@ public: * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the number of data records updated. */ - int Update(const Uri &uri, const NativeRdb::ValuesBucket &value, - const NativeRdb::DataAbilityPredicates &predicates) override; + ErrCode Update(const Uri &uri, const NativeRdb::AmValuesBucket &value, + const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) override; /** * @brief Deletes one or more data records from the database. @@ -212,7 +213,7 @@ public: * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the number of data records deleted. */ - int Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) override; + ErrCode Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates, int32_t& funcResult) override; /** * @brief Deletes one or more data records from the database. @@ -221,8 +222,8 @@ public: * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. * @return Returns the query result. */ - std::shared_ptr Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) override; + ErrCode Query(const Uri &uri, const std::vector &columns, + const NativeRdb::DataAbilityPredicates &predicates, std::shared_ptr& funcResult) override; /** * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be @@ -230,7 +231,7 @@ public: * @param uri Indicates the URI of the data. * @return Returns the MIME type that matches the data specified by uri. */ - std::string GetType(const Uri &uri) override; + ErrCode GetType(const Uri &uri, std::string& funcResult) override; /** * @brief Reloads data in the database. @@ -240,7 +241,7 @@ public: * processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. * @return Returns true if the data is successfully reloaded; returns false otherwise. */ - bool Reload(const Uri &uri, const AppExecFwk::PacMap &extras) override; + ErrCode Reload(const Uri &uri, const PacMap &extras, bool& funcResult) override; /** * @brief Inserts multiple data records into the database. @@ -248,20 +249,21 @@ public: * @param values Indicates the data records to insert. * @return Returns the number of data records inserted. */ - int BatchInsert(const Uri &uri, const std::vector &values) override; + ErrCode BatchInsert(const Uri &uri, const std::vector &values, + int32_t& funcResult) override; /** * @brief continue ability to target device. * @param deviceId target deviceId * @param versionCode Target bundle version. */ - void ContinueAbility(const std::string &deviceId, uint32_t versionCode) override; + ErrCode ContinueAbility(const std::string &deviceId, uint32_t versionCode) override; /** * @brief notify this ability continuation result. * @param result: Continuation result */ - void NotifyContinuationResult(int32_t result) override; + ErrCode NotifyContinuationResult(int32_t result) override; /** * @brief notify this ability current memory level. @@ -280,7 +282,7 @@ public: * @param uri Indicates the Uri object to normalize. * @return Returns the normalized Uri object if the Data ability supports URI normalization; returns null otherwise. */ - Uri NormalizeUri(const Uri &uri) override; + ErrCode NormalizeUri(const Uri &uri, AmUri& funcResult) override; /** * @brief Converts the given normalized uri generated by normalizeUri(ohos.utils.net.Uri) into a denormalized one. @@ -290,47 +292,47 @@ public: * to this method if there is nothing to do; returns null if the data identified by the original Uri cannot be found * in the current environment. */ - Uri DenormalizeUri(const Uri &uri) override; + ErrCode DenormalizeUri(const Uri &uri, AmUri& funcResult) override; /** * @brief Registers an observer to DataObsMgr specified by the given Uri. * @param uri Indicates the path of the data to operate. * @param dataObserver Indicates the IDataAbilityObserver object. */ - bool ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) override; + ErrCode ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) override; /** * @brief Deregisters an observer used for DataObsMgr specified by the given Uri. * @param uri Indicates the path of the data to operate. * @param dataObserver Indicates the IDataAbilityObserver object. */ - bool ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) override; + ErrCode ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) override; /** * @brief Notifies the registered observers of a change to the data resource specified by Uri. * @param uri Indicates the path of the data to operate. */ - bool ScheduleNotifyChange(const Uri &uri) override; + ErrCode ScheduleNotifyChange(const Uri &uri) override; /** * @brief Dump ability runner info. * @param params the params need to be Dumped * @param info ability runner info. */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override; + ErrCode DumpAbilityInfo(const std::vector ¶ms) override; /** * @brief Call Request */ - void CallRequest() override; + ErrCode CallRequest() override; /** * @brief Performs batch operations on the database * @param operations Indicates a list of database operations on the database. * @return Returns the result of each operation, in array. */ - std::vector> ExecuteBatch( - const std::vector> &operations) override; + ErrCode ExecuteBatch(const std::vector> &operations, + std::vector>& funcResult) override; /** * @brief create modal UIExtension. @@ -342,7 +344,7 @@ public: * @brief Update sessionToken. * @param sessionToken The token of session. */ - void UpdateSessionToken(sptr sessionToken) override; + ErrCode UpdateSessionToken(const sptr& sessionToken) override; private: /** diff --git a/interfaces/kits/native/ability/native/ui_ability_thread.h b/interfaces/kits/native/ability/native/ui_ability_thread.h index 820a7e0105c543dc7350473ee337919612266528..7456bd0c9b79eba606872bb02f7b99e8fb7d9097 100644 --- a/interfaces/kits/native/ability/native/ui_ability_thread.h +++ b/interfaces/kits/native/ability/native/ui_ability_thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -76,30 +76,30 @@ public: * @param targetState Indicates the lifecycle state. * @param sessionInfo Indicates the session info. */ - bool ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, - sptr sessionInfo = nullptr) override; + ErrCode ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, + const sptr& sessionInfo) override; /** * @brief Provide operating system ShareData information to the observer * @param requestCode Indicates the Ability request code. */ - void ScheduleShareData(const int32_t &requestCode) override; + ErrCode ScheduleShareData(int32_t requestCode) override; /** * @brief Provide operating system PrepareTerminateAbility information to the observer */ - bool SchedulePrepareTerminateAbility() override; + ErrCode SchedulePrepareTerminateAbility() override; /** * @brief Provide operating system SaveabilityState information to the observer */ - void ScheduleSaveAbilityState() override; + ErrCode ScheduleSaveAbilityState() override; /** * @brief Provide operating system RestoreAbilityState information to the observer * @param state Indicates resotre ability state used to dispatchRestoreAbilityState. */ - void ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) override; + ErrCode ScheduleRestoreAbilityState(const AppExecFwk::PacMap &state) override; /** * @brief Send the result code and data to be returned by this Page ability to the caller. @@ -112,33 +112,33 @@ public: * @param want Indicates the data returned after the ability is destroyed. You can define the data returned. This * parameter can be null. */ - void SendResult(int requestCode, int resultCode, const Want &resultData) override; + ErrCode SendResult(int requestCode, int resultCode, const Want &resultData) override; /** * @brief continue ability to target device. * @param deviceId target deviceId * @param versionCode Target bundle version. */ - void ContinueAbility(const std::string &deviceId, uint32_t versionCode) override; + ErrCode ContinueAbility(const std::string &deviceId, uint32_t versionCode) override; /** * @brief notify this ability continuation result. * @param result Continuation result */ - void NotifyContinuationResult(int32_t result) override; + ErrCode NotifyContinuationResult(int32_t result) override; /** * @brief Dump ability runner info. * @param runnerInfo ability runner info. */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override; + ErrCode DumpAbilityInfo(const std::vector ¶ms) override; /** * @brief Call Request */ - void CallRequest() override; + ErrCode CallRequest() override; - void OnExecuteIntent(const Want &want) override; + ErrCode OnExecuteIntent(const Want &want) override; /** * @brief create modal UIExtension. @@ -150,14 +150,14 @@ public: * @brief Update sessionToken. * @param sessionToken The token of session. */ - void UpdateSessionToken(sptr sessionToken) override; + ErrCode UpdateSessionToken(const sptr& sessionToken) override; - void ScheduleCollaborate(const Want &want) override; + ErrCode ScheduleCollaborate(const Want &want) override; - void ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, + ErrCode ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, const std::string &message) override; - void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override; + ErrCode ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override; private: void DumpAbilityInfoInner(const std::vector ¶ms, std::vector &info); diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 237513c55a1ef8f845bad13e4c29453c579192f3..159f6e8a3418778ed11a601a0c639c83e101e174 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -121,6 +121,7 @@ ohos_shared_library("abilityms") { configs = [ ":abilityms_config", ":abilityms_exception_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", ] include_dirs = [ "${ability_runtime_services_path}/appdfr/include", @@ -131,6 +132,7 @@ ohos_shared_library("abilityms") { ":wantagent_manager", "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_proxy", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", @@ -313,6 +315,8 @@ ohos_shared_library("wantagent_manager") { "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", ] + configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config" ] + external_deps = [ "ability_base:want", "c_utils:utils", @@ -422,6 +426,8 @@ ohos_shared_library("mission_list") { "src/task_data_persistence_mgr.cpp", ] + configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config" ] + deps = [ ":abilityms", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index 2205acc6e586d35825dfe18645ff80524f410c61..473e068168c9747ec15cbf350483294a92cad6b2 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -24,7 +24,6 @@ abilityms_files = [ "src/ability_manager_stub.cpp", "src/ability_record.cpp", "src/ability_manager_collaborator_proxy.cpp", - "src/ability_scheduler_proxy.cpp", "src/ability_start_with_wait_observer_manager/ability_start_with_wait_observer_manager.cpp", "src/ability_token_stub.cpp", "src/app_scheduler.cpp", diff --git a/services/abilitymgr/include/ability_scheduler_proxy.h b/services/abilitymgr/include/ability_scheduler_proxy.h deleted file mode 100644 index e25c6ac659746768422637821b744091a1e29d4e..0000000000000000000000000000000000000000 --- a/services/abilitymgr/include/ability_scheduler_proxy.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULE_PROXY_H -#define OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULE_PROXY_H - -#include "ability_scheduler_interface.h" - -#include - -namespace OHOS { -namespace NativeRdb { -class AbsSharedResultSet; -class DataAbilityPredicates; -class ValuesBucket; -} // namespace NativeRdb -namespace AppExecFwk { -} // namespace AppExecFwk -namespace AAFwk { -/** - * @class AbilitySchedulerProxy - * AbilityScheduler proxy. - */ -class AbilitySchedulerProxy : public IRemoteProxy { -public: - explicit AbilitySchedulerProxy(const sptr &impl) : IRemoteProxy(impl) - {} - - virtual ~AbilitySchedulerProxy() - {} - - /* - * ScheduleAbilityTransaction, schedule ability to transform life state. - * - * @param Want, Special Want for service type's ability. - * @param stateInfo, The lifecycle state to be transformed. - */ - bool ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &stateInfo, - sptr sessionInfo = nullptr) override; - - /* - * ScheduleShareData, schedule ability to transform life state and share data with orgin ability. - * - * @param want, special Want for service type's ability. - * @param stateInfo, the lifecycle state to be transformed. - * @param uniqueId, the Id of origin ability request. - */ - void ScheduleShareData(const int32_t &uniqueId) override; - - /* - * SendResult, Send result to app when ability is terminated with result want. - * - * @param requestCode, the requestCode of the ability to start. - * @param resultCode, the resultCode of the ability to terminate. - * @param resultWant, the want of the ability to terminate. - */ - void SendResult(int requestCode, int resultCode, const Want &resultWant) override; - - /* - * ScheduleConnectAbility, schedule service ability to connect. - * - * @param Want, Special Want for service type's ability. - */ - void ScheduleConnectAbility(const Want &want) override; - - /* - * ScheduleDisconnectAbility, schedule service ability to disconnect. - */ - void ScheduleDisconnectAbility(const Want &want) override; - - /* - * ScheduleCommandAbility, schedule service ability to command. - */ - void ScheduleCommandAbility(const Want &want, bool restart, int startId) override; - - void ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, - WindowCommand winCmd) override; - - /* - * SchedulePrepareTerminateAbility, schedule service ability to prepare terminate. - */ - bool SchedulePrepareTerminateAbility() override; - - /* - * ScheduleSaveAbilityState, scheduling save ability state. - */ - void ScheduleSaveAbilityState() override; - - /* - * ScheduleRestoreAbilityState, scheduling restore ability state. - */ - void ScheduleRestoreAbilityState(const PacMap &inState) override; - - /** - * @brief Obtains the MIME types of files supported. - * - * @param uri Indicates the path of the files to obtain. - * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. - * - * @return Returns the matched MIME types. If there is no match, null is returned. - */ - virtual std::vector GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; - - /** - * @brief Opens a file in a specified remote path. - * - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, - * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, - * or "rwt" for read and write access that truncates any existing file. - * - * @return Returns the file descriptor. - */ - virtual int OpenFile(const Uri &uri, const std::string &mode) override; - - /** - * @brief This is like openFile, open a file that need to be able to return sub-sections of files,often assets - * inside of their .hap. - * - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, - * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing - * data, or "rwt" for read and write access that truncates any existing file. - * - * @return Returns the RawFileDescriptor object containing file descriptor. - */ - virtual int OpenRawFile(const Uri &uri, const std::string &mode) override; - - /** - * @brief Inserts a single data record into the database. - * - * @param uri Indicates the path of the data to operate. - * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. - * - * @return Returns the index of the inserted data record. - */ - virtual int Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) override; - - /** - * @brief Calls the method of the Data ability. - * - * @param uri Indicates the Data ability of the method to call. - * @param method Indicates the method to call. - * @param arg Indicates the parameter of the String type. - * @param pacMap Defines a PacMap object for storing a series of values. - * - * @return Returns the call result. - */ - virtual std::shared_ptr Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) override; - - /** - * @brief Updates data records in the database. - * - * @param uri Indicates the path of data to update. - * @param value Indicates the data to update. This parameter can be null. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the number of data records updated. - */ - virtual int Update(const Uri &uri, const NativeRdb::ValuesBucket &value, - const NativeRdb::DataAbilityPredicates &predicates) override; - - /** - * @brief Deletes one or more data records from the database. - * - * @param uri Indicates the path of the data to operate. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the number of data records deleted. - */ - virtual int Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) override; - - /** - * @brief Deletes one or more data records from the database. - * - * @param uri Indicates the path of data to query. - * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the query result. - */ - virtual std::shared_ptr Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) override; - - /** - * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be - * implemented by a Data ability. Data abilities supports general data types, including text, HTML, and JPEG. - * - * @param uri Indicates the URI of the data. - * - * @return Returns the MIME type that matches the data specified by uri. - */ - std::string GetType(const Uri &uri) override; - - /** - * @brief Reloads data in the database. - * - * @param uri Indicates the position where the data is to reload. This parameter is mandatory. - * @param extras Indicates the PacMap object containing the additional parameters to be passed in this call. This - * parameter can be null. If a custom Sequenceable object is put in the PacMap object and will be transferred across - * processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. - * - * @return Returns true if the data is successfully reloaded; returns false otherwise. - */ - bool Reload(const Uri &uri, const PacMap &extras) override; - - /** - * @brief Inserts multiple data records into the database. - * - * @param uri Indicates the path of the data to operate. - * @param values Indicates the data records to insert. - * - * @return Returns the number of data records inserted. - */ - int BatchInsert(const Uri &uri, const std::vector &values) override; - - /** - * @brief Registers an observer to DataObsMgr specified by the given Uri. - * - * @param uri, Indicates the path of the data to operate. - * @param dataObserver, Indicates the IDataAbilityObserver object. - * - * @return Return true if success. otherwise return false. - */ - bool ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) override; - - /** - * @brief Deregisters an observer used for DataObsMgr specified by the given Uri. - * - * @param uri, Indicates the path of the data to operate. - * @param dataObserver, Indicates the IDataAbilityObserver object. - * - * @return Return true if success. otherwise return false. - */ - bool ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) override; - - /** - * @brief Notifies the registered observers of a change to the data resource specified by Uri. - * - * @param uri, Indicates the path of the data to operate. - * - * @return Return true if success. otherwise return false. - */ - bool ScheduleNotifyChange(const Uri &uri) override; - - /** - * @brief Converts the given uri that refer to the Data ability into a normalized URI. A normalized URI can be used - * across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability even if the - * context has changed. If you implement URI normalization for a Data ability, you must also implement - * denormalizeUri(ohos.utils.net.Uri) to enable URI denormalization. After this feature is enabled, URIs passed to - * any method that is called on the Data ability must require normalization verification and denormalization. The - * default implementation of this method returns null, indicating that this Data ability does not support URI - * normalization. - * - * @param uri Indicates the Uri object to normalize. - * - * @return Returns the normalized Uri object if the Data ability supports URI normalization; returns null otherwise. - */ - Uri NormalizeUri(const Uri &uri) override; - - /** - * @brief Converts the given normalized uri generated by normalizeUri(ohos.utils.net.Uri) into a denormalized one. - * The default implementation of this method returns the original URI passed to it. - * - * @param uri uri Indicates the Uri object to denormalize. - * - * @return Returns the denormalized Uri object if the denormalization is successful; returns the original Uri passed - * to this method if there is nothing to do; returns null if the data identified by the original Uri cannot be found - * in the current environment. - */ - Uri DenormalizeUri(const Uri &uri) override; - - /** - * @brief Performs batch operations on the database. - * - * @param operations Indicates a list of database operations on the database. - * @return Returns the result of each operation, in array. - */ - std::vector> ExecuteBatch( - const std::vector> &operations) override; - - /** - * ContinueAbility, call ContinueAbility() through proxy project, - * Notify continue ability. - * - * @param deviceId Target deviceId. - * @param versionCode Target bundle version. - * @return - */ - void ContinueAbility(const std::string& deviceId, uint32_t versionCode) override; - - /** - * NotifyContinuationResult, call NotifyContinuationResult() through proxy project, - * Notify continuation result to ability. - * - * @param The continuation result. - * @return - */ - void NotifyContinuationResult(int32_t result) override; - - /** - * Dump Ability Runner info. - * - * @param - * @return Ability Runner info. - */ - void DumpAbilityInfo(const std::vector ¶ms, std::vector &info) override; - void CallRequest() override; - int32_t CreateModalUIExtension(const Want &want) override; - - void OnExecuteIntent(const Want &want) override; - - /** - * @brief Update sessionToken. - * @param sessionToken The token of session. - */ - void UpdateSessionToken(sptr sessionToken) override; - - void ScheduleCollaborate(const Want &want) override; - - void ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, - const std::string &message) override; - - void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override; - -private: - bool WriteInterfaceToken(MessageParcel &data); - int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULE_PROXY_H diff --git a/services/abilitymgr/include/ability_scheduler_recipient.h b/services/abilitymgr/include/ability_scheduler_recipient.h new file mode 100644 index 0000000000000000000000000000000000000000..24e8975bb411a79b635d3ff96c1aa549abef6285 --- /dev/null +++ b/services/abilitymgr/include/ability_scheduler_recipient.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULER_RECIPIENT_H +#define OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULER_RECIPIENT_H + +#include + +#include "hilog_tag_wrapper.h" + +namespace OHOS { +namespace AAFwk { +/** + * @class AbilitySchedulerRecipient + * AbilitySchedulerRecipient notices IRemoteBroker died. + */ +class AbilitySchedulerRecipient : public IRemoteObject::DeathRecipient { +public: + using RemoteDiedHandler = std::function &)>; + explicit AbilitySchedulerRecipient(RemoteDiedHandler handler); + virtual ~AbilitySchedulerRecipient(); + virtual void OnRemoteDied(const wptr &remote); +private: + RemoteDiedHandler handler_; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULE_STUB_H \ No newline at end of file diff --git a/services/abilitymgr/include/ability_scheduler_stub.h b/services/abilitymgr/include/ability_scheduler_stub.h deleted file mode 100644 index e85b2d94faaa58b11f39ed2bcc4ef1832ff53685..0000000000000000000000000000000000000000 --- a/services/abilitymgr/include/ability_scheduler_stub.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2021-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_ABILITY_RUNTIME_ABILITY_SCHEDULE_STUB_H -#define OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULE_STUB_H - -#include - -#include "ability_scheduler_interface.h" - -#include -#include - -namespace OHOS { -namespace AAFwk { -/** - * @class AbilitySchedulerStub - * AbilityScheduler Stub. - */ -class AbilitySchedulerStub : public IRemoteStub { -public: - AbilitySchedulerStub(); - ~AbilitySchedulerStub(); - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - int AbilityTransactionInner(MessageParcel &data, MessageParcel &reply); - int SendResultInner(MessageParcel &data, MessageParcel &reply); - int ConnectAbilityInner(MessageParcel &data, MessageParcel &reply); - int DisconnectAbilityInner(MessageParcel &data, MessageParcel &reply); - int CommandAbilityInner(MessageParcel &data, MessageParcel &reply); - int PrepareTerminateAbilityInner(MessageParcel &data, MessageParcel &reply); - int CommandAbilityWindowInner(MessageParcel &data, MessageParcel &reply); - int SaveAbilityStateInner(MessageParcel &data, MessageParcel &reply); - int RestoreAbilityStateInner(MessageParcel &data, MessageParcel &reply); - int GetFileTypesInner(MessageParcel &data, MessageParcel &reply); - int OpenFileInner(MessageParcel &data, MessageParcel &reply); - int OpenRawFileInner(MessageParcel &data, MessageParcel &reply); - int InsertInner(MessageParcel &data, MessageParcel &reply); - int UpdatetInner(MessageParcel &data, MessageParcel &reply); - int DeleteInner(MessageParcel &data, MessageParcel &reply); - int QueryInner(MessageParcel &data, MessageParcel &reply); - int CallInner(MessageParcel &data, MessageParcel &reply); - int GetTypeInner(MessageParcel &data, MessageParcel &reply); - int ReloadInner(MessageParcel &data, MessageParcel &reply); - int BatchInsertInner(MessageParcel &data, MessageParcel &reply); - int RegisterObserverInner(MessageParcel &data, MessageParcel &reply); - int UnregisterObserverInner(MessageParcel &data, MessageParcel &reply); - int NotifyChangeInner(MessageParcel &data, MessageParcel &reply); - int NormalizeUriInner(MessageParcel &data, MessageParcel &reply); - int DenormalizeUriInner(MessageParcel &data, MessageParcel &reply); - int ExecuteBatchInner(MessageParcel &data, MessageParcel &reply); - int NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply); - int DumpAbilityInfoInner(MessageParcel& data, MessageParcel& reply); - int CallRequestInner(MessageParcel &data, MessageParcel &reply); - int OnExecuteIntentInner(MessageParcel &data, MessageParcel &reply); - int ContinueAbilityInner(MessageParcel &data, MessageParcel &reply); - int ShareDataInner(MessageParcel &data, MessageParcel &reply); - int CreateModalUIExtensionInner(MessageParcel &data, MessageParcel &reply); - int UpdateSessionTokenInner(MessageParcel &data, MessageParcel &reply); - int OnRemoteRequestInner( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); - int OnRemoteRequestInnerFirst( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); - int OnRemoteRequestInnerSecond( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); - int OnRemoteRequestInnerThird( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); - int CollaborateDataInner(MessageParcel &data); - int ScheduleAbilityRequestFailureInner(MessageParcel &data); - int ScheduleAbilityRequestSuccessInner(MessageParcel &data); -}; - -/** - * @class AbilitySchedulerRecipient - * AbilitySchedulerRecipient notices IRemoteBroker died. - */ -class AbilitySchedulerRecipient : public IRemoteObject::DeathRecipient { -public: - using RemoteDiedHandler = std::function &)>; - - explicit AbilitySchedulerRecipient(RemoteDiedHandler handler); - - virtual ~AbilitySchedulerRecipient(); - - virtual void OnRemoteDied(const wptr &remote); - -private: - RemoteDiedHandler handler_; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ABILITY_SCHEDULE_STUB_H diff --git a/services/abilitymgr/include/lifecycle_deal.h b/services/abilitymgr/include/lifecycle_deal.h index 85132710b305da05c35636823b04ad2a2638eb8d..aaf6c71684941f0a219e65aaee0b1f72a89e9109 100644 --- a/services/abilitymgr/include/lifecycle_deal.h +++ b/services/abilitymgr/include/lifecycle_deal.h @@ -19,7 +19,8 @@ #include #include -#include "ability_scheduler_interface.h" +#include "iability_scheduler.h" +#include "ui_extension_window_command.h" #include "want.h" #include "nocopyable.h" diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index bf010ca5e25c1a37ee89ecb7c8235f2222b04765..b5c341cd0225b8f5816d40c2dd9838c46b04d585 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -19,6 +19,7 @@ #include "ability_manager_service.h" #include "ability_resident_process_rdb.h" +#include "ability_scheduler_recipient.h" #include "ability_scheduler_stub.h" #include "app_exit_reason_data_manager.h" #include "app_utils.h" @@ -3358,7 +3359,7 @@ void AbilityRecord::DumpClientInfo(std::vector &info, const std::ve return; } std::unique_lock lock(dumpLock_); - scheduler_->DumpAbilityInfo(params, info); + scheduler_->DumpAbilityInfo(params); TAG_LOGI(AAFwkTag::ABILITYMGR, "dump begin wait"); isDumpTimeout_ = false; diff --git a/services/abilitymgr/src/ability_scheduler_proxy.cpp b/services/abilitymgr/src/ability_scheduler_proxy.cpp deleted file mode 100644 index d540ca7906630e3fc2ccf68fcf6ae5a2e5b24c3a..0000000000000000000000000000000000000000 --- a/services/abilitymgr/src/ability_scheduler_proxy.cpp +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "ability_scheduler_proxy.h" - -#include "ability_manager_errors.h" -#include "data_ability_observer_interface.h" -#include "data_ability_operation.h" -#include "data_ability_predicates.h" -#include "data_ability_result.h" -#include "error_msg_util.h" -#include "hilog_tag_wrapper.h" -#include "hitrace_meter.h" -#include "ipc_capacity_wrap.h" -#include "ishared_result_set.h" -#include "session_info.h" -#include "values_bucket.h" - -namespace OHOS { -namespace AAFwk { -namespace { -const int64_t SCHEDULE_IPC_LOG_TIME = 10000; -} -bool AbilitySchedulerProxy::WriteInterfaceToken(MessageParcel &data) -{ - if (!data.WriteInterfaceToken(AbilitySchedulerProxy::GetDescriptor())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return false; - } - return true; -} - -bool AbilitySchedulerProxy::ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &stateInfo, - sptr sessionInfo) -{ - HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITYMGR, "begin"); - auto start = std::chrono::system_clock::now(); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - return false; - } - auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast(this), - "ScheduleAbilityTransaction"); - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write want failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write want failed"); - return false; - } - data.WriteParcelable(&stateInfo); - if (sessionInfo) { - SessionInfo tmpInfo = *sessionInfo; - tmpInfo.want = Want(); - if (!data.WriteBool(true) || !data.WriteParcelable(&tmpInfo)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionInfo failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write sessionInfo failed"); - return false; - } - } else { - if (!data.WriteBool(false)) { - return false; - } - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_TRANSACTION, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, - std::string("ScheduleAbilityTransaction ipc error " + std::to_string(err))); - return false; - } - int64_t cost = std::chrono::duration_cast( - std::chrono::system_clock::now() - start).count(); - if (cost > SCHEDULE_IPC_LOG_TIME) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "ScheduleAbilityTransaction proxy cost %{public}" PRId64 "mirco seconds," - " data size: %{public}zu", cost, data.GetWritePosition()); - } else { - TAG_LOGD(AAFwkTag::ABILITYMGR, "ScheduleAbilityTransaction proxy cost %{public}" PRId64 "mirco seconds," - " data size: %{public}zu", cost, data.GetWritePosition()); - } - return true; -} - -void AbilitySchedulerProxy::ScheduleShareData(const int32_t &uniqueId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return; - } - if (!data.WriteInt32(uniqueId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "uniqueId write failed"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_SHARE_DATA, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } - return; -} - -void AbilitySchedulerProxy::SendResult(int requestCode, int resultCode, const Want &resultWant) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteInt32(requestCode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestCode failed"); - return; - } - if (!data.WriteInt32(resultCode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write resultCode failed"); - return; - } - if (!data.WriteParcelable(&resultWant)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SEND_RESULT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::ScheduleConnectAbility(const Want &want) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "fail to WriteParcelable"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_CONNECT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::ScheduleDisconnectAbility(const Want &want) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "fail to WriteParcelable"); - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_DISCONNECT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::ScheduleCommandAbility(const Want &want, bool restart, int startId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "WriteParcelable failed"); - return; - } - if (!data.WriteBool(restart)) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "WriteBool failed"); - return; - } - TAG_LOGD(AAFwkTag::SERVICE_EXT, "WriteInt32,startId:%{public}d", startId); - if (!data.WriteInt32(startId)) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "fail to WriteInt32"); - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_COMMAND, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "fail, err: %{public}d", err); - } -} - -bool AbilitySchedulerProxy::SchedulePrepareTerminateAbility() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to write interface"); - return false; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_PREPARE_TERMINATE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "failed, err: %{public}d", err); - return false; - } - return true; -} - -void AbilitySchedulerProxy::ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, - WindowCommand winCmd) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "writeParcelable failed"); - return; - } - if (!data.WriteParcelable(sessionInfo)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "writeParcelable failed"); - return; - } - if (!data.WriteInt32(winCmd)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32"); - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_COMMAND_WINDOW, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::ScheduleSaveAbilityState() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_SAVE_ABILITY_STATE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::ScheduleRestoreAbilityState(const PacMap &inState) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteParcelable(&inState)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "writeParcelable err"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_RESTORE_ABILITY_STATE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -/** - * @brief Obtains the MIME types of files supported. - * - * @param uri Indicates the path of the files to obtain. - * @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null. - * - * @return Returns the matched MIME types. If there is no match, null is returned. - */ -std::vector AbilitySchedulerProxy::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) -{ - std::vector types; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return types; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return types; - } - - if (!data.WriteString(mimeTypeFilter)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString mimeTypeFilter"); - return types; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_GETFILETYPES, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } - - if (!reply.ReadStringVector(&types)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadStringVector types"); - } - - return types; -} - -/** - * @brief Opens a file in a specified remote path. - * - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, - * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, - * or "rwt" for read and write access that truncates any existing file. - * - * @return Returns the file descriptor. - */ -int AbilitySchedulerProxy::OpenFile(const Uri &uri, const std::string &mode) -{ - int fd = -1; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return fd; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return fd; - } - - if (!data.WriteString(mode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString mode"); - return fd; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_OPENFILE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return fd; - } - - fd = reply.ReadFileDescriptor(); - if (fd == -1) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 fd"); - return fd; - } - - return fd; -} - -/** - * @brief This is like openFile, open a file that need to be able to return sub-sections of files,often assets - * inside of their .hap. - * - * @param uri Indicates the path of the file to open. - * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access - * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, - * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing - * data, or "rwt" for read and write access that truncates any existing file. - * - * @return Returns the RawFileDescriptor object containing file descriptor. - */ -int AbilitySchedulerProxy::OpenRawFile(const Uri &uri, const std::string &mode) -{ - int fd = -1; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return fd; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return fd; - } - - if (!data.WriteString(mode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString mode"); - return fd; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_OPENRAWFILE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return fd; - } - - if (!reply.ReadInt32(fd)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 fd"); - return fd; - } - - return fd; -} - -/** - * @brief Inserts a single data record into the database. - * - * @param uri Indicates the path of the data to operate. - * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. - * - * @return Returns the index of the inserted data record. - */ -int AbilitySchedulerProxy::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value) -{ - int index = -1; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return index; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return index; - } - - if (!value.Marshalling(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable value"); - return index; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_INSERT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return index; - } - - if (!reply.ReadInt32(index)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 index"); - return index; - } - - return index; -} - -/** - * @brief Inserts a single data record into the database. - * - * @param uri Indicates the path of the data to operate. - * @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted. - * - * @return Returns the index of the inserted data record. - */ -std::shared_ptr AbilitySchedulerProxy::Call( - const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return nullptr; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return nullptr; - } - - if (!data.WriteString(method)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString method"); - return nullptr; - } - - if (!data.WriteString(arg)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString arg"); - return nullptr; - } - - if (!data.WriteParcelable(&pacMap)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable pacMap"); - return nullptr; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_CALL, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return nullptr; - } - std::shared_ptr result(reply.ReadParcelable()); - if (!result) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelable value null"); - return nullptr; - } - return result; -} - -/** - * @brief Updates data records in the database. - * - * @param uri Indicates the path of data to update. - * @param value Indicates the data to update. This parameter can be null. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the number of data records updated. - */ -int AbilitySchedulerProxy::Update(const Uri &uri, const NativeRdb::ValuesBucket &value, - const NativeRdb::DataAbilityPredicates &predicates) -{ - int index = -1; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return index; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return index; - } - - if (!value.Marshalling(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable value"); - return index; - } - - if (!data.WriteParcelable(&predicates)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable predicates"); - return index; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_UPDATE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return index; - } - - if (!reply.ReadInt32(index)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 index"); - return index; - } - - return index; -} - -/** - * @brief Deletes one or more data records from the database. - * - * @param uri Indicates the path of the data to operate. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the number of data records deleted. - */ -int AbilitySchedulerProxy::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates) -{ - int index = -1; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return index; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return index; - } - - if (!data.WriteParcelable(&predicates)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable predicates"); - return index; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_DELETE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return index; - } - - if (!reply.ReadInt32(index)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 index"); - return index; - } - - return index; -} - -/** - * @brief Deletes one or more data records from the database. - * - * @param uri Indicates the path of data to query. - * @param columns Indicates the columns to query. If this parameter is null, all columns are queried. - * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null. - * - * @return Returns the query result. - */ -std::shared_ptr AbilitySchedulerProxy::Query( - const Uri &uri, std::vector &columns, const NativeRdb::DataAbilityPredicates &predicates) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return nullptr; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return nullptr; - } - - if (!data.WriteStringVector(columns)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteStringVector columns"); - return nullptr; - } - - if (!data.WriteParcelable(&predicates)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable predicates"); - return nullptr; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_QUERY, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return nullptr; - } - return OHOS::NativeRdb::ISharedResultSet::ReadFromParcel(reply); -} - -/** - * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be - * implemented by a Data ability. Data abilities supports general data types, including text, HTML, and JPEG. - * - * @param uri Indicates the URI of the data. - * - * @return Returns the MIME type that matches the data specified by uri. - */ -std::string AbilitySchedulerProxy::GetType(const Uri &uri) -{ - std::string type; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return type; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return type; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_GETTYPE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return type; - } - - type = reply.ReadString(); - if (type.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadString type"); - return type; - } - - return type; -} - -/** - * @brief Reloads data in the database. - * - * @param uri Indicates the position where the data is to reload. This parameter is mandatory. - * @param extras Indicates the PacMap object containing the additional parameters to be passed in this call. This - * parameter can be null. If a custom Sequenceable object is put in the PacMap object and will be transferred across - * processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. - * - * @return Returns true if the data is successfully reloaded; returns false otherwise. - */ -bool AbilitySchedulerProxy::Reload(const Uri &uri, const PacMap &extras) -{ - bool ret = false; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return ret; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return ret; - } - - if (!data.WriteParcelable(&extras)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable extras"); - return ret; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_RELOAD, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return ret; - } - - ret = reply.ReadBool(); - if (!ret) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadBool ret"); - return ret; - } - - return ret; -} - -/** - * @brief Inserts multiple data records into the database. - * - * @param uri Indicates the path of the data to operate. - * @param values Indicates the data records to insert. - * - * @return Returns the number of data records inserted. - */ -int AbilitySchedulerProxy::BatchInsert(const Uri &uri, const std::vector &values) -{ - int ret = -1; - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return ret; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return ret; - } - - int count = (int)values.size(); - if (!data.WriteInt32(count)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ret; - } - - for (int i = 0; i < count; i++) { - if (!values[i].Marshalling(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, index: %{public}d", i); - return ret; - } - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_BATCHINSERT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return ret; - } - - if (!reply.ReadInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 index"); - return ret; - } - - return ret; -} - -/** - * @brief Registers an observer to DataObsMgr specified by the given Uri. - * - * @param uri, Indicates the path of the data to operate. - * @param dataObserver, Indicates the IDataAbilityObserver object. - */ -bool AbilitySchedulerProxy::ScheduleRegisterObserver(const Uri &uri, const sptr &dataObserver) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s WriteInterfaceToken(data) return false", __func__); - return false; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s failed to WriteParcelable uri ", __func__); - return false; - } - - if (!data.WriteRemoteObject(dataObserver->AsObject())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s failed to WriteParcelable dataObserver ", __func__); - return false; - } - - int32_t result = SendTransactCmd(IAbilityScheduler::SCHEDULE_REGISTEROBSERVER, data, reply, option); - if (result == ERR_NONE) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s SendRequest ok, retval: %{public}d", __func__, reply.ReadInt32()); - return true; - } else { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s SendRequest error, result=%{public}d", __func__, result); - return false; - } -} - -/** - * @brief Deregisters an observer used for DataObsMgr specified by the given Uri. - * - * @param uri, Indicates the path of the data to operate. - * @param dataObserver, Indicates the IDataAbilityObserver object. - */ -bool AbilitySchedulerProxy::ScheduleUnregisterObserver(const Uri &uri, const sptr &dataObserver) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s WriteInterfaceToken(data) return false", __func__); - return false; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s failed to WriteParcelable uri ", __func__); - return false; - } - - if (!data.WriteRemoteObject(dataObserver->AsObject())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s failed to WriteParcelable dataObserver ", __func__); - return false; - } - - int32_t result = SendTransactCmd(IAbilityScheduler::SCHEDULE_UNREGISTEROBSERVER, data, reply, option); - if (result == ERR_NONE) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32()); - return true; - } else { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s SendRequest error, result=%{public}d", __func__, result); - return false; - } -} - -/** - * @brief Notifies the registered observers of a change to the data resource specified by Uri. - * - * @param uri, Indicates the path of the data to operate. - */ -bool AbilitySchedulerProxy::ScheduleNotifyChange(const Uri &uri) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s WriteInterfaceToken(data) return false", __func__); - return false; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s failed to WriteParcelable uri ", __func__); - return false; - } - - int32_t result = SendTransactCmd(IAbilityScheduler::SCHEDULE_NOTIFYCHANGE, data, reply, option); - if (result == ERR_NONE) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s SendRequest ok, retval: %{public}d", __func__, reply.ReadInt32()); - return true; - } else { - TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s SendRequest error, result=%{public}d", __func__, result); - return false; - } -} - -/** - * @brief Converts the given uri that refer to the Data ability into a normalized URI. A normalized URI can be used - * across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability even if the - * context has changed. If you implement URI normalization for a Data ability, you must also implement - * denormalizeUri(ohos.utils.net.Uri) to enable URI denormalization. After this feature is enabled, URIs passed to - * any method that is called on the Data ability must require normalization verification and denormalization. The - * default implementation of this method returns null, indicating that this Data ability does not support URI - * normalization. - * - * @param uri Indicates the Uri object to normalize. - * - * @return Returns the normalized Uri object if the Data ability supports URI normalization; returns null otherwise. - */ -Uri AbilitySchedulerProxy::NormalizeUri(const Uri &uri) -{ - Uri urivalue(""); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return urivalue; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return urivalue; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_NORMALIZEURI, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return Uri(""); - } - - std::unique_ptr info(reply.ReadParcelable()); - if (!info) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelable value null"); - return Uri(""); - } - return *info; -} - -/** - * @brief Converts the given normalized uri generated by normalizeUri(ohos.utils.net.Uri) into a denormalized one. - * The default implementation of this method returns the original URI passed to it. - * - * @param uri uri Indicates the Uri object to denormalize. - * - * @return Returns the denormalized Uri object if the denormalization is successful; returns the original Uri passed - * to this method if there is nothing to do; returns null if the data identified by the original Uri cannot be found - * in the current environment. - */ -Uri AbilitySchedulerProxy::DenormalizeUri(const Uri &uri) -{ - Uri urivalue(""); - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!WriteInterfaceToken(data)) { - return urivalue; - } - - if (!data.WriteParcelable(&uri)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable uri"); - return urivalue; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_DENORMALIZEURI, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return Uri(""); - } - - std::unique_ptr info(reply.ReadParcelable()); - if (!info) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelable value null"); - return Uri(""); - } - return *info; -} - -std::vector> AbilitySchedulerProxy::ExecuteBatch( - const std::vector> &operations) -{ - TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); - MessageParcel data; - MessageParcel reply; - MessageOption option; - - std::vector> results; - results.clear(); - - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "writer token failed"); - return results; - } - - int count = (int)operations.size(); - if (!data.WriteInt32(count)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 ret failed"); - return results; - } - - for (int i = 0; i < count; i++) { - if (!data.WriteParcelable(operations[i].get())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, - "failed, index: %{public}d", i); - return results; - } - } - - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_EXECUTEBATCH, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "sendRequest failed, err: %{public}d", err); - return results; - } - - int total = 0; - if (!reply.ReadInt32(total)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 count %{public}d", total); - return results; - } - - for (int i = 0; i < total; i++) { - std::shared_ptr dataAbilityResult( - reply.ReadParcelable()); - if (dataAbilityResult == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, - "null dataAbilityResult, index: %{public}d", i); - return results; - } - results.push_back(dataAbilityResult); - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "end %{public}d", total); - return results; -} - -void AbilitySchedulerProxy::ContinueAbility(const std::string& deviceId, uint32_t versionCode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "ContinueAbility fail to write token"); - return; - } - if (!data.WriteString(deviceId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "ContinueAbility fail to write deviceId"); - return; - } - if (!data.WriteUint32(versionCode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "ContinueAbility fail to write versionCode"); - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::CONTINUE_ABILITY, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::NotifyContinuationResult(int32_t result) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyContinuationResult fail to write token"); - return; - } - if (!data.WriteInt32(result)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyContinuationResult fail to write result"); - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::NOTIFY_CONTINUATION_RESULT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::DumpAbilityInfo(const std::vector ¶ms, std::vector &info) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "DumpAbilityRunner fail to write token"); - return; - } - - if (!data.WriteStringVector(params)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "DumpAbilityRunner fail to write params"); - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::DUMP_ABILITY_RUNNER_INNER, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } -} - -void AbilitySchedulerProxy::CallRequest() -{ - TAG_LOGD(AAFwkTag::ABILITYMGR, "start"); - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - - if (!WriteInterfaceToken(data)) { - return; - } - - int32_t err = SendTransactCmd(IAbilityScheduler::REQUEST_CALL_REMOTE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return; - } - - TAG_LOGD(AAFwkTag::ABILITYMGR, "end"); -} - -void AbilitySchedulerProxy::OnExecuteIntent(const Want &want) -{ - TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - return; - } - data.WriteParcelable(&want); - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ONEXECUTE_INTENT, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } - - TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); -} - -int32_t AbilitySchedulerProxy::CreateModalUIExtension(const Want &want) -{ - HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilitySchedulerProxy::CreateModalUIExtension start"); - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - AAFwk::ExtendMaxIpcCapacityForInnerWant(data); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface fail"); - return INNER_ERR; - } - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Write wants fail"); - return INNER_ERR; - } - int32_t err = SendTransactCmd(IAbilityScheduler::CREATE_MODAL_UI_EXTENSION, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - return err; - } - return reply.ReadInt32(); -} - -void AbilitySchedulerProxy::UpdateSessionToken(sptr sessionToken) -{ - MessageParcel data; - if (!WriteInterfaceToken(data)) { - return; - } - if (!data.WriteRemoteObject(sessionToken)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionToken failed"); - return; - } - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - int32_t err = SendTransactCmd(IAbilityScheduler::UPDATE_SESSION_TOKEN, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "sendRequest failed, err: %{public}d", err); - } -} - -int32_t AbilitySchedulerProxy::SendTransactCmd(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - sptr remote = Remote(); - if (remote == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote"); - return ERR_NULL_OBJECT; - } - - int32_t ret = remote->SendRequest(code, data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "sendRequest failed, code: %{public}d, ret: %{public}d", code, ret); - return ret; - } - return NO_ERROR; -} - -void AbilitySchedulerProxy::ScheduleCollaborate(const Want &want) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return; - } - auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast(this), - "ScheduleCollaborate"); - if (!data.WriteParcelable(&want)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write want failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write want failed"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_COLLABORATE_DATA, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } - return; -} - -void AbilitySchedulerProxy::ScheduleAbilityRequestFailure(const std::string &requestId, - const AppExecFwk::ElementName &element, const std::string &message) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return; - } - auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast(this), - "ScheduleAbilityRequestFailure"); - if (!data.WriteString(requestId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestId failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write requestId failed"); - return; - } - if (!data.WriteParcelable(&element)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write element failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write want failed"); - return; - } - if (!data.WriteString(message)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write message failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write message failed"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_REQUEST_FAILURE, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } - return; -} - -void AbilitySchedulerProxy::ScheduleAbilityRequestSuccess(const std::string &requestId, - const AppExecFwk::ElementName &element) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed"); - return; - } - auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast(this), - "ScheduleAbilityRequestSuccess"); - if (!data.WriteString(requestId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestId failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write requestId failed"); - return; - } - if (!data.WriteParcelable(&element)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "write element failed"); - AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write want failed"); - return; - } - int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_REQUEST_SUCCESS, data, reply, option); - if (err != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err); - } - return; -} -} // namespace AAFwk -} // namespace OHOS diff --git a/services/abilitymgr/src/ability_scheduler_recipient.cpp b/services/abilitymgr/src/ability_scheduler_recipient.cpp new file mode 100644 index 0000000000000000000000000000000000000000..94ffda6e77562e8787b27e38ec7b978f1a60d733 --- /dev/null +++ b/services/abilitymgr/src/ability_scheduler_recipient.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 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 "ability_scheduler_recipient.h" + +namespace OHOS { +namespace AAFwk { +void AbilitySchedulerRecipient::OnRemoteDied(const wptr &remote) +{ + TAG_LOGE(AAFwkTag::ABILITYMGR, "call"); + + if (handler_) { + handler_(remote); + } +} + +AbilitySchedulerRecipient::AbilitySchedulerRecipient(RemoteDiedHandler handler) : handler_(handler) +{} + +AbilitySchedulerRecipient::~AbilitySchedulerRecipient() +{} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/ability_scheduler_stub.cpp b/services/abilitymgr/src/ability_scheduler_stub.cpp deleted file mode 100644 index eded41b0f371c8e5682cf75bd8f065fa84603a71..0000000000000000000000000000000000000000 --- a/services/abilitymgr/src/ability_scheduler_stub.cpp +++ /dev/null @@ -1,798 +0,0 @@ -/* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ability_scheduler_stub.h" - -#include "ability_manager_errors.h" -#include "data_ability_observer_interface.h" -#include "data_ability_operation.h" -#include "data_ability_predicates.h" -#include "data_ability_result.h" -#include "hilog_tag_wrapper.h" -#include "ishared_result_set.h" -#include "session_info.h" -#include "values_bucket.h" - -namespace OHOS { -namespace AAFwk { -constexpr int CYCLE_LIMIT = 2000; -AbilitySchedulerStub::AbilitySchedulerStub() -{} - -AbilitySchedulerStub::~AbilitySchedulerStub() -{} - -int AbilitySchedulerStub::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - std::u16string descriptor = AbilitySchedulerStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "descriptor not equal to remote"); - return ERR_INVALID_STATE; - } - return OnRemoteRequestInner(code, data, reply, option); -} - -int AbilitySchedulerStub::OnRemoteRequestInner( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - int retCode = ERR_OK; - retCode = OnRemoteRequestInnerFirst(code, data, reply, option); - if (retCode != ERR_CODE_NOT_EXIST) { - return retCode; - } - retCode = OnRemoteRequestInnerSecond(code, data, reply, option); - if (retCode != ERR_CODE_NOT_EXIST) { - return retCode; - } - retCode = OnRemoteRequestInnerThird(code, data, reply, option); - if (retCode != ERR_CODE_NOT_EXIST) { - return retCode; - } - TAG_LOGW(AAFwkTag::ABILITYMGR, "default case, need check"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -} - -int AbilitySchedulerStub::OnRemoteRequestInnerFirst( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - switch (code) { - case SCHEDULE_ABILITY_TRANSACTION: - return AbilityTransactionInner(data, reply); - case SEND_RESULT: - return SendResultInner(data, reply); - case SCHEDULE_ABILITY_CONNECT: - return ConnectAbilityInner(data, reply); - case SCHEDULE_ABILITY_DISCONNECT: - return DisconnectAbilityInner(data, reply); - case SCHEDULE_ABILITY_COMMAND: - return CommandAbilityInner(data, reply); - case SCHEDULE_ABILITY_PREPARE_TERMINATE: - return PrepareTerminateAbilityInner(data, reply); - case SCHEDULE_ABILITY_COMMAND_WINDOW: - return CommandAbilityWindowInner(data, reply); - case SCHEDULE_SAVE_ABILITY_STATE: - return SaveAbilityStateInner(data, reply); - case SCHEDULE_RESTORE_ABILITY_STATE: - return RestoreAbilityStateInner(data, reply); - case SCHEDULE_GETFILETYPES: - return GetFileTypesInner(data, reply); - case SCHEDULE_OPENFILE: - return OpenFileInner(data, reply); - case SCHEDULE_OPENRAWFILE: - return OpenRawFileInner(data, reply); - case SCHEDULE_INSERT: - return InsertInner(data, reply); - case SCHEDULE_UPDATE: - return UpdatetInner(data, reply); - case SCHEDULE_DELETE: - return DeleteInner(data, reply); - } - return ERR_CODE_NOT_EXIST; -} - -int AbilitySchedulerStub::OnRemoteRequestInnerSecond( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - switch (code) { - case SCHEDULE_QUERY: - return QueryInner(data, reply); - case SCHEDULE_CALL: - return CallInner(data, reply); - case SCHEDULE_GETTYPE: - return GetTypeInner(data, reply); - case SCHEDULE_RELOAD: - return ReloadInner(data, reply); - case SCHEDULE_BATCHINSERT: - return BatchInsertInner(data, reply); - case SCHEDULE_REGISTEROBSERVER: - return RegisterObserverInner(data, reply); - case SCHEDULE_UNREGISTEROBSERVER: - return UnregisterObserverInner(data, reply); - case SCHEDULE_NOTIFYCHANGE: - return NotifyChangeInner(data, reply); - case SCHEDULE_NORMALIZEURI: - return NormalizeUriInner(data, reply); - case SCHEDULE_DENORMALIZEURI: - return DenormalizeUriInner(data, reply); - case SCHEDULE_EXECUTEBATCH: - return ExecuteBatchInner(data, reply); - case NOTIFY_CONTINUATION_RESULT: - return NotifyContinuationResultInner(data, reply); - case REQUEST_CALL_REMOTE: - return CallRequestInner(data, reply); - case CONTINUE_ABILITY: - return ContinueAbilityInner(data, reply); - case DUMP_ABILITY_RUNNER_INNER: - return DumpAbilityInfoInner(data, reply); - } - return ERR_CODE_NOT_EXIST; -} - -int AbilitySchedulerStub::OnRemoteRequestInnerThird( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - switch (code) { - case SCHEDULE_SHARE_DATA: - return ShareDataInner(data, reply); - case SCHEDULE_ONEXECUTE_INTENT: - return OnExecuteIntentInner(data, reply); - case CREATE_MODAL_UI_EXTENSION: - return CreateModalUIExtensionInner(data, reply); - case UPDATE_SESSION_TOKEN: - return UpdateSessionTokenInner(data, reply); - case SCHEDULE_COLLABORATE_DATA: - return CollaborateDataInner(data); - case SCHEDULE_ABILITY_REQUEST_FAILURE: - return ScheduleAbilityRequestFailureInner(data); - case SCHEDULE_ABILITY_REQUEST_SUCCESS: - return ScheduleAbilityRequestSuccessInner(data); - } - return ERR_CODE_NOT_EXIST; -} - -int AbilitySchedulerStub::AbilityTransactionInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - std::unique_ptr stateInfo(data.ReadParcelable()); - if (!stateInfo) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "ReadParcelable failed"); - return ERR_INVALID_VALUE; - } - sptr sessionInfo = nullptr; - if (data.ReadBool()) { - sessionInfo = data.ReadParcelable(); - } - ScheduleAbilityTransaction(*want, *stateInfo, sessionInfo); - return NO_ERROR; -} - -int AbilitySchedulerStub::ShareDataInner(MessageParcel &data, MessageParcel &reply) -{ - int32_t requestCode = data.ReadInt32(); - TAG_LOGI(AAFwkTag::ABILITYMGR, "requestCode:%{public}d", requestCode); - ScheduleShareData(requestCode); - return NO_ERROR; -} - -int AbilitySchedulerStub::SendResultInner(MessageParcel &data, MessageParcel &reply) -{ - int requestCode = data.ReadInt32(); - int resultCode = data.ReadInt32(); - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - SendResult(requestCode, resultCode, *want); - return NO_ERROR; -} - -int AbilitySchedulerStub::ConnectAbilityInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - ScheduleConnectAbility(*want); - return NO_ERROR; -} - -int AbilitySchedulerStub::DisconnectAbilityInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - ScheduleDisconnectAbility(*want); - return NO_ERROR; -} - -int AbilitySchedulerStub::CommandAbilityInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - bool reStart = data.ReadBool(); - int startId = data.ReadInt32(); - TAG_LOGD(AAFwkTag::ABILITYMGR, "ReadInt32, startId:%{public}d", startId); - ScheduleCommandAbility(*want, reStart, startId); - return NO_ERROR; -} - -int AbilitySchedulerStub::PrepareTerminateAbilityInner(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGI(AAFwkTag::ABILITYMGR, "prepare terminate call"); - bool ret = SchedulePrepareTerminateAbility(); - if (!reply.WriteInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to write ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::CommandAbilityWindowInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - sptr sessionInfo(data.ReadParcelable()); - int32_t winCmd = data.ReadInt32(); - ScheduleCommandAbilityWindow(*want, sessionInfo, static_cast(winCmd)); - return NO_ERROR; -} - -int AbilitySchedulerStub::SaveAbilityStateInner(MessageParcel &data, MessageParcel &reply) -{ - ScheduleSaveAbilityState(); - return NO_ERROR; -} - -int AbilitySchedulerStub::RestoreAbilityStateInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr pacMap(data.ReadParcelable()); - if (pacMap == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null pacMap"); - return ERR_INVALID_VALUE; - } - ScheduleRestoreAbilityState(*pacMap); - return NO_ERROR; -} - -int AbilitySchedulerStub::GetFileTypesInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::string mimeTypeFilter = data.ReadString(); - if (mimeTypeFilter.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null mimeTypeFilter"); - return ERR_INVALID_VALUE; - } - std::vector types = GetFileTypes(*uri, mimeTypeFilter); - if (!reply.WriteStringVector(types)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteStringVector types"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::OpenFileInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::string mode = data.ReadString(); - if (mode.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null mode"); - return ERR_INVALID_VALUE; - } - int fd = OpenFile(*uri, mode); - if (fd < 0) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "openFile fail, fd: %{pubilc}d", fd); - return ERR_INVALID_VALUE; - } - if (!reply.WriteFileDescriptor(fd)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteFileDescriptor fd"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::OpenRawFileInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::string mode = data.ReadString(); - if (mode.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null mode"); - return ERR_INVALID_VALUE; - } - int fd = OpenRawFile(*uri, mode); - if (!reply.WriteInt32(fd)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 fd"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::InsertInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - int index = Insert(*uri, NativeRdb::ValuesBucket::Unmarshalling(data)); - if (!reply.WriteInt32(index)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 index"); - return ERR_INVALID_VALUE; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); - return NO_ERROR; -} - -int AbilitySchedulerStub::CallInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::string method = data.ReadString(); - if (method.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null method"); - return ERR_INVALID_VALUE; - } - std::string arg = data.ReadString(); - if (arg.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null arg"); - return ERR_INVALID_VALUE; - } - - std::shared_ptr pacMap(data.ReadParcelable()); - if (pacMap == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null pacMap"); - return ERR_INVALID_VALUE; - } - std::shared_ptr result = Call(*uri, method, arg, *pacMap); - if (!reply.WriteParcelable(result.get())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable pacMap error"); - return ERR_INVALID_VALUE; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); - return NO_ERROR; -} - -int AbilitySchedulerStub::UpdatetInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - auto value = NativeRdb::ValuesBucket::Unmarshalling(data); - std::shared_ptr predicates( - data.ReadParcelable()); - if (predicates == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null predicates"); - return ERR_INVALID_VALUE; - } - int index = Update(*uri, std::move(value), *predicates); - if (!reply.WriteInt32(index)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 index"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::DeleteInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::shared_ptr predicates( - data.ReadParcelable()); - if (predicates == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null predicates"); - return ERR_INVALID_VALUE; - } - int index = Delete(*uri, *predicates); - if (!reply.WriteInt32(index)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 index"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::QueryInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::vector columns; - if (!data.ReadStringVector(&columns)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadStringVector columns"); - return ERR_INVALID_VALUE; - } - std::shared_ptr predicates( - data.ReadParcelable()); - if (predicates == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null predicates"); - return ERR_INVALID_VALUE; - } - auto resultSet = Query(*uri, columns, *predicates); - if (resultSet == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null resultSet"); - return ERR_INVALID_VALUE; - } - auto result = NativeRdb::ISharedResultSet::WriteToParcel(std::move(resultSet), reply); - if (result == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null result"); - return ERR_INVALID_VALUE; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); - return NO_ERROR; -} - -int AbilitySchedulerStub::GetTypeInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - std::string type = GetType(*uri); - if (!reply.WriteString(type)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteString type"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::ReloadInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - - std::shared_ptr extras(data.ReadParcelable()); - if (extras == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null extras"); - return ERR_INVALID_VALUE; - } - bool ret = Reload(*uri, *extras); - if (!reply.WriteBool(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to writeBool ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::BatchInsertInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - - int count = 0; - if (!data.ReadInt32(count)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 index"); - return ERR_INVALID_VALUE; - } - - if (count > CYCLE_LIMIT) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "count too large"); - return ERR_INVALID_VALUE; - } - std::vector values; - for (int i = 0; i < count; i++) { - values.emplace_back(NativeRdb::ValuesBucket::Unmarshalling(data)); - } - - int ret = BatchInsert(*uri, values); - if (!reply.WriteInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::RegisterObserverInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - auto obServer = iface_cast(data.ReadRemoteObject()); - if (obServer == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null obServer"); - return ERR_INVALID_VALUE; - } - - bool ret = ScheduleRegisterObserver(*uri, obServer); - if (!reply.WriteInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::UnregisterObserverInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - auto obServer = iface_cast(data.ReadRemoteObject()); - if (obServer == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null obServer"); - return ERR_INVALID_VALUE; - } - - bool ret = ScheduleUnregisterObserver(*uri, obServer); - if (!reply.WriteInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::NotifyChangeInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - - bool ret = ScheduleNotifyChange(*uri); - if (!reply.WriteInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::NormalizeUriInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - - Uri ret(""); - ret = NormalizeUri(*uri); - if (!reply.WriteParcelable(&ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable type"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::DenormalizeUriInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr uri(data.ReadParcelable()); - if (uri == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null uri"); - return ERR_INVALID_VALUE; - } - - Uri ret(""); - ret = DenormalizeUri(*uri); - if (!reply.WriteParcelable(&ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteParcelable type"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::ExecuteBatchInner(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); - int count = 0; - if (!data.ReadInt32(count)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to ReadInt32 count"); - return ERR_INVALID_VALUE; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "count:%{public}d", count); - if (count > CYCLE_LIMIT) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "count too large"); - return ERR_INVALID_VALUE; - } - std::vector> operations; - for (int i = 0; i < count; i++) { - std::shared_ptr dataAbilityOperation( - data.ReadParcelable()); - if (dataAbilityOperation == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null dataAbilityOperation, index: %{public}d", i); - return ERR_INVALID_VALUE; - } - operations.push_back(dataAbilityOperation); - } - - std::vector> results = ExecuteBatch(operations); - int total = (int)results.size(); - if (!reply.WriteInt32(total)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ERR_INVALID_VALUE; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "total:%{public}d", total); - for (int i = 0; i < total; i++) { - if (results[i] == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, - "null results[i], index: %{public}d", i); - return ERR_INVALID_VALUE; - } - if (!reply.WriteParcelable(results[i].get())) { - TAG_LOGE(AAFwkTag::ABILITYMGR, - "fail to WriteParcelable operation, index: %{public}d", i); - return ERR_INVALID_VALUE; - } - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "end"); - return NO_ERROR; -} - -int AbilitySchedulerStub::ContinueAbilityInner(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId = data.ReadString(); - uint32_t versionCode = data.ReadUint32(); - ContinueAbility(deviceId, versionCode); - return NO_ERROR; -} - -int AbilitySchedulerStub::NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply) -{ - int32_t result = data.ReadInt32(); - NotifyContinuationResult(result); - return NO_ERROR; -} - -int AbilitySchedulerStub::DumpAbilityInfoInner(MessageParcel &data, MessageParcel &reply) -{ - std::vector infos; - std::vector params; - if (!data.ReadStringVector(¶ms)) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "DumpAbilityInfoInner read params error"); - return ERR_INVALID_VALUE; - } - - DumpAbilityInfo(params, infos); - - return NO_ERROR; -} - -int AbilitySchedulerStub::CallRequestInner(MessageParcel &data, MessageParcel &reply) -{ - CallRequest(); - return NO_ERROR; -} - -int AbilitySchedulerStub::OnExecuteIntentInner(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - OnExecuteIntent(*want); - return NO_ERROR; -} - -int AbilitySchedulerStub::CreateModalUIExtensionInner(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - int ret = CreateModalUIExtension(*want); - if (!reply.WriteInt32(ret)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "fail to WriteInt32 ret"); - return ERR_INVALID_VALUE; - } - return NO_ERROR; -} - -int AbilitySchedulerStub::UpdateSessionTokenInner(MessageParcel &data, MessageParcel &reply) -{ - sptr sessionToken = data.ReadRemoteObject(); - UpdateSessionToken(sessionToken); - return NO_ERROR; -} - -int AbilitySchedulerStub::CollaborateDataInner(MessageParcel &data) -{ - std::shared_ptr want(data.ReadParcelable()); - if (want == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null want"); - return ERR_INVALID_VALUE; - } - ScheduleCollaborate(*want); - return NO_ERROR; -} - -int AbilitySchedulerStub::ScheduleAbilityRequestFailureInner(MessageParcel &data) -{ - std::string requestId = data.ReadString(); - std::unique_ptr element(data.ReadParcelable()); - if (element == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null element"); - return ERR_INVALID_VALUE; - } - std::string message = data.ReadString(); - ScheduleAbilityRequestFailure(requestId, *element, message); - return NO_ERROR; -} - -int AbilitySchedulerStub::ScheduleAbilityRequestSuccessInner(MessageParcel &data) -{ - std::string requestId = data.ReadString(); - std::unique_ptr element(data.ReadParcelable()); - if (element == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "null element"); - return ERR_INVALID_VALUE; - } - ScheduleAbilityRequestSuccess(requestId, *element); - return NO_ERROR; -} - -void AbilitySchedulerRecipient::OnRemoteDied(const wptr &remote) -{ - TAG_LOGE(AAFwkTag::ABILITYMGR, "call"); - - if (handler_) { - handler_(remote); - } -} - -AbilitySchedulerRecipient::AbilitySchedulerRecipient(RemoteDiedHandler handler) : handler_(handler) -{} - -AbilitySchedulerRecipient::~AbilitySchedulerRecipient() -{} -} // namespace AAFwk -} // namespace OHOS diff --git a/services/abilitymgr/src/data_ability/data_ability_manager.cpp b/services/abilitymgr/src/data_ability/data_ability_manager.cpp index fe0a4abfa9895f4ea8dddd188eb3599b62d997c3..0210322b0af8adf14eb7eba00b57f9e3381c58f2 100644 --- a/services/abilitymgr/src/data_ability/data_ability_manager.cpp +++ b/services/abilitymgr/src/data_ability/data_ability_manager.cpp @@ -562,7 +562,7 @@ void DataAbilityManager::DumpClientInfo(std::vector &info, bool isC // add dump client info if (isClient && record->GetScheduler() && record->GetAbilityRecord() && record->GetAbilityRecord()->IsReady()) { std::vector params; - record->GetScheduler()->DumpAbilityInfo(params, info); + record->GetScheduler()->DumpAbilityInfo(params); AppExecFwk::Configuration config; if (DelayedSingleton::GetInstance()->GetConfiguration(config) == ERR_OK) { info.emplace_back(" configuration: " + config.GetName()); diff --git a/services/abilitymgr/src/data_ability/data_ability_record.cpp b/services/abilitymgr/src/data_ability/data_ability_record.cpp index 74ec464a7ab4eb170faca968b7e8c88d55987db1..3c1a0cfea209ae4bc591d1f7f058d5a74c4842b2 100644 --- a/services/abilitymgr/src/data_ability/data_ability_record.cpp +++ b/services/abilitymgr/src/data_ability/data_ability_record.cpp @@ -142,7 +142,8 @@ int DataAbilityRecord::Attach(const sptr &scheduler) LifeCycleStateInfo state; state.state = AbilityLifeCycleState::ABILITY_STATE_ACTIVE; - scheduler->ScheduleAbilityTransaction(ability_->GetWant(), state); + sptr sessionInfo = nullptr; + scheduler->ScheduleAbilityTransaction(ability_->GetWant(), state, sessionInfo); return ERR_OK; } diff --git a/services/abilitymgr/src/lifecycle_deal.cpp b/services/abilitymgr/src/lifecycle_deal.cpp index 8fc5a0204113d9e7ec6aa4e2e0d3b6841488c198..89169cc1126c5ae4bc0267637948a53f8305ce88 100644 --- a/services/abilitymgr/src/lifecycle_deal.cpp +++ b/services/abilitymgr/src/lifecycle_deal.cpp @@ -47,7 +47,8 @@ void LifecycleDeal::Activate(const Want &want, LifeCycleStateInfo &stateInfo) stateInfo.caller.bundleName.c_str(), stateInfo.caller.abilityName.c_str()); stateInfo.state = AbilityLifeCycleState::ABILITY_STATE_ACTIVE; - abilityScheduler->ScheduleAbilityTransaction(want, stateInfo); + sptr sessionInfo = nullptr; + abilityScheduler->ScheduleAbilityTransaction(want, stateInfo, sessionInfo); } void LifecycleDeal::Inactivate(const Want &want, LifeCycleStateInfo &stateInfo, @@ -66,7 +67,8 @@ void LifecycleDeal::MoveToBackground(const Want &want, LifeCycleStateInfo &state auto abilityScheduler = GetScheduler(); CHECK_POINTER(abilityScheduler); stateInfo.state = AbilityLifeCycleState::ABILITY_STATE_BACKGROUND; - abilityScheduler->ScheduleAbilityTransaction(want, stateInfo); + sptr sessionInfo = nullptr; + abilityScheduler->ScheduleAbilityTransaction(want, stateInfo, sessionInfo); } void LifecycleDeal::ConnectAbility(const Want &want) @@ -183,7 +185,11 @@ bool LifecycleDeal::PrepareTerminateAbility() TAG_LOGE(AAFwkTag::ABILITYMGR, "null abilityScheduler"); return false; } - return abilityScheduler->SchedulePrepareTerminateAbility(); + bool ret = false; + if (abilityScheduler->SchedulePrepareTerminateAbility() == ERR_OK) { + ret = true; + } + return ret; } void LifecycleDeal::UpdateSessionToken(sptr sessionToken) diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index ade83eb7a01b176365192a96036d9f218c33b6cb..b5d9da775e38efdf907fe810e0260b34b1931ad4 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -99,7 +99,10 @@ ohos_shared_library("libappms") { defines += [ "ABILITY_PLATFORM_CHECK_PERMISSION" ] } - configs = [ ":appmgr_config" ] + configs = [ + ":appmgr_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", + ] cflags = [] if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h index cd9abffc0588cbce4c794e7a80b825e43551f9f9..9fb9ceae431fe7aed27a702c8606fa68bab70a20 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h @@ -48,118 +48,185 @@ public: class MockAbilityThread : public IRemoteStub { public: - virtual bool ScheduleAbilityTransaction(const Want& want, const LifeCycleStateInfo& targetState, - sptr sessionInfo = nullptr) + virtual ErrCode ScheduleAbilityTransaction(const Want& want, const LifeCycleStateInfo& targetState, + const sptr &sessionInfo) { - return true; + return ERR_OK; } - virtual void SendResult(int requestCode, int resultCode, const Want& resultWant) {}; - virtual void ScheduleConnectAbility(const Want& want) {}; - virtual void ScheduleDisconnectAbility(const Want& want) {}; - virtual void ScheduleCommandAbility(const Want& want, bool restart, int startId) {}; - virtual void ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, - AAFwk::WindowCommand winCmd) {}; - virtual void ScheduleSaveAbilityState() {}; - virtual void ScheduleRestoreAbilityState(const PacMap& inState) {}; - virtual std::vector GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter) + virtual ErrCode SendResult(int32_t requestCode, int32_t resultCode, const Want& resultWant) { - return std::vector(); + return ERR_OK; }; - virtual int OpenFile(const Uri& uri, const std::string& mode) + virtual ErrCode ScheduleConnectAbility(const Want& want) { - return OPENFILENUM; + return ERR_OK; }; - virtual int OpenRawFile(const Uri& uri, const std::string& mode) + virtual ErrCode ScheduleDisconnectAbility(const Want& want) { - return OPENRAWFILENUM; + return ERR_OK; }; - virtual int Insert(const Uri& uri, const NativeRdb::ValuesBucket& value) + virtual ErrCode ScheduleCommandAbility(const Want& want, bool restart, int32_t startId) { - return INSERTNUM; + return ERR_OK; }; - virtual int Update( - const Uri& uri, const NativeRdb::ValuesBucket& value, const NativeRdb::DataAbilityPredicates& predicates) + virtual ErrCode ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, + int32_t winCmd) { - return UPDATENUM; + return ERR_OK; }; - virtual int Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates) + virtual ErrCode ScheduleSaveAbilityState() { - return DELETENUM; + return ERR_OK; }; - virtual std::shared_ptr Query( - const Uri& uri, std::vector& columns, const NativeRdb::DataAbilityPredicates& predicates) + virtual ErrCode ScheduleRestoreAbilityState(const PacMap& inState) { - return std::make_shared("resultset"); + return ERR_OK; }; - std::shared_ptr Call( - const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap) + virtual ErrCode GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter, + std::vector& funcResult) { - return nullptr; + return ERR_OK; + }; + virtual ErrCode OpenFile(const Uri& uri, const std::string& mode, int& funcResult) + { + funcResult = OPENFILENUM; + return ERR_OK; + }; + virtual ErrCode OpenRawFile(const Uri& uri, const std::string& mode, int32_t& funcResult) + { + funcResult = OPENRAWFILENUM; + return ERR_OK; + }; + virtual ErrCode Insert(const Uri& uri, const NativeRdb::AmValuesBucket& value, int32_t& funcResult) + { + funcResult = INSERTNUM; + return ERR_OK; + }; + virtual ErrCode Update( + const Uri& uri, const NativeRdb::AmValuesBucket& value, const NativeRdb::DataAbilityPredicates& predicates, + int32_t& funcResult) + { + funcResult = UPDATENUM; + return ERR_OK; + }; + virtual ErrCode Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates, int32_t& funcResult) + { + funcResult = DELETENUM; + return ERR_OK; + }; + virtual ErrCode Query( + const Uri& uri, const std::vector& columns, const NativeRdb::DataAbilityPredicates& predicates, + std::shared_ptr& funcResult) + { + funcResult = std::make_shared( + std::make_shared("resultset")); + return ERR_OK; + }; + ErrCode Call( + const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap, + std::shared_ptr& funcResult) + { + funcResult = nullptr; + return ERR_OK; } - virtual std::string GetType(const Uri& uri) + virtual ErrCode GetType(const Uri& uri, std::string& funcResult) { - return std::string("Type1"); + funcResult = "type"; + return ERR_OK; }; - virtual bool Reload(const Uri& uri, const PacMap& extras) + virtual ErrCode Reload(const Uri& uri, const PacMap& extras, bool& funcResult) { - return true; + funcResult = true; + return ERR_OK; }; - virtual int BatchInsert(const Uri& uri, const std::vector& values) + virtual ErrCode BatchInsert(const Uri& uri, const std::vector& values, + int32_t& funcResult) { - return BATCHINSERTNUM; + funcResult = BATCHINSERTNUM; + return ERR_OK; }; - virtual bool ScheduleRegisterObserver(const Uri& uri, const sptr& dataObserver) + virtual ErrCode ScheduleRegisterObserver(const Uri& uri, const sptr& dataObserver) { - return true; + return ERR_OK; }; - virtual bool ScheduleUnregisterObserver(const Uri& uri, const sptr& dataObserver) + virtual ErrCode ScheduleUnregisterObserver(const Uri& uri, const sptr& dataObserver) { - return true; + return ERR_OK; }; - virtual bool ScheduleNotifyChange(const Uri& uri) + virtual ErrCode ScheduleNotifyChange(const Uri& uri) { - return true; + return ERR_OK; }; - virtual Uri NormalizeUri(const Uri& uri) + virtual ErrCode NormalizeUri(const Uri& uri, AmUri& funcResult) { - return Uri("dataability:///test.aaa"); + Uri tmpUri("dataability:///test.aaa"); + funcResult = AmUri(tmpUri); + return ERR_OK; }; - virtual Uri DenormalizeUri(const Uri& uri) + virtual ErrCode DenormalizeUri(const Uri& uri, AmUri& funcResult) { - return Uri("dataability:///test.aaa"); + Uri tmpUri("dataability:///test.aaa"); + funcResult = AmUri(tmpUri); + return ERR_OK; }; - virtual std::vector> ExecuteBatch( - const std::vector>& operations) + virtual ErrCode ExecuteBatch( + const std::vector>& operations, + std::vector>& funcResult) { - return std::vector>(); + return ERR_OK; }; - virtual void NotifyContinuationResult(int32_t result) {}; - virtual void ContinueAbility(const std::string& deviceId, uint32_t versionCode) {}; - virtual void DumpAbilityInfo(const std::vector& params, std::vector& info) {}; - virtual void CallRequest() + virtual ErrCode NotifyContinuationResult(int32_t result) { - return; + return ERR_OK; }; - virtual void OnExecuteIntent(const Want &want) {}; - virtual void ScheduleShareData(const int32_t &uniqueId) {}; - virtual bool SchedulePrepareTerminateAbility() + virtual ErrCode ContinueAbility(const std::string& deviceId, uint32_t versionCode) { - return false; - } - virtual int CreateModalUIExtension(const Want &want) + return ERR_OK; + }; + virtual ErrCode DumpAbilityInfo(const std::vector& params) + { + return ERR_OK; + }; + virtual ErrCode CallRequest() + { + return ERR_OK; + }; + virtual ErrCode OnExecuteIntent(const Want &want) { - return 0; + return ERR_OK; } - virtual void UpdateSessionToken(sptr sessionToken) {} - virtual void ScheduleCollaborate(const Want &want) {} + virtual ErrCode ScheduleShareData(int32_t uniqueId) + { + return ERR_OK; + } - virtual void ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, + virtual ErrCode SchedulePrepareTerminateAbility() + { + return ERR_OK; + } + virtual ErrCode CreateModalUIExtension(const Want &want) + { + return ERR_OK; + } + virtual ErrCode UpdateSessionToken(const sptr& sessionToken) + { + return ERR_OK; + } + virtual ErrCode ScheduleCollaborate(const Want &want) + { + return ERR_OK; + } + virtual ErrCode ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, const std::string &message) - {} + { + return ERR_OK; + } - virtual void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) - {} + virtual ErrCode ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) + { + return ERR_OK; + } }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/mock/services_abilitymgr_test/libs/aakit/include/ability_scheduler.h b/test/mock/services_abilitymgr_test/libs/aakit/include/ability_scheduler.h index fa940a4c678738267e9ab11db42f72c2b6d6b707..36d5e4ad0fa9f7799c08b433a6aa2846a685cfbd 100644 --- a/test/mock/services_abilitymgr_test/libs/aakit/include/ability_scheduler.h +++ b/test/mock/services_abilitymgr_test/libs/aakit/include/ability_scheduler.h @@ -30,101 +30,121 @@ public: AbilityScheduler(); virtual ~AbilityScheduler(); - bool ScheduleAbilityTransaction(const Want& want, const LifeCycleStateInfo& targetState, - sptr sessionInfo = nullptr) override; + ErrCode ScheduleAbilityTransaction(const Want &want, const LifeCycleStateInfo &targetState, + const sptr& sessionInfo) override; - void ScheduleShareData(const int32_t &uniqueId) override; + ErrCode ScheduleShareData(int32_t uniqueId) override; - void SendResult(int requestCode, int resultCode, const Want& resultWant) override; + ErrCode SendResult(int requestCode, int resultCode, const Want& resultWant) override; const AbilityResult& GetResult() const; - void ScheduleConnectAbility(const Want& want) override; + ErrCode ScheduleConnectAbility(const Want& want) override; - void ScheduleDisconnectAbility(const Want& want) override; + ErrCode ScheduleDisconnectAbility(const Want& want) override; - bool SchedulePrepareTerminateAbility() override; + ErrCode SchedulePrepareTerminateAbility() override; - void ScheduleCommandAbility(const Want& want, bool restart, int startId) override; + ErrCode ScheduleCommandAbility(const Want& want, bool restart, int32_t startId) override; - void ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, - WindowCommand winCmd) override; + ErrCode ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, + int32_t winCmd) override; - void ScheduleSaveAbilityState() override; + ErrCode ScheduleSaveAbilityState() override; - void ScheduleRestoreAbilityState(const PacMap& inState) override; + ErrCode ScheduleRestoreAbilityState(const PacMap& inState) override; - std::vector GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter) override; + ErrCode GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter, + std::vector& funcResult) override; - int OpenFile(const Uri& uri, const std::string& mode) override; + ErrCode OpenFile(const Uri& uri, const std::string& mode, int& funcResult) override; - int Insert(const Uri& uri, const NativeRdb::ValuesBucket& value) override; + ErrCode Insert(const Uri& uri, const NativeRdb::AmValuesBucket& value, int32_t& funcResult) override; - int Update(const Uri& uri, const NativeRdb::ValuesBucket& value, - const NativeRdb::DataAbilityPredicates& predicates) override; + ErrCode Update(const Uri& uri, const NativeRdb::AmValuesBucket& value, + const NativeRdb::DataAbilityPredicates& predicates, int32_t& funcResult) override; - int Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates) override; + ErrCode Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates, int32_t& funcResult) override; - std::shared_ptr Query( - const Uri& uri, std::vector& columns, const NativeRdb::DataAbilityPredicates& predicates) override; + ErrCode Query(const Uri& uri, const std::vector& columns, + const NativeRdb::DataAbilityPredicates& predicates, std::shared_ptr& funcResult) override; - std::shared_ptr Call( - const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap) override; + ErrCode Call(const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap, + std::shared_ptr& funcResult) override; - std::string GetType(const Uri& uri) override; + ErrCode GetType(const Uri& uri, std::string& funcResult) override; - int OpenRawFile(const Uri& uri, const std::string& mode) override; + ErrCode OpenRawFile(const Uri& uri, const std::string& mode, int32_t& funcResult) override; - bool Reload(const Uri& uri, const PacMap& extras) override; + ErrCode Reload(const Uri& uri, const PacMap& extras, bool& funcResult) override; - int BatchInsert(const Uri& uri, const std::vector& values) override; + ErrCode BatchInsert(const Uri& uri, const std::vector& values, + int32_t& funcResult) override; - Uri NormalizeUri(const Uri& uri) override; - Uri DenormalizeUri(const Uri& uri) override; - virtual bool ScheduleRegisterObserver(const Uri& uri, const sptr& dataObserver) override + ErrCode NormalizeUri(const Uri& uri, AmUri& funcResult) override; + ErrCode DenormalizeUri(const Uri& uri, AmUri& funcResult) override; + virtual ErrCode ScheduleRegisterObserver(const Uri& uri, const sptr& dataObserver) override { - return true; + return ERR_OK; }; - virtual bool ScheduleUnregisterObserver(const Uri& uri, const sptr& dataObserver) override + virtual ErrCode ScheduleUnregisterObserver(const Uri& uri, const sptr& dataObserver) override { - return true; + return ERR_OK; }; - virtual bool ScheduleNotifyChange(const Uri& uri) override + virtual ErrCode ScheduleNotifyChange(const Uri& uri) override { - return true; + return ERR_OK; }; - virtual std::vector> ExecuteBatch( - const std::vector>& operations) override + virtual ErrCode ExecuteBatch(const std::vector>& operations, + std::vector>& funcResult) override { - return std::vector>(); + return ERR_OK; }; - virtual void NotifyContinuationResult(int32_t result) override - {}; - virtual void ContinueAbility(const std::string& deviceId, uint32_t versionCode) override - {}; - virtual void DumpAbilityInfo(const std::vector& params, std::vector& info) override - {}; - virtual void CallRequest() override + virtual ErrCode NotifyContinuationResult(int32_t result) override { - return; + return ERR_OK; }; - virtual void OnExecuteIntent(const Want &want) override - {}; - virtual int CreateModalUIExtension(const Want &want) override + virtual ErrCode ContinueAbility(const std::string& deviceId, uint32_t versionCode) override { - return 0; + return ERR_OK; }; - virtual void UpdateSessionToken(sptr sessionToken) override {} + virtual ErrCode DumpAbilityInfo(const std::vector& params) override + { + return ERR_OK; + }; + virtual ErrCode CallRequest() override + { + return ERR_OK;; + }; + virtual ErrCode OnExecuteIntent(const Want &want) override + { + return ERR_OK; + }; + virtual ErrCode CreateModalUIExtension(const Want &want) override + { + return ERR_OK; + }; + virtual ErrCode UpdateSessionToken(const sptr& sessionToken) override + { + return ERR_OK; + } - virtual void ScheduleCollaborate(const Want &want) override {} + virtual ErrCode ScheduleCollaborate(const Want &want) override + { + return ERR_OK; + } - virtual void ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, + virtual ErrCode ScheduleAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element, const std::string &message) override - {} + { + return ERR_OK; + } - virtual void ScheduleAbilityRequestSuccess(const std::string &requestId, + virtual ErrCode ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override - {} + { + return ERR_OK; + } private: AbilityResult result_; }; diff --git a/test/mock/services_abilitymgr_test/libs/aakit/src/ability_scheduler.cpp b/test/mock/services_abilitymgr_test/libs/aakit/src/ability_scheduler.cpp index 524829903791562c22946a95b482f06c3a38a62c..76ee7753604a6bd32e7b0ed0865e4f841d5bfbd9 100644 --- a/test/mock/services_abilitymgr_test/libs/aakit/src/ability_scheduler.cpp +++ b/test/mock/services_abilitymgr_test/libs/aakit/src/ability_scheduler.cpp @@ -25,21 +25,24 @@ AbilityScheduler::AbilityScheduler() AbilityScheduler::~AbilityScheduler() {} -bool AbilityScheduler::ScheduleAbilityTransaction(const Want& want, const LifeCycleStateInfo& targetState, - sptr sessionInfo) +ErrCode AbilityScheduler::ScheduleAbilityTransaction(const Want& want, const LifeCycleStateInfo& targetState, + const sptr &sessionInfo) { TAG_LOGI(AAFwkTag::TEST, "AbilityScheduler ScheduleAbilityTransaction %d", targetState.state); (void)want; - return true; + return ERR_OK; } -void AbilityScheduler::ScheduleShareData(const int32_t &uniqueId) -{} +ErrCode AbilityScheduler::ScheduleShareData(int32_t uniqueId) +{ + return ERR_OK; +} -void AbilityScheduler::SendResult(int requestCode, int resultCode, const Want& resultWant) +ErrCode AbilityScheduler::SendResult(int requestCode, int resultCode, const Want& resultWant) { TAG_LOGI(AAFwkTag::TEST, "AbilityScheduler SendResult %d resultCode %d", requestCode, resultCode); result_ = AbilityResult(requestCode, resultCode, resultWant); + return ERR_OK; } const AbilityResult& AbilityScheduler::GetResult() const @@ -47,101 +50,125 @@ const AbilityResult& AbilityScheduler::GetResult() const return result_; } -void AbilityScheduler::ScheduleConnectAbility(const Want& want) +ErrCode AbilityScheduler::ScheduleConnectAbility(const Want& want) { (void)want; + return ERR_OK; } -void AbilityScheduler::ScheduleDisconnectAbility(const Want& want) -{} +ErrCode AbilityScheduler::ScheduleDisconnectAbility(const Want& want) +{ + return ERR_OK; +} -bool AbilityScheduler::SchedulePrepareTerminateAbility() +ErrCode AbilityScheduler::SchedulePrepareTerminateAbility() { - return false; + return ERR_OK; } -void AbilityScheduler::ScheduleCommandAbility(const Want& want, bool restart, int startId) -{} +ErrCode AbilityScheduler::ScheduleCommandAbility(const Want& want, bool restart, int32_t startId) +{ + return ERR_OK; +} -void AbilityScheduler::ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, - WindowCommand winCmd) -{} +ErrCode AbilityScheduler::ScheduleCommandAbilityWindow(const Want &want, const sptr &sessionInfo, + int32_t winCmd) +{ + return ERR_OK; +} -void AbilityScheduler::ScheduleSaveAbilityState() -{} +ErrCode AbilityScheduler::ScheduleSaveAbilityState() +{ + return ERR_OK; +} -void AbilityScheduler::ScheduleRestoreAbilityState(const PacMap& inState) -{} +ErrCode AbilityScheduler::ScheduleRestoreAbilityState(const PacMap& inState) +{ + return ERR_OK; +} -std::vector AbilityScheduler::GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter) +ErrCode AbilityScheduler::GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter, + std::vector& funcResult) { - std::vector values; - return values; + return ERR_OK; } -int AbilityScheduler::OpenFile(const Uri& uri, const std::string& mode) +ErrCode AbilityScheduler::OpenFile(const Uri& uri, const std::string& mode, int& funcResult) { - return -1; + funcResult = -1; + return ERR_OK; } -int AbilityScheduler::Insert(const Uri& uri, const NativeRdb::ValuesBucket& value) +ErrCode AbilityScheduler::Insert(const Uri& uri, const NativeRdb::AmValuesBucket& value, int32_t& funcResult) { - return -1; + funcResult = -1; + return ERR_OK; } -int AbilityScheduler::Update(const Uri& uri, const NativeRdb::ValuesBucket& value, - const NativeRdb::DataAbilityPredicates& predicates) +ErrCode AbilityScheduler::Update(const Uri& uri, const NativeRdb::AmValuesBucket& value, + const NativeRdb::DataAbilityPredicates& predicates, int32_t& funcResult) { - return -1; + funcResult = -1; + return ERR_OK; } -int AbilityScheduler::Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates) +ErrCode AbilityScheduler::Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates, + int32_t& funcResult) { - return -1; + funcResult = -1; + return ERR_OK; } -std::shared_ptr AbilityScheduler::Query( - const Uri& uri, std::vector& columns, const NativeRdb::DataAbilityPredicates& predicates) +ErrCode AbilityScheduler::Query(const Uri& uri, const std::vector& columns, + const NativeRdb::DataAbilityPredicates& predicates, std::shared_ptr& funcResult) { - return nullptr; + funcResult = nullptr; + return ERR_OK; } -std::shared_ptr AbilityScheduler::Call( - const Uri& uri, const std::string& method, const std::string& arg, const AppExecFwk::PacMap& pacMap) +ErrCode AbilityScheduler::Call(const Uri& uri, const std::string& method, const std::string& arg, + const AppExecFwk::PacMap& pacMap, std::shared_ptr& funcResult) { - return nullptr; + funcResult = nullptr; + return ERR_OK; } -std::string AbilityScheduler::GetType(const Uri& uri) +ErrCode AbilityScheduler::GetType(const Uri& uri, std::string& funcResult) { - return result_.resultWant_.GetType(); + return ERR_OK; } -int AbilityScheduler::OpenRawFile(const Uri& uri, const std::string& mode) +ErrCode AbilityScheduler::OpenRawFile(const Uri& uri, const std::string& mode, int32_t& funcResult) { - return -1; + funcResult = -1; + return ERR_OK; } -bool AbilityScheduler::Reload(const Uri& uri, const PacMap& extras) +ErrCode AbilityScheduler::Reload(const Uri& uri, const PacMap& extras, bool& funcResult) { - return false; + funcResult = false; + return ERR_OK; } -int AbilityScheduler::BatchInsert(const Uri& uri, const std::vector& values) +ErrCode AbilityScheduler::BatchInsert(const Uri& uri, const std::vector& values, + int32_t& funcResult) { - return -1; + funcResult = -1; + return ERR_OK; } -Uri AbilityScheduler::NormalizeUri(const Uri& uri) +ErrCode AbilityScheduler::NormalizeUri(const Uri& uri, AmUri& funcResult) { Uri urivalue(""); - return urivalue; + funcResult = AmUri(urivalue); + return ERR_OK; } -Uri AbilityScheduler::DenormalizeUri(const Uri& uri) +ErrCode AbilityScheduler::DenormalizeUri(const Uri& uri, AmUri& funcResult) { Uri urivalue(""); - return urivalue; + funcResult = AmUri(urivalue); + return ERR_OK; } } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 20214f053124a3ae0c6469f2a57c069c58e49c6e..c47367038e5b1410751566c8a0b052bfe6512379 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -117,8 +117,6 @@ ohos_source_set("abilityms_test_source") { "${ability_runtime_services_path}/abilitymgr/src/ability_manager_service.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_manager_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_record.cpp", - "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_proxy.cpp", - "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_token_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ams_configuration_parameter.cpp", "${ability_runtime_services_path}/abilitymgr/src/app_exit_reason_data_manager.cpp", diff --git a/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn b/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn index ea88cb70833b1dc153c75a8449ddeaa01d85c014..97ba6412c1fab968e49855da34caa2fd95a92641 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn @@ -85,7 +85,6 @@ ohos_unittest("ability_manager_service_thirteenth_test") { "${ability_runtime_services_path}/abilitymgr/src/ability_manager_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_record_death_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_running_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_start_with_wait_observer_manager/ability_start_with_wait_observer_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_token_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ams_configuration_parameter.cpp", diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index d6ec4e440c24ab088a7c976c62ade9d8402e6b8c..792332c252b665ea88203db2b5d06894fd1d3676 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -45,6 +45,7 @@ ohos_static_library("tools_aa_source_set") { public_configs = [ ":ability_command_config", ":ability_command_exception_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_idl_config", "${ability_runtime_services_path}/abilitymgr:abilityms_config", "${ability_runtime_services_path}/common:common_config", ]