mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Componentization: ability_base to remove bms dependencies
Signed-off-by: njupthan <hanhaibin@huawei.com>
This commit is contained in:
parent
0e88d6e56a
commit
5467afd87f
@ -16,6 +16,7 @@ import("//foundation/aafwk/standard/aafwk.gni")
|
||||
|
||||
config("task_dispatcher_public_config") {
|
||||
include_dirs = [
|
||||
"${aafwk_path}/services/common/include",
|
||||
"${appexecfwk_path}/common/log/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler/include",
|
||||
|
||||
@ -52,12 +53,12 @@ ohos_shared_library("task_dispatcher") {
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
deps = [
|
||||
"${appexecfwk_path}/common:libappexecfwk_common",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
deps = [ "${appexecfwk_path}/common:libappexecfwk_common" ]
|
||||
external_deps = [
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
subsystem_name = "aafwk"
|
||||
part_name = "ability_runtime"
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "task.h"
|
||||
#include "task_priority.h"
|
||||
|
||||
@ -80,7 +80,7 @@ public:
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
while (queue_.empty() && !stopFlag_) {
|
||||
APP_LOGI("BlockingQueue::Take empty_wait");
|
||||
HILOG_INFO("BlockingQueue::Take empty_wait");
|
||||
empty_.wait(lock);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
while (queue_.empty() && !stopFlag_) {
|
||||
if (empty_.wait_until(lock, timeout) == std::cv_status::timeout) {
|
||||
APP_LOGI("BlockingQueue::Poll timeout");
|
||||
HILOG_INFO("BlockingQueue::Poll timeout");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ private:
|
||||
void OnChanged(const TaskStage &stage)
|
||||
{
|
||||
if (stage.IsDone()) {
|
||||
APP_LOGI("ParallelTaskDispatcherBase task done.");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase task done.");
|
||||
callback_();
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ private:
|
||||
void OnChanged(const TaskStage &stage)
|
||||
{
|
||||
if (stage.IsDone()) {
|
||||
APP_LOGI("BarrierHandler task done.");
|
||||
HILOG_INFO("BarrierHandler task done.");
|
||||
callback_();
|
||||
}
|
||||
};
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "runnable.h"
|
||||
#include "task_priority.h"
|
||||
#include "task.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "base_task_dispatcher.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
@ -30,18 +30,18 @@ public:
|
||||
virtual ~TaskHandlerLibeventAdapter(){};
|
||||
bool Dispatch(const std::shared_ptr<Runnable> &runnable) override
|
||||
{
|
||||
APP_LOGI("TaskHandlerLibeventAdapter::Dispatch called.");
|
||||
HILOG_INFO("TaskHandlerLibeventAdapter::Dispatch called.");
|
||||
return EventHandler::PostTask(*(runnable.get()), EventQueue::Priority::HIGH);
|
||||
}
|
||||
|
||||
bool Dispatch(const std::shared_ptr<Runnable> &runnable, long delayMs) override
|
||||
{
|
||||
APP_LOGI("TaskHandlerLibeventAdapter::Delay Dispatch called.");
|
||||
HILOG_INFO("TaskHandlerLibeventAdapter::Delay Dispatch called.");
|
||||
return EventHandler::PostTask(*(runnable.get()), delayMs, EventQueue::Priority::HIGH);
|
||||
}
|
||||
bool DispatchSync(const std::shared_ptr<Runnable> &runnable) override
|
||||
{
|
||||
APP_LOGI("TaskHandlerLibeventAdapter::Delay Dispatch Sync called.");
|
||||
HILOG_INFO("TaskHandlerLibeventAdapter::Delay Dispatch Sync called.");
|
||||
return EventHandler::PostSyncTask(*(runnable.get()), EventQueue::Priority::HIGH);
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <condition_variable>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -51,7 +51,7 @@ public:
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
while (queue_.empty()) {
|
||||
APP_LOGI("ConcurrentQueue::Take blocked");
|
||||
HILOG_INFO("ConcurrentQueue::Take blocked");
|
||||
empty_.wait(lock);
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (queue_.empty()) {
|
||||
APP_LOGI("ConcurrentQueue::Poll empty");
|
||||
HILOG_INFO("ConcurrentQueue::Poll empty");
|
||||
return nullptr;
|
||||
}
|
||||
T front(queue_.front());
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <atomic>
|
||||
|
||||
#include "thread_factory.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -65,12 +65,12 @@ public:
|
||||
while (true) {
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
while (taskQueue_.empty() && !stopFlag_) {
|
||||
APP_LOGI("DelayQueue::taskQueue_ is empty");
|
||||
HILOG_INFO("DelayQueue::taskQueue_ is empty");
|
||||
emptyWait_.wait(lock);
|
||||
}
|
||||
|
||||
if (taskQueue_.empty() && stopFlag_) {
|
||||
APP_LOGI("DelayQueue::taskQueue is empty and stopFlag is true");
|
||||
HILOG_INFO("DelayQueue::taskQueue is empty and stopFlag is true");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "thread_factory.h"
|
||||
#include "task.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "appexecfwk_errors.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "runnable.h"
|
||||
#include "task.h"
|
||||
#include "thread_factory.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "base_task_dispatcher.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -31,101 +31,101 @@ BaseTaskDispatcher::BaseTaskDispatcher(const std::string &dispatcherName, const
|
||||
|
||||
ErrCode BaseTaskDispatcher::SyncDispatchBarrier(const std::shared_ptr<Runnable> &task)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::SyncDispatchBarrier called");
|
||||
HILOG_INFO("BaseTaskDispatcher::SyncDispatchBarrier called");
|
||||
return SyncDispatch(task);
|
||||
}
|
||||
|
||||
ErrCode BaseTaskDispatcher::AsyncDispatchBarrier(const std::shared_ptr<Runnable> &task)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::AsyncDispatchBarrier start");
|
||||
HILOG_INFO("BaseTaskDispatcher::AsyncDispatchBarrier start");
|
||||
std::shared_ptr<Revocable> revocable = AsyncDispatch(task);
|
||||
if (revocable != nullptr) {
|
||||
APP_LOGI("BaseTaskDispatcher::AsyncDispatchBarrier end");
|
||||
HILOG_INFO("BaseTaskDispatcher::AsyncDispatchBarrier end");
|
||||
return ERR_OK;
|
||||
}
|
||||
APP_LOGE("BaseTaskDispatcher::AsyncDispatchBarrier revocable is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::AsyncDispatchBarrier revocable is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
std::shared_ptr<Group> BaseTaskDispatcher::CreateDispatchGroup()
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::CreateDispatchGroup called.");
|
||||
HILOG_INFO("BaseTaskDispatcher::CreateDispatchGroup called.");
|
||||
return std::make_shared<GroupImpl>();
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> BaseTaskDispatcher::AsyncGroupDispatch(
|
||||
const std::shared_ptr<Group> &group, const std::shared_ptr<Runnable> &task)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::AsyncGroupDispatch called.");
|
||||
HILOG_INFO("BaseTaskDispatcher::AsyncGroupDispatch called.");
|
||||
return AsyncDispatch(task);
|
||||
}
|
||||
|
||||
bool BaseTaskDispatcher::GroupDispatchWait(const std::shared_ptr<Group> &group, long timeout)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::GroupDispatchWait start");
|
||||
HILOG_INFO("BaseTaskDispatcher::GroupDispatchWait start");
|
||||
if (group == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchWait group is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchWait group is nullptr");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<GroupImpl> groupImpl = CastToGroupImpl(group);
|
||||
if (groupImpl == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchWait groupImpl is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchWait groupImpl is nullptr");
|
||||
return false;
|
||||
}
|
||||
bool result = groupImpl->AwaitAllTasks(timeout);
|
||||
APP_LOGI("BaseTaskDispatcher::GroupDispatchWait start");
|
||||
HILOG_INFO("BaseTaskDispatcher::GroupDispatchWait start");
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrCode BaseTaskDispatcher::GroupDispatchNotify(
|
||||
const std::shared_ptr<Group> &group, const std::shared_ptr<Runnable> &task)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::GroupDispatchNotify start");
|
||||
HILOG_INFO("BaseTaskDispatcher::GroupDispatchNotify start");
|
||||
if (group == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify group cannot be null.");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify group cannot be null.");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify task cannot be null");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify task cannot be null");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
const std::function<void()> asyncDispatch = std::bind(&BaseTaskDispatcher::AsyncDispatch, this, task);
|
||||
if (asyncDispatch == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify asyncDispatch is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify asyncDispatch is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<Runnable> ptrCallback = std::make_shared<Runnable>(asyncDispatch);
|
||||
if (ptrCallback == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify runnable is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify runnable is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
if (group == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify group is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify group is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<GroupImpl> groupImpl = CastToGroupImpl(group);
|
||||
if (groupImpl == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify groupImpl is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify groupImpl is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
if (groupImpl->AddNotification(ptrCallback)) {
|
||||
APP_LOGI("BaseTaskDispatcher::GroupDispatchNotify end");
|
||||
HILOG_INFO("BaseTaskDispatcher::GroupDispatchNotify end");
|
||||
return ERR_OK;
|
||||
}
|
||||
APP_LOGE("BaseTaskDispatcher::GroupDispatchNotify addNotification failed");
|
||||
HILOG_ERROR("BaseTaskDispatcher::GroupDispatchNotify addNotification failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
ErrCode BaseTaskDispatcher::ApplyDispatch(const std::shared_ptr<IteratableTask<long>> &task, long iterations)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::ApplyDispatch start");
|
||||
HILOG_INFO("BaseTaskDispatcher::ApplyDispatch start");
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::ApplyDispatch task object is not set");
|
||||
HILOG_ERROR("BaseTaskDispatcher::ApplyDispatch task object is not set");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
if (iterations <= 0) {
|
||||
APP_LOGE("BaseTaskDispatcher::ApplyDispatch iterations must giant than 0");
|
||||
HILOG_ERROR("BaseTaskDispatcher::ApplyDispatch iterations must giant than 0");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
@ -133,28 +133,28 @@ ErrCode BaseTaskDispatcher::ApplyDispatch(const std::shared_ptr<IteratableTask<l
|
||||
for (long i = 0L; i < iterations; ++i) {
|
||||
std::shared_ptr<Runnable> ptrCallback = std::make_shared<Runnable>([task, i]() { (*task)(i); });
|
||||
if (ptrCallback == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::ApplyDispatch runnable is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::ApplyDispatch runnable is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<Revocable> revocable = AsyncDispatch(ptrCallback);
|
||||
if (revocable == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::ApplyDispatch revocable is nullptr, index:%{public}ld", i);
|
||||
HILOG_ERROR("BaseTaskDispatcher::ApplyDispatch revocable is nullptr, index:%{public}ld", i);
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
APP_LOGI("BaseTaskDispatcher::ApplyDispatch end");
|
||||
HILOG_INFO("BaseTaskDispatcher::ApplyDispatch end");
|
||||
return ERR_OK;
|
||||
}
|
||||
APP_LOGI("BaseTaskDispatcher::ApplyDispatch failed");
|
||||
HILOG_INFO("BaseTaskDispatcher::ApplyDispatch failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
ErrCode BaseTaskDispatcher::Check(const std::shared_ptr<Runnable> &task) const
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::Check called");
|
||||
HILOG_INFO("BaseTaskDispatcher::Check called");
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("dispatch task cannot be null.");
|
||||
HILOG_ERROR("dispatch task cannot be null.");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
return ERR_OK;
|
||||
@ -162,12 +162,12 @@ ErrCode BaseTaskDispatcher::Check(const std::shared_ptr<Runnable> &task) const
|
||||
|
||||
std::shared_ptr<GroupImpl> BaseTaskDispatcher::CastToGroupImpl(const std::shared_ptr<Group> &group)
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::CastToGroupImpl called");
|
||||
HILOG_INFO("BaseTaskDispatcher::CastToGroupImpl called");
|
||||
std::shared_ptr<GroupImpl> groupImpl_ptr = std::static_pointer_cast<GroupImpl>(group);
|
||||
if (groupImpl_ptr != nullptr) {
|
||||
return groupImpl_ptr;
|
||||
}
|
||||
APP_LOGE("group cannot instance of groupImpl ");
|
||||
HILOG_ERROR("group cannot instance of groupImpl ");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -184,14 +184,14 @@ TaskPriority BaseTaskDispatcher::GetPriority() const
|
||||
void BaseTaskDispatcher::TracePointBeforePost(
|
||||
std::shared_ptr<Task> &task, bool isAsyncTask, const std::string &dispatcherName) const
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::TracePointBeforePost called");
|
||||
HILOG_INFO("BaseTaskDispatcher::TracePointBeforePost called");
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::TracePointBeforePost the task is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::TracePointBeforePost the task is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string taskType = isAsyncTask ? "ASYNC_TASK_STRING" : "SYNC_TASK_STRING";
|
||||
long seq = task->GetSequence();
|
||||
APP_LOGI("BaseTaskDispatcher::TracePointBeforePost "
|
||||
HILOG_INFO("BaseTaskDispatcher::TracePointBeforePost "
|
||||
"log---TaskType:%{public}s,TaskSeq:%{public}ld,DispatcherName::%{public}s",
|
||||
taskType.c_str(),
|
||||
seq,
|
||||
@ -201,14 +201,14 @@ void BaseTaskDispatcher::TracePointBeforePost(
|
||||
void BaseTaskDispatcher::TracePointAfterPost(
|
||||
std::shared_ptr<Task> &task, bool isAsyncTask, const std::string &dispatcherName) const
|
||||
{
|
||||
APP_LOGI("BaseTaskDispatcher::TracePointAfterPost called");
|
||||
HILOG_INFO("BaseTaskDispatcher::TracePointAfterPost called");
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("BaseTaskDispatcher::TracePointAfterPost the task is nullptr");
|
||||
HILOG_ERROR("BaseTaskDispatcher::TracePointAfterPost the task is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string taskType = isAsyncTask ? "ASYNC_TASK_STRING" : "SYNC_TASK_STRING";
|
||||
long seq = task->GetSequence();
|
||||
APP_LOGI("BaseTaskDispatcher::TracePointAfterPost "
|
||||
HILOG_INFO("BaseTaskDispatcher::TracePointAfterPost "
|
||||
"log---TaskType:%{public}s,TaskSeq:%{public}ld,DispatcherName::%{public}s",
|
||||
taskType.c_str(),
|
||||
seq,
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "group_impl.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
GroupImpl::GroupImpl()
|
||||
@ -30,13 +30,13 @@ GroupImpl::GroupImpl()
|
||||
*/
|
||||
bool GroupImpl::AwaitAllTasks(long timeout)
|
||||
{
|
||||
APP_LOGI("GroupImpl::AwaitAllTasks start");
|
||||
HILOG_INFO("GroupImpl::AwaitAllTasks start");
|
||||
if (count_.load() == 0) {
|
||||
APP_LOGI("GroupImpl::AwaitAllTasks number of count_ is zero");
|
||||
HILOG_INFO("GroupImpl::AwaitAllTasks number of count_ is zero");
|
||||
return true;
|
||||
}
|
||||
if (timeout <= 0L) {
|
||||
APP_LOGW("GroupImpl::AwaitAllTasks timeout<=0");
|
||||
HILOG_WARN("GroupImpl::AwaitAllTasks timeout<=0");
|
||||
return false;
|
||||
}
|
||||
bool success = true;
|
||||
@ -44,12 +44,12 @@ bool GroupImpl::AwaitAllTasks(long timeout)
|
||||
while (count_.load() > 0) {
|
||||
if (condition_.wait_for(lock, std::chrono::milliseconds(timeout)) == std::cv_status::timeout) {
|
||||
success = false;
|
||||
APP_LOGI("GroupImpl::awaitAllTasks timeout");
|
||||
HILOG_INFO("GroupImpl::awaitAllTasks timeout");
|
||||
break;
|
||||
}
|
||||
APP_LOGI("GroupImpl::awaitAllTasks success");
|
||||
HILOG_INFO("GroupImpl::awaitAllTasks success");
|
||||
}
|
||||
APP_LOGI("GroupImpl::AwaitAllTasks end");
|
||||
HILOG_INFO("GroupImpl::AwaitAllTasks end");
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ bool GroupImpl::AwaitAllTasks(long timeout)
|
||||
*/
|
||||
void GroupImpl::Associate()
|
||||
{
|
||||
APP_LOGI("GroupImpl::Associate called add a task");
|
||||
HILOG_INFO("GroupImpl::Associate called add a task");
|
||||
count_.fetch_add(1);
|
||||
}
|
||||
/**
|
||||
@ -69,7 +69,7 @@ void GroupImpl::Associate()
|
||||
|
||||
void GroupImpl::NotifyTaskDone()
|
||||
{
|
||||
APP_LOGI("GroupImpl::NotifyTaskDone start. Called notify a task to complete");
|
||||
HILOG_INFO("GroupImpl::NotifyTaskDone start. Called notify a task to complete");
|
||||
count_.fetch_sub(1);
|
||||
int newValue = count_.load();
|
||||
if (newValue > 0) {
|
||||
@ -79,7 +79,7 @@ void GroupImpl::NotifyTaskDone()
|
||||
condition_.notify_all();
|
||||
DrainNotifications();
|
||||
|
||||
APP_LOGI("GroupImpl::NotifyTaskDone end");
|
||||
HILOG_INFO("GroupImpl::NotifyTaskDone end");
|
||||
}
|
||||
/**
|
||||
* @brief Adds the |notification| to notification list.
|
||||
@ -91,24 +91,24 @@ void GroupImpl::NotifyTaskDone()
|
||||
*/
|
||||
bool GroupImpl::AddNotification(const std::shared_ptr<Runnable> ¬ification)
|
||||
{
|
||||
APP_LOGI("GroupImpl::AddNotification start");
|
||||
HILOG_INFO("GroupImpl::AddNotification start");
|
||||
if (count_.load() != 0) {
|
||||
std::unique_lock<std::mutex> lock(dataMutex_);
|
||||
if (notifications_.size() == MAX_TASK) {
|
||||
APP_LOGW("GroupImpl::AddNotification called maximun number of tasks exceeded");
|
||||
HILOG_WARN("GroupImpl::AddNotification called maximun number of tasks exceeded");
|
||||
return false;
|
||||
}
|
||||
if (count_.load() != 0) {
|
||||
APP_LOGI("GroupImpl::AddNotification called add task");
|
||||
HILOG_INFO("GroupImpl::AddNotification called add task");
|
||||
notifications_.push_back(notification);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (notification) {
|
||||
APP_LOGI("GroupImpl::AddNotification notification execute");
|
||||
HILOG_INFO("GroupImpl::AddNotification notification execute");
|
||||
(*notification)();
|
||||
}
|
||||
APP_LOGI("GroupImpl::AddNotification end");
|
||||
HILOG_INFO("GroupImpl::AddNotification end");
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
@ -118,14 +118,14 @@ bool GroupImpl::AddNotification(const std::shared_ptr<Runnable> ¬ification)
|
||||
*/
|
||||
void GroupImpl::DrainNotifications()
|
||||
{
|
||||
APP_LOGI("GroupImpl::DrainNotifications start");
|
||||
HILOG_INFO("GroupImpl::DrainNotifications start");
|
||||
while (notifications_.size() > 0) {
|
||||
std::shared_ptr<Runnable> notification = notifications_.front();
|
||||
notifications_.pop_front();
|
||||
APP_LOGI("GroupImpl::DrainNotifications execute notification");
|
||||
HILOG_INFO("GroupImpl::DrainNotifications execute notification");
|
||||
(*notification)();
|
||||
}
|
||||
APP_LOGI("GroupImpl::DrainNotifications end");
|
||||
HILOG_INFO("GroupImpl::DrainNotifications end");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "parallel_task_dispatcher.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -34,53 +34,53 @@ std::shared_ptr<TaskExecuteInterceptor> ParallelTaskDispatcher::GetInterceptor()
|
||||
|
||||
ErrCode ParallelTaskDispatcher::SyncDispatchBarrier(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGD("ParallelTaskDispatcher::SyncDispatchBarrier start");
|
||||
HILOG_DEBUG("ParallelTaskDispatcher::SyncDispatchBarrier start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcher::SyncDispatchBarrier Check failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::SyncDispatchBarrier Check failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
std::shared_ptr<SyncTask> innerSyncTask = std::make_shared<SyncTask>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerSyncTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcher::SyncDispatchBarrier innerSyncTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::SyncDispatchBarrier innerSyncTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<Task> innerTask = std::static_pointer_cast<Task>(innerSyncTask);
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcher::SyncDispatchBarrier innerTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::SyncDispatchBarrier innerTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
APP_LOGD("ParallelTaskDispatcher::SyncDispatchBarrier into new sync task");
|
||||
HILOG_DEBUG("ParallelTaskDispatcher::SyncDispatchBarrier into new sync task");
|
||||
if (barrierHandler_ == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcher::SyncDispatchBarrier barrierHandler_ is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::SyncDispatchBarrier barrierHandler_ is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
barrierHandler_->AddBarrier(innerTask);
|
||||
innerSyncTask->WaitTask();
|
||||
APP_LOGD("ParallelTaskDispatcher::SyncDispatchBarrier end");
|
||||
HILOG_DEBUG("ParallelTaskDispatcher::SyncDispatchBarrier end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode ParallelTaskDispatcher::AsyncDispatchBarrier(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGD("ParallelTaskDispatcher::AsyncDispatchBarrier start");
|
||||
HILOG_DEBUG("ParallelTaskDispatcher::AsyncDispatchBarrier start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcher::AsyncDispatchBarrier check failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::AsyncDispatchBarrier check failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
if (barrierHandler_ == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcher::AsyncDispatchBarrier barrierHandler_ is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::AsyncDispatchBarrier barrierHandler_ is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
APP_LOGI("ParallelTaskDispatcher::AsyncDispatchBarrier into new async task");
|
||||
HILOG_INFO("ParallelTaskDispatcher::AsyncDispatchBarrier into new async task");
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcher::AsyncDispatchBarrier innerTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcher::AsyncDispatchBarrier innerTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
barrierHandler_->AddBarrier(innerTask);
|
||||
APP_LOGI("ParallelTaskDispatcher::AsyncDispatchBarrier end");
|
||||
HILOG_INFO("ParallelTaskDispatcher::AsyncDispatchBarrier end");
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "parallel_task_dispatcher_base.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "appexecfwk_errors.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -33,93 +33,93 @@ ParallelTaskDispatcherBase::ParallelTaskDispatcherBase(
|
||||
|
||||
ErrCode ParallelTaskDispatcherBase::InterceptedExecute(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGD("ParallelTaskDispatcherBase::InterceptedExecute start");
|
||||
HILOG_DEBUG("ParallelTaskDispatcherBase::InterceptedExecute start");
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::InterceptedExecute executor_ is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::InterceptedExecute executor_ is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
if ((GetInterceptor() != nullptr) &&
|
||||
GetInterceptor()->Intercept(task) == ERR_APPEXECFWK_INTERCEPT_TASK_EXECUTE_SUCCESS) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::InterceptedExecute intercept task execute success");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::InterceptedExecute intercept task execute success");
|
||||
return ERR_APPEXECFWK_INTERCEPT_TASK_EXECUTE_SUCCESS;
|
||||
}
|
||||
|
||||
executor_->Execute(task);
|
||||
APP_LOGI("ParallelTaskDispatcherBase::InterceptedExecute end");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::InterceptedExecute end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode ParallelTaskDispatcherBase::SyncDispatch(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("ParallelTaskDispatcherBase::SyncDispatch start");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::SyncDispatch start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::SyncDispatch check failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::SyncDispatch check failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
std::shared_ptr<SyncTask> innerSyncTask = std::make_shared<SyncTask>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerSyncTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::SyncDispatch innerSyncTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::SyncDispatch innerSyncTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<Task> innerTask = std::static_pointer_cast<Task>(innerSyncTask);
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::SyncDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::SyncDispatch innerTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
APP_LOGI("ParallelTaskDispatcherBase::SyncDispatch into new sync task");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::SyncDispatch into new sync task");
|
||||
ErrCode execute = InterceptedExecute(innerTask);
|
||||
if (execute != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::SyncDispatch execute failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::SyncDispatch execute failed");
|
||||
return execute;
|
||||
}
|
||||
innerSyncTask->WaitTask();
|
||||
APP_LOGI("ParallelTaskDispatcherBase::SyncDispatch end");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::SyncDispatch end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> ParallelTaskDispatcherBase::AsyncDispatch(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("ParallelTaskDispatcherBase::AsyncDispatch start");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::AsyncDispatch start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncDispatch check failed.");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncDispatch check failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncDispatch innerTask is nullptr.");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncDispatch innerTask is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, ASYNC_DISPATCHER_TAG);
|
||||
APP_LOGI("ParallelTaskDispatcherBase::AsyncDispatch into new async task");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::AsyncDispatch into new async task");
|
||||
ErrCode execute = InterceptedExecute(innerTask);
|
||||
if (execute != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncDispatch execute failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncDispatch execute failed");
|
||||
return nullptr;
|
||||
}
|
||||
APP_LOGI("ParallelTaskDispatcherBase::AsyncDispatch end");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::AsyncDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> ParallelTaskDispatcherBase::DelayDispatch(
|
||||
const std::shared_ptr<Runnable> &runnable, long delayMs)
|
||||
{
|
||||
APP_LOGI("ParallelTaskDispatcherBase::DelayDispatch start");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::DelayDispatch start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::DelayDispatch Check failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::DelayDispatch Check failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::DelayDispatch executor_ is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::DelayDispatch executor_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::DelayDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::DelayDispatch innerTask is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, DELAY_DISPATCHER_TAG);
|
||||
@ -127,42 +127,42 @@ std::shared_ptr<Revocable> ParallelTaskDispatcherBase::DelayDispatch(
|
||||
innerTask);
|
||||
bool executeFlag = executor_->DelayExecute(callback, delayMs);
|
||||
if (!executeFlag) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::DelayDispatch execute failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::DelayDispatch execute failed");
|
||||
return nullptr;
|
||||
}
|
||||
APP_LOGI("ParallelTaskDispatcherBase::DelayDispatch end");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::DelayDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> ParallelTaskDispatcherBase::AsyncGroupDispatch(
|
||||
const std::shared_ptr<Group> &group, const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("ParallelTaskDispatcherBase::AsyncGroupDispatch start");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::AsyncGroupDispatch start");
|
||||
if (group == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncGroupDispatch group is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncGroupDispatch group is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncGroupDispatch Check failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncGroupDispatch Check failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<GroupImpl> groupImpl = CastToGroupImpl(group);
|
||||
if (groupImpl == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncGroupDispatch groupImpl is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncGroupDispatch groupImpl is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
groupImpl->Associate();
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncGroupDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncGroupDispatch innerTask is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, ASYNC_GROUP_DISPATCHER_TAG);
|
||||
std::shared_ptr<MyTaskListener> ptrlistener = std::make_shared<MyTaskListener>();
|
||||
if (ptrlistener == nullptr) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncGroupDispatch ptrlistener is nullptr");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncGroupDispatch ptrlistener is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
const std::function<void()> onTaskDone = std::bind(&GroupImpl::NotifyTaskDone, groupImpl);
|
||||
@ -170,10 +170,10 @@ std::shared_ptr<Revocable> ParallelTaskDispatcherBase::AsyncGroupDispatch(
|
||||
innerTask->AddTaskListener(ptrlistener);
|
||||
ErrCode execute = InterceptedExecute(innerTask);
|
||||
if (execute != ERR_OK) {
|
||||
APP_LOGE("ParallelTaskDispatcherBase::AsyncGroupDispatch execute failed");
|
||||
HILOG_ERROR("ParallelTaskDispatcherBase::AsyncGroupDispatch execute failed");
|
||||
return nullptr;
|
||||
}
|
||||
APP_LOGI("ParallelTaskDispatcherBase::AsyncGroupDispatch end");
|
||||
HILOG_INFO("ParallelTaskDispatcherBase::AsyncGroupDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "serial_task_dispatcher.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "appexecfwk_errors.h"
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -43,20 +43,20 @@ std::string SerialTaskDispatcher::GetDispatcherName()
|
||||
|
||||
ErrCode SerialTaskDispatcher::SyncDispatch(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::SyncDispatch start");
|
||||
HILOG_INFO("SerialTaskDispatcher::SyncDispatch start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("SerialTaskDispatcher::SyncDispatch check failed");
|
||||
HILOG_ERROR("SerialTaskDispatcher::SyncDispatch check failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
std::shared_ptr<SyncTask> innerSyncTask = std::make_shared<SyncTask>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerSyncTask == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::SyncDispatch innerSyncTask is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::SyncDispatch innerSyncTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
std::shared_ptr<Task> innerTask = std::static_pointer_cast<Task>(innerSyncTask);
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::SyncDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::SyncDispatch innerTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
TracePointBeforePost(innerTask, false, SYNC_DISPATCHER_TAG);
|
||||
@ -64,45 +64,45 @@ ErrCode SerialTaskDispatcher::SyncDispatch(const std::shared_ptr<Runnable> &runn
|
||||
innerSyncTask->WaitTask();
|
||||
TracePointAfterPost(innerTask, false, DISPATCHER_TAG);
|
||||
|
||||
APP_LOGI("SerialTaskDispatcher::SyncDispatch end");
|
||||
HILOG_INFO("SerialTaskDispatcher::SyncDispatch end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> SerialTaskDispatcher::AsyncDispatch(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::AsyncDispatch start");
|
||||
HILOG_INFO("SerialTaskDispatcher::AsyncDispatch start");
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("SerialTaskDispatcher::AsyncDispatch Check failed");
|
||||
HILOG_ERROR("SerialTaskDispatcher::AsyncDispatch Check failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::AsyncDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::AsyncDispatch innerTask is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, ASYNC_DISPATCHER_TAG);
|
||||
APP_LOGI("SerialTaskDispatcher::AsyncDispatch into new async task");
|
||||
HILOG_INFO("SerialTaskDispatcher::AsyncDispatch into new async task");
|
||||
OnNewTaskIn(innerTask);
|
||||
APP_LOGI("SerialTaskDispatcher::AsyncDispatch end");
|
||||
HILOG_INFO("SerialTaskDispatcher::AsyncDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> SerialTaskDispatcher::DelayDispatch(const std::shared_ptr<Runnable> &runnable, long delayMs)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::DelayDispatch start");
|
||||
HILOG_INFO("SerialTaskDispatcher::DelayDispatch start");
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::DelayDispatch executor_ is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::DelayDispatch executor_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("SerialTaskDispatcher::DelayDispatch Check failed");
|
||||
HILOG_ERROR("SerialTaskDispatcher::DelayDispatch Check failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::DelayDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::DelayDispatch innerTask is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, DELAY_DISPATCHER_TAG);
|
||||
@ -110,38 +110,38 @@ std::shared_ptr<Revocable> SerialTaskDispatcher::DelayDispatch(const std::shared
|
||||
std::function<void()> callback = std::bind(&SerialTaskDispatcher::OnNewTaskIn, this, innerTask);
|
||||
bool executeFlag = executor_->DelayExecute(callback, delayMs);
|
||||
if (!executeFlag) {
|
||||
APP_LOGE("SerialTaskDispatcher::DelayDispatch execute failed");
|
||||
HILOG_ERROR("SerialTaskDispatcher::DelayDispatch execute failed");
|
||||
return nullptr;
|
||||
}
|
||||
APP_LOGI("SerialTaskDispatcher::DelayDispatch end");
|
||||
HILOG_INFO("SerialTaskDispatcher::DelayDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
|
||||
ErrCode SerialTaskDispatcher::OnNewTaskIn(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::OnNewTaskIn start");
|
||||
HILOG_INFO("SerialTaskDispatcher::OnNewTaskIn start");
|
||||
ErrCode code = Prepare(task);
|
||||
if (code != ERR_OK) {
|
||||
APP_LOGE("SerialTaskDispatcher::OnNewTaskIn Prepare failed");
|
||||
HILOG_ERROR("SerialTaskDispatcher::OnNewTaskIn Prepare failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (workingTasks_.Offer(task) == false) {
|
||||
APP_LOGW("SerialTaskDispatcher.onNewTaskIn exceed the maximum capacity of Queue");
|
||||
HILOG_WARN("SerialTaskDispatcher.onNewTaskIn exceed the maximum capacity of Queue");
|
||||
}
|
||||
}
|
||||
|
||||
Schedule();
|
||||
APP_LOGI("SerialTaskDispatcher::OnNewTaskIn end");
|
||||
HILOG_INFO("SerialTaskDispatcher::OnNewTaskIn end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode SerialTaskDispatcher::Prepare(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::Prepare start");
|
||||
HILOG_INFO("SerialTaskDispatcher::Prepare start");
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::Prepare task is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::Prepare task is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
// inline class
|
||||
@ -166,57 +166,57 @@ ErrCode SerialTaskDispatcher::Prepare(std::shared_ptr<Task> &task)
|
||||
// set inline listener
|
||||
std::shared_ptr<MyTaskListener> ptrlistener = std::make_shared<MyTaskListener>();
|
||||
if (ptrlistener == nullptr) {
|
||||
APP_LOGE("SerialTaskDispatcher::Prepare MyTaskListener is nullptr");
|
||||
HILOG_ERROR("SerialTaskDispatcher::Prepare MyTaskListener is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
const std::function<void()> onTaskDone = [&]() { OnTaskDone(); };
|
||||
ptrlistener->Callback(onTaskDone);
|
||||
task->AddTaskListener(ptrlistener);
|
||||
APP_LOGI("SerialTaskDispatcher::Prepare end");
|
||||
HILOG_INFO("SerialTaskDispatcher::Prepare end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void SerialTaskDispatcher::OnTaskDone()
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::OnTaskDone start");
|
||||
HILOG_INFO("SerialTaskDispatcher::OnTaskDone start");
|
||||
bool isExhausted = workingTasks_.Empty();
|
||||
DoNext(isExhausted);
|
||||
APP_LOGI("SerialTaskDispatcher::OnTaskDone end");
|
||||
HILOG_INFO("SerialTaskDispatcher::OnTaskDone end");
|
||||
}
|
||||
|
||||
bool SerialTaskDispatcher::Schedule()
|
||||
{
|
||||
bool init = false;
|
||||
if (!running_.compare_exchange_strong(init, true)) {
|
||||
APP_LOGW("SerialTaskDispatcher::schedule already running");
|
||||
HILOG_WARN("SerialTaskDispatcher::schedule already running");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("SerialTaskDispatcher::Schedule do next");
|
||||
HILOG_INFO("SerialTaskDispatcher::Schedule do next");
|
||||
return DoNext(false);
|
||||
}
|
||||
|
||||
bool SerialTaskDispatcher::DoNext(bool isExhausted)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::DoNext start");
|
||||
HILOG_INFO("SerialTaskDispatcher::DoNext start");
|
||||
std::shared_ptr<Task> nextptr = nullptr;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
nextptr = workingTasks_.Poll();
|
||||
if (nextptr == nullptr) {
|
||||
running_.store(false);
|
||||
APP_LOGW("SerialTaskDispatcher::DoNext no more task");
|
||||
HILOG_WARN("SerialTaskDispatcher::DoNext no more task");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DoWork(nextptr);
|
||||
APP_LOGI("SerialTaskDispatcher::DoNext end");
|
||||
HILOG_INFO("SerialTaskDispatcher::DoNext end");
|
||||
return true;
|
||||
}
|
||||
|
||||
void SerialTaskDispatcher::DoWork(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("SerialTaskDispatcher::DoWork called.");
|
||||
HILOG_INFO("SerialTaskDispatcher::DoWork called.");
|
||||
// |task| mustn't be null
|
||||
executor_->Execute(task);
|
||||
}
|
||||
|
@ -31,74 +31,74 @@ SpecTaskDispatcher::SpecTaskDispatcher(
|
||||
|
||||
ErrCode SpecTaskDispatcher::SyncDispatch(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("SpecTaskDispatcher::SyncDispatch start");
|
||||
HILOG_INFO("SpecTaskDispatcher::SyncDispatch start");
|
||||
if (handler_ == nullptr) {
|
||||
APP_LOGE("SpecTaskDispatcher::SyncDispatch handler is nullptr");
|
||||
HILOG_ERROR("SpecTaskDispatcher::SyncDispatch handler is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("SpecTaskDispatcher::SyncDispatch check failed");
|
||||
HILOG_ERROR("SpecTaskDispatcher::SyncDispatch check failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("SpecTaskDispatcher::SyncDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("SpecTaskDispatcher::SyncDispatch innerTask is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
TracePointBeforePost(innerTask, false, SYNC_DISPATCHER_TAG);
|
||||
APP_LOGI("SpecTaskDispatcher::SyncDispatch into new sync task");
|
||||
HILOG_INFO("SpecTaskDispatcher::SyncDispatch into new sync task");
|
||||
handler_->DispatchSync(runnable);
|
||||
TracePointAfterPost(innerTask, false, DISPATCHER_TAG);
|
||||
|
||||
APP_LOGI("SpecTaskDispatcher::SyncDispatch end");
|
||||
HILOG_INFO("SpecTaskDispatcher::SyncDispatch end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> SpecTaskDispatcher::AsyncDispatch(const std::shared_ptr<Runnable> &runnable)
|
||||
{
|
||||
APP_LOGI("SpecTaskDispatcher::AsyncDispatch start");
|
||||
HILOG_INFO("SpecTaskDispatcher::AsyncDispatch start");
|
||||
if (handler_ == nullptr) {
|
||||
APP_LOGE("SpecTaskDispatcher::AsyncDispatch handler is nullptr");
|
||||
HILOG_ERROR("SpecTaskDispatcher::AsyncDispatch handler is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("SpecTaskDispatcher::AsyncDispatch check failed");
|
||||
HILOG_ERROR("SpecTaskDispatcher::AsyncDispatch check failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("SpecTaskDispatcher::AsyncDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("SpecTaskDispatcher::AsyncDispatch innerTask is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, ASYNC_DISPATCHER_TAG);
|
||||
APP_LOGI("SpecTaskDispatcher::AsyncDispatch into new async task");
|
||||
HILOG_INFO("SpecTaskDispatcher::AsyncDispatch into new async task");
|
||||
handler_->Dispatch(runnable);
|
||||
APP_LOGI("SpecTaskDispatcher::AsyncDispatch end");
|
||||
HILOG_INFO("SpecTaskDispatcher::AsyncDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
|
||||
std::shared_ptr<Revocable> SpecTaskDispatcher::DelayDispatch(const std::shared_ptr<Runnable> &runnable, long delayMs)
|
||||
{
|
||||
APP_LOGI("SpecTaskDispatcher::DelayDispatch start");
|
||||
HILOG_INFO("SpecTaskDispatcher::DelayDispatch start");
|
||||
if (handler_ == nullptr) {
|
||||
APP_LOGE("SpecTaskDispatcher::DelayDispatch handler is nullptr");
|
||||
HILOG_ERROR("SpecTaskDispatcher::DelayDispatch handler is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (Check(runnable) != ERR_OK) {
|
||||
APP_LOGE("SpecTaskDispatcher::DelayDispatch check failed");
|
||||
HILOG_ERROR("SpecTaskDispatcher::DelayDispatch check failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> innerTask = std::make_shared<Task>(runnable, GetPriority(), shared_from_this());
|
||||
if (innerTask == nullptr) {
|
||||
APP_LOGE("SpecTaskDispatcher::DelayDispatch innerTask is nullptr");
|
||||
HILOG_ERROR("SpecTaskDispatcher::DelayDispatch innerTask is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
TracePointBeforePost(innerTask, true, DELAY_DISPATCHER_TAG);
|
||||
handler_->Dispatch(runnable, delayMs);
|
||||
APP_LOGI("SpecTaskDispatcher::DelayDispatch end");
|
||||
HILOG_INFO("SpecTaskDispatcher::DelayDispatch end");
|
||||
return innerTask;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "task_dispatcher_context.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -22,7 +22,7 @@ TaskDispatcherContext::TaskDispatcherContext()
|
||||
globalDispatchers_.resize(PRIORITY_COUNT);
|
||||
config_ = std::make_shared<DefaultWorkerPoolConfig>();
|
||||
if (config_ == nullptr) {
|
||||
APP_LOGE("TaskDispatcherContext::TaskDispatcherContext config is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::TaskDispatcherContext config is nullptr");
|
||||
executor_ = nullptr;
|
||||
} else {
|
||||
executor_ = std::make_shared<TaskExecutor>(config_);
|
||||
@ -41,10 +41,10 @@ TaskDispatcherContext::TaskDispatcherContext(const std::shared_ptr<TaskExecutor>
|
||||
TaskDispatcherContext::~TaskDispatcherContext()
|
||||
{
|
||||
if (executor_) {
|
||||
APP_LOGI("TaskDispatcherContext::~TaskDispatcherContext() terminate");
|
||||
HILOG_INFO("TaskDispatcherContext::~TaskDispatcherContext() terminate");
|
||||
executor_->Terminate(false);
|
||||
}
|
||||
APP_LOGI("TaskDispatcherContext::~TaskDispatcherContext end");
|
||||
HILOG_INFO("TaskDispatcherContext::~TaskDispatcherContext end");
|
||||
}
|
||||
|
||||
std::shared_ptr<WorkerPoolConfig> TaskDispatcherContext::GetWorkerPoolConfig() const
|
||||
@ -54,67 +54,67 @@ std::shared_ptr<WorkerPoolConfig> TaskDispatcherContext::GetWorkerPoolConfig() c
|
||||
|
||||
std::map<std::string, long> TaskDispatcherContext::GetWorkerThreadsInfo() const
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::GetWorkerThreadsInfo called");
|
||||
HILOG_INFO("TaskDispatcherContext::GetWorkerThreadsInfo called");
|
||||
if (executor_ != nullptr) {
|
||||
return executor_->GetWorkerThreadsInfo();
|
||||
}
|
||||
std::map<std::string, long> map;
|
||||
APP_LOGE("TaskDispatcherContext::GetWorkerThreadsInfo executor is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::GetWorkerThreadsInfo executor is nullptr");
|
||||
return map;
|
||||
}
|
||||
|
||||
std::map<std::shared_ptr<SerialTaskDispatcher>, std::string> TaskDispatcherContext::GetSerialDispatchers() const
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::GetSerialDispatchers called");
|
||||
HILOG_INFO("TaskDispatcherContext::GetSerialDispatchers called");
|
||||
return serialDispatchers_;
|
||||
}
|
||||
|
||||
int TaskDispatcherContext::GetWaitingTasksCount() const
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::GetWaitingTasksCount called");
|
||||
HILOG_INFO("TaskDispatcherContext::GetWaitingTasksCount called");
|
||||
if (executor_ != nullptr) {
|
||||
return executor_->GetPendingTasksSize();
|
||||
}
|
||||
APP_LOGE("TaskDispatcherContext::GetWaitingTasksCount executor is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::GetWaitingTasksCount executor is nullptr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
long TaskDispatcherContext::GetTaskCounter() const
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::GetTaskCounter called");
|
||||
HILOG_INFO("TaskDispatcherContext::GetTaskCounter called");
|
||||
if (executor_ != nullptr) {
|
||||
return executor_->GetTaskCounter();
|
||||
}
|
||||
APP_LOGE("TaskDispatcherContext::GetTaskCounter executor is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::GetTaskCounter executor is nullptr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<SerialTaskDispatcher> TaskDispatcherContext::CreateSerialDispatcher(
|
||||
const std::string &name, TaskPriority priority)
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::CreateSerialDispatcher start");
|
||||
HILOG_INFO("TaskDispatcherContext::CreateSerialDispatcher start");
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("TaskDispatcherContext::CreateSerialDispatcher executor is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::CreateSerialDispatcher executor is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<SerialTaskDispatcher> serialDispatcher =
|
||||
std::make_shared<SerialTaskDispatcher>(name, priority, executor_);
|
||||
serialDispatchers_.insert(std::pair<std::shared_ptr<SerialTaskDispatcher>, std::string>(serialDispatcher, name));
|
||||
APP_LOGI("TaskDispatcherContext::CreateSerialDispatcher end");
|
||||
HILOG_INFO("TaskDispatcherContext::CreateSerialDispatcher end");
|
||||
return serialDispatcher;
|
||||
}
|
||||
|
||||
std::shared_ptr<ParallelTaskDispatcher> TaskDispatcherContext::CreateParallelDispatcher(
|
||||
const std::string &name, TaskPriority priority)
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::CreateParallelDispatcher start");
|
||||
HILOG_INFO("TaskDispatcherContext::CreateParallelDispatcher start");
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("TaskDispatcherContext::CreateParallelDispatcher executor is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::CreateParallelDispatcher executor is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<ParallelTaskDispatcher> parallelTaskDispatcher =
|
||||
std::make_shared<ParallelTaskDispatcher>(name, priority, executor_);
|
||||
APP_LOGI("TaskDispatcherContext::CreateParallelDispatcher end");
|
||||
HILOG_INFO("TaskDispatcherContext::CreateParallelDispatcher end");
|
||||
return parallelTaskDispatcher;
|
||||
}
|
||||
|
||||
@ -130,42 +130,42 @@ int TaskDispatcherContext::MapPriorityIndex(TaskPriority priority) const
|
||||
default:
|
||||
return DEFAULT_PRIORITY_INDEX;
|
||||
}
|
||||
APP_LOGE("TaskDispatcherContext.mapPriorityIndex unhandled priority=%{public}d", priority);
|
||||
HILOG_ERROR("TaskDispatcherContext.mapPriorityIndex unhandled priority=%{public}d", priority);
|
||||
|
||||
return DEFAULT_PRIORITY_INDEX;
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskDispatcher> TaskDispatcherContext::GetGlobalTaskDispatcher(TaskPriority priority)
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::GetGlobalTaskDispatcher start");
|
||||
HILOG_INFO("TaskDispatcherContext::GetGlobalTaskDispatcher start");
|
||||
std::unique_lock<std::mutex> lock(mtx_);
|
||||
int index = MapPriorityIndex(priority);
|
||||
std::shared_ptr<TaskDispatcher> dispatcher = globalDispatchers_[index];
|
||||
if (dispatcher == nullptr) {
|
||||
APP_LOGI("TaskDispatcherContext::GetGlobalTaskDispatcher dispatcher is nullptr ");
|
||||
HILOG_INFO("TaskDispatcherContext::GetGlobalTaskDispatcher dispatcher is nullptr ");
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("TaskDispatcherContext::GetGlobalTaskDispatcher executor_ is nullptr ");
|
||||
HILOG_ERROR("TaskDispatcherContext::GetGlobalTaskDispatcher executor_ is nullptr ");
|
||||
return nullptr;
|
||||
}
|
||||
dispatcher = std::make_shared<GlobalTaskDispatcher>(priority, executor_);
|
||||
if (globalDispatchers_[index] == nullptr) {
|
||||
APP_LOGI("TaskDispatcherContext::GetGlobalTaskDispatcher dispatcher compareAndSet ");
|
||||
HILOG_INFO("TaskDispatcherContext::GetGlobalTaskDispatcher dispatcher compareAndSet ");
|
||||
globalDispatchers_.insert((globalDispatchers_.begin() + index), dispatcher);
|
||||
}
|
||||
}
|
||||
APP_LOGI("TaskDispatcherContext::GetGlobalTaskDispatcher end");
|
||||
HILOG_INFO("TaskDispatcherContext::GetGlobalTaskDispatcher end");
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
ErrCode TaskDispatcherContext::Shutdown(bool force)
|
||||
{
|
||||
APP_LOGI("TaskDispatcherContext::Shutdown start");
|
||||
HILOG_INFO("TaskDispatcherContext::Shutdown start");
|
||||
if (executor_ == nullptr) {
|
||||
APP_LOGE("TaskDispatcherContext::Shutdown executor_ is nullptr");
|
||||
HILOG_ERROR("TaskDispatcherContext::Shutdown executor_ is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
executor_->Terminate(force);
|
||||
APP_LOGI("TaskDispatcherContext::Shutdown end");
|
||||
HILOG_INFO("TaskDispatcherContext::Shutdown end");
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "barrier_handler.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -24,9 +24,9 @@ BarrierHandler::BarrierHandler(const std::shared_ptr<TaskExecutor> &executor)
|
||||
|
||||
ErrCode BarrierHandler::AddBarrier(std::shared_ptr<Task> &barrierTask)
|
||||
{
|
||||
APP_LOGI("BarrierHandler::AddBarrier start");
|
||||
HILOG_INFO("BarrierHandler::AddBarrier start");
|
||||
if (ListenToTask(barrierTask) != ERR_OK) {
|
||||
APP_LOGE("BarrierHandler::AddBarrier listenToTask failed");
|
||||
HILOG_ERROR("BarrierHandler::AddBarrier listenToTask failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
};
|
||||
|
||||
@ -36,66 +36,66 @@ ErrCode BarrierHandler::AddBarrier(std::shared_ptr<Task> &barrierTask)
|
||||
std::shared_ptr<BarrierPair> pair = barrierQueue_.size() == 0 ? nullptr : barrierQueue_.back();
|
||||
if ((pair == nullptr) || ((!HasTask(pair->tasks_)) && (pair->barrier_ == nullptr))) {
|
||||
execNow = true;
|
||||
APP_LOGI("BarrierHandler::AddBarrier need execute now");
|
||||
HILOG_INFO("BarrierHandler::AddBarrier need execute now");
|
||||
}
|
||||
if ((pair == nullptr) || (pair->barrier_ != nullptr)) {
|
||||
std::set<std::shared_ptr<Task>> tmp;
|
||||
std::shared_ptr<BarrierPair> barrierPair = std::make_shared<BarrierPair>(tmp, barrierTask);
|
||||
if (barrierPair == nullptr) {
|
||||
APP_LOGE("BarrierHandler::AddBarrier barrierPair is nullptr");
|
||||
HILOG_ERROR("BarrierHandler::AddBarrier barrierPair is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
barrierQueue_.push_back(barrierPair);
|
||||
APP_LOGI("BarrierHandler::AddBarrier barrierQueue push barrierPair");
|
||||
HILOG_INFO("BarrierHandler::AddBarrier barrierQueue push barrierPair");
|
||||
} else {
|
||||
pair->barrier_ = barrierTask;
|
||||
}
|
||||
}
|
||||
|
||||
if (execNow) {
|
||||
APP_LOGI("BarrierHandler::AddBarrier execute task");
|
||||
HILOG_INFO("BarrierHandler::AddBarrier execute task");
|
||||
executor_->Execute(barrierTask);
|
||||
}
|
||||
APP_LOGI("BarrierHandler::AddBarrier end");
|
||||
HILOG_INFO("BarrierHandler::AddBarrier end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BarrierHandler::Intercept(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("BarrierHandler::Intercept start");
|
||||
HILOG_INFO("BarrierHandler::Intercept start");
|
||||
if (ListenToTask(task) != ERR_OK) {
|
||||
APP_LOGE("BarrierHandler::Intercept listenToTask failed");
|
||||
HILOG_ERROR("BarrierHandler::Intercept listenToTask failed");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
};
|
||||
|
||||
// afterBarrier means is intercepted.
|
||||
bool intercepted = AddTaskAfterBarrier(task);
|
||||
if (intercepted) {
|
||||
APP_LOGI("BarrierHandler::Intercept intercepted a task.");
|
||||
HILOG_INFO("BarrierHandler::Intercept intercepted a task.");
|
||||
}
|
||||
ErrCode result = intercepted ? ERR_APPEXECFWK_INTERCEPT_TASK_EXECUTE_SUCCESS : ERR_APPEXECFWK_CHECK_FAILED;
|
||||
APP_LOGI("BarrierHandler::Intercept end, result:%{public}d", result);
|
||||
HILOG_INFO("BarrierHandler::Intercept end, result:%{public}d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrCode BarrierHandler::ListenToTask(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("BarrierHandler::ListenToTask start");
|
||||
HILOG_INFO("BarrierHandler::ListenToTask start");
|
||||
std::shared_ptr<MyTaskListener> ptrlistener = std::make_shared<MyTaskListener>();
|
||||
if (ptrlistener == nullptr) {
|
||||
APP_LOGE("BarrierHandler::listenToTask make shared MyTaskListener is nullptr");
|
||||
HILOG_ERROR("BarrierHandler::listenToTask make shared MyTaskListener is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
const std::function<void()> onTaskDone = std::bind(&BarrierHandler::OnTaskDone, this, task);
|
||||
ptrlistener->Callback(onTaskDone);
|
||||
task->AddTaskListener(ptrlistener);
|
||||
APP_LOGI("BarrierHandler::ListenToTask end");
|
||||
HILOG_INFO("BarrierHandler::ListenToTask end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void BarrierHandler::OnTaskDone(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("BarrierHandler::OnTaskDone start");
|
||||
HILOG_INFO("BarrierHandler::OnTaskDone start");
|
||||
// remove from head of queue.
|
||||
// Under the premise that task cannot be reused.
|
||||
bool removed = false;
|
||||
@ -106,11 +106,11 @@ void BarrierHandler::OnTaskDone(std::shared_ptr<Task> &task)
|
||||
if (HasTask(barrierPair->tasks_)) {
|
||||
removed = barrierPair->tasks_.erase(task) == 0 ? false : true;
|
||||
if (barrierPair->tasks_.empty() && (barrierPair->barrier_ != nullptr)) {
|
||||
APP_LOGI("Barrier.onTaskDone execute barrier task after task done.");
|
||||
HILOG_INFO("Barrier.onTaskDone execute barrier task after task done.");
|
||||
executor_->Execute(barrierPair->barrier_);
|
||||
}
|
||||
} else if (task == (barrierPair->barrier_)) {
|
||||
APP_LOGI("Barrier.onTaskDone remove a barrier.");
|
||||
HILOG_INFO("Barrier.onTaskDone remove a barrier.");
|
||||
barrierPair->barrier_ = nullptr;
|
||||
removed = true;
|
||||
// Driven to next barrier.
|
||||
@ -125,10 +125,10 @@ void BarrierHandler::OnTaskDone(std::shared_ptr<Task> &task)
|
||||
executor_->Execute(*it);
|
||||
}
|
||||
} else if (nextPair->barrier_ != nullptr) {
|
||||
APP_LOGI("Barrier.onTaskDone execute barrier task after barrier done.");
|
||||
HILOG_INFO("Barrier.onTaskDone execute barrier task after barrier done.");
|
||||
executor_->Execute(nextPair->barrier_);
|
||||
} else {
|
||||
APP_LOGW("Barrier.onTaskDone: Detected an empty node.");
|
||||
HILOG_WARN("Barrier.onTaskDone: Detected an empty node.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,20 +136,20 @@ void BarrierHandler::OnTaskDone(std::shared_ptr<Task> &task)
|
||||
}
|
||||
|
||||
if (!removed) {
|
||||
APP_LOGI("Barrier.onTaskDone: Task remove failed.");
|
||||
HILOG_INFO("Barrier.onTaskDone: Task remove failed.");
|
||||
}
|
||||
APP_LOGI("BarrierHandler::OnTaskDone end");
|
||||
HILOG_INFO("BarrierHandler::OnTaskDone end");
|
||||
}
|
||||
|
||||
bool BarrierHandler::AddTaskAfterBarrier(std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("BarrierHandler::AddTaskAfterBarrier start");
|
||||
HILOG_INFO("BarrierHandler::AddTaskAfterBarrier start");
|
||||
std::unique_lock<std::mutex> lock(barrierLock_);
|
||||
std::shared_ptr<BarrierPair> pair = barrierQueue_.size() == 0 ? nullptr : barrierQueue_.back();
|
||||
if ((pair == nullptr) || (pair->barrier_ != nullptr)) {
|
||||
std::shared_ptr<BarrierPair> tmp = std::make_shared<BarrierPair>(CreateTaskSet(task), nullptr);
|
||||
if (tmp == nullptr) {
|
||||
APP_LOGE("BarrierHandler::addTaskAfterBarrier make shared BarrierPair is nullptr");
|
||||
HILOG_ERROR("BarrierHandler::addTaskAfterBarrier make shared BarrierPair is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ bool BarrierHandler::AddTaskAfterBarrier(std::shared_ptr<Task> &task)
|
||||
} else {
|
||||
pair->tasks_.insert(task);
|
||||
}
|
||||
APP_LOGI("BarrierHandler::AddTaskAfterBarrier end");
|
||||
HILOG_INFO("BarrierHandler::AddTaskAfterBarrier end");
|
||||
return (barrierQueue_.size() > 1);
|
||||
}
|
||||
|
||||
|
@ -37,26 +37,26 @@ void SyncTask::Run()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
auto threadId = std::this_thread::get_id();
|
||||
APP_LOGI("SyncTask::Run begin thread=%{public}zu", CalculateHashCode(threadId));
|
||||
HILOG_INFO("SyncTask::Run begin thread=%{public}zu", CalculateHashCode(threadId));
|
||||
Task::Run();
|
||||
executed_.store(true);
|
||||
|
||||
// |waitTask| may have been multi invoked.
|
||||
condition_variable_.notify_all();
|
||||
APP_LOGI("SyncTask::Run end thread=%{public}zu", CalculateHashCode(threadId));
|
||||
HILOG_INFO("SyncTask::Run end thread=%{public}zu", CalculateHashCode(threadId));
|
||||
}
|
||||
|
||||
void SyncTask::WaitTask()
|
||||
{
|
||||
auto threadId = std::this_thread::get_id();
|
||||
APP_LOGI("SyncTask::WaitTask begin thread=%{public}zu", CalculateHashCode(threadId));
|
||||
HILOG_INFO("SyncTask::WaitTask begin thread=%{public}zu", CalculateHashCode(threadId));
|
||||
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
while (executed_ == false) {
|
||||
condition_variable_.wait(lock);
|
||||
}
|
||||
|
||||
APP_LOGI("SyncTask::WaitTask end thread=%{public}zu", CalculateHashCode(threadId));
|
||||
HILOG_INFO("SyncTask::WaitTask end thread=%{public}zu", CalculateHashCode(threadId));
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "task.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
/**
|
||||
@ -30,7 +30,7 @@ Task::Task(const std::shared_ptr<Runnable> &runnable, const TaskPriority priorit
|
||||
priority_ = priority;
|
||||
baseTaskDispatcher_ = baseTaskDispatcher;
|
||||
std::atomic_init(&state_, 0U);
|
||||
APP_LOGI("Task::Task init listener count=%{public}zu", taskListeners_.Size());
|
||||
HILOG_INFO("Task::Task init listener count=%{public}zu", taskListeners_.Size());
|
||||
}
|
||||
Task::~Task()
|
||||
{}
|
||||
@ -42,17 +42,17 @@ Task::~Task()
|
||||
*/
|
||||
void Task::Run()
|
||||
{
|
||||
APP_LOGI("Task::Run task run called start");
|
||||
HILOG_INFO("Task::Run task run called start");
|
||||
if (runnable_ == nullptr) {
|
||||
APP_LOGI("Task::Run called runnable_ is null");
|
||||
HILOG_INFO("Task::Run called runnable_ is null");
|
||||
return;
|
||||
}
|
||||
// Task cannot be reused.
|
||||
if (EnterExecute()) {
|
||||
APP_LOGI("Task::Run runnable_ Run called start");
|
||||
HILOG_INFO("Task::Run runnable_ Run called start");
|
||||
(*runnable_.get())();
|
||||
}
|
||||
APP_LOGI("Task::Run runnable_ Run called end");
|
||||
HILOG_INFO("Task::Run runnable_ Run called end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,11 +94,11 @@ long Task::GetSequence() const
|
||||
bool Task::Revoke()
|
||||
{
|
||||
if (runnable_ == nullptr) {
|
||||
APP_LOGE("Task.Revoke called runnable_ is null");
|
||||
HILOG_ERROR("Task.Revoke called runnable_ is null");
|
||||
return false;
|
||||
}
|
||||
RevokeResult result = SetRevoked();
|
||||
APP_LOGI("Task.Revoke result: %{public}u", result);
|
||||
HILOG_INFO("Task.Revoke result: %{public}u", result);
|
||||
if (result == SUCCESS) {
|
||||
OnTaskCanceled();
|
||||
}
|
||||
@ -112,7 +112,7 @@ bool Task::Revoke()
|
||||
*/
|
||||
void Task::AddTaskListener(const std::shared_ptr<TaskListener> &listener)
|
||||
{
|
||||
APP_LOGI("Task.AddTaskListener listener called start");
|
||||
HILOG_INFO("Task.AddTaskListener listener called start");
|
||||
taskListeners_.Offer(listener);
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ void Task::BeforeTaskExecute()
|
||||
void Task::AfterTaskExecute()
|
||||
{
|
||||
if ((state_ & EXECUTED) == EXECUTED) {
|
||||
APP_LOGI("Task.AfterTaskExecute taskStage called AFTER_EXECUTE");
|
||||
HILOG_INFO("Task.AfterTaskExecute taskStage called AFTER_EXECUTE");
|
||||
ConcurrentQueueStatusUpdate(TaskStage::AFTER_EXECUTE);
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ void Task::AfterTaskExecute()
|
||||
*/
|
||||
void Task::OnTaskCanceled()
|
||||
{
|
||||
APP_LOGI("Task.OnTaskCanceled taskStage called REVOKED");
|
||||
HILOG_INFO("Task.OnTaskCanceled taskStage called REVOKED");
|
||||
ConcurrentQueueStatusUpdate(TaskStage::REVOKED);
|
||||
}
|
||||
|
||||
@ -165,11 +165,11 @@ bool Task::EnterExecute()
|
||||
if ((state_ & stateNotIn) == 0) {
|
||||
// Not executed or revoked
|
||||
if (state_.compare_exchange_strong(value, EXECUTED)) {
|
||||
APP_LOGI("Task.EnterExecute return success");
|
||||
HILOG_INFO("Task.EnterExecute return success");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
APP_LOGE("Task.EnterExecute return fail, state=%{public}d, stateNotIn=%{public}d", value, stateNotIn);
|
||||
HILOG_ERROR("Task.EnterExecute return fail, state=%{public}d, stateNotIn=%{public}d", value, stateNotIn);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -180,16 +180,16 @@ Task::RevokeResult Task::SetRevoked()
|
||||
while (true) {
|
||||
unsigned int value = state_.load();
|
||||
if ((value & REVOKED) == REVOKED) {
|
||||
APP_LOGW("Task.SetRevoked return ALREADY_REVOKED");
|
||||
HILOG_WARN("Task.SetRevoked return ALREADY_REVOKED");
|
||||
return ALREADY_REVOKED;
|
||||
}
|
||||
if ((value & EXECUTED) == 0) {
|
||||
if (state_.compare_exchange_strong(value, REVOKED)) {
|
||||
APP_LOGI("Task.SetRevoked return SUCCESS");
|
||||
HILOG_INFO("Task.SetRevoked return SUCCESS");
|
||||
return SUCCESS;
|
||||
}
|
||||
} else {
|
||||
APP_LOGE("Task.SetRevoked return FAIL");
|
||||
HILOG_ERROR("Task.SetRevoked return FAIL");
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ Task::RevokeResult Task::SetRevoked()
|
||||
|
||||
void Task::ConcurrentQueueStatusUpdate(const TaskStage::TASKSTAGE taskstage)
|
||||
{
|
||||
APP_LOGI("Task.ConcurrentQueueStatusUpdate taskListeners_ called start");
|
||||
HILOG_INFO("Task.ConcurrentQueueStatusUpdate taskListeners_ called start");
|
||||
for (auto iter = taskListeners_.Begin(); iter != taskListeners_.End(); iter++) {
|
||||
(*iter)->OnChanged(taskstage);
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ std::shared_ptr<Thread> DefaultThreadFactory::Create()
|
||||
int value = std::atomic_fetch_add(&index_, 1);
|
||||
std::string name = std::string("PoolThread-") + std::to_string(value);
|
||||
pThread->thread_name_ = name;
|
||||
APP_LOGI("DefaultThreadFactory::Create thread name is %{public}s", name.c_str());
|
||||
HILOG_INFO("DefaultThreadFactory::Create thread name is %{public}s", name.c_str());
|
||||
} else {
|
||||
APP_LOGE("DefaultThreadFactory::Create error, thread is nullptr");
|
||||
HILOG_ERROR("DefaultThreadFactory::Create error, thread is nullptr");
|
||||
}
|
||||
|
||||
return pThread;
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "task_executor.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -30,15 +30,15 @@ TaskExecutor::TaskExecutor(const std::shared_ptr<WorkerPoolConfig> &config) : Wo
|
||||
TaskExecutor::~TaskExecutor()
|
||||
{
|
||||
if ((consumer_) && consumer_->joinable()) {
|
||||
APP_LOGI("TaskExecutor::~TaskExecutor consumer is running");
|
||||
HILOG_INFO("TaskExecutor::~TaskExecutor consumer is running");
|
||||
consumer_->join();
|
||||
}
|
||||
APP_LOGI("TaskExecutor::~TaskExecutor");
|
||||
HILOG_INFO("TaskExecutor::~TaskExecutor");
|
||||
}
|
||||
|
||||
void TaskExecutor::Execute(const std::shared_ptr<Task> &task)
|
||||
{
|
||||
APP_LOGI("TaskExecutor::Execute begin");
|
||||
HILOG_INFO("TaskExecutor::Execute begin");
|
||||
task->SetSequence(GetAndIncrement(sequence));
|
||||
|
||||
std::shared_ptr<TaskExecutor> executor = shared_from_this();
|
||||
@ -47,21 +47,21 @@ void TaskExecutor::Execute(const std::shared_ptr<Task> &task)
|
||||
std::shared_ptr<PriorityTaskWrapper> priorityTaskWrapper =
|
||||
std::make_shared<PriorityTaskWrapper>(task->GetPriority(), task);
|
||||
if (pendingTasks_->Offer(priorityTaskWrapper) == false) {
|
||||
APP_LOGW("TaskExecutor::Execute rejected a task");
|
||||
HILOG_WARN("TaskExecutor::Execute rejected a task");
|
||||
}
|
||||
}
|
||||
APP_LOGI("TaskExecutor::Execute end");
|
||||
HILOG_INFO("TaskExecutor::Execute end");
|
||||
}
|
||||
|
||||
ErrCode TaskExecutor::DoWorks(const std::shared_ptr<WorkerThread> &worker)
|
||||
{
|
||||
APP_LOGI("TaskExecutor::DoWorks begin");
|
||||
HILOG_INFO("TaskExecutor::DoWorks begin");
|
||||
if (worker == nullptr) {
|
||||
APP_LOGE("TaskExecutor::DoWorks worker is nullptr");
|
||||
HILOG_ERROR("TaskExecutor::DoWorks worker is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
if (worker->GetThread() == nullptr) {
|
||||
APP_LOGE("TaskExecutor::DoWorks worker GetThread is nullptr");
|
||||
HILOG_ERROR("TaskExecutor::DoWorks worker GetThread is nullptr");
|
||||
return ERR_APPEXECFWK_CHECK_FAILED;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ ErrCode TaskExecutor::DoWorks(const std::shared_ptr<WorkerThread> &worker)
|
||||
bool isInterrupted = false;
|
||||
bool done = false;
|
||||
while (((task != nullptr && done == false) || ((task = GetTask(worker)) != nullptr))) {
|
||||
APP_LOGI("TaskExecutor::DoWorks loop tasks.");
|
||||
HILOG_INFO("TaskExecutor::DoWorks loop tasks.");
|
||||
|
||||
BeforeRun(task);
|
||||
|
||||
@ -84,7 +84,7 @@ ErrCode TaskExecutor::DoWorks(const std::shared_ptr<WorkerThread> &worker)
|
||||
done = true;
|
||||
}
|
||||
OnWorkerExit(worker, isInterrupted);
|
||||
APP_LOGI("TaskExecutor::DoWorks end");
|
||||
HILOG_INFO("TaskExecutor::DoWorks end");
|
||||
return ERR_OK;
|
||||
}
|
||||
std::shared_ptr<Task> TaskExecutor::GetTask(const std::shared_ptr<WorkerThread> &workerThread)
|
||||
@ -95,33 +95,33 @@ std::shared_ptr<Task> TaskExecutor::GetTask(const std::shared_ptr<WorkerThread>
|
||||
|
||||
for (;;) {
|
||||
if (terminated_.load() && pendingTasks_->Empty()) {
|
||||
APP_LOGI("TaskExecutor::GetTask end: loop thread %{public}s is terminated",
|
||||
HILOG_INFO("TaskExecutor::GetTask end: loop thread %{public}s is terminated",
|
||||
workerThread->GetThreadName().c_str());
|
||||
DecrementThread();
|
||||
return nullRunnable;
|
||||
}
|
||||
|
||||
int workerCount = GetWorkCount();
|
||||
APP_LOGI("TaskExecutor::GetTask workerCount:%{public}d, GetCoreThreadCount: %{public}d",
|
||||
HILOG_INFO("TaskExecutor::GetTask workerCount:%{public}d, GetCoreThreadCount: %{public}d",
|
||||
workerCount,
|
||||
GetCoreThreadCount());
|
||||
bool needCheckTimeout = (workerCount > GetCoreThreadCount());
|
||||
if (isTimeout && needCheckTimeout && pendingTasks_->Empty()) {
|
||||
APP_LOGI("TaskExecutor::GetTask isTimeout is true");
|
||||
HILOG_INFO("TaskExecutor::GetTask isTimeout is true");
|
||||
if (CompareAndDecNum(workerCount)) {
|
||||
APP_LOGI("TaskExecutor::GetTask end: loop thread %{public}s is timeout",
|
||||
HILOG_INFO("TaskExecutor::GetTask end: loop thread %{public}s is timeout",
|
||||
workerThread->GetThreadName().c_str());
|
||||
return nullRunnable;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
APP_LOGI("TaskExecutor::GetTask need timeout=%{public}d", needCheckTimeout);
|
||||
HILOG_INFO("TaskExecutor::GetTask need timeout=%{public}d", needCheckTimeout);
|
||||
std::shared_ptr<PriorityTaskWrapper> next =
|
||||
needCheckTimeout ? pendingTasks_->Poll(GetKeepAliveTime()) : pendingTasks_->Take();
|
||||
|
||||
if (next != nullptr && next->task_ != nullptr) {
|
||||
APP_LOGI("TaskExecutor::GetTask end: loop thread %{public}s get next task",
|
||||
HILOG_INFO("TaskExecutor::GetTask end: loop thread %{public}s get next task",
|
||||
workerThread->GetThreadName().c_str());
|
||||
return next->task_;
|
||||
}
|
||||
@ -131,10 +131,10 @@ std::shared_ptr<Task> TaskExecutor::GetTask(const std::shared_ptr<WorkerThread>
|
||||
|
||||
void TaskExecutor::Terminate(bool force)
|
||||
{
|
||||
APP_LOGI("TaskExecutor::Terminate begin");
|
||||
HILOG_INFO("TaskExecutor::Terminate begin");
|
||||
TerminateConsumer();
|
||||
ClosePool(force);
|
||||
APP_LOGI("TaskExecutor::Terminate end");
|
||||
HILOG_INFO("TaskExecutor::Terminate end");
|
||||
}
|
||||
|
||||
void TaskExecutor::AfterRun(const std::shared_ptr<Task> &task)
|
||||
@ -151,16 +151,16 @@ bool TaskExecutor::DelayExecute(const Runnable &task, long delayMs)
|
||||
{
|
||||
if (delayMs <= 0) {
|
||||
task();
|
||||
APP_LOGI("TaskExecutor::DelayExecute end and delayMs less than 0");
|
||||
HILOG_INFO("TaskExecutor::DelayExecute end and delayMs less than 0");
|
||||
return true;
|
||||
}
|
||||
if (terminated_.load()) {
|
||||
APP_LOGI("TaskExecutor::DelayExecute end and terminate");
|
||||
HILOG_INFO("TaskExecutor::DelayExecute end and terminate");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<DelayTaskWrapper> delayTaskWrapper = std::make_shared<DelayTaskWrapper>(delayMs, task);
|
||||
if (delayTaskWrapper == nullptr) {
|
||||
APP_LOGI("TaskExecutor::DelayExecute end and delayTaskWrapper is nullptr");
|
||||
HILOG_INFO("TaskExecutor::DelayExecute end and delayTaskWrapper is nullptr");
|
||||
return false;
|
||||
}
|
||||
delayTasks_->Offer(delayTaskWrapper);
|
||||
@ -190,10 +190,10 @@ bool TaskExecutor::EnsureConsumeStarted()
|
||||
if (consumer_ == nullptr) {
|
||||
consumer_ = std::make_shared<std::thread>(&TaskExecutor::Consume, this);
|
||||
if (consumer_ == nullptr) {
|
||||
APP_LOGE("TaskExecutor::EnsureConsumeStarted consumer_ is nullptr");
|
||||
HILOG_ERROR("TaskExecutor::EnsureConsumeStarted consumer_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("TaskExecutor::EnsureConsumeStarted start a delay task consumer");
|
||||
HILOG_INFO("TaskExecutor::EnsureConsumeStarted start a delay task consumer");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,16 +204,16 @@ void TaskExecutor::Consume()
|
||||
{
|
||||
for (;;) {
|
||||
if (terminated_.load() && delayTasks_->Empty()) {
|
||||
APP_LOGI("TaskExecutor::Consume delay task is empty");
|
||||
HILOG_INFO("TaskExecutor::Consume delay task is empty");
|
||||
break;
|
||||
}
|
||||
std::shared_ptr<DelayTaskWrapper> delayTaskWrapper = delayTasks_->Take();
|
||||
if (delayTaskWrapper == nullptr || delayTaskWrapper->runnable_ == nullptr) {
|
||||
APP_LOGE("TaskExecutor::Consume delayTaskWrapper is nullptr");
|
||||
HILOG_ERROR("TaskExecutor::Consume delayTaskWrapper is nullptr");
|
||||
return;
|
||||
}
|
||||
(delayTaskWrapper->runnable_)();
|
||||
APP_LOGI("TaskExecutor::Consume after run");
|
||||
HILOG_INFO("TaskExecutor::Consume after run");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,10 @@ WorkerThread::WorkerThread(const std::shared_ptr<Delegate> &delegate, const std:
|
||||
void WorkerThread::Join()
|
||||
{
|
||||
if ((thread_) && (thread_->thread_) && thread_->thread_->joinable()) {
|
||||
APP_LOGI("WorkerThread::Join joinable thread");
|
||||
HILOG_INFO("WorkerThread::Join joinable thread");
|
||||
thread_->thread_->join();
|
||||
}
|
||||
APP_LOGI("WorkerThread::Join end");
|
||||
HILOG_INFO("WorkerThread::Join end");
|
||||
}
|
||||
|
||||
void WorkerThread::CreateThread()
|
||||
@ -48,7 +48,7 @@ void WorkerThread::CreateThread()
|
||||
|
||||
// start a thread to run task function.
|
||||
thread_->thread_ = std::make_shared<std::thread>(task);
|
||||
APP_LOGI("WorkerThread::CreateThread start thread. ");
|
||||
HILOG_INFO("WorkerThread::CreateThread start thread. ");
|
||||
}
|
||||
|
||||
void WorkerThread::IncTaskCount()
|
||||
|
@ -44,13 +44,13 @@ WorkerPool::~WorkerPool()
|
||||
{
|
||||
control_ = 0;
|
||||
|
||||
APP_LOGI("WorkerPool::~WorkerPool");
|
||||
HILOG_INFO("WorkerPool::~WorkerPool");
|
||||
}
|
||||
|
||||
bool WorkerPool::Init(const std::shared_ptr<WorkerPoolConfig> &config)
|
||||
{
|
||||
if (CheckConfigParams(config) == false) {
|
||||
APP_LOGE("WorkerPool::checkConfigParams parameters are illegal");
|
||||
HILOG_ERROR("WorkerPool::checkConfigParams parameters are illegal");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ bool WorkerPool::Init(const std::shared_ptr<WorkerPoolConfig> &config)
|
||||
bool WorkerPool::CheckConfigParams(const std::shared_ptr<WorkerPoolConfig> &config)
|
||||
{
|
||||
if (config == nullptr) {
|
||||
APP_LOGE("WorkerPool::CheckConfigParams config is nullptr");
|
||||
HILOG_ERROR("WorkerPool::CheckConfigParams config is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -73,18 +73,18 @@ bool WorkerPool::CheckConfigParams(const std::shared_ptr<WorkerPoolConfig> &conf
|
||||
int coreThreadCount = config->GetCoreThreadCount();
|
||||
|
||||
if (!CheckThreadCount(maxThreadCount, coreThreadCount)) {
|
||||
APP_LOGE("WorkerPool::CheckConfigParams parameters are illegal, maxThreadCount %{public}d is less than "
|
||||
HILOG_ERROR("WorkerPool::CheckConfigParams parameters are illegal, maxThreadCount %{public}d is less than "
|
||||
"coreThreadCount %{public}d",
|
||||
maxThreadCount,
|
||||
coreThreadCount);
|
||||
return false;
|
||||
}
|
||||
if (!CheckMaxThreadCount(maxThreadCount)) {
|
||||
APP_LOGE("WorkerPool::CheckConfigParams maxThreadCount %{public}d is illegal", maxThreadCount);
|
||||
HILOG_ERROR("WorkerPool::CheckConfigParams maxThreadCount %{public}d is illegal", maxThreadCount);
|
||||
return false;
|
||||
}
|
||||
if (!CheckCoreThreadCount(coreThreadCount)) {
|
||||
APP_LOGE("WorkerPool::CheckConfigParams coreThreadCount %{public}d is illegal", coreThreadCount);
|
||||
HILOG_ERROR("WorkerPool::CheckConfigParams coreThreadCount %{public}d is illegal", coreThreadCount);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -141,20 +141,20 @@ std::map<std::string, long> WorkerPool::GetWorkerThreadsInfo(void)
|
||||
|
||||
void WorkerPool::ClosePool(bool interrupt)
|
||||
{
|
||||
APP_LOGI("WorkerPool::ClosePool begin interrupt=%{public}d", interrupt);
|
||||
HILOG_INFO("WorkerPool::ClosePool begin interrupt=%{public}d", interrupt);
|
||||
std::unique_lock<std::mutex> mLock(poolLock_);
|
||||
|
||||
AdvanceStateTo(CLOSING);
|
||||
InterruptWorkers();
|
||||
|
||||
APP_LOGI("WorkerPool::ClosePool end");
|
||||
HILOG_INFO("WorkerPool::ClosePool end");
|
||||
}
|
||||
|
||||
void WorkerPool::InterruptWorkers(void)
|
||||
{
|
||||
APP_LOGI("WorkerPool::InterruptWorkers begin");
|
||||
HILOG_INFO("WorkerPool::InterruptWorkers begin");
|
||||
if (guardThread_ == nullptr) {
|
||||
APP_LOGE("WorkerPool::InterruptWorkers guardThread is nullptr");
|
||||
HILOG_ERROR("WorkerPool::InterruptWorkers guardThread is nullptr");
|
||||
return;
|
||||
}
|
||||
poolLock_.unlock();
|
||||
@ -169,21 +169,21 @@ void WorkerPool::InterruptWorkers(void)
|
||||
std::unique_lock<std::mutex> lock(exitPoolLock_);
|
||||
exitGuard_.wait(lock);
|
||||
if (guardThread_->joinable()) {
|
||||
APP_LOGI("WorkerPool::InterruptWorkers guardThread_ joinable");
|
||||
HILOG_INFO("WorkerPool::InterruptWorkers guardThread_ joinable");
|
||||
guardThread_->join();
|
||||
// Prevent manual call again
|
||||
guardThread_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
APP_LOGI("WorkerPool::InterruptWorkers end");
|
||||
HILOG_INFO("WorkerPool::InterruptWorkers end");
|
||||
}
|
||||
|
||||
void WorkerPool::CreateGuardThread()
|
||||
{
|
||||
APP_LOGI("WorkerPool::CreateGuardThread START");
|
||||
HILOG_INFO("WorkerPool::CreateGuardThread START");
|
||||
if (guardThread_ != nullptr) {
|
||||
APP_LOGW("WorkerPool::CreateGuardThread guardThread_ is not nullptr");
|
||||
HILOG_WARN("WorkerPool::CreateGuardThread guardThread_ is not nullptr");
|
||||
return;
|
||||
}
|
||||
auto guardTask = [&]() {
|
||||
@ -201,11 +201,11 @@ void WorkerPool::CreateGuardThread()
|
||||
}
|
||||
if (stop_.load() && exitPool_.empty() && pool_.empty()) {
|
||||
exitGuard_.notify_all();
|
||||
APP_LOGI("WorkerPool::CreateGuardThread break while");
|
||||
HILOG_INFO("WorkerPool::CreateGuardThread break while");
|
||||
break;
|
||||
}
|
||||
}
|
||||
APP_LOGI("WorkerPool::CreateGuardThread STOP");
|
||||
HILOG_INFO("WorkerPool::CreateGuardThread STOP");
|
||||
};
|
||||
|
||||
guardThread_ = std::make_shared<std::thread>(guardTask);
|
||||
@ -215,19 +215,19 @@ bool WorkerPool::AddWorker(const std::shared_ptr<Delegate> &delegate, const std:
|
||||
{
|
||||
bool added = false;
|
||||
if (!initFlag_.load()) {
|
||||
APP_LOGE("WorkerPool::AddWorker workPool init failed");
|
||||
HILOG_ERROR("WorkerPool::AddWorker workPool init failed");
|
||||
return added;
|
||||
}
|
||||
if (factory_ == nullptr) {
|
||||
APP_LOGE("WorkerPool::AddWorker factory_ is nullptr");
|
||||
HILOG_ERROR("WorkerPool::AddWorker factory_ is nullptr");
|
||||
return added;
|
||||
}
|
||||
if (task == nullptr) {
|
||||
APP_LOGE("WorkerPool::AddWorker task is nullptr");
|
||||
HILOG_ERROR("WorkerPool::AddWorker task is nullptr");
|
||||
return added;
|
||||
}
|
||||
if (delegate == nullptr) {
|
||||
APP_LOGE("WorkerPool::AddWorker delegate is nullptr");
|
||||
HILOG_ERROR("WorkerPool::AddWorker delegate is nullptr");
|
||||
return added;
|
||||
}
|
||||
std::unique_lock<std::mutex> mLock(poolLock_);
|
||||
@ -237,12 +237,12 @@ bool WorkerPool::AddWorker(const std::shared_ptr<Delegate> &delegate, const std:
|
||||
unsigned int value = control_.load();
|
||||
int num = GetWorkingThreadNum(value);
|
||||
if (num >= thread_limit_) {
|
||||
APP_LOGI("WorkerPool::AddWorker thread count exceed limits, num=%{public}d, limits=%{public}d", num,
|
||||
HILOG_INFO("WorkerPool::AddWorker thread count exceed limits, num=%{public}d, limits=%{public}d", num,
|
||||
thread_limit_);
|
||||
break;
|
||||
}
|
||||
if (!IsRunning(value)) {
|
||||
APP_LOGI("WorkerPool::AddWorker thread pool is not running. value=%{public}d, closing=%{public}d, "
|
||||
HILOG_INFO("WorkerPool::AddWorker thread pool is not running. value=%{public}d, closing=%{public}d, "
|
||||
"count_bits=%{public}d",
|
||||
value,
|
||||
CLOSING,
|
||||
@ -253,22 +253,22 @@ bool WorkerPool::AddWorker(const std::shared_ptr<Delegate> &delegate, const std:
|
||||
if (CompareAndIncThreadNum(num)) {
|
||||
newThread = std::make_shared<WorkerThread>(delegate, task, factory_);
|
||||
if (newThread == nullptr) {
|
||||
APP_LOGE("WorkerPool::AddWorker create thread fail");
|
||||
HILOG_ERROR("WorkerPool::AddWorker create thread fail");
|
||||
break;
|
||||
}
|
||||
|
||||
newThread->CreateThread();
|
||||
|
||||
APP_LOGI("WorkerPool::AddWorker create new thread");
|
||||
HILOG_INFO("WorkerPool::AddWorker create new thread");
|
||||
|
||||
pool_.emplace_back(newThread);
|
||||
APP_LOGI("WorkerPool::AddWorker pool_ add thread ,POOL SIZE: %{public}zu", pool_.size());
|
||||
HILOG_INFO("WorkerPool::AddWorker pool_ add thread ,POOL SIZE: %{public}zu", pool_.size());
|
||||
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
|
||||
APP_LOGW("WorkerPool::AddWorker set thread state error. retry. ");
|
||||
HILOG_WARN("WorkerPool::AddWorker set thread state error. retry. ");
|
||||
}
|
||||
return added;
|
||||
}
|
||||
@ -276,16 +276,16 @@ bool WorkerPool::AddWorker(const std::shared_ptr<Delegate> &delegate, const std:
|
||||
void WorkerPool::OnWorkerExit(const std::shared_ptr<WorkerThread> &worker, bool isInterrupted)
|
||||
{
|
||||
std::unique_lock<std::mutex> mLock(poolLock_);
|
||||
APP_LOGI("WorkerPool::OnWorkerExit start, pool size: %{public}zu", pool_.size());
|
||||
HILOG_INFO("WorkerPool::OnWorkerExit start, pool size: %{public}zu", pool_.size());
|
||||
for (auto it = pool_.begin(); it != pool_.end(); it++) {
|
||||
if ((*it).get() == worker.get()) {
|
||||
APP_LOGI("WorkerPool::OnWorkerExit erase current, size=%{public}zu, threads=%{public}d",
|
||||
HILOG_INFO("WorkerPool::OnWorkerExit erase current, size=%{public}zu, threads=%{public}d",
|
||||
pool_.size(),
|
||||
GetWorkingThreadNum(control_.load()));
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(exitPoolLock_);
|
||||
exitPool_.emplace_back(worker);
|
||||
APP_LOGI("WorkerPool::OnWorkerExit exit notify all");
|
||||
HILOG_INFO("WorkerPool::OnWorkerExit exit notify all");
|
||||
exit_.notify_all();
|
||||
}
|
||||
pool_.erase(it);
|
||||
@ -293,7 +293,7 @@ void WorkerPool::OnWorkerExit(const std::shared_ptr<WorkerThread> &worker, bool
|
||||
break;
|
||||
}
|
||||
}
|
||||
APP_LOGI("WorkerPool::OnWorkerExit end");
|
||||
HILOG_INFO("WorkerPool::OnWorkerExit end");
|
||||
}
|
||||
|
||||
void WorkerPool::AfterRun(const std::shared_ptr<Task> &task)
|
||||
@ -319,16 +319,16 @@ int WorkerPool::GetStateFromControl(unsigned int ctl)
|
||||
|
||||
void WorkerPool::AdvanceStateTo(unsigned int target)
|
||||
{
|
||||
APP_LOGI("WorkerPool::AdvanceStateTo begin");
|
||||
HILOG_INFO("WorkerPool::AdvanceStateTo begin");
|
||||
for (;;) {
|
||||
unsigned int current = control_.load();
|
||||
if ((current >= target) ||
|
||||
CompareAndSet(control_, current, CombineToControl(target, GetWorkingThreadNum(current)))) {
|
||||
APP_LOGI("WorkerPool::AdvanceStateTo break");
|
||||
HILOG_INFO("WorkerPool::AdvanceStateTo break");
|
||||
break;
|
||||
}
|
||||
}
|
||||
APP_LOGI("WorkerPool::AdvanceStateTo end");
|
||||
HILOG_INFO("WorkerPool::AdvanceStateTo end");
|
||||
}
|
||||
|
||||
int WorkerPool::CombineToControl(unsigned int state, unsigned int count)
|
||||
@ -345,12 +345,12 @@ bool WorkerPool::CompareAndIncThreadNum(int expect)
|
||||
|
||||
void WorkerPool::DecrementThread(void)
|
||||
{
|
||||
APP_LOGI("WorkerPool::DecrementThread begin");
|
||||
HILOG_INFO("WorkerPool::DecrementThread begin");
|
||||
int curr = control_.load();
|
||||
while (!CompareAndDecThreadNum(curr)) {
|
||||
curr = control_.load();
|
||||
}
|
||||
APP_LOGI("WorkerPool::DecrementThread end");
|
||||
HILOG_INFO("WorkerPool::DecrementThread end");
|
||||
}
|
||||
|
||||
bool WorkerPool::CompareAndDecThreadNum(int expect)
|
||||
|
@ -43,6 +43,7 @@ config("dispatcher_test_config") {
|
||||
defines = []
|
||||
|
||||
include_dirs = [
|
||||
"${aafwk_path}/services/common/include",
|
||||
"${appexecfwk_path}/common/log/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler/include",
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define private public
|
||||
#include "serial_task_dispatcher.h"
|
||||
#undef private
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "default_worker_pool_config.h"
|
||||
#include "task.h"
|
||||
|
@ -116,7 +116,7 @@ HWTEST(SpecTaskDispatcherTest, SyncDispatch_0100, Function | MediumTest | Level1
|
||||
std::this_thread::sleep_for(time);
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 0);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}));
|
||||
EXPECT_TRUE(count.load() == 1);
|
||||
|
||||
@ -126,7 +126,7 @@ HWTEST(SpecTaskDispatcherTest, SyncDispatch_0100, Function | MediumTest | Level1
|
||||
std::this_thread::sleep_for(time);
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 1);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}));
|
||||
EXPECT_TRUE(count.load() == 2);
|
||||
|
||||
@ -136,7 +136,7 @@ HWTEST(SpecTaskDispatcherTest, SyncDispatch_0100, Function | MediumTest | Level1
|
||||
std::this_thread::sleep_for(time);
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 2);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}));
|
||||
EXPECT_TRUE(count.load() == 3);
|
||||
|
||||
@ -184,7 +184,7 @@ HWTEST(SpecTaskDispatcherTest, AsyncDispatch_0100, Function | MediumTest | Level
|
||||
std::this_thread::sleep_for(time);
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 0);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}));
|
||||
EXPECT_TRUE(count.load() == 0);
|
||||
|
||||
@ -194,7 +194,7 @@ HWTEST(SpecTaskDispatcherTest, AsyncDispatch_0100, Function | MediumTest | Level
|
||||
std::this_thread::sleep_for(time);
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 1);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}));
|
||||
EXPECT_TRUE(count.load() == 0);
|
||||
|
||||
@ -204,7 +204,7 @@ HWTEST(SpecTaskDispatcherTest, AsyncDispatch_0100, Function | MediumTest | Level
|
||||
std::this_thread::sleep_for(time);
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 2);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}));
|
||||
EXPECT_TRUE(count.load() == 0);
|
||||
|
||||
@ -279,7 +279,7 @@ HWTEST(SpecTaskDispatcherTest, DelayDispatch_0100, Function | MediumTest | Level
|
||||
// execute second
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 2);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}),
|
||||
sleep1);
|
||||
EXPECT_TRUE(count.load() == 0);
|
||||
@ -289,7 +289,7 @@ HWTEST(SpecTaskDispatcherTest, DelayDispatch_0100, Function | MediumTest | Level
|
||||
// execute first
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 0 || index == 1);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}),
|
||||
sleep2);
|
||||
EXPECT_TRUE(count.load() == 0);
|
||||
@ -299,7 +299,7 @@ HWTEST(SpecTaskDispatcherTest, DelayDispatch_0100, Function | MediumTest | Level
|
||||
// execute first
|
||||
int index = count.fetch_add(1);
|
||||
EXPECT_TRUE(index == 0 || index == 1);
|
||||
APP_LOGD("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
HILOG_DEBUG("task %{public}d end, elapsed %{public}d ms", index, sleep);
|
||||
}),
|
||||
sleep3);
|
||||
EXPECT_TRUE(count.load() == 0);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define private public
|
||||
#include "sync_task.h"
|
||||
#undef private
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "default_worker_pool_config.h"
|
||||
#include "task.h"
|
||||
#include "task_priority.h"
|
||||
@ -55,7 +55,7 @@ HWTEST(SyncTaskTest, SyncTask_ConstructorTest_001, TestSize.Level0)
|
||||
long wait = 200;
|
||||
auto time = std::chrono::milliseconds(wait);
|
||||
std::this_thread::sleep_for(time);
|
||||
APP_LOGD("task %{public}d end", 0);
|
||||
HILOG_DEBUG("task %{public}d end", 0);
|
||||
});
|
||||
auto priorityLow = TaskPriority::LOW;
|
||||
auto priorityHigh = TaskPriority::HIGH;
|
||||
@ -90,7 +90,7 @@ HWTEST(SyncTaskTest, SyncTask_RunTest_001, TestSize.Level0)
|
||||
auto time = std::chrono::milliseconds(wait);
|
||||
std::this_thread::sleep_for(time);
|
||||
count++;
|
||||
APP_LOGD("task %{public}d end", count.load());
|
||||
HILOG_DEBUG("task %{public}d end", count.load());
|
||||
});
|
||||
auto priority = TaskPriority::DEFAULT;
|
||||
{
|
||||
@ -125,7 +125,7 @@ HWTEST(SyncTaskTest, SyncTask_WaitTest_001, TestSize.Level0)
|
||||
auto time = std::chrono::milliseconds(wait);
|
||||
std::this_thread::sleep_for(time);
|
||||
count++;
|
||||
APP_LOGD("task %{public}d end", count.load());
|
||||
HILOG_DEBUG("task %{public}d end", count.load());
|
||||
});
|
||||
auto priority = TaskPriority::LOW;
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define private public
|
||||
#include "work_thread.h"
|
||||
#undef private
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "default_thread_factory.h"
|
||||
#include "default_worker_pool_config.h"
|
||||
#include "task_priority.h"
|
||||
|
@ -20,6 +20,7 @@ config("dispatcher_mt_test_config") {
|
||||
defines = []
|
||||
|
||||
include_dirs = [
|
||||
"${aafwk_path}/services/common/include",
|
||||
"${appexecfwk_path}/common/log/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler/include",
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
// redefine private and protected since testcase need to invoke and test private function
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "base_task_dispatcher.h"
|
||||
#include "task_dispatcher.h"
|
||||
#include "task_dispatcher_context.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
// redefine private and protected since testcase need to invoke and test private function
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "base_task_dispatcher.h"
|
||||
#include "task_dispatcher.h"
|
||||
#include "task_dispatcher_context.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
#undef private
|
||||
#undef protected
|
||||
#include <gtest/gtest.h>
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
// redefine private and protected since testcase need to invoke and test private function
|
||||
#include <gtest/gtest.h>
|
||||
#include "app_log_wrapper.h"
|
||||
#include "base_task_dispatcher.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "task_dispatcher_context.h"
|
||||
#include "task_dispatcher.h"
|
||||
#include "spec_task_dispatcher.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
import("//build/ohos.gni")
|
||||
SO_DIR = "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime"
|
||||
INNERKITS_DIR = "//foundation/aafwk/standard/interfaces/innerkits"
|
||||
APPKIT_DIR = "//foundation/aafwk/standard/frameworks/kits"
|
||||
|
||||
config("ability_context_public_config") {
|
||||
@ -43,22 +42,20 @@ ohos_shared_library("ability_context_native") {
|
||||
"${SO_DIR}/src/local_call_record.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${APPKIT_DIR}/appkit:app_context",
|
||||
"${INNERKITS_DIR}/ability_manager:ability_manager",
|
||||
"${INNERKITS_DIR}/want:want",
|
||||
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
]
|
||||
deps = [ "${APPKIT_DIR}/appkit:app_context" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bytrace_standard:bytrace_core",
|
||||
"faultloggerd:lib_dfx_dump_catcher",
|
||||
"hichecker_native:libhichecker",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
|
@ -19,34 +19,24 @@ config("ability_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"${INNERKITS_PATH}/base/include",
|
||||
"//utils/native/base/include",
|
||||
"${SUBSYSTEM_DIR}/include",
|
||||
"//foundation/aafwk/standard/frameworks/kits/appkit/native/app/include",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/app_manager/include/appmgr",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/uri/include",
|
||||
"${INNERKITS_PATH}/want/include/ohos/aafwk/content",
|
||||
"${INNERKITS_PATH}/ability_manager/include",
|
||||
"//foundation/aafwk/standard/services/abilitymgr/include",
|
||||
"//foundation/appexecfwk/standard/common/log/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include/",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/form_manager/include",
|
||||
"//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime/app",
|
||||
"//foundation/aafwk/standard/frameworks/kits/appkit/native/app/include",
|
||||
"//foundation/aafwk/standard/frameworks/kits/fmskit/native/include",
|
||||
"//foundation/aafwk/standard/frameworks/kits/app/native/app/include",
|
||||
"//foundation/aafwk/standard/services/common/include",
|
||||
"//base/global/resmgr_standard/interfaces/innerkits/include",
|
||||
"//foundation/aafwk/standard/interfaces/kits/napi/aafwk/featureAbility",
|
||||
"//foundation/ace/napi/interfaces/kits",
|
||||
"//third_party/node/src",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/remote_register_service",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/distributed",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native/include/distributed_ability_runtime",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include/continuation",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/kits",
|
||||
"//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include",
|
||||
"//foundation/aafwk/standard/common/task_dispatcher/include/dispatcher",
|
||||
"//foundation/aafwk/standard/common/task_dispatcher/include/task",
|
||||
"//foundation/aafwk/standard/common/task_dispatcher/include/threading",
|
||||
@ -61,6 +51,8 @@ config("ability_config") {
|
||||
defines = [
|
||||
"APP_LOG_TAG = \"Ability\"",
|
||||
"LOG_DOMAIN = 0xD002200",
|
||||
"AMS_LOG_TAG = \"Ability\"",
|
||||
"AMS_LOG_DOMAIN = 0xD002200",
|
||||
]
|
||||
}
|
||||
|
||||
@ -87,6 +79,7 @@ config("ability_public_config") {
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/form_manager/include",
|
||||
"//foundation/windowmanager/interfaces/innerkits/wm",
|
||||
"//foundation/windowmanager/interfaces/kits/napi/window_runtime/window_stage_napi",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include/",
|
||||
"//third_party/jsoncpp/include",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
@ -104,15 +97,14 @@ ohos_shared_library("static_subscriber_ipc") {
|
||||
"${SUBSYSTEM_DIR}/src/static_subscriber_stub.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
deps = []
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ces_standard:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
subsystem_name = "aafwk"
|
||||
@ -241,34 +233,30 @@ ohos_shared_library("abilitykit_native") {
|
||||
|
||||
deps = [
|
||||
":static_subscriber_ipc",
|
||||
"${INNERKITS_PATH}/base:base",
|
||||
"${INNERKITS_PATH}/want:want",
|
||||
"//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk:libpermissionsdk_standard",
|
||||
"//foundation/aafwk/standard/common/task_dispatcher:task_dispatcher",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime:ability_context_native",
|
||||
"//foundation/aafwk/standard/frameworks/kits/appkit:app_context",
|
||||
"//foundation/aafwk/standard/frameworks/kits/appkit:appkit_delegator",
|
||||
"//foundation/aafwk/standard/frameworks/kits/wantagent:wantagent_innerkits",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/app_manager:app_manager",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/dataobs_manager:dataobs_manager",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
"//foundation/appexecfwk/standard/common:libappexecfwk_common",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-common",
|
||||
"//foundation/resourceschedule/background_task_mgr/interfaces/innerkits:bgtaskmgr_innerkits",
|
||||
|
||||
# "//foundation/multimodalinput/input/frameworks/proxy:libmmi-common",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:napi_base_context",
|
||||
"ability_runtime:runtime",
|
||||
"ability_runtime:task_dispatcher",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"background_task_mgr:bgtaskmgr_innerkits",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"bytrace_standard:bytrace_core",
|
||||
"ces_standard:cesfwk_innerkits",
|
||||
@ -278,9 +266,13 @@ ohos_shared_library("abilitykit_native") {
|
||||
"ipc:ipc_core",
|
||||
"ipc_js:rpc",
|
||||
"multimodalinput_base:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
"native_appdatamgr:native_appdatafwk",
|
||||
"native_appdatamgr:native_dataability",
|
||||
"native_appdatamgr:native_rdb",
|
||||
"permission_standard:libpermissionsdk_standard",
|
||||
"resmgr_standard:global_resmgr",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
@ -311,14 +303,13 @@ ohos_shared_library("dummy_classes") {
|
||||
configs = [ ":ability_config" ]
|
||||
public_configs = [ ":ability_public_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/appexecfwk/standard/common:libappexecfwk_common",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
deps = [ "//foundation/appexecfwk/standard/common:libappexecfwk_common" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
subsystem_name = "aafwk"
|
||||
@ -337,12 +328,13 @@ ohos_shared_library("service_extension_module") {
|
||||
deps = [
|
||||
":abilitykit_native",
|
||||
"//foundation/appexecfwk/standard/common:libappexecfwk_common",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:runtime",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
subsystem_name = "aafwk"
|
||||
@ -361,12 +353,13 @@ ohos_shared_library("datashare_ext_ability_module") {
|
||||
deps = [
|
||||
":abilitykit_native",
|
||||
"//foundation/appexecfwk/standard/common:libappexecfwk_common",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:runtime",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
subsystem_name = "aafwk"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,8 @@
|
||||
#include "ability_context.h"
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "bundle_constants.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "resource_manager.h"
|
||||
#include "sys_mgr_client.h"
|
||||
@ -30,19 +30,19 @@ int AbilityContext::ABILITY_CONTEXT_DEFAULT_REQUEST_CODE(0);
|
||||
|
||||
ErrCode AbilityContext::StartAbility(const AAFwk::Want &want, int requestCode)
|
||||
{
|
||||
APP_LOGI("AbilityContext::StartAbility called, requestCode = %{public}d", requestCode);
|
||||
HILOG_INFO("AbilityContext::StartAbility called, requestCode = %{public}d", requestCode);
|
||||
|
||||
AppExecFwk::AbilityType type = GetAbilityInfoType();
|
||||
if (type != AppExecFwk::AbilityType::PAGE && type != AppExecFwk::AbilityType::SERVICE) {
|
||||
APP_LOGE("AbilityContext::StartAbility AbilityType = %{public}d", type);
|
||||
HILOG_ERROR("AbilityContext::StartAbility AbilityType = %{public}d", type);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s. Start calling ams->StartAbility.", __func__);
|
||||
HILOG_INFO("%{public}s. Start calling ams->StartAbility.", __func__);
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, requestCode);
|
||||
APP_LOGI("%{public}s. End calling ams->StartAbility. ret=%{public}d", __func__, err);
|
||||
HILOG_INFO("%{public}s. End calling ams->StartAbility. ret=%{public}d", __func__, err);
|
||||
if (err != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::StartAbility is failed %{public}d", err);
|
||||
HILOG_ERROR("AbilityContext::StartAbility is failed %{public}d", err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -51,16 +51,16 @@ ErrCode AbilityContext::StartAbility(const Want &want, int requestCode, const Ab
|
||||
{
|
||||
AppExecFwk::AbilityType type = GetAbilityInfoType();
|
||||
if (AppExecFwk::AbilityType::PAGE != type && AppExecFwk::AbilityType::SERVICE != type) {
|
||||
APP_LOGE("AbilityContext::StartAbility AbilityType = %{public}d", type);
|
||||
HILOG_ERROR("AbilityContext::StartAbility AbilityType = %{public}d", type);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s. Start calling ams->StartAbility.", __func__);
|
||||
HILOG_INFO("%{public}s. Start calling ams->StartAbility.", __func__);
|
||||
ErrCode err =
|
||||
AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, abilityStartSetting, token_, requestCode);
|
||||
APP_LOGI("%{public}s. End calling ams->StartAbility. ret=%{public}d", __func__, err);
|
||||
HILOG_INFO("%{public}s. End calling ams->StartAbility. ret=%{public}d", __func__, err);
|
||||
if (err != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::StartAbility is failed %{public}d", err);
|
||||
HILOG_ERROR("AbilityContext::StartAbility is failed %{public}d", err);
|
||||
}
|
||||
|
||||
return err;
|
||||
@ -68,21 +68,21 @@ ErrCode AbilityContext::StartAbility(const Want &want, int requestCode, const Ab
|
||||
|
||||
ErrCode AbilityContext::TerminateAbility(int requestCode)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, requestCode);
|
||||
if (err != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::TerminateAbility is failed %{public}d", err);
|
||||
HILOG_ERROR("AbilityContext::TerminateAbility is failed %{public}d", err);
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return err;
|
||||
}
|
||||
|
||||
ErrCode AbilityContext::TerminateAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
std::shared_ptr<AbilityInfo> info = GetAbilityInfo();
|
||||
if (info == nullptr) {
|
||||
APP_LOGE("AbilityContext::TerminateAbility info == nullptr");
|
||||
HILOG_ERROR("AbilityContext::TerminateAbility info == nullptr");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
@ -90,24 +90,24 @@ ErrCode AbilityContext::TerminateAbility()
|
||||
|
||||
switch (info->type) {
|
||||
case AppExecFwk::AbilityType::PAGE:
|
||||
APP_LOGI("%{public}s begin ams->TerminateAbility for PAGE.", __func__);
|
||||
HILOG_INFO("%{public}s begin ams->TerminateAbility for PAGE.", __func__);
|
||||
err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, resultCode_, &resultWant_);
|
||||
APP_LOGI("%{public}s end ams->TerminateAbility for PAGE, ret=%{public}d", __func__, err);
|
||||
HILOG_INFO("%{public}s end ams->TerminateAbility for PAGE, ret=%{public}d", __func__, err);
|
||||
break;
|
||||
case AppExecFwk::AbilityType::SERVICE:
|
||||
APP_LOGI("%{public}s begin ams->TerminateAbility for SERVICE.", __func__);
|
||||
HILOG_INFO("%{public}s begin ams->TerminateAbility for SERVICE.", __func__);
|
||||
err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, -1, nullptr);
|
||||
APP_LOGI("%{public}s end ams->TerminateAbility for SERVICE, ret=%{public}d", __func__, err);
|
||||
HILOG_INFO("%{public}s end ams->TerminateAbility for SERVICE, ret=%{public}d", __func__, err);
|
||||
break;
|
||||
default:
|
||||
APP_LOGE("AbilityContext::TerminateAbility info type error is %{public}d", info->type);
|
||||
HILOG_ERROR("AbilityContext::TerminateAbility info type error is %{public}d", info->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (err != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::TerminateAbility is failed %{public}d", err);
|
||||
HILOG_ERROR("AbilityContext::TerminateAbility is failed %{public}d", err);
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -118,105 +118,105 @@ std::string AbilityContext::GetCallingBundle()
|
||||
|
||||
std::shared_ptr<ElementName> AbilityContext::GetElementName()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
std::shared_ptr<AbilityInfo> info = GetAbilityInfo();
|
||||
if (info == nullptr) {
|
||||
APP_LOGE("AbilityContext::GetElementName info == nullptr");
|
||||
HILOG_ERROR("AbilityContext::GetElementName info == nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ElementName> elementName = std::make_shared<ElementName>();
|
||||
if (elementName == nullptr) {
|
||||
APP_LOGE("AbilityContext::GetElementName elementName == nullptr");
|
||||
HILOG_ERROR("AbilityContext::GetElementName elementName == nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
elementName->SetAbilityName(info->name);
|
||||
elementName->SetBundleName(info->bundleName);
|
||||
elementName->SetDeviceID(info->deviceId);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return elementName;
|
||||
}
|
||||
|
||||
std::shared_ptr<ElementName> AbilityContext::GetCallingAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
std::shared_ptr<ElementName> elementName = std::make_shared<ElementName>();
|
||||
|
||||
if (elementName == nullptr) {
|
||||
APP_LOGE("AbilityContext::GetElementName elementName == nullptr");
|
||||
HILOG_ERROR("AbilityContext::GetElementName elementName == nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
elementName->SetAbilityName(callingAbilityName_);
|
||||
elementName->SetBundleName(callingBundleName_);
|
||||
elementName->SetDeviceID(callingDeviceId_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return elementName;
|
||||
}
|
||||
|
||||
bool AbilityContext::ConnectAbility(const Want &want, const sptr<AAFwk::IAbilityConnection> &conn)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
|
||||
AppExecFwk::AbilityType type = GetAbilityInfoType();
|
||||
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
APP_LOGE("AbilityContext::ConnectAbility info == nullptr");
|
||||
HILOG_ERROR("AbilityContext::ConnectAbility info == nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AppExecFwk::AbilityType::PAGE != type && AppExecFwk::AbilityType::SERVICE != type) {
|
||||
APP_LOGE("AbilityContext::ConnectAbility AbilityType = %{public}d", type);
|
||||
HILOG_ERROR("AbilityContext::ConnectAbility AbilityType = %{public}d", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, conn, token_);
|
||||
APP_LOGI("%{public}s end ConnectAbility, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s end ConnectAbility, ret=%{public}d", __func__, ret);
|
||||
bool value = ((ret == ERR_OK) ? true : false);
|
||||
if (!value) {
|
||||
APP_LOGE("AbilityContext::ConnectAbility ErrorCode = %{public}d", ret);
|
||||
HILOG_ERROR("AbilityContext::ConnectAbility ErrorCode = %{public}d", ret);
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return value;
|
||||
}
|
||||
|
||||
ErrCode AbilityContext::DisconnectAbility(const sptr<AAFwk::IAbilityConnection> &conn)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
|
||||
AppExecFwk::AbilityType type = GetAbilityInfoType();
|
||||
if (AppExecFwk::AbilityType::PAGE != type && AppExecFwk::AbilityType::SERVICE != type) {
|
||||
APP_LOGE("AbilityContext::DisconnectAbility AbilityType = %{public}d", type);
|
||||
HILOG_ERROR("AbilityContext::DisconnectAbility AbilityType = %{public}d", type);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn);
|
||||
APP_LOGI("%{public}s end ams->DisconnectAbility, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s end ams->DisconnectAbility, ret=%{public}d", __func__, ret);
|
||||
if (ret != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::DisconnectAbility error");
|
||||
HILOG_ERROR("AbilityContext::DisconnectAbility error");
|
||||
}
|
||||
APP_LOGD("AbilityContext::DisconnectAbility end");
|
||||
HILOG_DEBUG("AbilityContext::DisconnectAbility end");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AbilityContext::StopAbility(const AAFwk::Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
AppExecFwk::AbilityType type = GetAbilityInfoType();
|
||||
if (AppExecFwk::AbilityType::PAGE != type && AppExecFwk::AbilityType::SERVICE != type) {
|
||||
APP_LOGE("AbilityContext::StopAbility AbilityType = %{public}d", type);
|
||||
HILOG_ERROR("AbilityContext::StopAbility AbilityType = %{public}d", type);
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s begin ams->StopServiceAbility", __func__);
|
||||
HILOG_INFO("%{public}s begin ams->StopServiceAbility", __func__);
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StopServiceAbility(want);
|
||||
APP_LOGI("%{public}s end ams->StopServiceAbility, ret=%{public}d", __func__, err);
|
||||
HILOG_INFO("%{public}s end ams->StopServiceAbility, ret=%{public}d", __func__, err);
|
||||
if (err != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::StopAbility is failed %{public}d", err);
|
||||
HILOG_ERROR("AbilityContext::StopAbility is failed %{public}d", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ AppExecFwk::AbilityType AbilityContext::GetAbilityInfoType()
|
||||
{
|
||||
std::shared_ptr<AbilityInfo> info = GetAbilityInfo();
|
||||
if (info == nullptr) {
|
||||
APP_LOGE("AbilityContext::GetAbilityInfoType info == nullptr");
|
||||
HILOG_ERROR("AbilityContext::GetAbilityInfoType info == nullptr");
|
||||
return AppExecFwk::AbilityType::UNKNOWN;
|
||||
}
|
||||
|
||||
@ -328,102 +328,102 @@ std::shared_ptr<Context> AbilityContext::CreateBundleContext(std::string bundleN
|
||||
|
||||
std::shared_ptr<Global::Resource::ResourceManager> AbilityContext::GetResourceManager() const
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
std::shared_ptr<Context> appcontext = GetApplicationContext();
|
||||
if (appcontext == nullptr) {
|
||||
APP_LOGE("AbilityContext::GetResourceManager appcontext is nullptr");
|
||||
HILOG_ERROR("AbilityContext::GetResourceManager appcontext is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s begin appcontext->GetResourceManager.", __func__);
|
||||
HILOG_INFO("%{public}s begin appcontext->GetResourceManager.", __func__);
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager = appcontext->GetResourceManager();
|
||||
APP_LOGI("%{public}s end appcontext->GetResourceManager.", __func__);
|
||||
HILOG_INFO("%{public}s end appcontext->GetResourceManager.", __func__);
|
||||
if (resourceManager == nullptr) {
|
||||
APP_LOGE("AbilityContext::GetResourceManager resourceManager is nullptr");
|
||||
HILOG_ERROR("AbilityContext::GetResourceManager resourceManager is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return resourceManager;
|
||||
}
|
||||
|
||||
int AbilityContext::VerifySelfPermission(const std::string &permission)
|
||||
{
|
||||
APP_LOGI("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
|
||||
HILOG_INFO("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
|
||||
if (permission.empty()) {
|
||||
APP_LOGE("VerifySelfPermission permission invalid");
|
||||
HILOG_ERROR("VerifySelfPermission permission invalid");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
std::string bundle_name = GetBundleName();
|
||||
if (bundle_name.empty()) {
|
||||
APP_LOGE("VerifySelfPermission failed to get bundle name error");
|
||||
HILOG_ERROR("VerifySelfPermission failed to get bundle name error");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> ptr = GetBundleManager();
|
||||
if (ptr == nullptr) {
|
||||
APP_LOGE("VerifySelfPermission failed to get bundle manager service");
|
||||
HILOG_ERROR("VerifySelfPermission failed to get bundle manager service");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
HILOG_INFO("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
int ret = ptr->CheckPermission(bundle_name, permission);
|
||||
APP_LOGI("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AbilityContext::VerifyCallingPermission(const std::string &permission)
|
||||
{
|
||||
APP_LOGI("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
|
||||
HILOG_INFO("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
|
||||
if (permission.empty()) {
|
||||
APP_LOGE("VerifyCallingPermission permission invalid");
|
||||
HILOG_ERROR("VerifyCallingPermission permission invalid");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
std::string bundle_name = GetCallingBundle();
|
||||
if (bundle_name.empty()) {
|
||||
APP_LOGE("VerifyCallingPermission failed to get bundle name by uid");
|
||||
HILOG_ERROR("VerifyCallingPermission failed to get bundle name by uid");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> ptr = GetBundleManager();
|
||||
if (ptr == nullptr) {
|
||||
APP_LOGE("VerifyCallingPermission failed to get bundle manager service");
|
||||
HILOG_ERROR("VerifyCallingPermission failed to get bundle manager service");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
HILOG_INFO("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
int ret = ptr->CheckPermission(bundle_name, permission);
|
||||
APP_LOGI("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AbilityContext::CanRequestPermission(const std::string &permission)
|
||||
{
|
||||
APP_LOGI("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
|
||||
HILOG_INFO("%{public}s begin. permission=%{public}s", __func__, permission.c_str());
|
||||
if (permission.empty()) {
|
||||
APP_LOGE("CanRequestPermission permission invalid");
|
||||
HILOG_ERROR("CanRequestPermission permission invalid");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string bundle_name = GetBundleName();
|
||||
if (bundle_name.empty()) {
|
||||
APP_LOGE("CanRequestPermission failed to get bundle name error");
|
||||
HILOG_ERROR("CanRequestPermission failed to get bundle name error");
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> ptr = GetBundleManager();
|
||||
if (ptr == nullptr) {
|
||||
APP_LOGE("CanRequestPermission failed to get bundle manager service");
|
||||
HILOG_ERROR("CanRequestPermission failed to get bundle manager service");
|
||||
return true;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s start bms->CanRequestPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
HILOG_INFO("%{public}s start bms->CanRequestPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
bool ret = ptr->CanRequestPermission(bundle_name, permission, 0);
|
||||
APP_LOGI("%{public}s end bms->CanRequestPermission, ret=%{public}s", __func__, ret ? "true" : "false");
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end bms->CanRequestPermission, ret=%{public}s", __func__, ret ? "true" : "false");
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -434,32 +434,32 @@ int AbilityContext::VerifyCallingOrSelfPermission(const std::string &permission)
|
||||
|
||||
int AbilityContext::VerifyPermission(const std::string &permission, int pid, int uid)
|
||||
{
|
||||
APP_LOGI("%{public}s begin. permission=%{public}s, pid=%{public}d, uid=%{public}d",
|
||||
HILOG_INFO("%{public}s begin. permission=%{public}s, pid=%{public}d, uid=%{public}d",
|
||||
__func__,
|
||||
permission.c_str(),
|
||||
pid,
|
||||
uid);
|
||||
if (permission.empty()) {
|
||||
APP_LOGE("VerifyPermission permission invalid");
|
||||
HILOG_ERROR("VerifyPermission permission invalid");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> ptr = GetBundleManager();
|
||||
if (ptr == nullptr) {
|
||||
APP_LOGE("VerifyPermission failed to get bundle manager service");
|
||||
HILOG_ERROR("VerifyPermission failed to get bundle manager service");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
std::string bundle_name;
|
||||
if (!ptr->GetBundleNameForUid(uid, bundle_name)) {
|
||||
APP_LOGE("VerifyPermission failed to get bundle name by uid");
|
||||
HILOG_ERROR("VerifyPermission failed to get bundle name by uid");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
HILOG_INFO("%{public}s start bms->CheckPermission. bundle_name=%{public}s", __func__, bundle_name.c_str());
|
||||
int ret = ptr->CheckPermission(bundle_name, permission);
|
||||
APP_LOGI("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end bms->CheckPermission, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -467,28 +467,28 @@ void AbilityContext::GetPermissionDes(const std::string &permissionName, std::st
|
||||
{
|
||||
sptr<IBundleMgr> ptr = GetBundleManager();
|
||||
if (ptr == nullptr) {
|
||||
APP_LOGE("GetPermissionDes failed to get bundle manager service");
|
||||
HILOG_ERROR("GetPermissionDes failed to get bundle manager service");
|
||||
return;
|
||||
}
|
||||
|
||||
PermissionDef permissionDef;
|
||||
APP_LOGI("%{public}s start bms->GetPermissionDef. permissionName=%{public}s", __func__, permissionName.c_str());
|
||||
HILOG_INFO("%{public}s start bms->GetPermissionDef. permissionName=%{public}s", __func__, permissionName.c_str());
|
||||
if (ptr->GetPermissionDef(permissionName, permissionDef)) {
|
||||
des = permissionDef.description;
|
||||
}
|
||||
APP_LOGI("%{public}s end bms->GetPermissionDef.", __func__);
|
||||
HILOG_INFO("%{public}s end bms->GetPermissionDef.", __func__);
|
||||
}
|
||||
|
||||
void AbilityContext::RequestPermissionsFromUser(std::vector<std::string> &permissions, int requestCode)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (permissions.size() == 0) {
|
||||
APP_LOGE("AbilityContext::RequestPermissionsFromUser permissions is empty");
|
||||
HILOG_ERROR("AbilityContext::RequestPermissionsFromUser permissions is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
if (requestCode < 0) {
|
||||
APP_LOGE("AbilityContext::RequestPermissionsFromUser requestCode should be >= 0");
|
||||
HILOG_ERROR("AbilityContext::RequestPermissionsFromUser requestCode should be >= 0");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ void AbilityContext::RequestPermissionsFromUser(std::vector<std::string> &permis
|
||||
want.SetParam(OHOS_REQUEST_CALLER_BUNDLERNAME, GetBundleName());
|
||||
|
||||
StartAbility(want, requestCode);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
bool AbilityContext::DeleteFile(const std::string &fileName)
|
||||
@ -532,9 +532,9 @@ Uri AbilityContext::GetCaller()
|
||||
|
||||
void AbilityContext::AttachBaseContext(const std::shared_ptr<Context> &base)
|
||||
{
|
||||
APP_LOGI("AbilityContext::AttachBaseContext. Start.");
|
||||
HILOG_INFO("AbilityContext::AttachBaseContext. Start.");
|
||||
ContextContainer::AttachBaseContext(base);
|
||||
APP_LOGI("AbilityContext::AttachBaseContext. End.");
|
||||
HILOG_INFO("AbilityContext::AttachBaseContext. End.");
|
||||
}
|
||||
|
||||
std::string AbilityContext::GetExternalCacheDir()
|
||||
@ -629,21 +629,21 @@ int AbilityContext::GetThemeId()
|
||||
|
||||
bool AbilityContext::TerminateAbilityResult(int startId)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto abilityClient = AAFwk::AbilityManagerClient::GetInstance();
|
||||
if (abilityClient == nullptr) {
|
||||
APP_LOGE("AbilityContext::TerminateAbilityResult abilityClient is nullptr");
|
||||
HILOG_ERROR("AbilityContext::TerminateAbilityResult abilityClient is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s begin ams->TerminateAbilityResult, startId=%{public}d.", __func__, startId);
|
||||
HILOG_INFO("%{public}s begin ams->TerminateAbilityResult, startId=%{public}d.", __func__, startId);
|
||||
ErrCode errval = abilityClient->TerminateAbilityResult(token_, startId);
|
||||
APP_LOGI("%{public}s end ams->TerminateAbilityResult, ret=%{public}d.", __func__, errval);
|
||||
HILOG_INFO("%{public}s end ams->TerminateAbilityResult, ret=%{public}d.", __func__, errval);
|
||||
if (errval != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::TerminateAbilityResult TerminateAbilityResult retval is %d", errval);
|
||||
HILOG_ERROR("AbilityContext::TerminateAbilityResult TerminateAbilityResult retval is %d", errval);
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return (errval == ERR_OK) ? true : false;
|
||||
}
|
||||
|
||||
@ -679,28 +679,28 @@ void AbilityContext::TerminateAndRemoveMission()
|
||||
|
||||
void AbilityContext::StartAbilities(const std::vector<AAFwk::Want> &wants)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
for (auto want : wants) {
|
||||
StartAbility(want, ABILITY_CONTEXT_DEFAULT_REQUEST_CODE);
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
bool AbilityContext::IsFirstInMission()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto abilityClient = AAFwk::AbilityManagerClient::GetInstance();
|
||||
if (abilityClient == nullptr) {
|
||||
APP_LOGE("AbilityContext::IsFirstInMission abilityClient is nullptr");
|
||||
HILOG_ERROR("AbilityContext::IsFirstInMission abilityClient is nullptr");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s begin ams->IsFirstInMission.", __func__);
|
||||
HILOG_INFO("%{public}s begin ams->IsFirstInMission.", __func__);
|
||||
ErrCode errval = abilityClient->IsFirstInMission(token_);
|
||||
APP_LOGI("%{public}s end ams->IsFirstInMission, ret=%{public}d", __func__, errval);
|
||||
HILOG_INFO("%{public}s end ams->IsFirstInMission, ret=%{public}d", __func__, errval);
|
||||
if (errval != ERR_OK) {
|
||||
APP_LOGE("AbilityContext::IsFirstInMission IsFirstInMission retval is %d", errval);
|
||||
HILOG_ERROR("AbilityContext::IsFirstInMission IsFirstInMission retval is %d", errval);
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
|
||||
return (errval == ERR_OK) ? true : false;
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#include "ability_impl.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "bytrace.h"
|
||||
#include "data_ability_predicates.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "values_bucket.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -32,10 +32,10 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
std::shared_ptr<ContextDeal> &contextDeal)
|
||||
{
|
||||
BYTRACE_NAME(BYTRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
APP_LOGI("AbilityImpl::init begin");
|
||||
HILOG_INFO("AbilityImpl::init begin");
|
||||
if ((token == nullptr) || (application == nullptr) || (handler == nullptr) || (record == nullptr) ||
|
||||
ability == nullptr || contextDeal == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, token is nullptr, application is nullptr, handler is nullptr, record is "
|
||||
HILOG_ERROR("AbilityImpl::init failed, token is nullptr, application is nullptr, handler is nullptr, record is "
|
||||
"nullptr, ability is nullptr, contextDeal is nullptr");
|
||||
return;
|
||||
}
|
||||
@ -54,7 +54,7 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
abilityLifecycleCallbacks_ = application;
|
||||
contextDeal_ = contextDeal;
|
||||
APP_LOGI("AbilityImpl::init end");
|
||||
HILOG_INFO("AbilityImpl::init end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,9 +65,9 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
*/
|
||||
void AbilityImpl::Start(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Start ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::Start ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ void AbilityImpl::Start(const Want &want)
|
||||
ability_->HandleCreateAsContinuation(want);
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::Start");
|
||||
HILOG_INFO("AbilityImpl::Start");
|
||||
ability_->OnStart(want);
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
(ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
@ -96,7 +96,7 @@ void AbilityImpl::Start(const Want &want)
|
||||
(!ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
WindowEventRegister();
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,9 +106,9 @@ void AbilityImpl::Start(const Want &want)
|
||||
*/
|
||||
void AbilityImpl::Stop()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Stop ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::Stop ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ void AbilityImpl::Stop()
|
||||
abilityLifecycleCallbacks_->OnAbilityStop(ability_);
|
||||
ability_->Destroy(); // Release window and ability.
|
||||
ability_ = nullptr;
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,13 +132,13 @@ void AbilityImpl::Stop()
|
||||
*/
|
||||
void AbilityImpl::Active()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Active ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::Active ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::Active");
|
||||
HILOG_INFO("AbilityImpl::Active");
|
||||
ability_->OnActive();
|
||||
|
||||
if ((lifecycleState_ == AAFwk::ABILITY_STATE_INACTIVE) && (ability_->GetAbilityInfo()->type == AbilityType::PAGE)) {
|
||||
@ -148,7 +148,7 @@ void AbilityImpl::Active()
|
||||
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityActive(ability_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,13 +158,13 @@ void AbilityImpl::Active()
|
||||
*/
|
||||
void AbilityImpl::Inactive()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Inactive ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::Inactive ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::Inactive");
|
||||
HILOG_INFO("AbilityImpl::Inactive");
|
||||
ability_->OnInactive();
|
||||
|
||||
if ((lifecycleState_ == AAFwk::ABILITY_STATE_ACTIVE) && (ability_->GetAbilityInfo()->type == AbilityType::PAGE)) {
|
||||
@ -174,7 +174,7 @@ void AbilityImpl::Inactive()
|
||||
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityInactive(ability_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
bool AbilityImpl::IsStageBasedModel() const
|
||||
@ -193,18 +193,18 @@ int AbilityImpl::GetCompatibleVersion()
|
||||
|
||||
void AbilityImpl::AfterUnFocused()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (!ability_ || !ability_->GetAbilityInfo() || !contextDeal_ || !handler_) {
|
||||
APP_LOGE("AbilityImpl::AfterUnFocused failed");
|
||||
HILOG_ERROR("AbilityImpl::AfterUnFocused failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ability_->GetAbilityInfo()->isStageBasedModel) {
|
||||
APP_LOGI("new version ability, do nothing when after unfocused.");
|
||||
HILOG_INFO("new version ability, do nothing when after unfocused.");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("old version ability, window after unfocused.");
|
||||
HILOG_INFO("old version ability, window after unfocused.");
|
||||
auto task = [abilityImpl = shared_from_this(), ability = ability_, contextDeal = contextDeal_]() {
|
||||
auto info = contextDeal->GetLifeCycleStateInfo();
|
||||
info.state = AbilityLifeCycleState::ABILITY_STATE_INACTIVE;
|
||||
@ -212,19 +212,19 @@ void AbilityImpl::AfterUnFocused()
|
||||
abilityImpl->HandleAbilityTransaction(want, info);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
||||
{
|
||||
BYTRACE_NAME(BYTRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("new version ability, window after foreground.");
|
||||
HILOG_INFO("new version ability, window after foreground.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||
@ -233,13 +233,13 @@ void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
||||
{
|
||||
BYTRACE_NAME(BYTRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("new version ability, window after background.");
|
||||
HILOG_INFO("new version ability, window after background.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||
@ -247,17 +247,17 @@ void AbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterFocused()
|
||||
{
|
||||
APP_LOGI("%{public}s.", __func__);
|
||||
HILOG_INFO("%{public}s.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterUnFocused()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner) {
|
||||
owner->AfterUnFocused();
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,13 +268,13 @@ void AbilityImpl::WindowLifeCycleImpl::AfterUnFocused()
|
||||
*/
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::Foreground");
|
||||
HILOG_INFO("AbilityImpl::Foreground");
|
||||
ability_->OnForeground(want);
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
(ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
@ -283,7 +283,7 @@ void AbilityImpl::Foreground(const Want &want)
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
}
|
||||
abilityLifecycleCallbacks_->OnAbilityForeground(ability_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,13 +293,13 @@ void AbilityImpl::Foreground(const Want &want)
|
||||
*/
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::Background");
|
||||
HILOG_INFO("AbilityImpl::Background");
|
||||
ability_->OnLeaveForeground();
|
||||
ability_->OnBackground();
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
@ -309,7 +309,7 @@ void AbilityImpl::Background()
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND;
|
||||
}
|
||||
abilityLifecycleCallbacks_->OnAbilityBackground(ability_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,15 +319,15 @@ void AbilityImpl::Background()
|
||||
*/
|
||||
void AbilityImpl::DispatchSaveAbilityState()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::DispatchSaveAbilityState ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::DispatchSaveAbilityState ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::DispatchSaveAbilityState");
|
||||
HILOG_INFO("AbilityImpl::DispatchSaveAbilityState");
|
||||
needSaveDate_ = true;
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,15 +338,15 @@ void AbilityImpl::DispatchSaveAbilityState()
|
||||
*/
|
||||
void AbilityImpl::DispatchRestoreAbilityState(const PacMap &inState)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::DispatchRestoreAbilityState ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::DispatchRestoreAbilityState ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
hasSaveData_ = true;
|
||||
restoreData_ = inState;
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
@ -360,17 +360,17 @@ void AbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCy
|
||||
*/
|
||||
sptr<IRemoteObject> AbilityImpl::ConnectAbility(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::ConnectAbility ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::ConnectAbility ability_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl:: ConnectAbility");
|
||||
HILOG_INFO("AbilityImpl:: ConnectAbility");
|
||||
sptr<IRemoteObject> object = ability_->OnConnect(want);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityActive(ability_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
|
||||
return object;
|
||||
}
|
||||
@ -382,14 +382,14 @@ sptr<IRemoteObject> AbilityImpl::ConnectAbility(const Want &want)
|
||||
*/
|
||||
void AbilityImpl::DisconnectAbility(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::DisconnectAbility ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::DisconnectAbility ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
ability_->OnDisconnect(want);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -406,17 +406,17 @@ void AbilityImpl::DisconnectAbility(const Want &want)
|
||||
*/
|
||||
void AbilityImpl::CommandAbility(const Want &want, bool restart, int startId)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::CommandAbility ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::CommandAbility ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl:: CommandAbility");
|
||||
HILOG_INFO("AbilityImpl:: CommandAbility");
|
||||
ability_->OnCommand(want, restart, startId);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityActive(ability_);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -438,7 +438,7 @@ int AbilityImpl::GetCurrentState()
|
||||
*/
|
||||
void AbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::DoKeyDown called");
|
||||
HILOG_INFO("AbilityImpl::DoKeyDown called");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -451,7 +451,7 @@ void AbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
*/
|
||||
void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::DoKeyUp called");
|
||||
HILOG_INFO("AbilityImpl::DoKeyUp called");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -464,7 +464,7 @@ void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
*/
|
||||
void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::DoPointerEvent called");
|
||||
HILOG_INFO("AbilityImpl::DoPointerEvent called");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -480,9 +480,9 @@ void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEven
|
||||
*/
|
||||
void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &resultData)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::SendResult ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::SendResult ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -505,24 +505,24 @@ void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &result
|
||||
}
|
||||
grantResult.push_back(intOK);
|
||||
}
|
||||
APP_LOGI("%{public}s begin OnRequestPermissionsFromUserResult.", __func__);
|
||||
HILOG_INFO("%{public}s begin OnRequestPermissionsFromUserResult.", __func__);
|
||||
ability_->OnRequestPermissionsFromUserResult(requestCode, permissions, grantResult);
|
||||
APP_LOGI("%{public}s end OnRequestPermissionsFromUserResult.", __func__);
|
||||
HILOG_INFO("%{public}s end OnRequestPermissionsFromUserResult.", __func__);
|
||||
} else {
|
||||
APP_LOGI("%{public}s user cancel permissions.", __func__);
|
||||
HILOG_INFO("%{public}s user cancel permissions.", __func__);
|
||||
}
|
||||
} else if (resultData.HasParameter(PERMISSION_KEY)) {
|
||||
std::vector<std::string> permissions = resultData.GetStringArrayParam(PERMISSION_KEY);
|
||||
std::vector<int> grantedResult(permissions.size(), -1);
|
||||
if (resultCode > 0) {
|
||||
grantedResult = resultData.GetIntArrayParam(GRANTED_RESULT_KEY);
|
||||
APP_LOGI("%{public}s Get user granted result.", __func__);
|
||||
HILOG_INFO("%{public}s Get user granted result.", __func__);
|
||||
}
|
||||
ability_->OnRequestPermissionsFromUserResult(requestCode, permissions, grantedResult);
|
||||
} else {
|
||||
ability_->OnAbilityResult(requestCode, resultCode, resultData);
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,14 +533,14 @@ void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &result
|
||||
*/
|
||||
void AbilityImpl::NewWant(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::NewWant ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::NewWant ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
ability_->SetWant(want);
|
||||
ability_->OnNewWant(want);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -553,7 +553,7 @@ void AbilityImpl::NewWant(const Want &want)
|
||||
*/
|
||||
std::vector<std::string> AbilityImpl::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::GetFileTypes");
|
||||
HILOG_INFO("AbilityImpl::GetFileTypes");
|
||||
std::vector<std::string> types;
|
||||
return types;
|
||||
}
|
||||
@ -571,7 +571,7 @@ std::vector<std::string> AbilityImpl::GetFileTypes(const Uri &uri, const std::st
|
||||
*/
|
||||
int AbilityImpl::OpenFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::OpenFile");
|
||||
HILOG_INFO("AbilityImpl::OpenFile");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -589,7 +589,7 @@ int AbilityImpl::OpenFile(const Uri &uri, const std::string &mode)
|
||||
*/
|
||||
int AbilityImpl::OpenRawFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::OpenRawFile");
|
||||
HILOG_INFO("AbilityImpl::OpenRawFile");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ int AbilityImpl::OpenRawFile(const Uri &uri, const std::string &mode)
|
||||
*/
|
||||
int AbilityImpl::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::Insert");
|
||||
HILOG_INFO("AbilityImpl::Insert");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -619,7 +619,7 @@ int AbilityImpl::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value)
|
||||
int AbilityImpl::Update(
|
||||
const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::Update");
|
||||
HILOG_INFO("AbilityImpl::Update");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@ int AbilityImpl::Update(
|
||||
*/
|
||||
int AbilityImpl::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::Delete");
|
||||
HILOG_INFO("AbilityImpl::Delete");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ int AbilityImpl::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> AbilityImpl::Query(
|
||||
const Uri &uri, std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::Query");
|
||||
HILOG_INFO("AbilityImpl::Query");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -663,7 +663,7 @@ std::shared_ptr<NativeRdb::AbsSharedResultSet> AbilityImpl::Query(
|
||||
*/
|
||||
std::string AbilityImpl::GetType(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::GetType");
|
||||
HILOG_INFO("AbilityImpl::GetType");
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -692,7 +692,7 @@ bool AbilityImpl::Reload(const Uri &uri, const PacMap &extras)
|
||||
*/
|
||||
int AbilityImpl::BatchInsert(const Uri &uri, const std::vector<NativeRdb::ValuesBucket> &values)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::BatchInsert");
|
||||
HILOG_INFO("AbilityImpl::BatchInsert");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -701,13 +701,13 @@ int AbilityImpl::BatchInsert(const Uri &uri, const std::vector<NativeRdb::Values
|
||||
*/
|
||||
void AbilityImpl::SerUriString(const std::string &uri)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (contextDeal_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::SerUriString contextDeal_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::SerUriString contextDeal_ is nullptr");
|
||||
return;
|
||||
}
|
||||
contextDeal_->SerUriString(uri);
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -718,7 +718,7 @@ void AbilityImpl::SerUriString(const std::string &uri)
|
||||
void AbilityImpl::SetLifeCycleStateInfo(const AAFwk::LifeCycleStateInfo &info)
|
||||
{
|
||||
if (contextDeal_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::SetLifeCycleStateInfo contextDeal_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::SetLifeCycleStateInfo contextDeal_ is nullptr");
|
||||
return;
|
||||
}
|
||||
contextDeal_->SetLifeCycleStateInfo(info);
|
||||
@ -731,21 +731,21 @@ void AbilityImpl::SetLifeCycleStateInfo(const AAFwk::LifeCycleStateInfo &info)
|
||||
*/
|
||||
bool AbilityImpl::CheckAndRestore()
|
||||
{
|
||||
APP_LOGI("AbilityImpl::CheckAndRestore called start");
|
||||
HILOG_INFO("AbilityImpl::CheckAndRestore called start");
|
||||
if (!hasSaveData_) {
|
||||
APP_LOGE("AbilityImpl::CheckAndRestore hasSaveData_ is false");
|
||||
HILOG_ERROR("AbilityImpl::CheckAndRestore hasSaveData_ is false");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::CheckAndRestore ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::CheckAndRestore ability_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::CheckAndRestore ready to restore");
|
||||
HILOG_INFO("AbilityImpl::CheckAndRestore ready to restore");
|
||||
ability_->OnRestoreAbilityState(restoreData_);
|
||||
|
||||
APP_LOGI("AbilityImpl::CheckAndRestore called end");
|
||||
HILOG_INFO("AbilityImpl::CheckAndRestore called end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -756,24 +756,24 @@ bool AbilityImpl::CheckAndRestore()
|
||||
*/
|
||||
bool AbilityImpl::CheckAndSave()
|
||||
{
|
||||
APP_LOGI("AbilityImpl::CheckAndSave called start");
|
||||
HILOG_INFO("AbilityImpl::CheckAndSave called start");
|
||||
if (!needSaveDate_) {
|
||||
APP_LOGE("AbilityImpl::CheckAndSave needSaveDate_ is false");
|
||||
HILOG_ERROR("AbilityImpl::CheckAndSave needSaveDate_ is false");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::CheckAndSave ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::CheckAndSave ability_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::CheckAndSave ready to save");
|
||||
HILOG_INFO("AbilityImpl::CheckAndSave ready to save");
|
||||
ability_->OnSaveAbilityState(restoreData_);
|
||||
abilityLifecycleCallbacks_->OnAbilitySaveState(restoreData_);
|
||||
|
||||
needSaveDate_ = false;
|
||||
|
||||
APP_LOGI("AbilityImpl::CheckAndSave called end");
|
||||
HILOG_INFO("AbilityImpl::CheckAndSave called end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -813,7 +813,7 @@ void AbilityImpl::SetCallingContext(
|
||||
*/
|
||||
Uri AbilityImpl::NormalizeUri(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::NormalizeUri");
|
||||
HILOG_INFO("AbilityImpl::NormalizeUri");
|
||||
return uri;
|
||||
}
|
||||
|
||||
@ -829,7 +829,7 @@ Uri AbilityImpl::NormalizeUri(const Uri &uri)
|
||||
*/
|
||||
Uri AbilityImpl::DenormalizeUri(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::DenormalizeUri");
|
||||
HILOG_INFO("AbilityImpl::DenormalizeUri");
|
||||
return uri;
|
||||
}
|
||||
|
||||
@ -838,18 +838,18 @@ Uri AbilityImpl::DenormalizeUri(const Uri &uri)
|
||||
*/
|
||||
void AbilityImpl::ScheduleUpdateConfiguration(const Configuration &config)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::ScheduleUpdateConfiguration ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::ScheduleUpdateConfiguration ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lifecycleState_ != AAFwk::ABILITY_STATE_INITIAL) {
|
||||
APP_LOGI("ability name: [%{public}s]", ability_->GetAbilityName().c_str());
|
||||
HILOG_INFO("ability name: [%{public}s]", ability_->GetAbilityName().c_str());
|
||||
ability_->OnConfigurationUpdatedNotify(config);
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const
|
||||
@ -857,16 +857,16 @@ void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::KeyE
|
||||
int32_t code = keyEvent->GetKeyAction();
|
||||
if (code == MMI::KeyEvent::KEY_ACTION_DOWN) {
|
||||
abilityImpl_->DoKeyDown(keyEvent);
|
||||
APP_LOGI("AbilityImpl::OnKeyDown keyAction: %{public}d.", code);
|
||||
HILOG_INFO("AbilityImpl::OnKeyDown keyAction: %{public}d.", code);
|
||||
} else if (code == MMI::KeyEvent::KEY_ACTION_UP) {
|
||||
abilityImpl_->DoKeyUp(keyEvent);
|
||||
APP_LOGI("AbilityImpl::DoKeyUp keyAction: %{public}d.", code);
|
||||
HILOG_INFO("AbilityImpl::DoKeyUp keyAction: %{public}d.", code);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const
|
||||
{
|
||||
APP_LOGI("AbilityImpl::DoPointerEvent called.");
|
||||
HILOG_INFO("AbilityImpl::DoPointerEvent called.");
|
||||
abilityImpl_->DoPointerEvent(pointerEvent);
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::Poin
|
||||
*/
|
||||
void AbilityImpl::WindowEventRegister()
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
if (!ability_->GetAbilityInfo()->isStageBasedModel) {
|
||||
auto window = ability_->GetWindow();
|
||||
if (window) {
|
||||
@ -894,7 +894,7 @@ void AbilityImpl::WindowEventRegister()
|
||||
std::shared_ptr<AbilityPostEventTimeout> AbilityImpl::CreatePostEventTimeouter(std::string taskstr)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::CreatePostEventTimeouter ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::CreatePostEventTimeouter ability_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ std::shared_ptr<AbilityPostEventTimeout> AbilityImpl::CreatePostEventTimeouter(s
|
||||
std::vector<std::shared_ptr<DataAbilityResult>> AbilityImpl::ExecuteBatch(
|
||||
const std::vector<std::shared_ptr<DataAbilityOperation>> &operations)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::ExecuteBatch");
|
||||
HILOG_INFO("AbilityImpl::ExecuteBatch");
|
||||
std::vector<std::shared_ptr<DataAbilityResult>> results;
|
||||
return results;
|
||||
}
|
||||
@ -912,7 +912,7 @@ std::vector<std::shared_ptr<DataAbilityResult>> AbilityImpl::ExecuteBatch(
|
||||
void AbilityImpl::ContinueAbility(const std::string& deviceId)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::ContinueAbility ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::ContinueAbility ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
ability_->ContinueAbilityWithStack(deviceId);
|
||||
@ -921,7 +921,7 @@ void AbilityImpl::ContinueAbility(const std::string& deviceId)
|
||||
void AbilityImpl::NotifyContinuationResult(int32_t result)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::NotifyContinuationResult ability_ is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::NotifyContinuationResult ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
ability_->OnCompleteContinuation(result);
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ability_impl_factory.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "new_ability_impl.h"
|
||||
#include "page_ability_impl.h"
|
||||
#include "service_ability_impl.h"
|
||||
@ -49,12 +49,12 @@ std::shared_ptr<AbilityImpl> AbilityImplFactory::MakeAbilityImplObject(const std
|
||||
int compatibleVersion)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
APP_LOGE("AbilityImplFactory::MakeAbilityImplObject is error nullptr == info ");
|
||||
HILOG_ERROR("AbilityImplFactory::MakeAbilityImplObject is error nullptr == info ");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityImpl> abilityImpl = nullptr;
|
||||
APP_LOGI("AbilityImplFactory::MakeAbilityImplObject type:%{public}d, isStageBasedModel:%{public}d", info->type,
|
||||
HILOG_INFO("AbilityImplFactory::MakeAbilityImplObject type:%{public}d, isStageBasedModel:%{public}d", info->type,
|
||||
info->isStageBasedModel);
|
||||
switch (info->type) {
|
||||
case AppExecFwk::AbilityType::PAGE:
|
||||
@ -71,7 +71,7 @@ std::shared_ptr<AbilityImpl> AbilityImplFactory::MakeAbilityImplObject(const std
|
||||
abilityImpl = std::make_shared<DataAbilityImpl>();
|
||||
break;
|
||||
default:
|
||||
APP_LOGE("AbilityImplFactory::MakeAbilityImplObject is error");
|
||||
HILOG_ERROR("AbilityImplFactory::MakeAbilityImplObject is error");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "ability_lifecycle_observer_interface.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -29,7 +29,7 @@ namespace AppExecFwk {
|
||||
*/
|
||||
LifeCycle::Event LifeCycle::GetLifecycleState()
|
||||
{
|
||||
APP_LOGI("LifeCycle::GetLifecycleState: called");
|
||||
HILOG_INFO("LifeCycle::GetLifecycleState: called");
|
||||
return state_;
|
||||
}
|
||||
|
||||
@ -43,10 +43,10 @@ LifeCycle::Event LifeCycle::GetLifecycleState()
|
||||
*/
|
||||
void LifeCycle::AddObserver(const std::shared_ptr<ILifecycleObserver> &observer)
|
||||
{
|
||||
APP_LOGI("LifeCycle::AddObserver: called");
|
||||
HILOG_INFO("LifeCycle::AddObserver: called");
|
||||
|
||||
if (observer == nullptr) {
|
||||
APP_LOGI("LifeCycle::AddObserver: observer is null");
|
||||
HILOG_INFO("LifeCycle::AddObserver: observer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -61,9 +61,9 @@ void LifeCycle::AddObserver(const std::shared_ptr<ILifecycleObserver> &observer)
|
||||
*/
|
||||
void LifeCycle::DispatchLifecycle(const LifeCycle::Event &event, const Want &want)
|
||||
{
|
||||
APP_LOGI("LifeCycle::DispatchLifecycle: event:%{public}d", event);
|
||||
HILOG_INFO("LifeCycle::DispatchLifecycle: event:%{public}d", event);
|
||||
if ((event != LifeCycle::Event::ON_FOREGROUND) && (event != LifeCycle::Event::ON_START)) {
|
||||
APP_LOGE("event value error: event is %{public}d", event);
|
||||
HILOG_ERROR("event value error: event is %{public}d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -100,10 +100,10 @@ void LifeCycle::DispatchLifecycle(const LifeCycle::Event &event, const Want &wan
|
||||
*/
|
||||
void LifeCycle::DispatchLifecycle(const LifeCycle::Event &event)
|
||||
{
|
||||
APP_LOGI("LifeCycle::DispatchLifecycle: event:%{public}d", event);
|
||||
HILOG_INFO("LifeCycle::DispatchLifecycle: event:%{public}d", event);
|
||||
if ((event != LifeCycle::Event::ON_ACTIVE) && (event != LifeCycle::Event::ON_BACKGROUND) &&
|
||||
(event != LifeCycle::Event::ON_INACTIVE) && (event != LifeCycle::Event::ON_STOP)) {
|
||||
APP_LOGE("event value error: event is %{public}d", event);
|
||||
HILOG_ERROR("event value error: event is %{public}d", event);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -155,10 +155,10 @@ void LifeCycle::DispatchLifecycle(const LifeCycle::Event &event)
|
||||
*/
|
||||
void LifeCycle::RemoveObserver(const std::shared_ptr<ILifecycleObserver> &observer)
|
||||
{
|
||||
APP_LOGI("LifeCycle::RemoveObserver: called");
|
||||
HILOG_INFO("LifeCycle::RemoveObserver: called");
|
||||
|
||||
if (observer == nullptr) {
|
||||
APP_LOGI("LifeCycle::RemoveObserver: observer is null");
|
||||
HILOG_INFO("LifeCycle::RemoveObserver: observer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -33,7 +33,7 @@ AbilityLoader &AbilityLoader::GetInstance()
|
||||
void AbilityLoader::RegisterAbility(const std::string &abilityName, const CreateAblity &createFunc)
|
||||
{
|
||||
abilities_.emplace(abilityName, createFunc);
|
||||
APP_LOGD("AbilityLoader::RegisterAbility:%{public}s", abilityName.c_str());
|
||||
HILOG_DEBUG("AbilityLoader::RegisterAbility:%{public}s", abilityName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ void AbilityLoader::RegisterAbility(const std::string &abilityName, const Create
|
||||
void AbilityLoader::RegisterExtension(const std::string &abilityName, const CreateExtension &createFunc)
|
||||
{
|
||||
extensions_.emplace(abilityName, createFunc);
|
||||
APP_LOGD("AbilityLoader::RegisterExtension:%{public}s", abilityName.c_str());
|
||||
HILOG_DEBUG("AbilityLoader::RegisterExtension:%{public}s", abilityName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ Ability *AbilityLoader::GetAbilityByName(const std::string &abilityName)
|
||||
if (it != abilities_.end()) {
|
||||
return it->second();
|
||||
} else {
|
||||
APP_LOGE("AbilityLoader::GetAbilityByName failed:%{public}s", abilityName.c_str());
|
||||
HILOG_ERROR("AbilityLoader::GetAbilityByName failed:%{public}s", abilityName.c_str());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -79,7 +79,7 @@ AbilityRuntime::Extension *AbilityLoader::GetExtensionByName(const std::string &
|
||||
if (it != extensions_.end()) {
|
||||
return it->second();
|
||||
} else {
|
||||
APP_LOGE("AbilityLoader::GetExtensionByName failed:%{public}s", abilityName.c_str());
|
||||
HILOG_ERROR("AbilityLoader::GetExtensionByName failed:%{public}s", abilityName.c_str());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "ability_post_event_timeout.h"
|
||||
|
||||
#include "ability_handler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -40,9 +40,9 @@ AbilityPostEventTimeout::~AbilityPostEventTimeout()
|
||||
|
||||
void AbilityPostEventTimeout::TimingBegin(int64_t delaytime)
|
||||
{
|
||||
APP_LOGI("AbilityPostEventTimeout::TimingBegin() call %{public}s", task_.c_str());
|
||||
HILOG_INFO("AbilityPostEventTimeout::TimingBegin() call %{public}s", task_.c_str());
|
||||
if (handler_ == nullptr) {
|
||||
APP_LOGE("AbilityPostEventTimeout::TimingBegin %{public}s handler_ is nullptr", task_.c_str());
|
||||
HILOG_ERROR("AbilityPostEventTimeout::TimingBegin %{public}s handler_ is nullptr", task_.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void AbilityPostEventTimeout::TimingBegin(int64_t delaytime)
|
||||
void AbilityPostEventTimeout::TimeEnd()
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
APP_LOGE("AbilityPostEventTimeout::TimeEnd %{public}s handler_ is nullptr", task_.c_str());
|
||||
HILOG_ERROR("AbilityPostEventTimeout::TimeEnd %{public}s handler_ is nullptr", task_.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,19 +65,19 @@ void AbilityPostEventTimeout::TimeEnd()
|
||||
|
||||
void AbilityPostEventTimeout::TimeOutProc()
|
||||
{
|
||||
APP_LOGI("AbilityPostEventTimeout::TimeOutProc() call %{public}s", task_.c_str());
|
||||
HILOG_INFO("AbilityPostEventTimeout::TimeOutProc() call %{public}s", task_.c_str());
|
||||
if (handler_ == nullptr) {
|
||||
APP_LOGE("AbilityPostEventTimeout::TimeEnd %{public}s handler_ is nullptr", task_.c_str());
|
||||
HILOG_ERROR("AbilityPostEventTimeout::TimeEnd %{public}s handler_ is nullptr", task_.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lck(mtx_);
|
||||
if (!taskExec_) {
|
||||
taskExec_ = true;
|
||||
APP_LOGW("TimeOutProc %{public}s Event TimeOut", task_.c_str());
|
||||
HILOG_WARN("TimeOutProc %{public}s Event TimeOut", task_.c_str());
|
||||
handler_->RemoveTask(task_);
|
||||
} else {
|
||||
APP_LOGW("AbilityPostEventTimeout::TimeOutProc Exec Failed, The Event is %{public}s", task_.c_str());
|
||||
HILOG_WARN("AbilityPostEventTimeout::TimeOutProc Exec Failed, The Event is %{public}s", task_.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
static void *g_handle = nullptr;
|
||||
@ -55,9 +55,9 @@ AbilityProcess::~AbilityProcess()
|
||||
|
||||
ErrCode AbilityProcess::StartAbility(Ability *ability, CallAbilityParam param, CallbackInfo callback)
|
||||
{
|
||||
APP_LOGI("AbilityProcess::StartAbility begin");
|
||||
HILOG_INFO("AbilityProcess::StartAbility begin");
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("AbilityProcess::StartAbility ability is nullptr");
|
||||
HILOG_ERROR("AbilityProcess::StartAbility ability is nullptr");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
@ -67,15 +67,15 @@ ErrCode AbilityProcess::StartAbility(Ability *ability, CallAbilityParam param, C
|
||||
windowMode == AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY) {
|
||||
param.want.SetParam(Want::PARAM_RESV_WINDOW_MODE, windowMode);
|
||||
}
|
||||
APP_LOGI("window mode is %{public}d", windowMode);
|
||||
HILOG_INFO("window mode is %{public}d", windowMode);
|
||||
|
||||
ErrCode err = ERR_OK;
|
||||
if (param.forResultOption == true) {
|
||||
if (param.setting == nullptr) {
|
||||
APP_LOGI("%{public}s param.setting == nullptr call StartAbilityForResult.", __func__);
|
||||
HILOG_INFO("%{public}s param.setting == nullptr call StartAbilityForResult.", __func__);
|
||||
err = ability->StartAbilityForResult(param.want, param.requestCode);
|
||||
} else {
|
||||
APP_LOGI("%{public}s param.setting != nullptr call StartAbilityForResult.", __func__);
|
||||
HILOG_INFO("%{public}s param.setting != nullptr call StartAbilityForResult.", __func__);
|
||||
err = ability->StartAbilityForResult(param.want, param.requestCode, *(param.setting));
|
||||
}
|
||||
|
||||
@ -84,9 +84,9 @@ ErrCode AbilityProcess::StartAbility(Ability *ability, CallAbilityParam param, C
|
||||
std::map<int, CallbackInfo> map;
|
||||
auto it = abilityResultMap_.find(ability);
|
||||
if (it == abilityResultMap_.end()) {
|
||||
APP_LOGI("AbilityProcess::StartAbility ability: %{public}p is not in the abilityResultMap_", ability);
|
||||
HILOG_INFO("AbilityProcess::StartAbility ability: %{public}p is not in the abilityResultMap_", ability);
|
||||
} else {
|
||||
APP_LOGI("AbilityProcess::StartAbility ability: %{public}p is in the abilityResultMap_", ability);
|
||||
HILOG_INFO("AbilityProcess::StartAbility ability: %{public}p is in the abilityResultMap_", ability);
|
||||
map = it->second;
|
||||
}
|
||||
callback.errCode = err;
|
||||
@ -94,33 +94,33 @@ ErrCode AbilityProcess::StartAbility(Ability *ability, CallAbilityParam param, C
|
||||
abilityResultMap_[ability] = map;
|
||||
} else {
|
||||
if (param.setting == nullptr) {
|
||||
APP_LOGI("%{public}s param.setting == nullptr call StartAbility.", __func__);
|
||||
HILOG_INFO("%{public}s param.setting == nullptr call StartAbility.", __func__);
|
||||
err = ability->StartAbility(param.want);
|
||||
} else {
|
||||
APP_LOGI("%{public}s param.setting != nullptr call StartAbility.", __func__);
|
||||
HILOG_INFO("%{public}s param.setting != nullptr call StartAbility.", __func__);
|
||||
err = ability->StartAbility(param.want, *(param.setting));
|
||||
}
|
||||
}
|
||||
APP_LOGI("AbilityProcess::StartAbility end");
|
||||
HILOG_INFO("AbilityProcess::StartAbility end");
|
||||
return err;
|
||||
}
|
||||
|
||||
void AbilityProcess::OnAbilityResult(Ability *ability, int requestCode, int resultCode, const Want &resultData)
|
||||
{
|
||||
APP_LOGI("AbilityProcess::OnAbilityResult begin");
|
||||
HILOG_INFO("AbilityProcess::OnAbilityResult begin");
|
||||
|
||||
std::lock_guard<std::mutex> lock_l(mutex_);
|
||||
|
||||
auto it = abilityResultMap_.find(ability);
|
||||
if (it == abilityResultMap_.end()) {
|
||||
APP_LOGE("AbilityProcess::OnAbilityResult ability: %{public}p is not in the abilityResultMap", ability);
|
||||
HILOG_ERROR("AbilityProcess::OnAbilityResult ability: %{public}p is not in the abilityResultMap", ability);
|
||||
return;
|
||||
}
|
||||
std::map<int, CallbackInfo> map = it->second;
|
||||
|
||||
auto callback = map.find(requestCode);
|
||||
if (callback == map.end()) {
|
||||
APP_LOGE("AbilityProcess::OnAbilityResult requestCode: %{public}d is not in the map", requestCode);
|
||||
HILOG_ERROR("AbilityProcess::OnAbilityResult requestCode: %{public}d is not in the map", requestCode);
|
||||
return;
|
||||
}
|
||||
CallbackInfo callbackInfo = callback->second;
|
||||
@ -129,7 +129,7 @@ void AbilityProcess::OnAbilityResult(Ability *ability, int requestCode, int resu
|
||||
if (g_handle == nullptr) {
|
||||
g_handle = dlopen(SHARED_LIBRARY_FEATURE_ABILITY, RTLD_LAZY);
|
||||
if (g_handle == nullptr) {
|
||||
APP_LOGE("%{public}s, dlopen failed %{public}s. %{public}s",
|
||||
HILOG_ERROR("%{public}s, dlopen failed %{public}s. %{public}s",
|
||||
__func__,
|
||||
SHARED_LIBRARY_FEATURE_ABILITY,
|
||||
dlerror());
|
||||
@ -140,7 +140,8 @@ void AbilityProcess::OnAbilityResult(Ability *ability, int requestCode, int resu
|
||||
// get function
|
||||
auto func = reinterpret_cast<NAPICallOnAbilityResult>(dlsym(g_handle, FUNC_CALL_ON_ABILITY_RESULT));
|
||||
if (func == nullptr) {
|
||||
APP_LOGE("%{public}s, dlsym failed %{public}s. %{public}s", __func__, FUNC_CALL_ON_ABILITY_RESULT, dlerror());
|
||||
HILOG_ERROR(
|
||||
"%{public}s, dlsym failed %{public}s. %{public}s", __func__, FUNC_CALL_ON_ABILITY_RESULT, dlerror());
|
||||
dlclose(g_handle);
|
||||
g_handle = nullptr;
|
||||
return;
|
||||
@ -150,15 +151,15 @@ void AbilityProcess::OnAbilityResult(Ability *ability, int requestCode, int resu
|
||||
map.erase(requestCode);
|
||||
|
||||
abilityResultMap_[ability] = map;
|
||||
APP_LOGI("AbilityProcess::OnAbilityResult end");
|
||||
HILOG_INFO("AbilityProcess::OnAbilityResult end");
|
||||
}
|
||||
|
||||
void AbilityProcess::RequestPermissionsFromUser(
|
||||
Ability *ability, CallAbilityPermissionParam ¶m, CallbackInfo callbackInfo)
|
||||
{
|
||||
APP_LOGI("AbilityProcess::RequestPermissionsFromUser begin");
|
||||
HILOG_INFO("AbilityProcess::RequestPermissionsFromUser begin");
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("AbilityProcess::RequestPermissionsFromUser ability is nullptr");
|
||||
HILOG_ERROR("AbilityProcess::RequestPermissionsFromUser ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,11 +170,11 @@ void AbilityProcess::RequestPermissionsFromUser(
|
||||
std::map<int, CallbackInfo> map;
|
||||
auto it = abilityRequestPermissionsForUserMap_.find(ability);
|
||||
if (it == abilityRequestPermissionsForUserMap_.end()) {
|
||||
APP_LOGI("AbilityProcess::RequestPermissionsFromUser ability: %{public}p is not in the "
|
||||
HILOG_INFO("AbilityProcess::RequestPermissionsFromUser ability: %{public}p is not in the "
|
||||
"abilityRequestPermissionsForUserMap_",
|
||||
ability);
|
||||
} else {
|
||||
APP_LOGI("AbilityProcess::RequestPermissionsFromUser ability: %{public}p is in the "
|
||||
HILOG_INFO("AbilityProcess::RequestPermissionsFromUser ability: %{public}p is in the "
|
||||
"abilityRequestPermissionsForUserMap_",
|
||||
ability);
|
||||
map = it->second;
|
||||
@ -182,15 +183,15 @@ void AbilityProcess::RequestPermissionsFromUser(
|
||||
map[param.requestCode] = callbackInfo;
|
||||
abilityRequestPermissionsForUserMap_[ability] = map;
|
||||
}
|
||||
APP_LOGI("AbilityProcess::RequestPermissionsFromUser end");
|
||||
HILOG_INFO("AbilityProcess::RequestPermissionsFromUser end");
|
||||
}
|
||||
|
||||
void AbilityProcess::OnRequestPermissionsFromUserResult(Ability *ability, int requestCode,
|
||||
const std::vector<std::string> &permissions, const std::vector<int> &grantResults)
|
||||
{
|
||||
APP_LOGI("AbilityProcess::OnRequestPermissionsFromUserResult begin");
|
||||
HILOG_INFO("AbilityProcess::OnRequestPermissionsFromUserResult begin");
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("AbilityProcess::OnRequestPermissionsFromUserResult ability is nullptr");
|
||||
HILOG_ERROR("AbilityProcess::OnRequestPermissionsFromUserResult ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -198,7 +199,7 @@ void AbilityProcess::OnRequestPermissionsFromUserResult(Ability *ability, int re
|
||||
|
||||
auto it = abilityRequestPermissionsForUserMap_.find(ability);
|
||||
if (it == abilityRequestPermissionsForUserMap_.end()) {
|
||||
APP_LOGE("AbilityProcess::OnRequestPermissionsFromUserResult ability: %{public}p is not in the "
|
||||
HILOG_ERROR("AbilityProcess::OnRequestPermissionsFromUserResult ability: %{public}p is not in the "
|
||||
"abilityRequestPermissionsForUserMap_",
|
||||
ability);
|
||||
return;
|
||||
@ -207,7 +208,7 @@ void AbilityProcess::OnRequestPermissionsFromUserResult(Ability *ability, int re
|
||||
|
||||
auto callback = map.find(requestCode);
|
||||
if (callback == map.end()) {
|
||||
APP_LOGE("AbilityProcess::OnRequestPermissionsFromUserResult requestCode: %{public}d is not in the map",
|
||||
HILOG_ERROR("AbilityProcess::OnRequestPermissionsFromUserResult requestCode: %{public}d is not in the map",
|
||||
requestCode);
|
||||
return;
|
||||
}
|
||||
@ -217,7 +218,7 @@ void AbilityProcess::OnRequestPermissionsFromUserResult(Ability *ability, int re
|
||||
if (g_handle == nullptr) {
|
||||
g_handle = dlopen(SHARED_LIBRARY_FEATURE_ABILITY, RTLD_LAZY);
|
||||
if (g_handle == nullptr) {
|
||||
APP_LOGE("%{public}s, dlopen failed %{public}s. %{public}s",
|
||||
HILOG_ERROR("%{public}s, dlopen failed %{public}s. %{public}s",
|
||||
__func__,
|
||||
SHARED_LIBRARY_FEATURE_ABILITY,
|
||||
dlerror());
|
||||
@ -229,7 +230,7 @@ void AbilityProcess::OnRequestPermissionsFromUserResult(Ability *ability, int re
|
||||
auto func = reinterpret_cast<NAPICallOnRequestPermissionsFromUserResult>(
|
||||
dlsym(g_handle, FUNC_CALL_ON_REQUEST_PERMISSIONS_FROM_USERRESULT));
|
||||
if (func == nullptr) {
|
||||
APP_LOGE("%{public}s, dlsym failed %{public}s. %{public}s",
|
||||
HILOG_ERROR("%{public}s, dlsym failed %{public}s. %{public}s",
|
||||
__func__,
|
||||
FUNC_CALL_ON_REQUEST_PERMISSIONS_FROM_USERRESULT,
|
||||
dlerror());
|
||||
@ -241,7 +242,7 @@ void AbilityProcess::OnRequestPermissionsFromUserResult(Ability *ability, int re
|
||||
map.erase(requestCode);
|
||||
|
||||
abilityRequestPermissionsForUserMap_[ability] = map;
|
||||
APP_LOGI("AbilityProcess::OnRequestPermissionsFromUserResult end");
|
||||
HILOG_INFO("AbilityProcess::OnRequestPermissionsFromUserResult end");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
||||
#include "ability_window.h"
|
||||
#include "ability.h"
|
||||
#include "ability_handler.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -33,11 +33,11 @@ AbilityWindow::~AbilityWindow()
|
||||
*/
|
||||
void AbilityWindow::Init(std::shared_ptr<AbilityHandler>& handler, std::shared_ptr<Ability> ability)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
handler_ = handler;
|
||||
ability_ = std::weak_ptr<IAbilityEvent>(ability);
|
||||
windowScene_ = std::make_shared<Rosen::WindowScene>();
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,28 +52,28 @@ bool AbilityWindow::InitWindow(Rosen::WindowType winType,
|
||||
std::shared_ptr<AbilityRuntime::AbilityContext> &abilityContext,
|
||||
sptr<Rosen::IWindowLifeCycle> &listener, int32_t displayId, sptr<Rosen::WindowOption> option)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto ret = windowScene_->Init(displayId, abilityContext, listener, option);
|
||||
if (ret != OHOS::Rosen::WMError::WM_OK) {
|
||||
APP_LOGE("%{public}s error. failed to init window scene!", __func__);
|
||||
HILOG_ERROR("%{public}s error. failed to init window scene!", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto window = windowScene_->GetMainWindow();
|
||||
if (!window) {
|
||||
APP_LOGI("%{public}s window is nullptr.", __func__);
|
||||
HILOG_INFO("%{public}s window is nullptr.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = window->SetWindowType(winType);
|
||||
if (ret != OHOS::Rosen::WMError::WM_OK) {
|
||||
APP_LOGE("Set window type error, errcode = %{public}d", ret);
|
||||
HILOG_ERROR("Set window type error, errcode = %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
winType_ = winType;
|
||||
|
||||
isWindowAttached = true;
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -83,19 +83,19 @@ bool AbilityWindow::InitWindow(Rosen::WindowType winType,
|
||||
*/
|
||||
void AbilityWindow::OnPostAbilityStart()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::OnPostAbilityStart window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::OnPostAbilityStart window not attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowScene_) {
|
||||
APP_LOGI("%{public}s begin windowScene_->GoBackground.", __func__);
|
||||
HILOG_INFO("%{public}s begin windowScene_->GoBackground.", __func__);
|
||||
windowScene_->GoBackground();
|
||||
APP_LOGI("%{public}s end windowScene_->GoBackground.", __func__);
|
||||
HILOG_INFO("%{public}s end windowScene_->GoBackground.", __func__);
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,25 +104,25 @@ void AbilityWindow::OnPostAbilityStart()
|
||||
*/
|
||||
void AbilityWindow::OnPostAbilityActive()
|
||||
{
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityActive called.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityActive called.");
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::OnPostAbilityActive window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::OnPostAbilityActive window not attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowScene_) {
|
||||
APP_LOGI("%{public}s begin windowScene_->GoForeground.", __func__);
|
||||
HILOG_INFO("%{public}s begin windowScene_->GoForeground.", __func__);
|
||||
windowScene_->GoForeground();
|
||||
APP_LOGI("%{public}s end windowScene_->GoForeground.", __func__);
|
||||
HILOG_INFO("%{public}s end windowScene_->GoForeground.", __func__);
|
||||
|
||||
APP_LOGI("%{public}s begin windowScene_->RequestFocus.", __func__);
|
||||
HILOG_INFO("%{public}s begin windowScene_->RequestFocus.", __func__);
|
||||
if (!(winType_ >= Rosen::WindowType::SYSTEM_WINDOW_BASE && winType_ < Rosen::WindowType::SYSTEM_WINDOW_END)) {
|
||||
windowScene_->RequestFocus();
|
||||
}
|
||||
APP_LOGI("%{public}s end windowScene_->RequestFocus.", __func__);
|
||||
HILOG_INFO("%{public}s end windowScene_->RequestFocus.", __func__);
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityActive end.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityActive end.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,12 +131,12 @@ void AbilityWindow::OnPostAbilityActive()
|
||||
*/
|
||||
void AbilityWindow::OnPostAbilityInactive()
|
||||
{
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityInactive called.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityInactive called.");
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::OnPostAbilityInactive window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::OnPostAbilityInactive window not attached.");
|
||||
return;
|
||||
}
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityInactive end.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityInactive end.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,19 +145,19 @@ void AbilityWindow::OnPostAbilityInactive()
|
||||
*/
|
||||
void AbilityWindow::OnPostAbilityBackground(uint32_t sceneFlag)
|
||||
{
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityBackground called.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityBackground called.");
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::OnPostAbilityBackground window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::OnPostAbilityBackground window not attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowScene_) {
|
||||
APP_LOGI("%{public}s begin windowScene_->GoBackground, sceneFlag:%{public}d.", __func__, sceneFlag);
|
||||
HILOG_INFO("%{public}s begin windowScene_->GoBackground, sceneFlag:%{public}d.", __func__, sceneFlag);
|
||||
windowScene_->GoBackground(sceneFlag);
|
||||
APP_LOGI("%{public}s end windowScene_->GoBackground.", __func__);
|
||||
HILOG_INFO("%{public}s end windowScene_->GoBackground.", __func__);
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityBackground end.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityBackground end.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,19 +166,19 @@ void AbilityWindow::OnPostAbilityBackground(uint32_t sceneFlag)
|
||||
*/
|
||||
void AbilityWindow::OnPostAbilityForeground(uint32_t sceneFlag)
|
||||
{
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityForeground called.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityForeground called.");
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::OnPostAbilityForeground window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::OnPostAbilityForeground window not attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowScene_) {
|
||||
APP_LOGI("%{public}s begin windowScene_->GoForeground, sceneFlag:%{public}d.", __func__, sceneFlag);
|
||||
HILOG_INFO("%{public}s begin windowScene_->GoForeground, sceneFlag:%{public}d.", __func__, sceneFlag);
|
||||
windowScene_->GoForeground(sceneFlag);
|
||||
APP_LOGI("%{public}s end windowScene_->GoForeground.", __func__);
|
||||
HILOG_INFO("%{public}s end windowScene_->GoForeground.", __func__);
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityForeground end.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityForeground end.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,19 +187,19 @@ void AbilityWindow::OnPostAbilityForeground(uint32_t sceneFlag)
|
||||
*/
|
||||
void AbilityWindow::OnPostAbilityStop()
|
||||
{
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityStop called.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityStop called.");
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::OnPostAbilityStop window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::OnPostAbilityStop window not attached.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (windowScene_) {
|
||||
windowScene_ = nullptr;
|
||||
APP_LOGI("AbilityWindow::widow windowScene_ release end.");
|
||||
HILOG_INFO("AbilityWindow::widow windowScene_ release end.");
|
||||
}
|
||||
|
||||
isWindowAttached = false;
|
||||
APP_LOGI("AbilityWindow::OnPostAbilityStop end.");
|
||||
HILOG_INFO("AbilityWindow::OnPostAbilityStop end.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,7 +210,7 @@ void AbilityWindow::OnPostAbilityStop()
|
||||
const sptr<Rosen::Window> AbilityWindow::GetWindow()
|
||||
{
|
||||
if (!isWindowAttached) {
|
||||
APP_LOGE("AbilityWindow::GetWindow window not attached.");
|
||||
HILOG_ERROR("AbilityWindow::GetWindow window not attached.");
|
||||
}
|
||||
return windowScene_ ? windowScene_->GetMainWindow() : nullptr;
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include "continuation_handler.h"
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "distributed_errors.h"
|
||||
#include "element_name.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
using OHOS::AAFwk::WantParams;
|
||||
namespace OHOS {
|
||||
@ -33,13 +33,13 @@ ContinuationHandler::ContinuationHandler(
|
||||
bool ContinuationHandler::HandleStartContinuationWithStack(const sptr<IRemoteObject> &token,
|
||||
const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (token == nullptr) {
|
||||
APP_LOGE("HandleStartContinuationWithStack token is null.");
|
||||
HILOG_ERROR("HandleStartContinuationWithStack token is null.");
|
||||
return false;
|
||||
}
|
||||
if (abilityInfo_ == nullptr) {
|
||||
APP_LOGE("HandleStartContinuationWithStack abilityInfo is null.");
|
||||
HILOG_ERROR("HandleStartContinuationWithStack abilityInfo is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ bool ContinuationHandler::HandleStartContinuationWithStack(const sptr<IRemoteObj
|
||||
std::shared_ptr<ContinuationManager> continuationManagerTmp = nullptr;
|
||||
continuationManagerTmp = continuationManager_.lock();
|
||||
if (continuationManagerTmp == nullptr) {
|
||||
APP_LOGE("HandleStartContinuationWithStack: get continuationManagerTmp is nullptr");
|
||||
HILOG_ERROR("HandleStartContinuationWithStack: get continuationManagerTmp is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ bool ContinuationHandler::HandleStartContinuationWithStack(const sptr<IRemoteObj
|
||||
WantParams wantParams;
|
||||
int32_t status = continuationManagerTmp->OnContinue(wantParams);
|
||||
if (status != ERR_OK) {
|
||||
APP_LOGI("OnContinue failed, BundleName = %{public}s, ClassName= %{public}s, status: %{public}d",
|
||||
HILOG_INFO("OnContinue failed, BundleName = %{public}s, ClassName= %{public}s, status: %{public}d",
|
||||
abilityInfo_->bundleName.c_str(),
|
||||
abilityInfo_->name.c_str(),
|
||||
status);
|
||||
@ -67,22 +67,22 @@ bool ContinuationHandler::HandleStartContinuationWithStack(const sptr<IRemoteObj
|
||||
|
||||
int result = AAFwk::AbilityManagerClient::GetInstance()->StartContinuation(want, token, status);
|
||||
if (result != ERR_OK) {
|
||||
APP_LOGE("startContinuation failed.");
|
||||
HILOG_ERROR("startContinuation failed.");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContinuationHandler::HandleStartContinuation(const sptr<IRemoteObject> &token, const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (token == nullptr) {
|
||||
APP_LOGE("ContinuationHandler::HandleStartContinuation token is null.");
|
||||
HILOG_ERROR("ContinuationHandler::HandleStartContinuation token is null.");
|
||||
return false;
|
||||
}
|
||||
if (abilityInfo_ == nullptr) {
|
||||
APP_LOGE("ContinuationHandler::HandleStartContinuation abilityInfo is null.");
|
||||
HILOG_ERROR("ContinuationHandler::HandleStartContinuation abilityInfo is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -91,14 +91,14 @@ bool ContinuationHandler::HandleStartContinuation(const sptr<IRemoteObject> &tok
|
||||
std::shared_ptr<ContinuationManager> continuationManagerTmp = nullptr;
|
||||
continuationManagerTmp = continuationManager_.lock();
|
||||
if (continuationManagerTmp == nullptr) {
|
||||
APP_LOGE("handleStartContinuation: get continuationManagerTmp is nullptr");
|
||||
HILOG_ERROR("handleStartContinuation: get continuationManagerTmp is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
// DMS decided to start continuation. Callback to ability.
|
||||
if (!continuationManagerTmp->StartContinuation()) {
|
||||
APP_LOGI("handleStartContinuation: Ability rejected.");
|
||||
APP_LOGI("ID_ABILITY_SHELL_CONTINUE_ABILITY, BundleName = %{public}s, ClassName= %{public}s",
|
||||
HILOG_INFO("handleStartContinuation: Ability rejected.");
|
||||
HILOG_INFO("ID_ABILITY_SHELL_CONTINUE_ABILITY, BundleName = %{public}s, ClassName= %{public}s",
|
||||
abilityInfo_->bundleName.c_str(),
|
||||
abilityInfo_->name.c_str());
|
||||
return false;
|
||||
@ -106,8 +106,8 @@ bool ContinuationHandler::HandleStartContinuation(const sptr<IRemoteObject> &tok
|
||||
|
||||
WantParams wantParams;
|
||||
if (!continuationManagerTmp->SaveData(wantParams)) {
|
||||
APP_LOGI("handleStartContinuation: ScheduleSaveData failed.");
|
||||
APP_LOGI("ID_ABILITY_SHELL_CONTINUE_ABILITY, BundleName = %{public}s, ClassName= %{public}s",
|
||||
HILOG_INFO("handleStartContinuation: ScheduleSaveData failed.");
|
||||
HILOG_INFO("ID_ABILITY_SHELL_CONTINUE_ABILITY, BundleName = %{public}s, ClassName= %{public}s",
|
||||
abilityInfo_->bundleName.c_str(),
|
||||
abilityInfo_->name.c_str());
|
||||
return false;
|
||||
@ -118,18 +118,18 @@ bool ContinuationHandler::HandleStartContinuation(const sptr<IRemoteObject> &tok
|
||||
|
||||
int result = AAFwk::AbilityManagerClient::GetInstance()->StartContinuation(want, token, 0);
|
||||
if (result != 0) {
|
||||
APP_LOGE("distClient_.startContinuation failed.");
|
||||
HILOG_ERROR("distClient_.startContinuation failed.");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContinuationHandler::HandleReceiveRemoteScheduler(const sptr<IRemoteObject> &remoteReplica)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteReplica == nullptr) {
|
||||
APP_LOGE("scheduler is nullptr");
|
||||
HILOG_ERROR("scheduler is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -152,66 +152,66 @@ void ContinuationHandler::HandleReceiveRemoteScheduler(const sptr<IRemoteObject>
|
||||
}
|
||||
|
||||
remoteReplicaProxy_->PassPrimary(remotePrimaryStub_);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationHandler::HandleCompleteContinuation(int result)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<ContinuationManager> continuationManagerTmp = nullptr;
|
||||
continuationManagerTmp = continuationManager_.lock();
|
||||
if (continuationManagerTmp == nullptr) {
|
||||
APP_LOGE("ContinuationHandler::HandleCompleteContinuation: get continuationManagerTmp is nullptr");
|
||||
HILOG_ERROR("ContinuationHandler::HandleCompleteContinuation: get continuationManagerTmp is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
continuationManagerTmp->CompleteContinuation(result);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationHandler::SetReversible(bool reversible)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
reversible_ = reversible;
|
||||
}
|
||||
|
||||
void ContinuationHandler::SetAbilityInfo(std::shared_ptr<AbilityInfo> &abilityInfo)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
abilityInfo_ = std::make_shared<AbilityInfo>(*(abilityInfo.get()));
|
||||
ClearDeviceInfo(abilityInfo_);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationHandler::SetPrimaryStub(const sptr<IRemoteObject> &Primary)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
remotePrimaryStub_ = Primary;
|
||||
}
|
||||
|
||||
void ContinuationHandler::ClearDeviceInfo(std::shared_ptr<AbilityInfo> &abilityInfo)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
abilityInfo->deviceId = "";
|
||||
abilityInfo->deviceTypes.clear();
|
||||
}
|
||||
|
||||
void ContinuationHandler::OnReplicaDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteReplicaProxy_ == nullptr) {
|
||||
APP_LOGE("BUG: remote death notifies to a unready replica.");
|
||||
HILOG_ERROR("BUG: remote death notifies to a unready replica.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto object = remote.promote();
|
||||
if (!object) {
|
||||
APP_LOGE("replica on remoteReplica died: null object.");
|
||||
HILOG_ERROR("replica on remoteReplica died: null object.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (object != remoteReplicaProxy_->AsObject()) {
|
||||
APP_LOGE("replica on remoteReplica died: remoteReplica is not matches with remote.");
|
||||
HILOG_ERROR("replica on remoteReplica died: remoteReplica is not matches with remote.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -224,80 +224,80 @@ void ContinuationHandler::OnReplicaDied(const wptr<IRemoteObject> &remote)
|
||||
remoteReplicaProxy_.clear();
|
||||
|
||||
NotifyReplicaTerminated();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationHandler::NotifyReplicaTerminated()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
CleanUpAfterReverse();
|
||||
|
||||
std::shared_ptr<ContinuationManager> continuationManagerTmp = nullptr;
|
||||
continuationManagerTmp = continuationManager_.lock();
|
||||
if (continuationManagerTmp == nullptr) {
|
||||
APP_LOGE("ContinuationHandler::NotifyReplicaTerminated: get continuationManagerTmp is nullptr");
|
||||
HILOG_ERROR("ContinuationHandler::NotifyReplicaTerminated: get continuationManagerTmp is nullptr");
|
||||
return;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
continuationManagerTmp->NotifyRemoteTerminated();
|
||||
}
|
||||
|
||||
Want ContinuationHandler::SetWantParams(const WantParams &wantParams)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
Want want;
|
||||
want.SetParams(wantParams);
|
||||
want.AddFlags(want.FLAG_ABILITY_CONTINUATION);
|
||||
if (abilityInfo_->launchMode != LaunchMode::STANDARD) {
|
||||
APP_LOGI("SetWantParams: Clear task.");
|
||||
HILOG_INFO("SetWantParams: Clear task.");
|
||||
}
|
||||
if (reversible_) {
|
||||
APP_LOGI("SetWantParams: Reversible.");
|
||||
HILOG_INFO("SetWantParams: Reversible.");
|
||||
want.AddFlags(Want::FLAG_ABILITY_CONTINUATION_REVERSIBLE);
|
||||
}
|
||||
ElementName element("", abilityInfo_->bundleName, abilityInfo_->name);
|
||||
want.SetElement(element);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return want;
|
||||
}
|
||||
|
||||
void ContinuationHandler::CleanUpAfterReverse()
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
remoteReplicaProxy_ = nullptr;
|
||||
}
|
||||
|
||||
void ContinuationHandler::PassPrimary(const sptr<IRemoteObject> &Primary)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
remotePrimaryProxy_ = iface_cast<IReverseContinuationSchedulerPrimary>(Primary);
|
||||
}
|
||||
|
||||
bool ContinuationHandler::ReverseContinuation()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
if (remotePrimaryProxy_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuation:remotePrimaryProxy_ not initialized, can not reverse");
|
||||
HILOG_ERROR("ReverseContinuation:remotePrimaryProxy_ not initialized, can not reverse");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilityInfo_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuation: abilityInfo is null");
|
||||
HILOG_ERROR("ReverseContinuation: abilityInfo is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ContinuationManager> continuationManagerTmp = nullptr;
|
||||
continuationManagerTmp = continuationManager_.lock();
|
||||
if (continuationManagerTmp == nullptr) {
|
||||
APP_LOGE("ReverseContinuation: get continuationManagerTmp is nullptr");
|
||||
HILOG_ERROR("ReverseContinuation: get continuationManagerTmp is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!continuationManagerTmp->StartContinuation()) {
|
||||
APP_LOGE("ReverseContinuation: Ability rejected.");
|
||||
APP_LOGI("ReverseContinuation, BundleName = %{public}s, ClassName= %{public}s",
|
||||
HILOG_ERROR("ReverseContinuation: Ability rejected.");
|
||||
HILOG_INFO("ReverseContinuation, BundleName = %{public}s, ClassName= %{public}s",
|
||||
abilityInfo_->bundleName.c_str(),
|
||||
abilityInfo_->name.c_str());
|
||||
return false;
|
||||
@ -305,8 +305,8 @@ bool ContinuationHandler::ReverseContinuation()
|
||||
|
||||
WantParams wantParams;
|
||||
if (!continuationManagerTmp->SaveData(wantParams)) {
|
||||
APP_LOGE("ReverseContinuation: SaveData failed.");
|
||||
APP_LOGI("ReverseContinuation, BundleName = %{public}s, ClassName= %{public}s",
|
||||
HILOG_ERROR("ReverseContinuation: SaveData failed.");
|
||||
HILOG_INFO("ReverseContinuation, BundleName = %{public}s, ClassName= %{public}s",
|
||||
abilityInfo_->bundleName.c_str(),
|
||||
abilityInfo_->name.c_str());
|
||||
return false;
|
||||
@ -315,41 +315,41 @@ bool ContinuationHandler::ReverseContinuation()
|
||||
Want want;
|
||||
want.SetParams(wantParams);
|
||||
if (remotePrimaryProxy_->ContinuationBack(want)) {
|
||||
APP_LOGE("reverseContinuation: ContinuationBack send failed.");
|
||||
HILOG_ERROR("reverseContinuation: ContinuationBack send failed.");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContinuationHandler::NotifyReverseResult(int reverseResult)
|
||||
{
|
||||
APP_LOGI("NotifyReverseResult: Start. result = %{public}d", reverseResult);
|
||||
HILOG_INFO("NotifyReverseResult: Start. result = %{public}d", reverseResult);
|
||||
if (reverseResult == 0) {
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationHandler::NotifyReverseResult failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationHandler::NotifyReverseResult failed. ability is nullptr");
|
||||
return;
|
||||
}
|
||||
ability->TerminateAbility();
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ContinuationHandler::ContinuationBack(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<ContinuationManager> continuationManagerTmp = nullptr;
|
||||
continuationManagerTmp = continuationManager_.lock();
|
||||
if (continuationManagerTmp == nullptr) {
|
||||
APP_LOGE("ContinuationBack: get continuationManagerTmp is nullptr");
|
||||
HILOG_ERROR("ContinuationBack: get continuationManagerTmp is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
if (!continuationManagerTmp->RestoreFromRemote(want.GetParams())) {
|
||||
APP_LOGI("ContinuationBack: RestoreFromRemote failed.");
|
||||
HILOG_INFO("ContinuationBack: RestoreFromRemote failed.");
|
||||
result = ABILITY_FAILED_RESTORE_DATA;
|
||||
}
|
||||
|
||||
@ -357,34 +357,34 @@ bool ContinuationHandler::ContinuationBack(const Want &want)
|
||||
if (result == 0) {
|
||||
CleanUpAfterReverse();
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContinuationHandler::NotifyTerminationToPrimary()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remotePrimaryProxy_ == nullptr) {
|
||||
APP_LOGE("NotifyTerminationToPrimary: remotePrimary not initialized, can not notify");
|
||||
HILOG_ERROR("NotifyTerminationToPrimary: remotePrimary not initialized, can not notify");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("NotifyTerminationToPrimary: Start");
|
||||
HILOG_INFO("NotifyTerminationToPrimary: Start");
|
||||
remotePrimaryProxy_->NotifyReplicaTerminated();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ContinuationHandler::ReverseContinueAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteReplicaProxy_ == nullptr) {
|
||||
APP_LOGE("ReverseContinueAbility: remoteReplica not initialized, can not reverse");
|
||||
HILOG_ERROR("ReverseContinueAbility: remoteReplica not initialized, can not reverse");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("ReverseContinueAbility: Start");
|
||||
HILOG_INFO("ReverseContinueAbility: Start");
|
||||
bool requestSendSuccess = remoteReplicaProxy_->ReverseContinuation();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return requestSendSuccess;
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,10 @@
|
||||
#include "ability.h"
|
||||
#include "ability_continuation_interface.h"
|
||||
#include "ability_manager_client.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "continuation_handler.h"
|
||||
#include "distributed_client.h"
|
||||
#include "distributed_objectstore.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "operation_builder.h"
|
||||
#include "string_ex.h"
|
||||
#include "string_wrapper.h"
|
||||
@ -45,9 +45,9 @@ ContinuationManager::ContinuationManager()
|
||||
bool ContinuationManager::Init(const std::shared_ptr<Ability> &ability, const sptr<IRemoteObject> &continueToken,
|
||||
const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<ContinuationHandler> &continuationHandler)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::Init failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::Init failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
ability_ = ability;
|
||||
@ -55,24 +55,24 @@ bool ContinuationManager::Init(const std::shared_ptr<Ability> &ability, const sp
|
||||
std::shared_ptr<Ability> abilityTmp = nullptr;
|
||||
abilityTmp = ability_.lock();
|
||||
if (abilityTmp == nullptr) {
|
||||
APP_LOGE("ContinuationManager::Init failed. get ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::Init failed. get ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilityTmp->GetAbilityInfo() == nullptr) {
|
||||
APP_LOGE("ContinuationManager::Init failed. abilityInfo is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::Init failed. abilityInfo is nullptr");
|
||||
return false;
|
||||
}
|
||||
abilityInfo_ = abilityTmp->GetAbilityInfo();
|
||||
|
||||
if (continueToken == nullptr) {
|
||||
APP_LOGE("ContinuationManager::Init failed. continueToken is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::Init failed. continueToken is nullptr");
|
||||
return false;
|
||||
}
|
||||
continueToken_ = continueToken;
|
||||
|
||||
continuationHandler_ = continuationHandler;
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -88,25 +88,25 @@ std::string ContinuationManager::GetOriginalDeviceId()
|
||||
|
||||
void ContinuationManager::ContinueAbilityWithStack(const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
HandleContinueAbilityWithStack(deviceId);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ContinuationManager::HandleContinueAbilityWithStack(const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
if (!CheckAbilityToken()) {
|
||||
APP_LOGE("HandleContinueAbilityWithStack checkAbilityToken failed");
|
||||
HILOG_ERROR("HandleContinueAbilityWithStack checkAbilityToken failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> continueToken = continueToken_;
|
||||
std::shared_ptr<ContinuationHandler> continuationHandler = continuationHandler_.lock();
|
||||
if (continuationHandler == nullptr) {
|
||||
APP_LOGE("HandleContinueAbilityWithStack continuationHandler is nullptr");
|
||||
HILOG_ERROR("HandleContinueAbilityWithStack continuationHandler is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -115,52 +115,52 @@ bool ContinuationManager::HandleContinueAbilityWithStack(const std::string &devi
|
||||
continuationHandler->HandleStartContinuationWithStack(continueToken, deviceId);
|
||||
};
|
||||
if (!mainHandler_->PostTask(task)) {
|
||||
APP_LOGE("HandleContinueAbilityWithStack postTask failed");
|
||||
HILOG_ERROR("HandleContinueAbilityWithStack postTask failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t ContinuationManager::OnStartAndSaveData(WantParams &wantParams)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (!ability->OnStartContinuation()) {
|
||||
APP_LOGE("Ability rejected.");
|
||||
HILOG_ERROR("Ability rejected.");
|
||||
return CONTINUE_ABILITY_REJECTED;
|
||||
}
|
||||
if (!ability->OnSaveData(wantParams)) {
|
||||
APP_LOGE("SaveData failed.");
|
||||
HILOG_ERROR("SaveData failed.");
|
||||
return CONTINUE_SAVE_DATA_FAILED;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t ContinuationManager::OnContinueAndGetContent(WantParams &wantParams)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
bool status;
|
||||
APP_LOGI("OnContinue begin");
|
||||
HILOG_INFO("OnContinue begin");
|
||||
status = ability->OnContinue(wantParams);
|
||||
APP_LOGI("OnContinue end");
|
||||
HILOG_INFO("OnContinue end");
|
||||
if (!status) {
|
||||
APP_LOGE("OnContinue failed.");
|
||||
HILOG_ERROR("OnContinue failed.");
|
||||
return CONTINUE_ON_CONTINUE_FAILED;
|
||||
}
|
||||
auto abilityInfo = abilityInfo_.lock();
|
||||
@ -169,25 +169,25 @@ int32_t ContinuationManager::OnContinueAndGetContent(WantParams &wantParams)
|
||||
|
||||
status = GetContentInfo(wantParams);
|
||||
if (!status) {
|
||||
APP_LOGE("GetContentInfo failed.");
|
||||
HILOG_ERROR("GetContentInfo failed.");
|
||||
return CONTINUE_GET_CONTENT_FAILED;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t ContinuationManager::OnContinue(WantParams &wantParams)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
auto ability = ability_.lock();
|
||||
auto abilityInfo = abilityInfo_.lock();
|
||||
if (ability == nullptr || abilityInfo == nullptr) {
|
||||
APP_LOGE("ability or abilityInfo is nullptr");
|
||||
HILOG_ERROR("ability or abilityInfo is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
bool stageBased = abilityInfo->isStageBasedModel;
|
||||
APP_LOGI("ability isStageBasedModel %{public}d", stageBased);
|
||||
HILOG_INFO("ability isStageBasedModel %{public}d", stageBased);
|
||||
if (!stageBased) {
|
||||
return OnStartAndSaveData(wantParams);
|
||||
} else {
|
||||
@ -197,42 +197,44 @@ int32_t ContinuationManager::OnContinue(WantParams &wantParams)
|
||||
|
||||
bool ContinuationManager::GetContentInfo(WantParams &wantParams)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string pageStack = ability->GetContentInfo();
|
||||
if (pageStack.empty()) {
|
||||
APP_LOGE("GetContentInfo failed.");
|
||||
HILOG_ERROR("GetContentInfo failed.");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("ability pageStack: %{public}s", pageStack.c_str());
|
||||
HILOG_INFO("ability pageStack: %{public}s", pageStack.c_str());
|
||||
wantParams.SetParam(PAGE_STACK_PROPERTY_NAME, String::Box(pageStack));
|
||||
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContinuationManager::ContinueAbility(bool reversible, const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (CheckContinuationIllegal()) {
|
||||
APP_LOGE("ContinuationManager::ContinueAbility failed. Ability not available to continueAbility.");
|
||||
HILOG_ERROR("ContinuationManager::ContinueAbility failed. Ability not available to continueAbility.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (progressState_ != ProgressState::INITIAL) {
|
||||
APP_LOGE("ContinuationManager::ContinueAbility failed. Another request in progress. progressState_: %{public}d",
|
||||
HILOG_ERROR(
|
||||
"ContinuationManager::ContinueAbility failed. Another request in progress. progressState_: %{public}d",
|
||||
progressState_);
|
||||
return;
|
||||
}
|
||||
|
||||
if (continuationState_ != ContinuationState::LOCAL_RUNNING) {
|
||||
APP_LOGE("ContinuationManager::ContinueAbility failed. Illegal continuation state. Current state is %{public}d",
|
||||
HILOG_ERROR(
|
||||
"ContinuationManager::ContinueAbility failed. Illegal continuation state. Current state is %{public}d",
|
||||
continuationState_);
|
||||
return;
|
||||
}
|
||||
@ -241,26 +243,27 @@ void ContinuationManager::ContinueAbility(bool reversible, const std::string &de
|
||||
reversible_ = reversible;
|
||||
ChangeProcessState(ProgressState::WAITING_SCHEDULE);
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ContinuationManager::ReverseContinueAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (progressState_ != ProgressState::INITIAL) {
|
||||
APP_LOGE("ContinuationManager::ReverseContinueAbility failed. progressState_ is %{public}d.", progressState_);
|
||||
HILOG_ERROR(
|
||||
"ContinuationManager::ReverseContinueAbility failed. progressState_ is %{public}d.", progressState_);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (continuationState_ != ContinuationState::REMOTE_RUNNING) {
|
||||
APP_LOGE("ContinuationManager::ReverseContinueAbility failed. continuationState_ is %{public}d.",
|
||||
HILOG_ERROR("ContinuationManager::ReverseContinueAbility failed. continuationState_ is %{public}d.",
|
||||
continuationState_);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ContinuationHandler> continuationHandler = continuationHandler_.lock();
|
||||
if (continuationHandler == nullptr) {
|
||||
APP_LOGE("ContinuationManager::ReverseContinueAbility failed. continuationHandler_ is nullptr.");
|
||||
HILOG_ERROR("ContinuationManager::ReverseContinueAbility failed. continuationHandler_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -269,39 +272,39 @@ bool ContinuationManager::ReverseContinueAbility()
|
||||
ChangeProcessState(ProgressState::WAITING_SCHEDULE);
|
||||
RestoreStateWhenTimeout(TIMEOUT_MS_WAIT_REMOTE_NOTIFY_BACK, ProgressState::WAITING_SCHEDULE);
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return requestSuccess;
|
||||
}
|
||||
|
||||
bool ContinuationManager::StartContinuation()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
ChangeProcessState(ProgressState::IN_PROGRESS);
|
||||
bool result = DoScheduleStartContinuation();
|
||||
if (!result) {
|
||||
ChangeProcessState(ProgressState::INITIAL);
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ContinuationManager::SaveData(WantParams &saveData)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
bool result = DoScheduleSaveData(saveData);
|
||||
if (!result) {
|
||||
ChangeProcessState(ProgressState::INITIAL);
|
||||
} else {
|
||||
RestoreStateWhenTimeout(TIMEOUT_MS_WAIT_DMS_NOTIFY_CONTINUATION_COMPLETE, ProgressState::IN_PROGRESS);
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ContinuationManager::RestoreData(
|
||||
const WantParams &restoreData, bool reversible, const std::string &originalDeviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
ChangeProcessState(ProgressState::IN_PROGRESS);
|
||||
bool result = DoScheduleRestoreData(restoreData);
|
||||
if (reversible) {
|
||||
@ -309,31 +312,32 @@ bool ContinuationManager::RestoreData(
|
||||
}
|
||||
originalDeviceId_ = originalDeviceId;
|
||||
ChangeProcessState(ProgressState::INITIAL);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ContinuationManager::NotifyCompleteContinuation(
|
||||
const std::string &originDeviceId, int sessionId, bool success, const sptr<IRemoteObject> &reverseScheduler)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->NotifyCompleteContinuation(
|
||||
originDeviceId, sessionId, success);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationManager::CompleteContinuation(int result)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (CheckContinuationIllegal()) {
|
||||
APP_LOGE("ContinuationManager::CompleteContinuation failed. Ability not available to complete continuation.");
|
||||
HILOG_ERROR(
|
||||
"ContinuationManager::CompleteContinuation failed. Ability not available to complete continuation.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::CheckContinuationIllegal failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::CheckContinuationIllegal failed. ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -347,12 +351,12 @@ void ContinuationManager::CompleteContinuation(int result)
|
||||
if (!reversible_) {
|
||||
ability->TerminateAbility();
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ContinuationManager::RestoreFromRemote(const WantParams &restoreData)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
ChangeProcessState(ProgressState::IN_PROGRESS);
|
||||
bool result = DoRestoreFromRemote(restoreData);
|
||||
/*
|
||||
@ -363,60 +367,60 @@ bool ContinuationManager::RestoreFromRemote(const WantParams &restoreData)
|
||||
if (result) {
|
||||
continuationState_ = ContinuationState::LOCAL_RUNNING;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ContinuationManager::NotifyRemoteTerminated()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
continuationState_ = ContinuationState::LOCAL_RUNNING;
|
||||
ChangeProcessState(ProgressState::INITIAL);
|
||||
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::NotifyRemoteTerminated failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::NotifyRemoteTerminated failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
ability->OnRemoteTerminated();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContinuationManager::CheckContinuationIllegal()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::CheckContinuationIllegal failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::CheckContinuationIllegal failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ability->GetState() >= AbilityLifecycleExecutor::LifecycleState::UNINITIALIZED) {
|
||||
APP_LOGE("ContinuationManager::CheckContinuationIllegal failed. ability state is wrong: %{public}d",
|
||||
HILOG_ERROR("ContinuationManager::CheckContinuationIllegal failed. ability state is wrong: %{public}d",
|
||||
ability->GetState());
|
||||
return true;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContinuationManager::HandleContinueAbility(bool reversible, const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
if (!CheckAbilityToken()) {
|
||||
APP_LOGE("ContinuationManager::HandleContinueAbility failed. CheckAbilityToken failed");
|
||||
HILOG_ERROR("ContinuationManager::HandleContinueAbility failed. CheckAbilityToken failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> continueToken = continueToken_;
|
||||
std::shared_ptr<ContinuationHandler> continuationHandler = continuationHandler_.lock();
|
||||
if (continuationHandler == nullptr) {
|
||||
APP_LOGE("ContinuationManager::HandleContinueAbility failed. continuationHandler is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::HandleContinueAbility failed. continuationHandler is nullptr");
|
||||
return false;
|
||||
}
|
||||
continuationHandler->SetReversible(reversible);
|
||||
@ -427,11 +431,11 @@ bool ContinuationManager::HandleContinueAbility(bool reversible, const std::stri
|
||||
};
|
||||
|
||||
if (!mainHandler_->PostTask(task)) {
|
||||
APP_LOGE("ContinuationManager::HandleContinueAbility failed.PostTask failed");
|
||||
HILOG_ERROR("ContinuationManager::HandleContinueAbility failed.PostTask failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -442,7 +446,7 @@ ContinuationManager::ProgressState ContinuationManager::GetProcessState()
|
||||
|
||||
void ContinuationManager::ChangeProcessState(const ProgressState &newState)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin. progressState_: %{public}d, newState: %{public}d",
|
||||
HILOG_INFO("%{public}s called begin. progressState_: %{public}d, newState: %{public}d",
|
||||
__func__,
|
||||
progressState_,
|
||||
newState);
|
||||
@ -455,18 +459,18 @@ void ContinuationManager::ChangeProcessStateToInit()
|
||||
{
|
||||
if (mainHandler_ != nullptr) {
|
||||
mainHandler_->RemoveTask("Restore_State_When_Timeout");
|
||||
APP_LOGI("Restore_State_When_Timeout task removed");
|
||||
HILOG_INFO("Restore_State_When_Timeout task removed");
|
||||
}
|
||||
ChangeProcessState(ProgressState::INITIAL);
|
||||
}
|
||||
|
||||
void ContinuationManager::RestoreStateWhenTimeout(long timeoutInMs, const ProgressState &preState)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
InitMainHandlerIfNeed();
|
||||
|
||||
auto timeoutTask = [continuationManager = shared_from_this(), preState]() {
|
||||
APP_LOGI(
|
||||
HILOG_INFO(
|
||||
"ContinuationManager::RestoreStateWhenTimeout called. preState = %{public}d, currentState = %{public}d.",
|
||||
preState,
|
||||
continuationManager->GetProcessState());
|
||||
@ -475,45 +479,45 @@ void ContinuationManager::RestoreStateWhenTimeout(long timeoutInMs, const Progre
|
||||
}
|
||||
};
|
||||
mainHandler_->PostTask(timeoutTask, "Restore_State_When_Timeout", timeoutInMs);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationManager::InitMainHandlerIfNeed()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (mainHandler_ == nullptr) {
|
||||
APP_LOGI("Try to init main handler.");
|
||||
HILOG_INFO("Try to init main handler.");
|
||||
std::lock_guard<std::mutex> lock_l(lock_);
|
||||
if ((mainHandler_ == nullptr) && (EventRunner::GetMainEventRunner() != nullptr)) {
|
||||
mainHandler_ = std::make_shared<EventHandler>(EventRunner::GetMainEventRunner());
|
||||
}
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ContinuationManager::CheckAbilityToken()
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
if (continueToken_ == nullptr) {
|
||||
APP_LOGI("%{public}s called failed", __func__);
|
||||
HILOG_INFO("%{public}s called failed", __func__);
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called success", __func__);
|
||||
HILOG_INFO("%{public}s called success", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContinuationManager::CheckDmsInterfaceResult(int result, const std::string &interfaceName)
|
||||
{
|
||||
APP_LOGI("ContinuationManager::CheckDmsInterfaceResult called. interfaceName: %{public}s, result: %{public}d.",
|
||||
HILOG_INFO("ContinuationManager::CheckDmsInterfaceResult called. interfaceName: %{public}s, result: %{public}d.",
|
||||
interfaceName.c_str(),
|
||||
result);
|
||||
}
|
||||
|
||||
bool ContinuationManager::DoScheduleStartContinuation()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (CheckContinuationIllegal()) {
|
||||
APP_LOGE(
|
||||
HILOG_ERROR(
|
||||
"ContinuationManager::DoScheduleStartContinuation called. Ability not available to startContinuation.");
|
||||
return false;
|
||||
}
|
||||
@ -521,29 +525,29 @@ bool ContinuationManager::DoScheduleStartContinuation()
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleStartContinuation failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleStartContinuation failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
if (!ability->OnStartContinuation()) {
|
||||
APP_LOGI("%{public}s called failed to StartContinuation", __func__);
|
||||
HILOG_INFO("%{public}s called failed to StartContinuation", __func__);
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContinuationManager::DoScheduleSaveData(WantParams &saveData)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (CheckContinuationIllegal()) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleSaveData failed. Ability not available to save data.");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleSaveData failed. Ability not available to save data.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleSaveData failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleSaveData failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -554,24 +558,24 @@ bool ContinuationManager::DoScheduleSaveData(WantParams &saveData)
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleSaveData failed. Ability save data failed.");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleSaveData failed. Ability save data failed.");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ContinuationManager::DoScheduleRestoreData(const WantParams &restoreData)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (CheckContinuationIllegal()) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleRestoreData failed. Ability not available to restore data.");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleRestoreData failed. Ability not available to restore data.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleRestoreData failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleRestoreData failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -582,19 +586,19 @@ bool ContinuationManager::DoScheduleRestoreData(const WantParams &restoreData)
|
||||
|
||||
bool ret = ability->OnRestoreData(abilityRestoreData);
|
||||
if (!ret) {
|
||||
APP_LOGE("ContinuationManager::DoScheduleRestoreData failed. Ability restore data failed.");
|
||||
HILOG_ERROR("ContinuationManager::DoScheduleRestoreData failed. Ability restore data failed.");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ContinuationManager::DoRestoreFromRemote(const WantParams &restoreData)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
ability = ability_.lock();
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("ContinuationManager::DoRestoreFromRemote failed. ability is nullptr");
|
||||
HILOG_ERROR("ContinuationManager::DoRestoreFromRemote failed. ability is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -605,9 +609,9 @@ bool ContinuationManager::DoRestoreFromRemote(const WantParams &restoreData)
|
||||
|
||||
bool ret = ability->OnRestoreData(abilityRestoreData);
|
||||
if (!ret) {
|
||||
APP_LOGE("ContinuationManager::DoRestoreFromRemote failed. Ability restore data failed.");
|
||||
HILOG_ERROR("ContinuationManager::DoRestoreFromRemote failed. Ability restore data failed.");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "reverse_continuation_scheduler_primary.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "continuation_handler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -31,22 +31,22 @@ ReverseContinuationSchedulerPrimary::ReverseContinuationSchedulerPrimary(
|
||||
*/
|
||||
void ReverseContinuationSchedulerPrimary::NotifyReplicaTerminated()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
auto task = [reverseContinuationSchedulerPrimary = this]() {
|
||||
reverseContinuationSchedulerPrimary->HandlerNotifyReplicaTerminated();
|
||||
};
|
||||
|
||||
if (mainHandler_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimary::NotifyReplicaTerminated mainHandler_ == nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimary::NotifyReplicaTerminated mainHandler_ == nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = mainHandler_->PostTask(task);
|
||||
if (!ret) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimary::NotifyReplicaTerminated PostTask error");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimary::NotifyReplicaTerminated PostTask error");
|
||||
return;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,50 +57,50 @@ void ReverseContinuationSchedulerPrimary::NotifyReplicaTerminated()
|
||||
*/
|
||||
bool ReverseContinuationSchedulerPrimary::ContinuationBack(const AAFwk::Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
auto task = [reverseContinuationSchedulerPrimary = this, want]() {
|
||||
reverseContinuationSchedulerPrimary->HandlerContinuationBack(want);
|
||||
};
|
||||
|
||||
if (mainHandler_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimary::ContinuationBack mainHandler_ == nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimary::ContinuationBack mainHandler_ == nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = mainHandler_->PostTask(task);
|
||||
if (!ret) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimary::ContinuationBack PostTask error");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimary::ContinuationBack PostTask error");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReverseContinuationSchedulerPrimary::HandlerNotifyReplicaTerminated()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IReverseContinuationSchedulerPrimaryHandler> continuationHandler = nullptr;
|
||||
continuationHandler = continuationHandler_.lock();
|
||||
if (continuationHandler == nullptr) {
|
||||
APP_LOGE(
|
||||
HILOG_ERROR(
|
||||
"ReverseContinuationSchedulerPrimary::HandlerNotifyReplicaTerminated get continuationHandler is nullptr");
|
||||
return;
|
||||
}
|
||||
continuationHandler->NotifyReplicaTerminated();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ReverseContinuationSchedulerPrimary::HandlerContinuationBack(const AAFwk::Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IReverseContinuationSchedulerPrimaryHandler> continuationHandler = nullptr;
|
||||
continuationHandler = continuationHandler_.lock();
|
||||
if (continuationHandler == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimary::HandlerContinuationBack get continuationHandler is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimary::HandlerContinuationBack get continuationHandler is nullptr");
|
||||
return;
|
||||
}
|
||||
continuationHandler->ContinuationBack(want);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "reverse_continuation_scheduler_primary_proxy.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -30,25 +30,25 @@ ReverseContinuationSchedulerPrimaryProxy::ReverseContinuationSchedulerPrimaryPro
|
||||
*/
|
||||
void ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(ReverseContinuationSchedulerPrimaryProxy::GetDescriptor())) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated write interface token failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated write interface token failed");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = Remote();
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated Remote() is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated Remote() is nullptr");
|
||||
return;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
IReverseContinuationSchedulerPrimary::NOTIFY_REPLICA_TERMINATED, data, reply, option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated SendRequest return false");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated SendRequest return false");
|
||||
return;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,28 +59,28 @@ void ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated()
|
||||
*/
|
||||
bool ReverseContinuationSchedulerPrimaryProxy::ContinuationBack(const AAFwk::Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(ReverseContinuationSchedulerPrimaryProxy::GetDescriptor())) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack write interface token failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack write interface token failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack fail to WriteParcelable");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack fail to WriteParcelable");
|
||||
return false;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = Remote();
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack Remote() is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack Remote() is nullptr");
|
||||
return false;
|
||||
}
|
||||
if (!remoteObject->SendRequest(IReverseContinuationSchedulerPrimary::CONTINUATION_BACK, data, reply, option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack SendRequest return false");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryProxy::ContinuationBack SendRequest return false");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "reverse_continuation_scheduler_primary_stub.h"
|
||||
#include "ability_scheduler_interface.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -48,11 +48,11 @@ ReverseContinuationSchedulerPrimaryStub::~ReverseContinuationSchedulerPrimaryStu
|
||||
int ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::u16string token = data.ReadInterfaceToken();
|
||||
std::u16string descriptor = Str8ToStr16(DESCRIPTOR);
|
||||
if (descriptor != token) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest failed, DESCRIPTOR != touken");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest failed, DESCRIPTOR != touken");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -62,37 +62,37 @@ int ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest(
|
||||
if (func != nullptr) {
|
||||
return (this->*func)(data, reply);
|
||||
} else {
|
||||
APP_LOGW("ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest failed, func is nullptr");
|
||||
HILOG_WARN("ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest failed, func is nullptr");
|
||||
}
|
||||
} else {
|
||||
APP_LOGW("ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest failed, iter not find");
|
||||
HILOG_WARN("ReverseContinuationSchedulerPrimaryStub::OnRemoteRequest failed, iter not find");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int ReverseContinuationSchedulerPrimaryStub::NotifyReplicaTerminatedInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
NotifyReplicaTerminated();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return 0;
|
||||
}
|
||||
int ReverseContinuationSchedulerPrimaryStub::ContinuationBackInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
AAFwk::Want *want = data.ReadParcelable<AAFwk::Want>();
|
||||
if (want == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryStub::ContinuationBackInner want is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryStub::ContinuationBackInner want is nullptr");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ContinuationBack(*want)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryStub::NotifyReverseaTerminatedInner failed, ContinuationBack() "
|
||||
HILOG_ERROR("ReverseContinuationSchedulerPrimaryStub::NotifyReverseaTerminatedInner failed, ContinuationBack() "
|
||||
"return false");
|
||||
return -1;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "reverse_continuation_scheduler_replica.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -26,97 +26,97 @@ ReverseContinuationSchedulerReplica::ReverseContinuationSchedulerReplica(
|
||||
}
|
||||
void ReverseContinuationSchedulerReplica::PassPrimary(const sptr<IRemoteObject> &primary)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
auto task = [reverseContinuationSchedulerReplica = this, primary]() {
|
||||
reverseContinuationSchedulerReplica->HandlerPassPrimary(primary);
|
||||
};
|
||||
|
||||
if (mainHandler_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::PassPrimary mainHandler_ == nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::PassPrimary mainHandler_ == nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = mainHandler_->PostTask(task);
|
||||
if (!ret) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::PassPrimary PostTask error");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::PassPrimary PostTask error");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
bool ReverseContinuationSchedulerReplica::ReverseContinuation()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
auto task = [reverseContinuationSchedulerReplica = this]() {
|
||||
reverseContinuationSchedulerReplica->HandlerReverseContinuation();
|
||||
};
|
||||
|
||||
if (mainHandler_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::ReverseContinuation mainHandler_ == nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::ReverseContinuation mainHandler_ == nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = mainHandler_->PostTask(task);
|
||||
if (!ret) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::ReverseContinuation PostTask error");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::ReverseContinuation PostTask error");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
void ReverseContinuationSchedulerReplica::NotifyReverseResult(int reverseResult)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
auto task = [reverseContinuationSchedulerReplica = this, reverseResult]() {
|
||||
reverseContinuationSchedulerReplica->HandlerNotifyReverseResult(reverseResult);
|
||||
};
|
||||
|
||||
if (mainHandler_ == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::NotifyReverseResult mainHandler_ == nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::NotifyReverseResult mainHandler_ == nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = mainHandler_->PostTask(task);
|
||||
if (!ret) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::NotifyReverseResult PostTask error");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::NotifyReverseResult PostTask error");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ReverseContinuationSchedulerReplica::HandlerPassPrimary(const sptr<IRemoteObject> &primary)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IReverseContinuationSchedulerReplicaHandler> replicaHandlerTmp = nullptr;
|
||||
replicaHandlerTmp = replicaHandler_.lock();
|
||||
if (replicaHandlerTmp == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::PassPrimary get replicaHandlerTmp is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::PassPrimary get replicaHandlerTmp is nullptr");
|
||||
return;
|
||||
}
|
||||
replicaHandlerTmp->PassPrimary(primary);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
bool ReverseContinuationSchedulerReplica::HandlerReverseContinuation()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IReverseContinuationSchedulerReplicaHandler> replicaHandlerTmp = nullptr;
|
||||
replicaHandlerTmp = replicaHandler_.lock();
|
||||
if (replicaHandlerTmp == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::PassPrimary get replicaHandlerTmp is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::PassPrimary get replicaHandlerTmp is nullptr");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return replicaHandlerTmp->ReverseContinuation();
|
||||
}
|
||||
|
||||
void ReverseContinuationSchedulerReplica::HandlerNotifyReverseResult(int reverseResult)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IReverseContinuationSchedulerReplicaHandler> replicaHandlerTmp = nullptr;
|
||||
replicaHandlerTmp = replicaHandler_.lock();
|
||||
if (replicaHandlerTmp == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplica::PassPrimary get replicaHandlerTmp is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplica::PassPrimary get replicaHandlerTmp is nullptr");
|
||||
return;
|
||||
}
|
||||
replicaHandlerTmp->NotifyReverseResult(reverseResult);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "reverse_continuation_scheduler_replica_proxy.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -31,42 +31,42 @@ sptr<IRemoteObject> ReverseContinuationSchedulerReplicaProxy::AsObject()
|
||||
}
|
||||
void ReverseContinuationSchedulerReplicaProxy::PassPrimary(const sptr<IRemoteObject> &primary)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(ReverseContinuationSchedulerReplicaProxy::GetDescriptor())) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::PassPrimary write interface token failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary write interface token failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteRemoteObject(primary)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::PassPrimary write parcel callback failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary write parcel callback failed");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = Remote();
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::PassPrimary Remote() is NULL");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary Remote() is NULL");
|
||||
return;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::PASS_PRIMARY), data, reply, option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::PassPrimary SendRequest return false");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary SendRequest return false");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
bool ReverseContinuationSchedulerReplicaProxy::ReverseContinuation()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(ReverseContinuationSchedulerReplicaProxy::GetDescriptor())) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation write interface token failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation write interface token failed");
|
||||
return false;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = Remote();
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation Remote() is nullptr");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation Remote() is nullptr");
|
||||
return false;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
@ -74,29 +74,29 @@ bool ReverseContinuationSchedulerReplicaProxy::ReverseContinuation()
|
||||
data,
|
||||
reply,
|
||||
option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation SendRequest return false");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation SendRequest return false");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return true;
|
||||
}
|
||||
void ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult(int reverseResult)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(ReverseContinuationSchedulerReplicaProxy::GetDescriptor())) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult write interface token failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult write interface token failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(reverseResult)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult write parcel flags failed");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult write parcel flags failed");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = Remote();
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult Remote() is NULL");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult Remote() is NULL");
|
||||
return;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
@ -104,9 +104,9 @@ void ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult(int reverseRe
|
||||
data,
|
||||
reply,
|
||||
option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult SendRequest return false");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult SendRequest return false");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "reverse_continuation_scheduler_replica_stub.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -33,35 +33,35 @@ ReverseContinuationSchedulerReplicaStub::~ReverseContinuationSchedulerReplicaStu
|
||||
}
|
||||
int32_t ReverseContinuationSchedulerReplicaStub::PassPrimaryInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
const sptr<IRemoteObject> primary = data.ReadParcelable<IRemoteObject>();
|
||||
PassPrimary(primary);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
int32_t ReverseContinuationSchedulerReplicaStub::ReverseContinuationInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
ReverseContinuation();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
int32_t ReverseContinuationSchedulerReplicaStub::NotifyReverseResultInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
int reverseResult = data.ReadInt32();
|
||||
NotifyReverseResult(reverseResult);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int ReverseContinuationSchedulerReplicaStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin, code = %{public}d, flags= %{public}d.", __func__, code, option.GetFlags());
|
||||
HILOG_INFO("%{public}s called begin, code = %{public}d, flags= %{public}d.", __func__, code, option.GetFlags());
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (remoteDescriptor != ReverseContinuationSchedulerReplicaStub::GetDescriptor()) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaStub::OnRemoteRequest token is invalid");
|
||||
HILOG_ERROR("ReverseContinuationSchedulerReplicaStub::OnRemoteRequest token is invalid");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ int ReverseContinuationSchedulerReplicaStub::OnRemoteRequest(
|
||||
return (this->*continuationFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
#include "connect_callback_proxy.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "extra_params.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -29,15 +29,15 @@ namespace AppExecFwk {
|
||||
*/
|
||||
void ConnectCallbackProxy::Connect(const string &deviceId, const string &deviceType)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IConnectCallback::GetDescriptor()) || !data.WriteString(deviceId) ||
|
||||
data.WriteString(deviceType)) {
|
||||
APP_LOGE("%{public}s params is wrong", __func__);
|
||||
HILOG_ERROR("%{public}s params is wrong", __func__);
|
||||
return;
|
||||
}
|
||||
RemoteRequest(data, COMMAND_CONNECT);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
/**
|
||||
* @brief Remote device sends disconnection request.
|
||||
@ -46,25 +46,25 @@ void ConnectCallbackProxy::Connect(const string &deviceId, const string &deviceT
|
||||
*/
|
||||
void ConnectCallbackProxy::Disconnect(const string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IConnectCallback::GetDescriptor()) || !data.WriteString(deviceId)) {
|
||||
APP_LOGE("%{public}s params is wrong", __func__);
|
||||
HILOG_ERROR("%{public}s params is wrong", __func__);
|
||||
return;
|
||||
}
|
||||
RemoteRequest(data, COMMAND_DISCONNECT);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
void ConnectCallbackProxy::RemoteRequest(MessageParcel &data, int commandDisconnect)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (Remote() == nullptr) {
|
||||
return;
|
||||
}
|
||||
Remote()->SendRequest(commandDisconnect, data, reply, option);
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
#include "connect_callback_stub.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -29,20 +29,20 @@ ConnectCallbackStub::ConnectCallbackStub()
|
||||
|
||||
int ConnectCallbackStub::ConnectInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
string deviceId = Str16ToStr8(data.ReadString16());
|
||||
string deviceType = Str16ToStr8(data.ReadString16());
|
||||
Connect(deviceId, deviceType);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return OHOS::ERR_NONE;
|
||||
}
|
||||
|
||||
int ConnectCallbackStub::DisconnectInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
string deviceId = Str16ToStr8(data.ReadString16());
|
||||
Disconnect(deviceId);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return OHOS::ERR_NONE;
|
||||
}
|
||||
/**
|
||||
@ -55,10 +55,10 @@ int ConnectCallbackStub::DisconnectInner(MessageParcel &data, MessageParcel &rep
|
||||
int ConnectCallbackStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
std::u16string token = data.ReadInterfaceToken();
|
||||
if (token.compare(IConnectCallback::GetDescriptor()) != 0) {
|
||||
APP_LOGE("%{public}s Descriptor is wrong", __func__);
|
||||
HILOG_ERROR("%{public}s Descriptor is wrong", __func__);
|
||||
return OHOS::ERR_INVALID_REPLY;
|
||||
}
|
||||
auto localFuncIt = memberFuncMap_.find(code);
|
||||
@ -68,7 +68,7 @@ int ConnectCallbackStub::OnRemoteRequest(
|
||||
return (this->*memberFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
APP_LOGI("ConnectCallbackStub::OnRemoteRequest, default case, need check.");
|
||||
HILOG_INFO("ConnectCallbackStub::OnRemoteRequest, default case, need check.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include "continuation_connector.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "continuation_device_callback_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "remote_register_service_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -62,14 +62,14 @@ sptr<ContinuationConnector> ContinuationConnector::GetInstance(const std::weak_p
|
||||
void ContinuationConnector::OnAbilityConnectDone(
|
||||
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::OnAbilityConnectDone failed, remote is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::OnAbilityConnectDone failed, remote is nullptr");
|
||||
return;
|
||||
}
|
||||
remoteRegisterService_ = iface_cast<RemoteRegisterServiceProxy>(remoteObject);
|
||||
if (remoteRegisterService_ == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::OnAbilityConnectDone failed, remoteRegisterService_ is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::OnAbilityConnectDone failed, remoteRegisterService_ is nullptr");
|
||||
return;
|
||||
}
|
||||
isConnected_.store(true);
|
||||
@ -80,7 +80,7 @@ void ContinuationConnector::OnAbilityConnectDone(
|
||||
}
|
||||
continuationRequestList_.clear();
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,10 +94,10 @@ void ContinuationConnector::OnAbilityConnectDone(
|
||||
*/
|
||||
void ContinuationConnector::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
remoteRegisterService_ = nullptr;
|
||||
isConnected_.store(false);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,18 +107,18 @@ void ContinuationConnector::OnAbilityDisconnectDone(const AppExecFwk::ElementNam
|
||||
*/
|
||||
void ContinuationConnector::BindRemoteRegisterAbility(const std::shared_ptr<AppExecFwk::ContinuationRequest> &request)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr tmpcontext = context_.lock();
|
||||
if (tmpcontext == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::BindRemoteRegisterAbility failed, context_.lock is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::BindRemoteRegisterAbility failed, context_.lock is nullptr");
|
||||
return;
|
||||
}
|
||||
if (request == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::BindRemoteRegisterAbility failed, request is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::BindRemoteRegisterAbility failed, request is nullptr");
|
||||
return;
|
||||
}
|
||||
if (IsAbilityConnected()) {
|
||||
APP_LOGI("ContinuationConnector::BindRemoteRegisterAbility, remote register bounded");
|
||||
HILOG_INFO("ContinuationConnector::BindRemoteRegisterAbility, remote register bounded");
|
||||
request->Execute();
|
||||
return;
|
||||
}
|
||||
@ -128,7 +128,7 @@ void ContinuationConnector::BindRemoteRegisterAbility(const std::shared_ptr<AppE
|
||||
continuationRequestList_.push_back(request);
|
||||
}
|
||||
BindRemoteRegisterAbility();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,17 +136,17 @@ void ContinuationConnector::BindRemoteRegisterAbility(const std::shared_ptr<AppE
|
||||
*/
|
||||
void ContinuationConnector::UnbindRemoteRegisterAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr tmpcontext = context_.lock();
|
||||
if (tmpcontext == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::UnbindRemoteRegisterAbility failed, context_.lock is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::UnbindRemoteRegisterAbility failed, context_.lock is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
tmpcontext->DisconnectAbility(this);
|
||||
isConnected_.store(false);
|
||||
remoteRegisterService_ = nullptr;
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,13 +168,13 @@ bool ContinuationConnector::IsAbilityConnected()
|
||||
*/
|
||||
bool ContinuationConnector::Unregister(int token)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteRegisterService_ == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::Unregister failed, remoteRegisterService_ is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::Unregister failed, remoteRegisterService_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return remoteRegisterService_->Unregister(token);
|
||||
}
|
||||
|
||||
@ -189,13 +189,13 @@ bool ContinuationConnector::Unregister(int token)
|
||||
*/
|
||||
bool ContinuationConnector::UpdateConnectStatus(int token, const std::string &deviceId, int status)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteRegisterService_ == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::UpdateConnectStatus failed, remoteRegisterService_ is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::UpdateConnectStatus failed, remoteRegisterService_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return remoteRegisterService_->UpdateConnectStatus(token, deviceId, status);
|
||||
}
|
||||
|
||||
@ -208,12 +208,12 @@ bool ContinuationConnector::UpdateConnectStatus(int token, const std::string &de
|
||||
*/
|
||||
bool ContinuationConnector::ShowDeviceList(int token, const AppExecFwk::ExtraParams ¶meter)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteRegisterService_ == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::ShowDeviceList failed, remoteRegisterService_ is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::ShowDeviceList failed, remoteRegisterService_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return remoteRegisterService_->ShowDeviceList(token, parameter);
|
||||
}
|
||||
|
||||
@ -230,25 +230,25 @@ bool ContinuationConnector::ShowDeviceList(int token, const AppExecFwk::ExtraPar
|
||||
int ContinuationConnector::Register(std::weak_ptr<Context> &context, std::string bundleName,
|
||||
const AppExecFwk::ExtraParams ¶meter, std::shared_ptr<IContinuationDeviceCallback> &callback)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr pcontext = context.lock();
|
||||
if (pcontext == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::Register failed, pcontext is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::Register failed, pcontext is nullptr");
|
||||
return -1;
|
||||
}
|
||||
if (remoteRegisterService_ == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::Register failed, remoteRegisterService_ is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::Register failed, remoteRegisterService_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
sptr<IRemoteObject> token = pcontext->GetToken();
|
||||
if (token == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::Register failed, token is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::Register failed, token is nullptr");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sptr<ContinuationDeviceCallbackProxy> callBackSptr(new (std::nothrow) ContinuationDeviceCallbackProxy(callback));
|
||||
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return remoteRegisterService_->Register(bundleName, token, parameter, callBackSptr);
|
||||
}
|
||||
|
||||
@ -257,17 +257,17 @@ int ContinuationConnector::Register(std::weak_ptr<Context> &context, std::string
|
||||
*/
|
||||
void ContinuationConnector::BindRemoteRegisterAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr tmpcontext = context_.lock();
|
||||
if (tmpcontext == nullptr) {
|
||||
APP_LOGE("ContinuationConnector::BindRemoteRegisterAbility failed, context_.lock is nullptr");
|
||||
HILOG_ERROR("ContinuationConnector::BindRemoteRegisterAbility failed, context_.lock is nullptr");
|
||||
return;
|
||||
}
|
||||
Want want;
|
||||
want.SetElementName(CONNECTOR_DEVICE_ID, CONNECTOR_BUNDLE_NAME, CONNECTOR_ABILITY_NAME);
|
||||
want.AddFlags(Want::FLAG_NOT_OHOS_COMPONENT);
|
||||
tmpcontext->ConnectAbility(want, this);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "continuation_device_callback_proxy.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
/**
|
||||
@ -30,28 +30,28 @@ ContinuationDeviceCallbackProxy::~ContinuationDeviceCallbackProxy()
|
||||
{}
|
||||
void ContinuationDeviceCallbackProxy::Connect(const std::string &deviceId, const std::string &deviceType)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IContinuationDeviceCallback> callback = nullptr;
|
||||
callback = callback_.lock();
|
||||
if (callback == nullptr) {
|
||||
APP_LOGE("%{public}s callback is null", __func__);
|
||||
HILOG_ERROR("%{public}s callback is null", __func__);
|
||||
return;
|
||||
}
|
||||
callback->OnDeviceConnectDone(deviceId, deviceType);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationDeviceCallbackProxy::Disconnect(const std::string &deviceId)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::shared_ptr<IContinuationDeviceCallback> callback = nullptr;
|
||||
callback = callback_.lock();
|
||||
if (callback == nullptr) {
|
||||
APP_LOGE("%{public}s callback is null", __func__);
|
||||
HILOG_ERROR("%{public}s callback is null", __func__);
|
||||
return;
|
||||
}
|
||||
callback->OnDeviceDisconnectDone(deviceId);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -14,10 +14,10 @@
|
||||
*/
|
||||
#include "continuation_register_manager.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "continuation_device_callback_interface.h"
|
||||
#include "continuation_register_manager_proxy.h"
|
||||
#include "extra_params.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "request_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -41,12 +41,12 @@ void ContinuationRegisterManager::Register(const std::string &bundleName, const
|
||||
const std::shared_ptr<IContinuationDeviceCallback> &deviceCallback,
|
||||
const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (continuationRegisterManagerProxy_ != nullptr) {
|
||||
continuationRegisterManagerProxy_->Register(bundleName, parameter, deviceCallback, requestCallback);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
} else {
|
||||
APP_LOGE("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,12 +58,12 @@ void ContinuationRegisterManager::Register(const std::string &bundleName, const
|
||||
*/
|
||||
void ContinuationRegisterManager::Unregister(int token, const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (continuationRegisterManagerProxy_ != nullptr) {
|
||||
continuationRegisterManagerProxy_->Unregister(token, requestCallback);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
} else {
|
||||
APP_LOGE("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,12 +78,12 @@ void ContinuationRegisterManager::Unregister(int token, const std::shared_ptr<Re
|
||||
void ContinuationRegisterManager::UpdateConnectStatus(
|
||||
int token, const std::string &deviceId, int status, const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (continuationRegisterManagerProxy_ != nullptr) {
|
||||
continuationRegisterManagerProxy_->UpdateConnectStatus(token, deviceId, status, requestCallback);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
} else {
|
||||
APP_LOGE("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,12 +97,12 @@ void ContinuationRegisterManager::UpdateConnectStatus(
|
||||
void ContinuationRegisterManager::ShowDeviceList(
|
||||
int token, const ExtraParams ¶meter, const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (continuationRegisterManagerProxy_ != nullptr) {
|
||||
continuationRegisterManagerProxy_->ShowDeviceList(token, parameter, requestCallback);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
} else {
|
||||
APP_LOGE("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,12 +111,12 @@ void ContinuationRegisterManager::ShowDeviceList(
|
||||
*/
|
||||
void ContinuationRegisterManager::Disconnect(void)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (continuationRegisterManagerProxy_ != nullptr) {
|
||||
continuationRegisterManagerProxy_->Disconnect();
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
} else {
|
||||
APP_LOGE("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
HILOG_ERROR("%{public}s, ContinuationRegisterManagerProxy is null", __func__);
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -14,11 +14,11 @@
|
||||
*/
|
||||
#include "continuation_register_manager_proxy.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "context.h"
|
||||
#include "continuation_connector.h"
|
||||
#include "continuation_device_callback_interface.h"
|
||||
#include "continuation_request.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "request_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -35,16 +35,16 @@ ContinuationRequestRegister::ContinuationRequestRegister(const std::string &bund
|
||||
void ContinuationRequestRegister::Execute(void)
|
||||
{
|
||||
if (continuatinConnector_ == nullptr) {
|
||||
APP_LOGE("%{public}s called, continuatinConnector is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = continuatinConnector_->Register(context_, bundleName_, parameter_, deviceCallback_);
|
||||
if (requestCallback_ != nullptr) {
|
||||
requestCallback_->OnResult(ret);
|
||||
APP_LOGI("%{public}s called, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s called, ret=%{public}d", __func__, ret);
|
||||
} else {
|
||||
APP_LOGE("%{public}s called, requestCallback is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, requestCallback is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,16 +56,16 @@ ContinuationRequestUnRegister::ContinuationRequestUnRegister(int token)
|
||||
void ContinuationRequestUnRegister::Execute(void)
|
||||
{
|
||||
if (continuatinConnector_ == nullptr) {
|
||||
APP_LOGE("%{public}s called, continuatinConnector is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = continuatinConnector_->Unregister(token_);
|
||||
if (requestCallback_ != nullptr) {
|
||||
requestCallback_->OnResult(ret ? 0 : -1);
|
||||
APP_LOGI("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1));
|
||||
HILOG_INFO("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1));
|
||||
} else {
|
||||
APP_LOGE("%{public}s called, requestCallback is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, requestCallback is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,16 +80,16 @@ ContinuationRequestUpdateConnectStatus::ContinuationRequestUpdateConnectStatus(
|
||||
void ContinuationRequestUpdateConnectStatus::Execute(void)
|
||||
{
|
||||
if (continuatinConnector_ == nullptr) {
|
||||
APP_LOGE("%{public}s called, continuatinConnector is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = continuatinConnector_->UpdateConnectStatus(token_, deviceId_, status_);
|
||||
if (requestCallback_ != nullptr) {
|
||||
requestCallback_->OnResult(ret ? 0 : -1);
|
||||
APP_LOGI("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1));
|
||||
HILOG_INFO("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1));
|
||||
} else {
|
||||
APP_LOGE("%{public}s called, requestCallback is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, requestCallback is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,16 +102,16 @@ ContinuationRequestShowDeviceList::ContinuationRequestShowDeviceList(int token,
|
||||
void ContinuationRequestShowDeviceList::Execute(void)
|
||||
{
|
||||
if (continuatinConnector_ == nullptr) {
|
||||
APP_LOGE("%{public}s called, continuatinConnector is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, continuatinConnector is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = continuatinConnector_->ShowDeviceList(token_, parameter_);
|
||||
if (requestCallback_ != nullptr) {
|
||||
requestCallback_->OnResult(ret ? 0 : -1);
|
||||
APP_LOGI("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1));
|
||||
HILOG_INFO("%{public}s called, ret=%{public}d", __func__, (ret ? 0 : -1));
|
||||
} else {
|
||||
APP_LOGE("%{public}s called, requestCallback is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, requestCallback is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,10 +142,10 @@ void ContinuationRegisterManagerProxy::Register(const std::string &bundleName, c
|
||||
const std::shared_ptr<IContinuationDeviceCallback> &deviceCallback,
|
||||
const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
if (context_.lock() == nullptr || applicationContext_.lock() == nullptr) {
|
||||
APP_LOGE("%{public}s context or applicationContext is null", __func__);
|
||||
HILOG_ERROR("%{public}s context or applicationContext is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ void ContinuationRegisterManagerProxy::Register(const std::string &bundleName, c
|
||||
|
||||
SendRequest(applicationContext_, request);
|
||||
} else {
|
||||
APP_LOGE("%{public}s Create ContinuationRequestRegister failed", __func__);
|
||||
HILOG_ERROR("%{public}s Create ContinuationRequestRegister failed", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,10 +174,10 @@ void ContinuationRegisterManagerProxy::Register(const std::string &bundleName, c
|
||||
*/
|
||||
void ContinuationRegisterManagerProxy::Unregister(int token, const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
if (applicationContext_.lock() == nullptr) {
|
||||
APP_LOGI("%{public}s Context is null", __func__);
|
||||
HILOG_INFO("%{public}s Context is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ void ContinuationRegisterManagerProxy::Unregister(int token, const std::shared_p
|
||||
|
||||
SendRequest(applicationContext_, request);
|
||||
} else {
|
||||
APP_LOGE("%{public}s Create ContinuationRequestUnRegister failed", __func__);
|
||||
HILOG_ERROR("%{public}s Create ContinuationRequestUnRegister failed", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,10 +209,10 @@ void ContinuationRegisterManagerProxy::Unregister(int token, const std::shared_p
|
||||
void ContinuationRegisterManagerProxy::UpdateConnectStatus(
|
||||
int token, const std::string &deviceId, int status, const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
if (applicationContext_.lock() == nullptr) {
|
||||
APP_LOGI("%{public}s Context is null", __func__);
|
||||
HILOG_INFO("%{public}s Context is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ void ContinuationRegisterManagerProxy::UpdateConnectStatus(
|
||||
|
||||
SendRequest(applicationContext_, request);
|
||||
} else {
|
||||
APP_LOGE("%{public}s Create ContinuationRequestUpdateConnectStatus failed", __func__);
|
||||
HILOG_ERROR("%{public}s Create ContinuationRequestUpdateConnectStatus failed", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,10 +243,10 @@ void ContinuationRegisterManagerProxy::UpdateConnectStatus(
|
||||
void ContinuationRegisterManagerProxy::ShowDeviceList(
|
||||
int token, const ExtraParams ¶meter, const std::shared_ptr<RequestCallback> &requestCallback)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
if (applicationContext_.lock() == nullptr) {
|
||||
APP_LOGI("%{public}s Context is null", __func__);
|
||||
HILOG_INFO("%{public}s Context is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -259,9 +259,9 @@ void ContinuationRegisterManagerProxy::ShowDeviceList(
|
||||
std::shared_ptr<ContinuationRequest> request(pContinuationRequestShowDeviceList);
|
||||
|
||||
SendRequest(applicationContext_, request);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
} else {
|
||||
APP_LOGE("%{public}s Create ContinuationRequestShowDeviceList failed", __func__);
|
||||
HILOG_ERROR("%{public}s Create ContinuationRequestShowDeviceList failed", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,20 +270,20 @@ void ContinuationRegisterManagerProxy::ShowDeviceList(
|
||||
*/
|
||||
void ContinuationRegisterManagerProxy::Disconnect(void)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
|
||||
if (continuatinConnector_ != nullptr && continuatinConnector_->IsAbilityConnected()) {
|
||||
continuatinConnector_->UnbindRemoteRegisterAbility();
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
void ContinuationRegisterManagerProxy::SendRequest(
|
||||
const std::weak_ptr<Context> &context, const std::shared_ptr<ContinuationRequest> &request)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (request == nullptr) {
|
||||
APP_LOGE("%{public}s called, request is null", __func__);
|
||||
HILOG_ERROR("%{public}s called, request is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ void ContinuationRegisterManagerProxy::SendRequest(
|
||||
} else {
|
||||
request->Execute();
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "remote_register_service_proxy.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -28,16 +28,16 @@ namespace AppExecFwk {
|
||||
int RemoteRegisterServiceProxy::Register(const std::string &bundleName, const sptr<IRemoteObject> &token,
|
||||
const ExtraParams &extras, const sptr<IConnectCallback> &callback)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
if (bundleName.empty() || token == nullptr || callback == nullptr) {
|
||||
APP_LOGE("%{public}s param invalid", __func__);
|
||||
HILOG_ERROR("%{public}s param invalid", __func__);
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
APP_LOGE("%{public}s remote is null", __func__);
|
||||
HILOG_ERROR("%{public}s remote is null", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ int RemoteRegisterServiceProxy::Register(const std::string &bundleName, const sp
|
||||
if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteString(bundleName) ||
|
||||
data.WriteRemoteObject(token) || !data.WriteInt32(1) || !extras.Marshalling(data) ||
|
||||
!data.WriteRemoteObject(callback->AsObject())) {
|
||||
APP_LOGE("%{public}s Failed to write transfer data.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to write transfer data.", __func__);
|
||||
return IPC_INVOKER_WRITE_TRANS_ERR;
|
||||
}
|
||||
|
||||
@ -53,10 +53,10 @@ int RemoteRegisterServiceProxy::Register(const std::string &bundleName, const sp
|
||||
MessageOption option;
|
||||
int result = remote->SendRequest(COMMAND_REGISTER, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok", __func__);
|
||||
HILOG_INFO("%{public}s SendRequest ok", __func__);
|
||||
return reply.ReadInt32();
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return IPC_INVOKER_TRANSLATE_ERR;
|
||||
}
|
||||
}
|
||||
@ -68,17 +68,17 @@ int RemoteRegisterServiceProxy::Register(const std::string &bundleName, const sp
|
||||
*/
|
||||
bool RemoteRegisterServiceProxy::Unregister(int registerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
APP_LOGE("%{public}s remote is null", __func__);
|
||||
HILOG_ERROR("%{public}s remote is null", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteInt32(registerToken)) {
|
||||
APP_LOGE("%{public}s Failed to write transfer data.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to write transfer data.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -86,10 +86,10 @@ bool RemoteRegisterServiceProxy::Unregister(int registerToken)
|
||||
MessageOption option;
|
||||
int32_t result = remote->SendRequest(COMMAND_UNREGISTER, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok", __func__);
|
||||
HILOG_INFO("%{public}s SendRequest ok", __func__);
|
||||
return reply.ReadInt32() == ERR_NONE;
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -103,18 +103,18 @@ bool RemoteRegisterServiceProxy::Unregister(int registerToken)
|
||||
*/
|
||||
bool RemoteRegisterServiceProxy::UpdateConnectStatus(int registerToken, const std::string &deviceId, int status)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
APP_LOGE("%{public}s remote is null", __func__);
|
||||
HILOG_ERROR("%{public}s remote is null", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteInt32(registerToken) ||
|
||||
!data.WriteString(deviceId) || !data.WriteInt32(status)) {
|
||||
APP_LOGE("%{public}s Failed to write transfer data.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to write transfer data.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -122,10 +122,10 @@ bool RemoteRegisterServiceProxy::UpdateConnectStatus(int registerToken, const st
|
||||
MessageOption option;
|
||||
int32_t result = remote->SendRequest(COMMAND_UPDATE_CONNECT_STATUS, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok", __func__);
|
||||
HILOG_INFO("%{public}s SendRequest ok", __func__);
|
||||
return reply.ReadInt32() == ERR_NONE;
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -138,18 +138,18 @@ bool RemoteRegisterServiceProxy::UpdateConnectStatus(int registerToken, const st
|
||||
*/
|
||||
bool RemoteRegisterServiceProxy::ShowDeviceList(int registerToken, const ExtraParams &extras)
|
||||
{
|
||||
APP_LOGI("%{public}s called", __func__);
|
||||
HILOG_INFO("%{public}s called", __func__);
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
APP_LOGE("%{public}s remote is null", __func__);
|
||||
HILOG_ERROR("%{public}s remote is null", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteInt32(registerToken) ||
|
||||
!data.WriteInt32(1) || !extras.Marshalling(data)) {
|
||||
APP_LOGE("%{public}s Failed to write transfer data.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to write transfer data.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -157,10 +157,10 @@ bool RemoteRegisterServiceProxy::ShowDeviceList(int registerToken, const ExtraPa
|
||||
MessageOption option;
|
||||
int32_t result = remote->SendRequest(COMMAND_SHOW_DEVICE_LIST, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok", __func__);
|
||||
HILOG_INFO("%{public}s SendRequest ok", __func__);
|
||||
return reply.ReadInt32() == ERR_NONE;
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "remote_register_service_stub.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -33,12 +33,12 @@ RemoteRegisterServiceStub::~RemoteRegisterServiceStub()
|
||||
int RemoteRegisterServiceStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
APP_LOGI("%{public}s called, cmd=%{public}d, flags=%{public}d", __func__, code, option.GetFlags());
|
||||
HILOG_INFO("%{public}s called, cmd=%{public}d, flags=%{public}d", __func__, code, option.GetFlags());
|
||||
|
||||
std::u16string descriptor = IRemoteRegisterService::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
APP_LOGI("%{public}s local descriptor is not equal to remote", __func__);
|
||||
HILOG_INFO("%{public}s local descriptor is not equal to remote", __func__);
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@ -50,13 +50,13 @@ int RemoteRegisterServiceStub::OnRemoteRequest(
|
||||
}
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s Not found cmd, need check.", __func__);
|
||||
HILOG_INFO("%{public}s Not found cmd, need check.", __func__);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
std::string bundleName = data.ReadString();
|
||||
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
|
||||
ExtraParams *pExtras = nullptr;
|
||||
@ -66,7 +66,7 @@ int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel
|
||||
}
|
||||
if (pExtras == nullptr) {
|
||||
reply.WriteInt32(ERR_INVALID_DATA);
|
||||
APP_LOGE("%{public}s Failed to read ExtraParams.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to read ExtraParams.", __func__);
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel
|
||||
delete pExtras;
|
||||
pExtras = nullptr;
|
||||
reply.WriteInt32(ERR_NULL_OBJECT);
|
||||
APP_LOGE("%{public}s Failed to read IConnectCallback.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to read IConnectCallback.", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
@ -84,35 +84,35 @@ int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel
|
||||
delete pExtras;
|
||||
pExtras = nullptr;
|
||||
reply.WriteInt32(result);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int RemoteRegisterServiceStub::UnregisterInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
int registerToken = data.ReadInt32();
|
||||
bool result = Unregister(registerToken);
|
||||
reply.WriteInt32(result ? ERR_NONE : IPC_STUB_ERR);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int RemoteRegisterServiceStub::UpdateConnectStatusInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
int registerToken = data.ReadInt32(registerToken);
|
||||
std::string deviceId = data.ReadString();
|
||||
int status = data.ReadInt32();
|
||||
bool result = UpdateConnectStatus(registerToken, deviceId, status);
|
||||
reply.WriteInt32(result ? ERR_NONE : IPC_STUB_ERR);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int RemoteRegisterServiceStub::ShowDeviceListInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
int registerToken = data.ReadInt32();
|
||||
ExtraParams *pExtras = nullptr;
|
||||
int32_t extraId = data.ReadInt32();
|
||||
@ -121,7 +121,7 @@ int RemoteRegisterServiceStub::ShowDeviceListInner(MessageParcel &data, MessageP
|
||||
}
|
||||
if (pExtras == nullptr) {
|
||||
reply.WriteInt32(ERR_INVALID_DATA);
|
||||
APP_LOGE("%{public}s Failed to read ExtraParams.", __func__);
|
||||
HILOG_ERROR("%{public}s Failed to read ExtraParams.", __func__);
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ int RemoteRegisterServiceStub::ShowDeviceListInner(MessageParcel &data, MessageP
|
||||
delete pExtras;
|
||||
pExtras = nullptr;
|
||||
reply.WriteInt32(result ? ERR_NONE : IPC_STUB_ERR);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,8 @@
|
||||
#include "data_ability_impl.h"
|
||||
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_predicates.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "values_bucket.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -32,12 +32,12 @@ using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient;
|
||||
*/
|
||||
void DataAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
APP_LOGI("DataAbilityImpl::sourceState:%{public}d; targetState: %{public}d; isNewWant: %{public}d",
|
||||
HILOG_INFO("DataAbilityImpl::sourceState:%{public}d; targetState: %{public}d; isNewWant: %{public}d",
|
||||
lifecycleState_,
|
||||
targetState.state,
|
||||
targetState.isNewWant);
|
||||
if ((lifecycleState_ == targetState.state) && !targetState.isNewWant) {
|
||||
APP_LOGE("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
HILOG_ERROR("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ void DataAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
APP_LOGE("DataAbilityImpl::HandleAbilityTransaction state is error");
|
||||
HILOG_ERROR("DataAbilityImpl::HandleAbilityTransaction state is error");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
@ -74,7 +74,7 @@ std::vector<std::string> DataAbilityImpl::GetFileTypes(const Uri &uri, const std
|
||||
{
|
||||
std::vector<std::string> types;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::GetFileTypes ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::GetFileTypes ability_ is nullptr");
|
||||
return types;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ int DataAbilityImpl::OpenFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
int fd = -1;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::OpenFile ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::OpenFile ability_ is nullptr");
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ int DataAbilityImpl::OpenRawFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
int fd = -1;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::OpenRawFile ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::OpenRawFile ability_ is nullptr");
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ int DataAbilityImpl::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value
|
||||
{
|
||||
int index = -1;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::Insert ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::Insert ability_ is nullptr");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ int DataAbilityImpl::Update(
|
||||
{
|
||||
int index = -1;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::Update ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::Update ability_ is nullptr");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ int DataAbilityImpl::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicat
|
||||
{
|
||||
int index = -1;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::Delete ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::Delete ability_ is nullptr");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ std::shared_ptr<NativeRdb::AbsSharedResultSet> DataAbilityImpl::Query(
|
||||
const Uri &uri, std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::Query ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::Query ability_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ std::string DataAbilityImpl::GetType(const Uri &uri)
|
||||
{
|
||||
std::string type;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::GetType ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::GetType ability_ is nullptr");
|
||||
return type;
|
||||
}
|
||||
type = ability_->GetType(uri);
|
||||
@ -244,7 +244,7 @@ bool DataAbilityImpl::Reload(const Uri &uri, const PacMap &extras)
|
||||
{
|
||||
bool ret = false;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::Reload ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::Reload ability_ is nullptr");
|
||||
return ret;
|
||||
}
|
||||
ret = ability_->Reload(uri, extras);
|
||||
@ -263,7 +263,7 @@ int DataAbilityImpl::BatchInsert(const Uri &uri, const std::vector<NativeRdb::Va
|
||||
{
|
||||
int ret = -1;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::BatchInsert ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::BatchInsert ability_ is nullptr");
|
||||
return ret;
|
||||
}
|
||||
ret = ability_->BatchInsert(uri, values);
|
||||
@ -285,7 +285,7 @@ Uri DataAbilityImpl::NormalizeUri(const Uri &uri)
|
||||
{
|
||||
Uri urivalue("");
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::NormalizeUri ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::NormalizeUri ability_ is nullptr");
|
||||
return urivalue;
|
||||
}
|
||||
urivalue = ability_->NormalizeUri(uri);
|
||||
@ -308,7 +308,7 @@ Uri DataAbilityImpl::DenormalizeUri(const Uri &uri)
|
||||
{
|
||||
Uri urivalue("");
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::DenormalizeUri ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::DenormalizeUri ability_ is nullptr");
|
||||
return urivalue;
|
||||
}
|
||||
urivalue = ability_->DenormalizeUri(uri);
|
||||
@ -318,16 +318,16 @@ Uri DataAbilityImpl::DenormalizeUri(const Uri &uri)
|
||||
std::vector<std::shared_ptr<DataAbilityResult>> DataAbilityImpl::ExecuteBatch(
|
||||
const std::vector<std::shared_ptr<DataAbilityOperation>> &operations)
|
||||
{
|
||||
APP_LOGI("DataAbilityImpl::ExecuteBatch start");
|
||||
HILOG_INFO("DataAbilityImpl::ExecuteBatch start");
|
||||
std::vector<std::shared_ptr<DataAbilityResult>> results;
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("DataAbilityImpl::ExecuteBatch ability_ is nullptr");
|
||||
HILOG_ERROR("DataAbilityImpl::ExecuteBatch ability_ is nullptr");
|
||||
results.clear();
|
||||
return results;
|
||||
}
|
||||
|
||||
results = ability_->ExecuteBatch(operations);
|
||||
APP_LOGI("DataAbilityImpl::ExecuteBatch end, results size:%{public}zu", results.size());
|
||||
HILOG_INFO("DataAbilityImpl::ExecuteBatch end, results size:%{public}zu", results.size());
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "data_ability_operation.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_predicates.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "values_bucket.h"
|
||||
@ -141,146 +140,146 @@ DataAbilityOperation &DataAbilityOperation::operator=(const DataAbilityOperation
|
||||
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperation::NewInsertBuilder(const std::shared_ptr<Uri> &uri)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::NewInsertBuilder start");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewInsertBuilder start");
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataAbilityOperation::NewInsertBuilder uri is nullptr");
|
||||
HILOG_ERROR("DataAbilityOperation::NewInsertBuilder uri is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> builder =
|
||||
std::make_shared<DataAbilityOperationBuilder>(TYPE_INSERT, uri);
|
||||
APP_LOGD("DataAbilityOperation::NewInsertBuilder end");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewInsertBuilder end");
|
||||
return builder;
|
||||
}
|
||||
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperation::NewUpdateBuilder(const std::shared_ptr<Uri> &uri)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::NewUpdateBuilder start");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewUpdateBuilder start");
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataAbilityOperation::NewUpdateBuilder uri is nullptr");
|
||||
HILOG_ERROR("DataAbilityOperation::NewUpdateBuilder uri is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> builder =
|
||||
std::make_shared<DataAbilityOperationBuilder>(TYPE_UPDATE, uri);
|
||||
APP_LOGD("DataAbilityOperation::NewUpdateBuilder end");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewUpdateBuilder end");
|
||||
return builder;
|
||||
}
|
||||
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperation::NewDeleteBuilder(const std::shared_ptr<Uri> &uri)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::NewDeleteBuilder start");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewDeleteBuilder start");
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataAbilityOperation::NewDeleteBuilder uri is nullptr");
|
||||
HILOG_ERROR("DataAbilityOperation::NewDeleteBuilder uri is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> builder =
|
||||
std::make_shared<DataAbilityOperationBuilder>(TYPE_DELETE, uri);
|
||||
APP_LOGD("DataAbilityOperation::NewDeleteBuilder end");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewDeleteBuilder end");
|
||||
return builder;
|
||||
}
|
||||
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperation::NewAssertBuilder(const std::shared_ptr<Uri> &uri)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::NewAssertBuilder start");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewAssertBuilder start");
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataAbilityOperation::NewAssertBuilder uri is nullptr");
|
||||
HILOG_ERROR("DataAbilityOperation::NewAssertBuilder uri is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> builder =
|
||||
std::make_shared<DataAbilityOperationBuilder>(TYPE_ASSERT, uri);
|
||||
APP_LOGD("DataAbilityOperation::NewAssertBuilder end");
|
||||
HILOG_DEBUG("DataAbilityOperation::NewAssertBuilder end");
|
||||
return builder;
|
||||
}
|
||||
|
||||
int DataAbilityOperation::GetType() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetType");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetType");
|
||||
return type_;
|
||||
}
|
||||
|
||||
std::shared_ptr<Uri> DataAbilityOperation::GetUri() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetUri");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetUri");
|
||||
return uri_;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> DataAbilityOperation::GetValuesBucket() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetValuesBucket");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetValuesBucket");
|
||||
return valuesBucket_;
|
||||
}
|
||||
|
||||
int DataAbilityOperation::GetExpectedCount() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetExpectedCount");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetExpectedCount");
|
||||
return expectedCount_;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityOperation::GetDataAbilityPredicates() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetDataAbilityPredicates");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetDataAbilityPredicates");
|
||||
return dataAbilityPredicates_;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> DataAbilityOperation::GetValuesBucketReferences() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetValuesBucketReferences");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetValuesBucketReferences");
|
||||
return valuesBucketReferences_;
|
||||
}
|
||||
std::map<int, int> DataAbilityOperation::GetDataAbilityPredicatesBackReferences() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::GetDataAbilityPredicatesBackReferences");
|
||||
HILOG_DEBUG("DataAbilityOperation::GetDataAbilityPredicatesBackReferences");
|
||||
return dataAbilityPredicatesBackReferences_;
|
||||
}
|
||||
bool DataAbilityOperation::IsInsertOperation() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::IsInsertOperation:%d", type_ == TYPE_INSERT);
|
||||
HILOG_DEBUG("DataAbilityOperation::IsInsertOperation:%d", type_ == TYPE_INSERT);
|
||||
return type_ == TYPE_INSERT;
|
||||
}
|
||||
bool DataAbilityOperation::IsUpdateOperation() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::IsUpdateOperation:%d", type_ == TYPE_UPDATE);
|
||||
HILOG_DEBUG("DataAbilityOperation::IsUpdateOperation:%d", type_ == TYPE_UPDATE);
|
||||
return type_ == TYPE_UPDATE;
|
||||
}
|
||||
bool DataAbilityOperation::IsDeleteOperation() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::IsDeleteOperation:%d", type_ == TYPE_DELETE);
|
||||
HILOG_DEBUG("DataAbilityOperation::IsDeleteOperation:%d", type_ == TYPE_DELETE);
|
||||
return type_ == TYPE_DELETE;
|
||||
}
|
||||
bool DataAbilityOperation::IsAssertOperation() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::IsAssertOperation:%d", type_ == TYPE_ASSERT);
|
||||
HILOG_DEBUG("DataAbilityOperation::IsAssertOperation:%d", type_ == TYPE_ASSERT);
|
||||
return type_ == TYPE_ASSERT;
|
||||
}
|
||||
bool DataAbilityOperation::IsInterruptionAllowed() const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::IsInterruptionAllowed:%d", interrupted_);
|
||||
HILOG_DEBUG("DataAbilityOperation::IsInterruptionAllowed:%d", interrupted_);
|
||||
return interrupted_;
|
||||
}
|
||||
bool DataAbilityOperation::Marshalling(Parcel &out) const
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::Marshalling start");
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling start");
|
||||
if (!out.WriteInt32(type_)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(type_) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(type_) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteInt32(expectedCount_)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out.WriteBool(interrupted_)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uri_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out.WriteParcelable(uri_.get())) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -291,28 +290,28 @@ bool DataAbilityOperation::Marshalling(Parcel &out) const
|
||||
|
||||
if (valuesBucket_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out.WriteParcelable(valuesBucket_.get())) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!out.WriteInt32(VALUE_NULL)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (dataAbilityPredicates_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteParcelable(dataAbilityPredicates_.get())) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -323,11 +322,11 @@ bool DataAbilityOperation::Marshalling(Parcel &out) const
|
||||
|
||||
if (valuesBucketReferences_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteParcelable(valuesBucketReferences_.get())) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -340,64 +339,64 @@ bool DataAbilityOperation::Marshalling(Parcel &out) const
|
||||
if (!dataAbilityPredicatesBackReferences_.empty()) {
|
||||
referenceSize = dataAbilityPredicatesBackReferences_.size();
|
||||
if (!out.WriteInt32(referenceSize)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (referenceSize >= REFERENCE_THRESHOLD) {
|
||||
APP_LOGI("DataAbilityOperation::Marshalling referenceSize >= REFERENCE_THRESHOLD");
|
||||
HILOG_INFO("DataAbilityOperation::Marshalling referenceSize >= REFERENCE_THRESHOLD");
|
||||
return true;
|
||||
}
|
||||
for (auto it = dataAbilityPredicatesBackReferences_.begin(); it != dataAbilityPredicatesBackReferences_.end();
|
||||
it++) {
|
||||
|
||||
if (!out.WriteInt32(it->first)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteInt32(it->second)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
APP_LOGD("DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_ is empty");
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_ is empty");
|
||||
if (!out.WriteInt32(referenceSize)) {
|
||||
APP_LOGE("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
APP_LOGD("DataAbilityOperation::Marshalling end");
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling end");
|
||||
return true;
|
||||
}
|
||||
DataAbilityOperation *DataAbilityOperation::Unmarshalling(Parcel &in)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::Unmarshalling start");
|
||||
HILOG_DEBUG("DataAbilityOperation::Unmarshalling start");
|
||||
DataAbilityOperation *dataAbilityOperation = new (std::nothrow) DataAbilityOperation();
|
||||
if (dataAbilityOperation != nullptr && !dataAbilityOperation->ReadFromParcel(in)) {
|
||||
APP_LOGE("DataAbilityOperation::Unmarshalling dataAbilityOperation(%p) error", dataAbilityOperation);
|
||||
HILOG_ERROR("DataAbilityOperation::Unmarshalling dataAbilityOperation(%p) error", dataAbilityOperation);
|
||||
delete dataAbilityOperation;
|
||||
dataAbilityOperation = nullptr;
|
||||
}
|
||||
APP_LOGD("DataAbilityOperation::Unmarshalling end");
|
||||
HILOG_DEBUG("DataAbilityOperation::Unmarshalling end");
|
||||
return dataAbilityOperation;
|
||||
}
|
||||
bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::ReadFromParcel start");
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel start");
|
||||
if (!in.ReadInt32(type_)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel ReadInt32(type_) error");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(type_) error");
|
||||
return false;
|
||||
}
|
||||
if (!in.ReadInt32(expectedCount_)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
interrupted_ = in.ReadBool();
|
||||
|
||||
int empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
if (empty == VALUE_OBJECT) {
|
||||
@ -408,10 +407,10 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
|
||||
empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
APP_LOGD("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
empty == VALUE_OBJECT ? "VALUE_OBJECT" : "VALUE_NULL");
|
||||
if (empty == VALUE_OBJECT) {
|
||||
valuesBucket_.reset(in.ReadParcelable<NativeRdb::ValuesBucket>());
|
||||
@ -421,10 +420,10 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
|
||||
empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
APP_LOGD("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
empty == VALUE_OBJECT ? "VALUE_OBJECT" : "VALUE_NULL");
|
||||
if (empty == VALUE_OBJECT) {
|
||||
dataAbilityPredicates_.reset(in.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
@ -434,10 +433,10 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
|
||||
empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
APP_LOGD("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
(empty == VALUE_OBJECT) ? "VALUE_OBJECT" : "VALUE_NULL");
|
||||
if (empty == VALUE_OBJECT) {
|
||||
valuesBucketReferences_.reset(in.ReadParcelable<NativeRdb::ValuesBucket>());
|
||||
@ -447,11 +446,11 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
|
||||
int referenceSize = 0;
|
||||
if (!in.ReadInt32(referenceSize)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel end");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel end");
|
||||
return false;
|
||||
}
|
||||
if (referenceSize >= REFERENCE_THRESHOLD) {
|
||||
APP_LOGI("DataAbilityOperation::ReadFromParcel referenceSize:%{public}d >= REFERENCE_THRESHOLD:%{public}d",
|
||||
HILOG_INFO("DataAbilityOperation::ReadFromParcel referenceSize:%{public}d >= REFERENCE_THRESHOLD:%{public}d",
|
||||
referenceSize, REFERENCE_THRESHOLD);
|
||||
return true;
|
||||
}
|
||||
@ -460,36 +459,36 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
int first = 0;
|
||||
int second = 0;
|
||||
if (!in.ReadInt32(first)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel end");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel end");
|
||||
return false;
|
||||
}
|
||||
if (!in.ReadInt32(second)) {
|
||||
APP_LOGE("DataAbilityOperation::ReadFromParcel end");
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel end");
|
||||
return false;
|
||||
}
|
||||
dataAbilityPredicatesBackReferences_.insert(std::make_pair(first, second));
|
||||
}
|
||||
|
||||
APP_LOGD("DataAbilityOperation::ReadFromParcel end");
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel end");
|
||||
return true;
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperation> DataAbilityOperation::CreateFromParcel(Parcel &in)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::CreateFromParcel start");
|
||||
HILOG_DEBUG("DataAbilityOperation::CreateFromParcel start");
|
||||
std::shared_ptr<DataAbilityOperation> operation = std::make_shared<DataAbilityOperation>(in);
|
||||
APP_LOGD("DataAbilityOperation::CreateFromParcel end");
|
||||
HILOG_DEBUG("DataAbilityOperation::CreateFromParcel end");
|
||||
return operation;
|
||||
}
|
||||
void DataAbilityOperation::PutMap(Parcel &in)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperation::PutMap start");
|
||||
HILOG_DEBUG("DataAbilityOperation::PutMap start");
|
||||
int count = in.ReadInt32();
|
||||
if (count > 0 && count < REFERENCE_THRESHOLD) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
dataAbilityPredicatesBackReferences_.insert(std::make_pair(in.ReadInt32(), in.ReadInt32()));
|
||||
}
|
||||
}
|
||||
APP_LOGD("DataAbilityOperation::PutMap end");
|
||||
HILOG_DEBUG("DataAbilityOperation::PutMap end");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "data_ability_operation_builder.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_predicates.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "values_bucket.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -38,22 +38,23 @@ DataAbilityOperationBuilder::~DataAbilityOperationBuilder()
|
||||
|
||||
std::shared_ptr<DataAbilityOperation> DataAbilityOperationBuilder::Build()
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::Build start");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::Build start");
|
||||
if (type_ != DataAbilityOperation::TYPE_UPDATE || (valuesBucket_ != nullptr && !valuesBucket_->IsEmpty())) {
|
||||
std::shared_ptr<DataAbilityOperation> operation = std::make_shared<DataAbilityOperation>(shared_from_this());
|
||||
APP_LOGD("DataAbilityOperationBuilder::Build end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::Build end");
|
||||
return operation;
|
||||
}
|
||||
APP_LOGE("DataAbilityOperationBuilder::Build return nullptr");
|
||||
HILOG_ERROR("DataAbilityOperationBuilder::Build return nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithValuesBucket(
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> &values)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithValuesBucket start");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithValuesBucket start");
|
||||
if (type_ != DataAbilityOperation::TYPE_INSERT && type_ != DataAbilityOperation::TYPE_UPDATE &&
|
||||
type_ != DataAbilityOperation::TYPE_ASSERT) {
|
||||
APP_LOGE("DataAbilityOperationBuilder::WithValuesBucket only inserts, updates can have values, type=%{public}d",
|
||||
HILOG_ERROR(
|
||||
"DataAbilityOperationBuilder::WithValuesBucket only inserts, updates can have values, type=%{public}d",
|
||||
type_);
|
||||
return nullptr;
|
||||
}
|
||||
@ -62,87 +63,89 @@ std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithVa
|
||||
values->GetAll(valuesMap);
|
||||
|
||||
valuesBucket_.reset(new (std::nothrow) NativeRdb::ValuesBucket(valuesMap));
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithValuesBucket end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithValuesBucket end");
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithPredicates(
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> &predicates)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithPredicates start");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithPredicates start");
|
||||
if (type_ != DataAbilityOperation::TYPE_DELETE && type_ != DataAbilityOperation::TYPE_UPDATE &&
|
||||
type_ != DataAbilityOperation::TYPE_ASSERT) {
|
||||
APP_LOGE(
|
||||
HILOG_ERROR(
|
||||
"DataAbilityOperationBuilder::withPredicates only deletes and updates can have selections, type=%{public}d",
|
||||
type_);
|
||||
return nullptr;
|
||||
}
|
||||
dataAbilityPredicates_ = predicates;
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithPredicates end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithPredicates end");
|
||||
return shared_from_this();
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithExpectedCount(int count)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithExpectedCount start");
|
||||
APP_LOGI("DataAbilityOperationBuilder::WithExpectedCount expectedCount:%{public}d", count);
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithExpectedCount start");
|
||||
HILOG_INFO("DataAbilityOperationBuilder::WithExpectedCount expectedCount:%{public}d", count);
|
||||
if (type_ != DataAbilityOperation::TYPE_UPDATE && type_ != DataAbilityOperation::TYPE_DELETE &&
|
||||
type_ != DataAbilityOperation::TYPE_ASSERT) {
|
||||
APP_LOGE("DataAbilityOperationBuilder::withExpectedCount only updates, deletes can have expected counts, "
|
||||
"type=%{public}d",
|
||||
HILOG_ERROR("DataAbilityOperationBuilder::withExpectedCount only updates, deletes can have expected counts, "
|
||||
"type=%{public}d",
|
||||
type_);
|
||||
return nullptr;
|
||||
}
|
||||
expectedCount_ = count;
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithExpectedCount end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithExpectedCount end");
|
||||
return shared_from_this();
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithPredicatesBackReference(
|
||||
int requestArgIndex, int previousResult)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithPredicatesBackReference start");
|
||||
APP_LOGI("DataAbilityOperationBuilder::WithPredicatesBackReference requestArgIndex:%{public}d, "
|
||||
"previousResult:%{public}d",
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithPredicatesBackReference start");
|
||||
HILOG_INFO("DataAbilityOperationBuilder::WithPredicatesBackReference requestArgIndex:%{public}d, "
|
||||
"previousResult:%{public}d",
|
||||
requestArgIndex,
|
||||
previousResult);
|
||||
if (type_ != DataAbilityOperation::TYPE_UPDATE && type_ != DataAbilityOperation::TYPE_DELETE &&
|
||||
type_ != DataAbilityOperation::TYPE_ASSERT) {
|
||||
APP_LOGE("DataAbilityOperationBuilder::withPredicatesBackReference only updates, deletes, and asserts can have "
|
||||
"select back-references, type=%{public}d",
|
||||
HILOG_ERROR(
|
||||
"DataAbilityOperationBuilder::withPredicatesBackReference only updates, deletes, and asserts can have "
|
||||
"select back-references, type=%{public}d",
|
||||
type_);
|
||||
return nullptr;
|
||||
}
|
||||
dataAbilityPredicatesBackReferences_.insert(std::make_pair(requestArgIndex, previousResult));
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithPredicatesBackReference end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithPredicatesBackReference end");
|
||||
return shared_from_this();
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithValueBackReferences(
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> &backReferences)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithValueBackReferences start");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithValueBackReferences start");
|
||||
if (type_ != DataAbilityOperation::TYPE_INSERT && type_ != DataAbilityOperation::TYPE_UPDATE &&
|
||||
type_ != DataAbilityOperation::TYPE_ASSERT) {
|
||||
APP_LOGE("DataAbilityOperationBuilder::withValueBackReferences only inserts, updates, and asserts can have "
|
||||
"value back-references, type=%{public}d",
|
||||
HILOG_ERROR("DataAbilityOperationBuilder::withValueBackReferences only inserts, updates, and asserts can have "
|
||||
"value back-references, type=%{public}d",
|
||||
type_);
|
||||
return nullptr;
|
||||
}
|
||||
valuesBucketReferences_ = backReferences;
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithValueBackReferences end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithValueBackReferences end");
|
||||
return shared_from_this();
|
||||
}
|
||||
std::shared_ptr<DataAbilityOperationBuilder> DataAbilityOperationBuilder::WithInterruptionAllowed(bool interrupted)
|
||||
{
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithInterruptionAllowed start");
|
||||
APP_LOGI("DataAbilityOperationBuilder::WithInterruptionAllowed interrupted=%{public}d", interrupted);
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithInterruptionAllowed start");
|
||||
HILOG_INFO("DataAbilityOperationBuilder::WithInterruptionAllowed interrupted=%{public}d", interrupted);
|
||||
if (type_ != DataAbilityOperation::TYPE_INSERT && type_ != DataAbilityOperation::TYPE_UPDATE &&
|
||||
type_ != DataAbilityOperation::TYPE_ASSERT && type_ != DataAbilityOperation::TYPE_DELETE) {
|
||||
APP_LOGE("DataAbilityOperationBuilder::withInterruptionAllowed only inserts, updates, delete, and asserts can "
|
||||
"have value back-references, type=%{public}d",
|
||||
HILOG_ERROR(
|
||||
"DataAbilityOperationBuilder::withInterruptionAllowed only inserts, updates, delete, and asserts can "
|
||||
"have value back-references, type=%{public}d",
|
||||
type_);
|
||||
return nullptr;
|
||||
}
|
||||
interrupted_ = interrupted;
|
||||
APP_LOGD("DataAbilityOperationBuilder::WithInterruptionAllowed end");
|
||||
HILOG_DEBUG("DataAbilityOperationBuilder::WithInterruptionAllowed end");
|
||||
return shared_from_this();
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_macro.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -87,7 +88,7 @@ DataAbilityResult *DataAbilityResult::CreateFromParcel(Parcel &parcel)
|
||||
{
|
||||
DataAbilityResult *dataAbilityResult = new (std::nothrow) DataAbilityResult(parcel);
|
||||
if (dataAbilityResult == nullptr) {
|
||||
APP_LOGE("DataAbilityResult::CreateFromParcel dataAbilityResult is nullptr");
|
||||
HILOG_ERROR("DataAbilityResult::CreateFromParcel dataAbilityResult is nullptr");
|
||||
}
|
||||
return dataAbilityResult;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include "datashare_connection.h"
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "datashare_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -52,18 +52,18 @@ sptr<DataShareConnection> DataShareConnection::GetInstance()
|
||||
void DataShareConnection::OnAbilityConnectDone(
|
||||
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
if (remoteObject == nullptr) {
|
||||
APP_LOGE("DataShareConnection::OnAbilityConnectDone failed, remote is nullptr");
|
||||
HILOG_ERROR("DataShareConnection::OnAbilityConnectDone failed, remote is nullptr");
|
||||
return;
|
||||
}
|
||||
dataShareProxy_ = iface_cast<DataShareProxy>(remoteObject);
|
||||
if (dataShareProxy_ == nullptr) {
|
||||
APP_LOGE("DataShareConnection::OnAbilityConnectDone failed, dataShareProxy_ is nullptr");
|
||||
HILOG_ERROR("DataShareConnection::OnAbilityConnectDone failed, dataShareProxy_ is nullptr");
|
||||
return;
|
||||
}
|
||||
isConnected_.store(true);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,10 +77,10 @@ void DataShareConnection::OnAbilityConnectDone(
|
||||
*/
|
||||
void DataShareConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
dataShareProxy_ = nullptr;
|
||||
isConnected_.store(false);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
HILOG_INFO("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,9 +88,9 @@ void DataShareConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName
|
||||
*/
|
||||
void DataShareConnection::ConnectDataShareExtAbility(const AAFwk::Want &want, const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, this, token);
|
||||
APP_LOGI("%{public}s called end, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s called end, ret=%{public}d", __func__, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,11 +98,11 @@ void DataShareConnection::ConnectDataShareExtAbility(const AAFwk::Want &want, co
|
||||
*/
|
||||
void DataShareConnection::DisconnectDataShareExtAbility()
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
HILOG_INFO("%{public}s called begin", __func__);
|
||||
dataShareProxy_ = nullptr;
|
||||
isConnected_.store(false);
|
||||
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(this);
|
||||
APP_LOGI("%{public}s called end, ret=%{public}d", __func__, ret);
|
||||
HILOG_INFO("%{public}s called end, ret=%{public}d", __func__, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,11 +19,11 @@
|
||||
#include <string_ex.h>
|
||||
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_observer_interface.h"
|
||||
#include "data_ability_operation.h"
|
||||
#include "data_ability_predicates.h"
|
||||
#include "data_ability_result.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "ishared_result_set.h"
|
||||
#include "pac_map.h"
|
||||
@ -33,7 +33,7 @@ namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
std::vector<std::string> DataShareProxy::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
std::vector<std::string> types;
|
||||
|
||||
MessageParcel data;
|
||||
@ -41,50 +41,50 @@ std::vector<std::string> DataShareProxy::GetFileTypes(const Uri &uri, const std:
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return types;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return types;
|
||||
}
|
||||
|
||||
if (!data.WriteString(mimeTypeFilter)) {
|
||||
APP_LOGE("fail to WriteString mimeTypeFilter");
|
||||
HILOG_ERROR("fail to WriteString mimeTypeFilter");
|
||||
return types;
|
||||
}
|
||||
|
||||
int32_t err = Remote()->SendRequest(CMD_GET_FILE_TYPES, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("GetFileTypes fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("GetFileTypes fail to SendRequest. err: %d", err);
|
||||
}
|
||||
|
||||
if (!reply.ReadStringVector(&types)) {
|
||||
APP_LOGE("fail to ReadStringVector types");
|
||||
HILOG_ERROR("fail to ReadStringVector types");
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return types;
|
||||
}
|
||||
|
||||
int DataShareProxy::OpenFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
int fd = -1;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (!data.WriteString(mode)) {
|
||||
APP_LOGE("fail to WriteString mode");
|
||||
HILOG_ERROR("fail to WriteString mode");
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -92,37 +92,37 @@ int DataShareProxy::OpenFile(const Uri &uri, const std::string &mode)
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_OPEN_FILE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("OpenFile fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("OpenFile fail to SendRequest. err: %d", err);
|
||||
return fd;
|
||||
}
|
||||
|
||||
fd = reply.ReadFileDescriptor();
|
||||
if (fd == -1) {
|
||||
APP_LOGE("fail to ReadFileDescriptor fd");
|
||||
HILOG_ERROR("fail to ReadFileDescriptor fd");
|
||||
return fd;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int DataShareProxy::OpenRawFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
int fd = -1;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (!data.WriteString(mode)) {
|
||||
APP_LOGE("fail to WriteString mode");
|
||||
HILOG_ERROR("fail to WriteString mode");
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -130,36 +130,36 @@ int DataShareProxy::OpenRawFile(const Uri &uri, const std::string &mode)
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_OPEN_RAW_FILE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("OpenRawFile fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("OpenRawFile fail to SendRequest. err: %d", err);
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(fd)) {
|
||||
APP_LOGE("fail to ReadInt32 fd");
|
||||
HILOG_ERROR("fail to ReadInt32 fd");
|
||||
return fd;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int DataShareProxy::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
int index = -1;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&value)) {
|
||||
APP_LOGE("fail to WriteParcelable value");
|
||||
HILOG_ERROR("fail to WriteParcelable value");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -167,42 +167,42 @@ int DataShareProxy::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value)
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_INSERT, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("Insert fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("Insert fail to SendRequest. err: %d", err);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(index)) {
|
||||
APP_LOGE("fail to ReadInt32 index");
|
||||
HILOG_ERROR("fail to ReadInt32 index");
|
||||
return index;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return index;
|
||||
}
|
||||
|
||||
int DataShareProxy::Update(const Uri &uri, const NativeRdb::ValuesBucket &value,
|
||||
const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
int index = -1;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&value)) {
|
||||
APP_LOGE("fail to WriteParcelable value");
|
||||
HILOG_ERROR("fail to WriteParcelable value");
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&predicates)) {
|
||||
APP_LOGE("fail to WriteParcelable predicates");
|
||||
HILOG_ERROR("fail to WriteParcelable predicates");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -210,36 +210,36 @@ int DataShareProxy::Update(const Uri &uri, const NativeRdb::ValuesBucket &value,
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_UPDATE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("Update fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("Update fail to SendRequest. err: %d", err);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(index)) {
|
||||
APP_LOGE("fail to ReadInt32 index");
|
||||
HILOG_ERROR("fail to ReadInt32 index");
|
||||
return index;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return index;
|
||||
}
|
||||
|
||||
int DataShareProxy::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
int index = -1;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&predicates)) {
|
||||
APP_LOGE("fail to WriteParcelable predicates");
|
||||
HILOG_ERROR("fail to WriteParcelable predicates");
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -247,41 +247,41 @@ int DataShareProxy::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicate
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_DELETE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("Delete fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("Delete fail to SendRequest. err: %d", err);
|
||||
return index;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(index)) {
|
||||
APP_LOGE("fail to ReadInt32 index");
|
||||
HILOG_ERROR("fail to ReadInt32 index");
|
||||
return index;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return index;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> DataShareProxy::Query(const Uri &uri,
|
||||
std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!data.WriteStringVector(columns)) {
|
||||
APP_LOGE("fail to WriteStringVector columns");
|
||||
HILOG_ERROR("fail to WriteStringVector columns");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&predicates)) {
|
||||
APP_LOGE("fail to WriteParcelable predicates");
|
||||
HILOG_ERROR("fail to WriteParcelable predicates");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -289,24 +289,24 @@ std::shared_ptr<NativeRdb::AbsSharedResultSet> DataShareProxy::Query(const Uri &
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_QUERY, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("Query fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("Query fail to SendRequest. err: %d", err);
|
||||
return nullptr;
|
||||
}
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return OHOS::NativeRdb::ISharedResultSet::ReadFromParcel(reply);
|
||||
}
|
||||
|
||||
std::string DataShareProxy::GetType(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
std::string type;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return type;
|
||||
}
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -314,44 +314,44 @@ std::string DataShareProxy::GetType(const Uri &uri)
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_GET_TYPE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("GetFileTypes fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("GetFileTypes fail to SendRequest. err: %d", err);
|
||||
return type;
|
||||
}
|
||||
|
||||
type = reply.ReadString();
|
||||
if (type.empty()) {
|
||||
APP_LOGE("fail to ReadString type");
|
||||
HILOG_ERROR("fail to ReadString type");
|
||||
return type;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return type;
|
||||
}
|
||||
|
||||
int DataShareProxy::BatchInsert(const Uri &uri, const std::vector<NativeRdb::ValuesBucket> &values)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
int ret = -1;
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int count = values.size();
|
||||
if (!data.WriteInt32(count)) {
|
||||
APP_LOGE("fail to WriteInt32 ret");
|
||||
HILOG_ERROR("fail to WriteInt32 ret");
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (!data.WriteParcelable(&values[i])) {
|
||||
APP_LOGE("fail to WriteParcelable ret, index = %{public}d", i);
|
||||
HILOG_ERROR("fail to WriteParcelable ret, index = %{public}d", i);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -360,35 +360,35 @@ int DataShareProxy::BatchInsert(const Uri &uri, const std::vector<NativeRdb::Val
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_BATCH_INSERT, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("GetFileTypes fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("GetFileTypes fail to SendRequest. err: %d", err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32(ret)) {
|
||||
APP_LOGE("fail to ReadInt32 index");
|
||||
HILOG_ERROR("fail to ReadInt32 index");
|
||||
return ret;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DataShareProxy::RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("%{public}s failed to WriteParcelable uri ", __func__);
|
||||
HILOG_ERROR("%{public}s failed to WriteParcelable uri ", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(dataObserver->AsObject())) {
|
||||
APP_LOGE("%{public}s failed to WriteParcelable dataObserver ", __func__);
|
||||
HILOG_ERROR("%{public}s failed to WriteParcelable dataObserver ", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -396,31 +396,31 @@ bool DataShareProxy::RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbi
|
||||
MessageOption option;
|
||||
int32_t result = Remote()->SendRequest(CMD_REGISTER_OBSERVER, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32());
|
||||
HILOG_INFO("%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32());
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s end.", __func__);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataShareProxy::UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("%{public}s failed to WriteParcelable uri ", __func__);
|
||||
HILOG_ERROR("%{public}s failed to WriteParcelable uri ", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(dataObserver->AsObject())) {
|
||||
APP_LOGE("%{public}s failed to WriteParcelable dataObserver ", __func__);
|
||||
HILOG_ERROR("%{public}s failed to WriteParcelable dataObserver ", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -428,26 +428,26 @@ bool DataShareProxy::UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataA
|
||||
MessageOption option;
|
||||
int32_t result = Remote()->SendRequest(CMD_UNREGISTER_OBSERVER, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32());
|
||||
HILOG_INFO("%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32());
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataShareProxy::NotifyChange(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("%{public}s failed to WriteParcelable uri ", __func__);
|
||||
HILOG_ERROR("%{public}s failed to WriteParcelable uri ", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -455,27 +455,27 @@ bool DataShareProxy::NotifyChange(const Uri &uri)
|
||||
MessageOption option;
|
||||
int32_t result = Remote()->SendRequest(CMD_NOTIFY_CHANGE, data, reply, option);
|
||||
if (result == ERR_NONE) {
|
||||
APP_LOGI("%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32());
|
||||
HILOG_INFO("%{public}s SendRequest ok, retval is %{public}d", __func__, reply.ReadInt32());
|
||||
} else {
|
||||
APP_LOGE("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
HILOG_ERROR("%{public}s SendRequest error, result=%{public}d", __func__, result);
|
||||
return false;
|
||||
}
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
Uri DataShareProxy::NormalizeUri(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
Uri urivalue("");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return urivalue;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return urivalue;
|
||||
}
|
||||
|
||||
@ -483,31 +483,31 @@ Uri DataShareProxy::NormalizeUri(const Uri &uri)
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_NORMALIZE_URI, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("NormalizeUri fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("NormalizeUri fail to SendRequest. err: %d", err);
|
||||
return urivalue;
|
||||
}
|
||||
|
||||
std::unique_ptr<Uri> info(reply.ReadParcelable<Uri>());
|
||||
if (!info) {
|
||||
APP_LOGE("ReadParcelable value is nullptr.");
|
||||
HILOG_ERROR("ReadParcelable value is nullptr.");
|
||||
return urivalue;
|
||||
}
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return *info;
|
||||
}
|
||||
|
||||
Uri DataShareProxy::DenormalizeUri(const Uri &uri)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
Uri urivalue("");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return urivalue;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
APP_LOGE("fail to WriteParcelable uri");
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return urivalue;
|
||||
}
|
||||
|
||||
@ -515,41 +515,41 @@ Uri DataShareProxy::DenormalizeUri(const Uri &uri)
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_DENORMALIZE_URI, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("DenormalizeUri fail to SendRequest. err: %d", err);
|
||||
HILOG_ERROR("DenormalizeUri fail to SendRequest. err: %d", err);
|
||||
return urivalue;
|
||||
}
|
||||
|
||||
std::unique_ptr<Uri> info(reply.ReadParcelable<Uri>());
|
||||
if (!info) {
|
||||
APP_LOGE("ReadParcelable value is nullptr.");
|
||||
HILOG_ERROR("ReadParcelable value is nullptr.");
|
||||
return urivalue;
|
||||
}
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return *info;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> DataShareProxy::ExecuteBatch(
|
||||
const std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> &operations)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
MessageParcel data;
|
||||
std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> results;
|
||||
results.clear();
|
||||
|
||||
if (!data.WriteInterfaceToken(DataShareProxy::GetDescriptor())) {
|
||||
APP_LOGE("%{public}s WriteInterfaceToken failed", __func__);
|
||||
HILOG_ERROR("%{public}s WriteInterfaceToken failed", __func__);
|
||||
return results;
|
||||
}
|
||||
|
||||
int count = operations.size();
|
||||
if (!data.WriteInt32(count)) {
|
||||
APP_LOGE("fail to WriteInt32 ret");
|
||||
HILOG_ERROR("fail to WriteInt32 ret");
|
||||
return results;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (!data.WriteParcelable(operations[i].get())) {
|
||||
APP_LOGE("fail to WriteParcelable ret, index = %{public}d", i);
|
||||
HILOG_ERROR("fail to WriteParcelable ret, index = %{public}d", i);
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@ -558,26 +558,26 @@ std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> DataShareProxy::Exec
|
||||
MessageOption option;
|
||||
int32_t err = Remote()->SendRequest(CMD_EXECUTE_BATCH, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
APP_LOGE("fail to SendRequest. err: %{public}d", err);
|
||||
HILOG_ERROR("fail to SendRequest. err: %{public}d", err);
|
||||
return results;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
if (!reply.ReadInt32(total)) {
|
||||
APP_LOGE("fail to ReadInt32 count %{public}d", total);
|
||||
HILOG_ERROR("fail to ReadInt32 count %{public}d", total);
|
||||
return results;
|
||||
}
|
||||
|
||||
for (int i = 0; i < total; i++) {
|
||||
AppExecFwk::DataAbilityResult *result = reply.ReadParcelable<AppExecFwk::DataAbilityResult>();
|
||||
if (result == nullptr) {
|
||||
APP_LOGE("result is nullptr, index = %{public}d", i);
|
||||
HILOG_ERROR("result is nullptr, index = %{public}d", i);
|
||||
return results;
|
||||
}
|
||||
std::shared_ptr<AppExecFwk::DataAbilityResult> dataAbilityResult(result);
|
||||
results.push_back(dataAbilityResult);
|
||||
}
|
||||
APP_LOGI("%{public}s end successfully.", __func__);
|
||||
HILOG_INFO("%{public}s end successfully.", __func__);
|
||||
return results;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
#include "datashare_stub.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_observer_interface.h"
|
||||
#include "data_ability_operation.h"
|
||||
#include "data_ability_predicates.h"
|
||||
#include "data_ability_result.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "ishared_result_set.h"
|
||||
#include "values_bucket.h"
|
||||
@ -53,11 +53,11 @@ DataShareStub::~DataShareStub()
|
||||
int DataShareStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
|
||||
MessageOption& option)
|
||||
{
|
||||
APP_LOGI("%{public}s Received stub message: %{public}d", __func__, code);
|
||||
HILOG_INFO("%{public}s Received stub message: %{public}d", __func__, code);
|
||||
std::u16string descriptor = DataShareStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
APP_LOGI("local descriptor is not equal to remote");
|
||||
HILOG_INFO("local descriptor is not equal to remote");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ int DataShareStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessagePa
|
||||
return (this->*(itFunc->second))(data, reply);
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s remote request unhandled: %{public}d", __func__, code);
|
||||
HILOG_INFO("%{public}s remote request unhandled: %{public}d", __func__, code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
@ -74,17 +74,17 @@ ErrCode DataShareStub::CmdGetFileTypes(MessageParcel &data, MessageParcel &reply
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::string mimeTypeFilter = data.ReadString();
|
||||
if (mimeTypeFilter.empty()) {
|
||||
APP_LOGE("DataShareStub mimeTypeFilter is nullptr");
|
||||
HILOG_ERROR("DataShareStub mimeTypeFilter is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::vector<std::string> types = GetFileTypes(*uri, mimeTypeFilter);
|
||||
if (!reply.WriteStringVector(types)) {
|
||||
APP_LOGE("fail to WriteStringVector types");
|
||||
HILOG_ERROR("fail to WriteStringVector types");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -94,21 +94,21 @@ ErrCode DataShareStub::CmdOpenFile(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::string mode = data.ReadString();
|
||||
if (mode.empty()) {
|
||||
APP_LOGE("DataShareStub mode is nullptr");
|
||||
HILOG_ERROR("DataShareStub mode is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int fd = OpenFile(*uri, mode);
|
||||
if (fd < 0) {
|
||||
APP_LOGE("OpenFile fail, fd is %{pubilc}d", fd);
|
||||
HILOG_ERROR("OpenFile fail, fd is %{pubilc}d", fd);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!reply.WriteFileDescriptor(fd)) {
|
||||
APP_LOGE("fail to WriteFileDescriptor fd");
|
||||
HILOG_ERROR("fail to WriteFileDescriptor fd");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -118,17 +118,17 @@ ErrCode DataShareStub::CmdOpenRawFile(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::string mode = data.ReadString();
|
||||
if (mode.empty()) {
|
||||
APP_LOGE("DataShareStub mode is nullptr");
|
||||
HILOG_ERROR("DataShareStub mode is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int fd = OpenRawFile(*uri, mode);
|
||||
if (!reply.WriteInt32(fd)) {
|
||||
APP_LOGE("fail to WriteInt32 fd");
|
||||
HILOG_ERROR("fail to WriteInt32 fd");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -138,20 +138,20 @@ ErrCode DataShareStub::CmdInsert(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> value(data.ReadParcelable<NativeRdb::ValuesBucket>());
|
||||
if (value == nullptr) {
|
||||
APP_LOGE("ReadParcelable value is nullptr");
|
||||
HILOG_ERROR("ReadParcelable value is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int index = Insert(*uri, *value);
|
||||
if (!reply.WriteInt32(index)) {
|
||||
APP_LOGE("fail to WriteInt32 index");
|
||||
HILOG_ERROR("fail to WriteInt32 index");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
APP_LOGI("DataShareStub::CmdInsertInner end");
|
||||
HILOG_INFO("DataShareStub::CmdInsertInner end");
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@ -159,23 +159,23 @@ ErrCode DataShareStub::CmdUpdate(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> value(data.ReadParcelable<NativeRdb::ValuesBucket>());
|
||||
if (value == nullptr) {
|
||||
APP_LOGE("ReadParcelable value is nullptr");
|
||||
HILOG_ERROR("ReadParcelable value is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(
|
||||
data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
if (predicates == nullptr) {
|
||||
APP_LOGE("ReadParcelable predicates is nullptr");
|
||||
HILOG_ERROR("ReadParcelable predicates is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int index = Update(*uri, *value, *predicates);
|
||||
if (!reply.WriteInt32(index)) {
|
||||
APP_LOGE("fail to WriteInt32 index");
|
||||
HILOG_ERROR("fail to WriteInt32 index");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -185,18 +185,18 @@ ErrCode DataShareStub::CmdDelete(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(
|
||||
data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
if (predicates == nullptr) {
|
||||
APP_LOGE("ReadParcelable predicates is nullptr");
|
||||
HILOG_ERROR("ReadParcelable predicates is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int index = Delete(*uri, *predicates);
|
||||
if (!reply.WriteInt32(index)) {
|
||||
APP_LOGE("fail to WriteInt32 index");
|
||||
HILOG_ERROR("fail to WriteInt32 index");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -206,31 +206,31 @@ ErrCode DataShareStub::CmdQuery(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::vector<std::string> columns;
|
||||
if (!data.ReadStringVector(&columns)) {
|
||||
APP_LOGE("fail to ReadStringVector columns");
|
||||
HILOG_ERROR("fail to ReadStringVector columns");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(
|
||||
data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
if (predicates == nullptr) {
|
||||
APP_LOGE("ReadParcelable predicates is nullptr");
|
||||
HILOG_ERROR("ReadParcelable predicates is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
auto resultSet = Query(*uri, columns, *predicates);
|
||||
if (resultSet == nullptr) {
|
||||
APP_LOGE("fail to WriteParcelable resultSet");
|
||||
HILOG_ERROR("fail to WriteParcelable resultSet");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
auto result = NativeRdb::ISharedResultSet::WriteToParcel(std::move(resultSet), reply);
|
||||
if (result == nullptr) {
|
||||
APP_LOGE("!resultSet->Marshalling(reply)");
|
||||
HILOG_ERROR("!resultSet->Marshalling(reply)");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
APP_LOGI("DataShareStub::CmdQueryInner end");
|
||||
HILOG_INFO("DataShareStub::CmdQueryInner end");
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@ -238,12 +238,12 @@ ErrCode DataShareStub::CmdGetType(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::string type = GetType(*uri);
|
||||
if (!reply.WriteString(type)) {
|
||||
APP_LOGE("fail to WriteString type");
|
||||
HILOG_ERROR("fail to WriteString type");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -253,13 +253,13 @@ ErrCode DataShareStub::CmdBatchInsert(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
if (!data.ReadInt32(count)) {
|
||||
APP_LOGE("fail to ReadInt32 index");
|
||||
HILOG_ERROR("fail to ReadInt32 index");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ ErrCode DataShareStub::CmdBatchInsert(MessageParcel &data, MessageParcel &reply)
|
||||
for (int i = 0; i < count; i++) {
|
||||
NativeRdb::ValuesBucket *value = data.ReadParcelable<NativeRdb::ValuesBucket>();
|
||||
if (value == nullptr) {
|
||||
APP_LOGE("DataShareStub value is nullptr, index = %{public}d", i);
|
||||
HILOG_ERROR("DataShareStub value is nullptr, index = %{public}d", i);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
values.emplace_back(*value);
|
||||
@ -275,7 +275,7 @@ ErrCode DataShareStub::CmdBatchInsert(MessageParcel &data, MessageParcel &reply)
|
||||
|
||||
int ret = BatchInsert(*uri, values);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
APP_LOGE("fail to WriteInt32 ret");
|
||||
HILOG_ERROR("fail to WriteInt32 ret");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -286,18 +286,18 @@ ErrCode DataShareStub::CmdRegisterObserver(MessageParcel &data, MessageParcel &r
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
auto obServer = iface_cast<AAFwk::IDataAbilityObserver>(data.ReadParcelable<IRemoteObject>());
|
||||
if (obServer == nullptr) {
|
||||
APP_LOGE("DataShareStub obServer is nullptr");
|
||||
HILOG_ERROR("DataShareStub obServer is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
bool ret = RegisterObserver(*uri, obServer);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
APP_LOGE("fail to WriteInt32 ret");
|
||||
HILOG_ERROR("fail to WriteInt32 ret");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -307,18 +307,18 @@ ErrCode DataShareStub::CmdUnregisterObserver(MessageParcel &data, MessageParcel
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
auto obServer = iface_cast<AAFwk::IDataAbilityObserver>(data.ReadParcelable<IRemoteObject>());
|
||||
if (obServer == nullptr) {
|
||||
APP_LOGE("DataShareStub obServer is nullptr");
|
||||
HILOG_ERROR("DataShareStub obServer is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
bool ret = UnregisterObserver(*uri, obServer);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
APP_LOGE("fail to WriteInt32 ret");
|
||||
HILOG_ERROR("fail to WriteInt32 ret");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -328,13 +328,13 @@ ErrCode DataShareStub::CmdNotifyChange(MessageParcel &data, MessageParcel &reply
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
bool ret = NotifyChange(*uri);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
APP_LOGE("fail to WriteInt32 ret");
|
||||
HILOG_ERROR("fail to WriteInt32 ret");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -344,14 +344,14 @@ ErrCode DataShareStub::CmdNormalizeUri(MessageParcel &data, MessageParcel &reply
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
Uri ret("");
|
||||
ret = NormalizeUri(*uri);
|
||||
if (!reply.WriteParcelable(&ret)) {
|
||||
APP_LOGE("fail to WriteParcelable type");
|
||||
HILOG_ERROR("fail to WriteParcelable type");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -361,14 +361,14 @@ ErrCode DataShareStub::CmdDenormalizeUri(MessageParcel &data, MessageParcel &rep
|
||||
{
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
APP_LOGE("DataShareStub uri is nullptr");
|
||||
HILOG_ERROR("DataShareStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
Uri ret("");
|
||||
ret = DenormalizeUri(*uri);
|
||||
if (!reply.WriteParcelable(&ret)) {
|
||||
APP_LOGE("fail to WriteParcelable type");
|
||||
HILOG_ERROR("fail to WriteParcelable type");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
@ -376,18 +376,18 @@ ErrCode DataShareStub::CmdDenormalizeUri(MessageParcel &data, MessageParcel &rep
|
||||
|
||||
ErrCode DataShareStub::CmdExecuteBatch(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGI("DataShareStub::CmdExecuteBatchInner start");
|
||||
HILOG_INFO("DataShareStub::CmdExecuteBatchInner start");
|
||||
int count = 0;
|
||||
if (!data.ReadInt32(count)) {
|
||||
APP_LOGE("DataShareStub::CmdExecuteBatchInner fail to ReadInt32 count");
|
||||
HILOG_ERROR("DataShareStub::CmdExecuteBatchInner fail to ReadInt32 count");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
APP_LOGI("DataShareStub::CmdExecuteBatchInner count:%{public}d", count);
|
||||
HILOG_INFO("DataShareStub::CmdExecuteBatchInner count:%{public}d", count);
|
||||
std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> operations;
|
||||
for (int i = 0; i < count; i++) {
|
||||
AppExecFwk::DataAbilityOperation *operation = data.ReadParcelable<AppExecFwk::DataAbilityOperation>();
|
||||
if (operation == nullptr) {
|
||||
APP_LOGE("DataShareStub::CmdExecuteBatchInner operation is nullptr, index = %{public}d", i);
|
||||
HILOG_ERROR("DataShareStub::CmdExecuteBatchInner operation is nullptr, index = %{public}d", i);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<AppExecFwk::DataAbilityOperation> dataAbilityOperation(operation);
|
||||
@ -397,22 +397,22 @@ ErrCode DataShareStub::CmdExecuteBatch(MessageParcel &data, MessageParcel &reply
|
||||
std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> results = ExecuteBatch(operations);
|
||||
int total = results.size();
|
||||
if (!reply.WriteInt32(total)) {
|
||||
APP_LOGE("DataShareStub::CmdExecuteBatchInner fail to WriteInt32 ret");
|
||||
HILOG_ERROR("DataShareStub::CmdExecuteBatchInner fail to WriteInt32 ret");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
APP_LOGI("DataShareStub::CmdExecuteBatchInner total:%{public}d", total);
|
||||
HILOG_INFO("DataShareStub::CmdExecuteBatchInner total:%{public}d", total);
|
||||
for (int i = 0; i < total; i++) {
|
||||
if (results[i] == nullptr) {
|
||||
APP_LOGE("DataShareStub::CmdExecuteBatchInner results[i] is nullptr, index = %{public}d", i);
|
||||
HILOG_ERROR("DataShareStub::CmdExecuteBatchInner results[i] is nullptr, index = %{public}d", i);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!reply.WriteParcelable(results[i].get())) {
|
||||
APP_LOGE(
|
||||
HILOG_ERROR(
|
||||
"DataShareStub::CmdExecuteBatchInner fail to WriteParcelable operation, index = %{public}d", i);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
APP_LOGI("DataShareStub::CmdExecuteBatchInner end");
|
||||
HILOG_INFO("DataShareStub::CmdExecuteBatchInner end");
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "dummy_data_ability_predicates.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -43,7 +43,7 @@ DataAbilityPredicates *DataAbilityPredicates::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DataAbilityPredicates *dataAbilityPredicates = new (std::nothrow) DataAbilityPredicates();
|
||||
if (dataAbilityPredicates && !dataAbilityPredicates->ReadFromParcel(parcel)) {
|
||||
APP_LOGE("DataAbilityPredicates::Unmarshalling ReadFromParcel failed");
|
||||
HILOG_ERROR("DataAbilityPredicates::Unmarshalling ReadFromParcel failed");
|
||||
delete dataAbilityPredicates;
|
||||
dataAbilityPredicates = nullptr;
|
||||
}
|
||||
@ -58,7 +58,7 @@ DataAbilityPredicates *DataAbilityPredicates::Unmarshalling(Parcel &parcel)
|
||||
bool DataAbilityPredicates::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
|
||||
APP_LOGE("dataAbilityPredicates::Marshalling WriteString16 failed");
|
||||
HILOG_ERROR("dataAbilityPredicates::Marshalling WriteString16 failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "dummy_result_set.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -43,7 +43,7 @@ ResultSet *ResultSet::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ResultSet *resultSet = new (std::nothrow) ResultSet();
|
||||
if (resultSet && !resultSet->ReadFromParcel(parcel)) {
|
||||
APP_LOGE("ResultSet::Unmarshalling ReadFromParcel failed");
|
||||
HILOG_ERROR("ResultSet::Unmarshalling ReadFromParcel failed");
|
||||
delete resultSet;
|
||||
resultSet = nullptr;
|
||||
}
|
||||
@ -58,7 +58,7 @@ ResultSet *ResultSet::Unmarshalling(Parcel &parcel)
|
||||
bool ResultSet::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
|
||||
APP_LOGE("ResultSet::Marshalling WriteString16 failed");
|
||||
HILOG_ERROR("ResultSet::Marshalling WriteString16 failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "dummy_values_bucket.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -43,7 +43,7 @@ ValuesBucket *ValuesBucket::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ValuesBucket *valuesBucket = new (std::nothrow) ValuesBucket();
|
||||
if (valuesBucket && !valuesBucket->ReadFromParcel(parcel)) {
|
||||
APP_LOGE("ValuesBucket::Unmarshalling ReadFromParcel failed");
|
||||
HILOG_ERROR("ValuesBucket::Unmarshalling ReadFromParcel failed");
|
||||
delete valuesBucket;
|
||||
valuesBucket = nullptr;
|
||||
}
|
||||
@ -58,7 +58,7 @@ ValuesBucket *ValuesBucket::Unmarshalling(Parcel &parcel)
|
||||
bool ValuesBucket::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
|
||||
APP_LOGE("valuesBucket::Marshalling WriteString16 failed");
|
||||
HILOG_ERROR("valuesBucket::Marshalling WriteString16 failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -13,11 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "form_constants.h"
|
||||
#include "form_host_client.h"
|
||||
#include "form_js_event_handler.h"
|
||||
#include "form_mgr.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -26,7 +26,7 @@ FormJsEventHandler::FormJsEventHandler(
|
||||
const std::shared_ptr<EventRunner> &runner, const std::shared_ptr<Ability> &ability, const FormJsInfo &formJsInfo)
|
||||
: EventHandler(runner), formJsInfo_(formJsInfo), ability_(ability)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,12 +36,12 @@ FormJsEventHandler::FormJsEventHandler(
|
||||
*/
|
||||
void FormJsEventHandler::ProcessEvent(const InnerEvent::Pointer &event)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
if (!event) {
|
||||
APP_LOGE("%{public}s, param illegal, event is nullptr", __func__);
|
||||
HILOG_ERROR("%{public}s, param illegal, event is nullptr", __func__);
|
||||
return;
|
||||
}
|
||||
APP_LOGD("%{public}s, inner event id obtained: %u.", __func__, event->GetInnerEventId());
|
||||
HILOG_DEBUG("%{public}s, inner event id obtained: %u.", __func__, event->GetInnerEventId());
|
||||
|
||||
switch (event->GetInnerEventId()) {
|
||||
case FORM_ROUTE_EVENT: {
|
||||
@ -57,7 +57,7 @@ void FormJsEventHandler::ProcessEvent(const InnerEvent::Pointer &event)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
APP_LOGW("unsupported event.");
|
||||
HILOG_WARN("unsupported event.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -69,14 +69,14 @@ void FormJsEventHandler::ProcessEvent(const InnerEvent::Pointer &event)
|
||||
*/
|
||||
void FormJsEventHandler::ProcessRouterEvent(Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
if (!IsSystemApp()) {
|
||||
APP_LOGW("%{public}s, not system application, cannot mixture package router", __func__);
|
||||
HILOG_WARN("%{public}s, not system application, cannot mixture package router", __func__);
|
||||
return;
|
||||
}
|
||||
if (!want.HasParameter(Constants::PARAM_FORM_ABILITY_NAME_KEY)) {
|
||||
APP_LOGE("%{public}s, param illegal, abilityName is not exist", __func__);
|
||||
HILOG_ERROR("%{public}s, param illegal, abilityName is not exist", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,34 +91,35 @@ void FormJsEventHandler::ProcessRouterEvent(Want &want)
|
||||
*/
|
||||
void FormJsEventHandler::ProcessMessageEvent(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
if (!want.HasParameter(Constants::PARAM_FORM_IDENTITY_KEY)) {
|
||||
APP_LOGE("%{public}s, formid is not exist", __func__);
|
||||
HILOG_ERROR("%{public}s, formid is not exist", __func__);
|
||||
return;
|
||||
}
|
||||
std::string strFormId = want.GetStringParam(Constants::PARAM_FORM_IDENTITY_KEY);
|
||||
int64_t formId = std::stoll(strFormId);
|
||||
if (formId <= 0) {
|
||||
APP_LOGE("%{public}s error, The passed formid is invalid. Its value must be larger than 0.", __func__);
|
||||
HILOG_ERROR("%{public}s error, The passed formid is invalid. Its value must be larger than 0.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!want.HasParameter(Constants::PARAM_MESSAGE_KEY)) {
|
||||
APP_LOGE("%{public}s, message info is not exist", __func__);
|
||||
HILOG_ERROR("%{public}s, message info is not exist", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FormMgr::GetRecoverStatus() == Constants::IN_RECOVERING) {
|
||||
APP_LOGE("%{public}s error, form is in recover status, can't do action on form.", __func__);
|
||||
HILOG_ERROR("%{public}s error, form is in recover status, can't do action on form.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
// requestForm request to fms
|
||||
int resultCode = FormMgr::GetInstance().MessageEvent(formId, want, FormHostClient::GetInstance());
|
||||
if (resultCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s error, failed to notify the form service that the form user's lifecycle is updated, error "
|
||||
"code is %{public}d.",
|
||||
HILOG_ERROR(
|
||||
"%{public}s error, failed to notify the form service that the form user's lifecycle is updated, error "
|
||||
"code is %{public}d.",
|
||||
__func__,
|
||||
resultCode);
|
||||
return;
|
||||
@ -127,17 +128,17 @@ void FormJsEventHandler::ProcessMessageEvent(const Want &want)
|
||||
|
||||
bool FormJsEventHandler::IsSystemApp() const
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
int32_t callingUid = IPCSkeleton::GetCallingUid();
|
||||
if (callingUid > Constants::MAX_SYSTEM_APP_UID) {
|
||||
APP_LOGW("%{public}s warn, callingUid is %{public}d, which is larger than %{public}d.",
|
||||
HILOG_WARN("%{public}s warn, callingUid is %{public}d, which is larger than %{public}d.",
|
||||
__func__,
|
||||
callingUid,
|
||||
Constants::MAX_SYSTEM_APP_UID);
|
||||
return false;
|
||||
} else {
|
||||
APP_LOGD("%{public}s, callingUid = %{public}d.", __func__, callingUid);
|
||||
HILOG_DEBUG("%{public}s, callingUid = %{public}d.", __func__, callingUid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "form_supply_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "permission/permission.h"
|
||||
#include "permission/permission_kit.h"
|
||||
@ -42,7 +42,7 @@ int FormProviderClient::AcquireProviderFormInfo(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
Want newWant(want);
|
||||
newWant.SetParam(Constants::ACQUIRE_TYPE, want.GetIntParam(Constants::ACQUIRE_TYPE, 0));
|
||||
@ -52,16 +52,16 @@ int FormProviderClient::AcquireProviderFormInfo(
|
||||
newWant.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formId));
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
FormProviderInfo formProviderInfo;
|
||||
newWant.SetParam(Constants::PROVIDER_FLAG, ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY);
|
||||
return HandleAcquire(formProviderInfo, newWant, callerToken);
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come, %{public}s.", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
HILOG_INFO("%{public}s come, %{public}s.", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s warn, AcquireProviderFormInfo caller permission denied.", __func__);
|
||||
HILOG_WARN("%{public}s warn, AcquireProviderFormInfo caller permission denied.", __func__);
|
||||
FormProviderInfo formProviderInfo;
|
||||
newWant.SetParam(Constants::PROVIDER_FLAG, ERR_APPEXECFWK_FORM_PERMISSION_DENY);
|
||||
return HandleAcquire(formProviderInfo, newWant, callerToken);
|
||||
@ -73,7 +73,7 @@ int FormProviderClient::AcquireProviderFormInfo(
|
||||
createWant.RemoveParam(Constants::ACQUIRE_TYPE);
|
||||
createWant.RemoveParam(Constants::FORM_SUPPLY_INFO);
|
||||
FormProviderInfo formProviderInfo = ownerAbility->OnCreate(createWant);
|
||||
APP_LOGD("%{public}s, formId: %{public}" PRId64 ", data: %{public}s",
|
||||
HILOG_DEBUG("%{public}s, formId: %{public}" PRId64 ", data: %{public}s",
|
||||
__func__, formId, formProviderInfo.GetFormDataString().c_str());
|
||||
return HandleAcquire(formProviderInfo, newWant, callerToken);
|
||||
}
|
||||
@ -87,24 +87,24 @@ int FormProviderClient::AcquireProviderFormInfo(
|
||||
*/
|
||||
int FormProviderClient::NotifyFormDelete(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
// The error code for business operation.
|
||||
int errorCode = ERR_OK;
|
||||
do {
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
break;
|
||||
}
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s caller permission denied", __func__);
|
||||
HILOG_WARN("%{public}s caller permission denied", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
break;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
HILOG_INFO("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
ownerAbility->OnDelete(formId);
|
||||
} while (false);
|
||||
|
||||
@ -116,7 +116,7 @@ int FormProviderClient::NotifyFormDelete(const int64_t formId, const Want &want,
|
||||
} else {
|
||||
// If errorCode is ERR_OK,return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -134,24 +134,24 @@ int FormProviderClient::NotifyFormsDelete(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
// The error code for business operation.
|
||||
int errorCode = ERR_OK;
|
||||
do {
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
break;
|
||||
}
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s caller permission denied", __func__);
|
||||
HILOG_WARN("%{public}s caller permission denied", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
break;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come,formIds size=%{public}zu, abilityName:%{public}s",
|
||||
HILOG_INFO("%{public}s come,formIds size=%{public}zu, abilityName:%{public}s",
|
||||
__func__, formIds.size(), ownerAbility->GetAbilityName().c_str());
|
||||
for (int64_t formId : formIds) {
|
||||
ownerAbility->OnDelete(formId);
|
||||
@ -166,7 +166,7 @@ int FormProviderClient::NotifyFormsDelete(
|
||||
} else {
|
||||
// If errorCode is ERR_OK,return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -185,25 +185,25 @@ int FormProviderClient::NotifyFormUpdate(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
// The error code for business operation.
|
||||
int errorCode = ERR_OK;
|
||||
do {
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, owner ability is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, owner ability is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGE("%{public}s warn, caller permission denied.", __func__);
|
||||
HILOG_ERROR("%{public}s warn, caller permission denied.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
break;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come, %{public}s.", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
HILOG_INFO("%{public}s come, %{public}s.", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
ownerAbility->OnUpdate(formId);
|
||||
} while (false);
|
||||
|
||||
@ -215,7 +215,7 @@ int FormProviderClient::NotifyFormUpdate(
|
||||
} else {
|
||||
// If errorCode is ERR_OK,return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -235,20 +235,20 @@ int FormProviderClient::EventNotify(
|
||||
const int32_t formVisibleType, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
// The error code for business operation.
|
||||
int errorCode = ERR_OK;
|
||||
do {
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, owner ability is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, owner ability is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s warn, caller permission denied.", __func__);
|
||||
HILOG_WARN("%{public}s warn, caller permission denied.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
break;
|
||||
}
|
||||
@ -258,7 +258,7 @@ int FormProviderClient::EventNotify(
|
||||
formEventsMap.insert(std::make_pair(formId, formVisibleType));
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come, %{public}s.", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
HILOG_INFO("%{public}s come, %{public}s.", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
ownerAbility->OnVisibilityChanged(formEventsMap);
|
||||
} while (false);
|
||||
|
||||
@ -270,7 +270,7 @@ int FormProviderClient::EventNotify(
|
||||
} else {
|
||||
// If errorCode is ERR_OK,return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -288,23 +288,23 @@ int FormProviderClient::NotifyFormCastTempForm(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
// The error code for business operation.
|
||||
int errorCode = ERR_OK;
|
||||
do {
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
break;
|
||||
}
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s caller permission denied", __func__);
|
||||
HILOG_WARN("%{public}s caller permission denied", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
break;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
HILOG_INFO("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
ownerAbility->OnCastTemptoNormal(formId);
|
||||
} while (false);
|
||||
|
||||
@ -316,7 +316,7 @@ int FormProviderClient::NotifyFormCastTempForm(
|
||||
} else {
|
||||
// If errorCode is ERR_OK,return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -335,23 +335,23 @@ int FormProviderClient::FireFormEvent(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
// The error code for business operation.
|
||||
int errorCode = ERR_OK;
|
||||
do {
|
||||
std::shared_ptr<Ability> ownerAbility = GetOwner();
|
||||
if (ownerAbility == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
break;
|
||||
}
|
||||
if (!CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s caller permission denied", __func__);
|
||||
HILOG_WARN("%{public}s caller permission denied", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_PERMISSION_DENY;
|
||||
break;
|
||||
}
|
||||
|
||||
APP_LOGI("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
HILOG_INFO("%{public}s come, %{public}s", __func__, ownerAbility->GetAbilityName().c_str());
|
||||
ownerAbility->OnTriggerEvent(formId, message);
|
||||
} while (false);
|
||||
|
||||
@ -363,7 +363,7 @@ int FormProviderClient::FireFormEvent(
|
||||
} else {
|
||||
// If errorCode is ERR_OK,return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -421,15 +421,15 @@ std::shared_ptr<Ability> FormProviderClient::GetOwner()
|
||||
|
||||
bool FormProviderClient::CheckIsSystemApp() const
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
int32_t callingUid = IPCSkeleton::GetCallingUid();
|
||||
if (callingUid > Constants::MAX_SYSTEM_APP_UID) {
|
||||
APP_LOGW("%{public}s warn, callingUid is %{public}d, which is larger than %{public}d.", __func__, callingUid,
|
||||
HILOG_WARN("%{public}s warn, callingUid is %{public}d, which is larger than %{public}d.", __func__, callingUid,
|
||||
Constants::MAX_SYSTEM_APP_UID);
|
||||
return false;
|
||||
} else {
|
||||
APP_LOGD("%{public}s, callingUid = %{public}d.", __func__, callingUid);
|
||||
HILOG_DEBUG("%{public}s, callingUid = %{public}d.", __func__, callingUid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -439,16 +439,16 @@ int FormProviderClient::HandleAcquire(
|
||||
const Want &newWant,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s start, image state is %{public}d",
|
||||
HILOG_INFO("%{public}s start, image state is %{public}d",
|
||||
__func__, formProviderInfo.GetFormData().GetImageDataState());
|
||||
|
||||
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
|
||||
if (formSupplyClient == nullptr) {
|
||||
APP_LOGW("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
HILOG_WARN("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED;
|
||||
}
|
||||
formSupplyClient->OnAcquire(formProviderInfo, newWant);
|
||||
APP_LOGI("%{public}s end", __func__);
|
||||
HILOG_INFO("%{public}s end", __func__);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -456,11 +456,11 @@ int FormProviderClient::HandleDisconnect(const Want &want, const sptr<IRemoteOb
|
||||
{
|
||||
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
|
||||
if (formSupplyClient == nullptr) {
|
||||
APP_LOGW("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
HILOG_WARN("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED;
|
||||
}
|
||||
|
||||
APP_LOGD("%{public}s come, connectId: %{public}ld.", __func__,
|
||||
HILOG_DEBUG("%{public}s come, connectId: %{public}ld.", __func__,
|
||||
want.GetLongParam(Constants::FORM_CONNECT_ID, 0L));
|
||||
|
||||
formSupplyClient->OnEventHandle(want);
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
#include "string_ex.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "form_extension.h"
|
||||
#include "form_supply_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "permission/permission.h"
|
||||
#include "permission/permission_kit.h"
|
||||
@ -41,10 +41,10 @@ using namespace OHOS::AppExecFwk;
|
||||
int FormExtensionProviderClient::AcquireProviderFormInfo(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
|
||||
if (formSupplyClient == nullptr) {
|
||||
APP_LOGW("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
HILOG_WARN("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ int FormExtensionProviderClient::AcquireProviderFormInfo(const int64_t formId, c
|
||||
connectWant.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formId));
|
||||
|
||||
if (!FormProviderClient::CheckIsSystemApp()) {
|
||||
APP_LOGW("%{public}s warn, AcquireProviderFormInfo caller permission denied.", __func__);
|
||||
HILOG_WARN("%{public}s warn, AcquireProviderFormInfo caller permission denied.", __func__);
|
||||
FormProviderInfo formProviderInfo;
|
||||
connectWant.SetParam(Constants::PROVIDER_FLAG, ERR_APPEXECFWK_FORM_PERMISSION_DENY);
|
||||
return FormProviderClient::HandleAcquire(formProviderInfo, connectWant, callerToken);
|
||||
@ -74,7 +74,7 @@ int FormExtensionProviderClient::AcquireProviderFormInfo(const int64_t formId, c
|
||||
void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
Want connectWant(want);
|
||||
connectWant.SetParam(Constants::ACQUIRE_TYPE, want.GetIntParam(Constants::ACQUIRE_TYPE, 0));
|
||||
connectWant.SetParam(Constants::FORM_CONNECT_ID, want.GetLongParam(Constants::FORM_CONNECT_ID, 0));
|
||||
@ -85,7 +85,7 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const int64_t
|
||||
FormProviderInfo formProviderInfo;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
connectWant.SetParam(Constants::PROVIDER_FLAG, ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY);
|
||||
} else {
|
||||
Want createWant(want);
|
||||
@ -96,17 +96,17 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const int64_t
|
||||
createWant.SetElement(want.GetElement());
|
||||
|
||||
formProviderInfo = ownerFormExtension->OnCreate(createWant);
|
||||
APP_LOGD("%{public}s, formId: %{public}s, data: %{public}s",
|
||||
HILOG_DEBUG("%{public}s, formId: %{public}s, data: %{public}s",
|
||||
__func__, createWant.GetStringParam(Constants::PARAM_FORM_IDENTITY_KEY).c_str(),
|
||||
formProviderInfo.GetFormDataString().c_str());
|
||||
}
|
||||
|
||||
int error = FormProviderClient::HandleAcquire(formProviderInfo, connectWant, callerToken);
|
||||
if (error != ERR_OK) {
|
||||
APP_LOGE("%{public}s HandleAcquire failed", __func__);
|
||||
HILOG_ERROR("%{public}s HandleAcquire failed", __func__);
|
||||
HandleResultCode(error, connectWant, callerToken);
|
||||
}
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,10 +119,10 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const int64_t
|
||||
int FormExtensionProviderClient::NotifyFormDelete(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
APP_LOGE("%{public}s CheckParam failed", __func__);
|
||||
HILOG_ERROR("%{public}s CheckParam failed", __func__);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -138,18 +138,18 @@ int FormExtensionProviderClient::NotifyFormDelete(const int64_t formId, const Wa
|
||||
void FormExtensionProviderClient::NotifyFormExtensionDelete(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnDestroy(formId);
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,10 +163,10 @@ void FormExtensionProviderClient::NotifyFormExtensionDelete(const int64_t formId
|
||||
int FormExtensionProviderClient::NotifyFormsDelete(const std::vector<int64_t> &formIds, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
APP_LOGE("%{public}s CheckParam failed", __func__);
|
||||
HILOG_ERROR("%{public}s CheckParam failed", __func__);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -182,11 +182,11 @@ int FormExtensionProviderClient::NotifyFormsDelete(const std::vector<int64_t> &f
|
||||
void FormExtensionProviderClient::NotifyFormExtensionsDelete(const std::vector<int64_t> &formIds,
|
||||
const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
for (int64_t formId : formIds) {
|
||||
@ -195,7 +195,7 @@ void FormExtensionProviderClient::NotifyFormExtensionsDelete(const std::vector<i
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,10 +209,10 @@ void FormExtensionProviderClient::NotifyFormExtensionsDelete(const std::vector<i
|
||||
int FormExtensionProviderClient::NotifyFormUpdate(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
APP_LOGE("%{public}s CheckParam failed", __func__);
|
||||
HILOG_ERROR("%{public}s CheckParam failed", __func__);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -228,18 +228,18 @@ int FormExtensionProviderClient::NotifyFormUpdate(const int64_t formId, const Wa
|
||||
void FormExtensionProviderClient::NotifyFormExtensionUpdate(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnUpdate(formId);
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,10 +254,10 @@ void FormExtensionProviderClient::NotifyFormExtensionUpdate(const int64_t formId
|
||||
int FormExtensionProviderClient::EventNotify(const std::vector<int64_t> &formIds, const int32_t formVisibleType,
|
||||
const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
APP_LOGE("%{public}s CheckParam failed", __func__);
|
||||
HILOG_ERROR("%{public}s CheckParam failed", __func__);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -273,11 +273,11 @@ int FormExtensionProviderClient::EventNotify(const std::vector<int64_t> &formIds
|
||||
void FormExtensionProviderClient::EventNotifyExtension(const std::vector<int64_t> &formIds,
|
||||
const int32_t formVisibleType, const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
std::map<int64_t, int32_t> formEventsMap;
|
||||
@ -288,7 +288,7 @@ void FormExtensionProviderClient::EventNotifyExtension(const std::vector<int64_t
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,10 +301,10 @@ void FormExtensionProviderClient::EventNotifyExtension(const std::vector<int64_t
|
||||
int FormExtensionProviderClient::NotifyFormCastTempForm(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
APP_LOGE("%{public}s CheckParam failed", __func__);
|
||||
HILOG_ERROR("%{public}s CheckParam failed", __func__);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -320,18 +320,18 @@ int FormExtensionProviderClient::NotifyFormCastTempForm(const int64_t formId, co
|
||||
void FormExtensionProviderClient::NotifyFormExtensionCastTempForm(const int64_t formId, const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnCastToNormal(formId);
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,10 +345,10 @@ void FormExtensionProviderClient::NotifyFormExtensionCastTempForm(const int64_t
|
||||
int FormExtensionProviderClient::FireFormEvent(const int64_t formId, const std::string &message,
|
||||
const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
std::pair<int, int> errorCode = CheckParam(want, callerToken);
|
||||
if (errorCode.first != ERR_OK) {
|
||||
APP_LOGE("%{public}s CheckParam failed", __func__);
|
||||
HILOG_ERROR("%{public}s CheckParam failed", __func__);
|
||||
return errorCode.second;
|
||||
}
|
||||
|
||||
@ -364,18 +364,18 @@ int FormExtensionProviderClient::FireFormEvent(const int64_t formId, const std::
|
||||
void FormExtensionProviderClient::FireFormExtensionEvent(const int64_t formId, const std::string &message,
|
||||
const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
ownerFormExtension->OnEvent(formId, message);
|
||||
}
|
||||
|
||||
HandleResultCode(errorCode, want, callerToken);
|
||||
APP_LOGI("%{public}s called end.", __func__);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,7 +386,7 @@ void FormExtensionProviderClient::FireFormExtensionEvent(const int64_t formId, c
|
||||
void FormExtensionProviderClient::SetOwner(const std::shared_ptr<FormExtension> formExtension)
|
||||
{
|
||||
if (formExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, SetOwner::formExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, SetOwner::formExtension is nullptr.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -404,7 +404,7 @@ void FormExtensionProviderClient::SetOwner(const std::shared_ptr<FormExtension>
|
||||
void FormExtensionProviderClient::ClearOwner(const std::shared_ptr<FormExtension> formExtension)
|
||||
{
|
||||
if (formExtension == nullptr) {
|
||||
APP_LOGE("%{public}s error, ClearOwner::formExtension is nullptr.", __func__);
|
||||
HILOG_ERROR("%{public}s error, ClearOwner::formExtension is nullptr.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ int FormExtensionProviderClient::HandleResultCode(int errorCode, const Want &wan
|
||||
} else {
|
||||
// If errorCode is ERR_OK return disconnectErrorCode.
|
||||
if (disconnectErrorCode != ERR_OK) {
|
||||
APP_LOGE("%{public}s, disconnect error.", __func__);
|
||||
HILOG_ERROR("%{public}s, disconnect error.", __func__);
|
||||
}
|
||||
return disconnectErrorCode;
|
||||
}
|
||||
@ -448,11 +448,11 @@ std::pair<int, int> FormExtensionProviderClient::CheckParam(const Want &want, co
|
||||
{
|
||||
sptr<IFormSupply> formSupplyClient = iface_cast<IFormSupply>(callerToken);
|
||||
if (formSupplyClient == nullptr) {
|
||||
APP_LOGE("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
HILOG_ERROR("%{public}s warn, IFormSupply is nullptr", __func__);
|
||||
return std::pair<int, int>(ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED, ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED);
|
||||
}
|
||||
if (!FormProviderClient::CheckIsSystemApp()) {
|
||||
APP_LOGE("%{public}s warn, caller permission denied.", __func__);
|
||||
HILOG_ERROR("%{public}s warn, caller permission denied.", __func__);
|
||||
int errorCode = HandleResultCode(ERR_APPEXECFWK_FORM_PERMISSION_DENY, want, callerToken);
|
||||
return std::pair<int, int>(ERR_APPEXECFWK_FORM_PERMISSION_DENY, errorCode);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "new_ability_impl.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -29,7 +29,7 @@ using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient;
|
||||
|
||||
void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
APP_LOGI("NewAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
HILOG_INFO("NewAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
"isNewWant: %{public}d, sceneFlag: %{public}d",
|
||||
lifecycleState_,
|
||||
targetState.state,
|
||||
@ -39,7 +39,7 @@ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Lif
|
||||
if (ability_ != nullptr && targetState.state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||
ability_->RequsetFocus(want);
|
||||
}
|
||||
APP_LOGE("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
HILOG_ERROR("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -58,11 +58,11 @@ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Lif
|
||||
bool ret = false;
|
||||
ret = AbilityTransaction(want, targetState);
|
||||
if (ret) {
|
||||
APP_LOGI("AbilityThread::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
HILOG_INFO("AbilityThread::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData());
|
||||
APP_LOGI("AbilityThread::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
HILOG_INFO("AbilityThread::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
}
|
||||
APP_LOGI("NewAbilityImpl::HandleAbilityTransaction end");
|
||||
HILOG_INFO("NewAbilityImpl::HandleAbilityTransaction end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,7 +76,7 @@ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Lif
|
||||
*/
|
||||
bool NewAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
APP_LOGI("NewAbilityImpl::AbilityTransaction begin");
|
||||
HILOG_INFO("NewAbilityImpl::AbilityTransaction begin");
|
||||
bool ret = true;
|
||||
switch (targetState.state) {
|
||||
case AAFwk::ABILITY_STATE_INITIAL: {
|
||||
@ -103,11 +103,11 @@ bool NewAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycle
|
||||
}
|
||||
default: {
|
||||
ret = false;
|
||||
APP_LOGE("NewAbilityImpl::HandleAbilityTransaction state error");
|
||||
HILOG_ERROR("NewAbilityImpl::HandleAbilityTransaction state error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
APP_LOGI("NewAbilityImpl::AbilityTransaction end: retVal = %{public}d", (int)ret);
|
||||
HILOG_INFO("NewAbilityImpl::AbilityTransaction end: retVal = %{public}d", (int)ret);
|
||||
return ret;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "page_ability_impl.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -29,7 +29,7 @@ using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient;
|
||||
void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
AbilityImpl::SetUseNewMission(targetState.useNewMission);
|
||||
APP_LOGI("PageAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
HILOG_INFO("PageAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
"isNewWant: %{public}d, sceneFlag: %{public}d",
|
||||
lifecycleState_,
|
||||
targetState.state,
|
||||
@ -39,7 +39,7 @@ void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
if (ability_ != nullptr && targetState.state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||
ability_->RequsetFocus(want);
|
||||
}
|
||||
APP_LOGE("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
HILOG_ERROR("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -70,11 +70,11 @@ void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
ret = AbilityTransaction(want, targetState);
|
||||
}
|
||||
if (ret) {
|
||||
APP_LOGI("AbilityThread::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
HILOG_INFO("AbilityThread::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData());
|
||||
APP_LOGI("AbilityThread::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
HILOG_INFO("AbilityThread::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
}
|
||||
APP_LOGI("PageAbilityImpl::HandleAbilityTransaction end");
|
||||
HILOG_INFO("PageAbilityImpl::HandleAbilityTransaction end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
*/
|
||||
bool PageAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
APP_LOGI("PageAbilityImpl::AbilityTransaction begin");
|
||||
HILOG_INFO("PageAbilityImpl::AbilityTransaction begin");
|
||||
bool ret = true;
|
||||
switch (targetState.state) {
|
||||
case AAFwk::ABILITY_STATE_INITIAL: {
|
||||
@ -124,11 +124,11 @@ bool PageAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycl
|
||||
}
|
||||
default: {
|
||||
ret = false;
|
||||
APP_LOGE("PageAbilityImpl::HandleAbilityTransaction state error");
|
||||
HILOG_ERROR("PageAbilityImpl::HandleAbilityTransaction state error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
APP_LOGI("PageAbilityImpl::AbilityTransaction end: retVal = %{public}d", (int)ret);
|
||||
HILOG_INFO("PageAbilityImpl::AbilityTransaction end: retVal = %{public}d", (int)ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ bool PageAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycl
|
||||
*/
|
||||
bool PageAbilityImpl::AbilityTransactionNew(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
APP_LOGI("PageAbilityImpl::AbilityTransaction begin");
|
||||
HILOG_INFO("PageAbilityImpl::AbilityTransaction begin");
|
||||
bool ret = true;
|
||||
switch (targetState.state) {
|
||||
case AAFwk::ABILITY_STATE_INITIAL: {
|
||||
@ -175,11 +175,11 @@ bool PageAbilityImpl::AbilityTransactionNew(const Want &want, const AAFwk::LifeC
|
||||
}
|
||||
default: {
|
||||
ret = false;
|
||||
APP_LOGE("PageAbilityImpl::HandleAbilityTransaction state error");
|
||||
HILOG_ERROR("PageAbilityImpl::HandleAbilityTransaction state error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
APP_LOGI("PageAbilityImpl::AbilityTransaction end: retVal = %{public}d", (int)ret);
|
||||
HILOG_INFO("PageAbilityImpl::AbilityTransaction end: retVal = %{public}d", (int)ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -193,18 +193,18 @@ bool PageAbilityImpl::AbilityTransactionNew(const Want &want, const AAFwk::LifeC
|
||||
*/
|
||||
void PageAbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
APP_LOGI("PageAbilityImpl::DoKeyDown begin");
|
||||
HILOG_INFO("PageAbilityImpl::DoKeyDown begin");
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("PageAbilityImpl::DoKeyDown ability_ == nullptr");
|
||||
HILOG_ERROR("PageAbilityImpl::DoKeyDown ability_ == nullptr");
|
||||
return;
|
||||
}
|
||||
auto abilitInfo = ability_->GetAbilityInfo();
|
||||
APP_LOGI("PageAbilityImpl::DoKeyDown called %{public}s And Focus is %{public}s",
|
||||
HILOG_INFO("PageAbilityImpl::DoKeyDown called %{public}s And Focus is %{public}s",
|
||||
abilitInfo->name.c_str(),
|
||||
ability_->HasWindowFocus() ? "true" : "false");
|
||||
|
||||
ability_->OnKeyDown(keyEvent);
|
||||
APP_LOGI("PageAbilityImpl::DoKeyDown end");
|
||||
HILOG_INFO("PageAbilityImpl::DoKeyDown end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,18 +217,18 @@ void PageAbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
*/
|
||||
void PageAbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
APP_LOGI("PageAbilityImpl::DoKeyUp begin");
|
||||
HILOG_INFO("PageAbilityImpl::DoKeyUp begin");
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("PageAbilityImpl::DoKeyUp ability_ == nullptr");
|
||||
HILOG_ERROR("PageAbilityImpl::DoKeyUp ability_ == nullptr");
|
||||
return;
|
||||
}
|
||||
auto abilitInfo = ability_->GetAbilityInfo();
|
||||
APP_LOGI("PageAbilityImpl::DoKeyUp called %{public}s And Focus is %{public}s",
|
||||
HILOG_INFO("PageAbilityImpl::DoKeyUp called %{public}s And Focus is %{public}s",
|
||||
abilitInfo->name.c_str(),
|
||||
ability_->HasWindowFocus() ? "true" : "false");
|
||||
|
||||
ability_->OnKeyUp(keyEvent);
|
||||
APP_LOGI("PageAbilityImpl::DoKeyUp end");
|
||||
HILOG_INFO("PageAbilityImpl::DoKeyUp end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,18 +241,18 @@ void PageAbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
*/
|
||||
void PageAbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
APP_LOGI("PageAbilityImpl::DoPointerEvent begin");
|
||||
HILOG_INFO("PageAbilityImpl::DoPointerEvent begin");
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("PageAbilityImpl::DoPointerEvent ability_ == nullptr");
|
||||
HILOG_ERROR("PageAbilityImpl::DoPointerEvent ability_ == nullptr");
|
||||
return;
|
||||
}
|
||||
auto abilitInfo = ability_->GetAbilityInfo();
|
||||
APP_LOGI("PageAbilityImpl::DoPointerEvent called %{public}s And Focus is %{public}s",
|
||||
HILOG_INFO("PageAbilityImpl::DoPointerEvent called %{public}s And Focus is %{public}s",
|
||||
abilitInfo->name.c_str(),
|
||||
ability_->HasWindowFocus() ? "true" : "false");
|
||||
|
||||
ability_->OnPointerEvent(pointerEvent);
|
||||
APP_LOGI("PageAbilityImpl::DoPointerEvent end");
|
||||
HILOG_INFO("PageAbilityImpl::DoPointerEvent end");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "service_ability_impl.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -28,13 +28,13 @@ using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient;
|
||||
*/
|
||||
void ServiceAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
HILOG_INFO("ServiceAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
"isNewWant: %{public}d",
|
||||
lifecycleState_,
|
||||
targetState.state,
|
||||
targetState.isNewWant);
|
||||
if (lifecycleState_ == targetState.state) {
|
||||
APP_LOGE("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
HILOG_ERROR("Org lifeCycleState equals to Dst lifeCycleState.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -58,17 +58,17 @@ void ServiceAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk:
|
||||
}
|
||||
default: {
|
||||
ret = false;
|
||||
APP_LOGE("ServiceAbilityImpl::HandleAbilityTransaction state is error");
|
||||
HILOG_ERROR("ServiceAbilityImpl::HandleAbilityTransaction state is error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
HILOG_INFO("ServiceAbilityImpl::HandleAbilityTransaction before AbilityManagerClient->AbilityTransitionDone");
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData());
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
HILOG_INFO("ServiceAbilityImpl::HandleAbilityTransaction after AbilityManagerClient->AbilityTransitionDone");
|
||||
}
|
||||
APP_LOGI("ServiceAbilityImpl::HandleAbilityTransaction end");
|
||||
HILOG_INFO("ServiceAbilityImpl::HandleAbilityTransaction end");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include "task_handler_client.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -41,18 +40,18 @@ TaskHandlerClient::~TaskHandlerClient()
|
||||
|
||||
bool TaskHandlerClient::PostTask(std::function<void()> task, long delayTime)
|
||||
{
|
||||
APP_LOGI("TaskHandlerClient::PostTask called");
|
||||
HILOG_INFO("TaskHandlerClient::PostTask called");
|
||||
|
||||
if (taskHandler_ == nullptr) {
|
||||
if (!CreateRunner()) {
|
||||
APP_LOGE("TaskHandlerClient::PostTask failed, CreateRunner failed");
|
||||
HILOG_ERROR("TaskHandlerClient::PostTask failed, CreateRunner failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = taskHandler_->PostTask(task, delayTime, EventQueue::Priority::LOW);
|
||||
if (!ret) {
|
||||
APP_LOGE("TaskHandlerClient::PostTask failed, taskHandler_ PostTask failed");
|
||||
HILOG_ERROR("TaskHandlerClient::PostTask failed, taskHandler_ PostTask failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -62,12 +61,12 @@ bool TaskHandlerClient::CreateRunner()
|
||||
if (taskHandler_ == nullptr) {
|
||||
std::shared_ptr<EventRunner> runner = EventRunner::Create("TaskRunner");
|
||||
if (runner == nullptr) {
|
||||
APP_LOGE("TaskHandlerClient::CreateRunner failed, runner is nullptr");
|
||||
HILOG_ERROR("TaskHandlerClient::CreateRunner failed, runner is nullptr");
|
||||
return false;
|
||||
}
|
||||
taskHandler_ = std::make_shared<TaskHandler>(runner);
|
||||
if (taskHandler_ == nullptr) {
|
||||
APP_LOGE("TaskHandlerClient::CreateRunner failed, taskHandler_ is nullptr");
|
||||
HILOG_ERROR("TaskHandlerClient::CreateRunner failed, taskHandler_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ config("module_private_config") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
defines = [
|
||||
"APP_LOG_TAG = \"AbilityUnitTest\"",
|
||||
"LOG_DOMAIN = 0xD002201",
|
||||
"AMS_LOG_TAG = \"AbilityUnitTest\"",
|
||||
"AMS_LOG_DOMAIN = 0xD002201",
|
||||
]
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ config("module_ability_context_config") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
defines = [
|
||||
"APP_LOG_TAG = \"AbilityUnitTest\"",
|
||||
"LOG_DOMAIN = 0xD002201",
|
||||
"AMS_LOG_TAG = \"AbilityUnitTest\"",
|
||||
"AMS_LOG_DOMAIN = 0xD002201",
|
||||
]
|
||||
}
|
||||
|
||||
@ -533,6 +533,7 @@ ohos_unittest("ability_impl_test") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
@ -861,8 +862,8 @@ config("data_uri_utils_test_config") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
defines = [
|
||||
"APP_LOG_TAG = \"AbilityUnitTest\"",
|
||||
"LOG_DOMAIN = 0xD002201",
|
||||
"AMS_LOG_TAG = \"AbilityUnitTest\"",
|
||||
"AMS_LOG_DOMAIN = 0xD002201",
|
||||
]
|
||||
}
|
||||
ohos_unittest("data_uri_utils_test") {
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "ability.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
@ -27,7 +27,7 @@ REGISTER_AA(Ability)
|
||||
void Ability::Init(std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> &application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token)
|
||||
{
|
||||
APP_LOGI("Ability::Init called.");
|
||||
HILOG_INFO("Ability::Init called.");
|
||||
|
||||
abilityInfo_ = abilityInfo;
|
||||
handler_ = handler;
|
||||
@ -143,11 +143,11 @@ void Ability::SetUIContent(int layoutRes, std::shared_ptr<Context> &context, int
|
||||
void Ability::SetUIContent(const WindowConfig &config)
|
||||
{
|
||||
if (abilityWindow_ == nullptr) {
|
||||
APP_LOGE("Ability::SetUIContent abilityWindow_ is nullptr");
|
||||
HILOG_ERROR("Ability::SetUIContent abilityWindow_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("Ability::SetUIContent called");
|
||||
HILOG_INFO("Ability::SetUIContent called");
|
||||
abilityWindow_->SetWindowConfig(config);
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ void Ability::SetUIContent(const WindowConfig &config)
|
||||
*/
|
||||
std::unique_ptr<Window> &Ability::GetWindow(int windowID)
|
||||
{
|
||||
APP_LOGI("Ability::GetWindow called windowID = %d.", windowID);
|
||||
HILOG_INFO("Ability::GetWindow called windowID = %d.", windowID);
|
||||
|
||||
return abilityWindow_->GetWindow(windowID);
|
||||
}
|
||||
@ -247,17 +247,17 @@ void Ability::OnBackPressed()
|
||||
|
||||
void Ability::OnNewWant(const Want &want)
|
||||
{
|
||||
APP_LOGI("Ability::OnNewWant called");
|
||||
HILOG_INFO("Ability::OnNewWant called");
|
||||
}
|
||||
|
||||
void Ability::OnRestoreAbilityState(const PacMap &inState)
|
||||
{
|
||||
APP_LOGI("Ability::OnRestoreAbilityState called");
|
||||
HILOG_INFO("Ability::OnRestoreAbilityState called");
|
||||
}
|
||||
|
||||
void Ability::OnSaveAbilityState(const PacMap &outState)
|
||||
{
|
||||
APP_LOGI("Ability::OnSaveAbilityState called");
|
||||
HILOG_INFO("Ability::OnSaveAbilityState called");
|
||||
}
|
||||
|
||||
void Ability::OnEventDispatch()
|
||||
@ -283,10 +283,10 @@ std::shared_ptr<AAFwk::Want> Ability::GetWant()
|
||||
void Ability::SetResult(int resultCode, const Want &resultData)
|
||||
{
|
||||
if (abilityInfo_ == nullptr) {
|
||||
APP_LOGI("Ability::SetResult nullptr == abilityInfo_");
|
||||
HILOG_INFO("Ability::SetResult nullptr == abilityInfo_");
|
||||
return;
|
||||
}
|
||||
APP_LOGI("Ability::SetResult called type = %{public}d", abilityInfo_->type);
|
||||
HILOG_INFO("Ability::SetResult called type = %{public}d", abilityInfo_->type);
|
||||
if (abilityInfo_->type == AppExecFwk::AbilityType::PAGE) {
|
||||
AbilityContext::resultWant_ = resultData;
|
||||
AbilityContext::resultCode_ = resultCode;
|
||||
@ -387,16 +387,16 @@ std::shared_ptr<Uri> Ability::DenormalizeUri(const Uri &uri)
|
||||
|
||||
std::shared_ptr<LifeCycle> Ability::GetLifecycle()
|
||||
{
|
||||
APP_LOGI("Ability::GetLifecycle called");
|
||||
HILOG_INFO("Ability::GetLifecycle called");
|
||||
return lifecycle_;
|
||||
}
|
||||
|
||||
AbilityLifecycleExecutor::LifecycleState Ability::GetState()
|
||||
{
|
||||
APP_LOGI("Ability::GetState called");
|
||||
HILOG_INFO("Ability::GetState called");
|
||||
|
||||
if (abilityLifecycleExecutor_ == nullptr) {
|
||||
APP_LOGI("Ability::GetState error. abilityLifecycleExecutor_ == nullptr.");
|
||||
HILOG_INFO("Ability::GetState error. abilityLifecycleExecutor_ == nullptr.");
|
||||
return AbilityLifecycleExecutor::LifecycleState::UNINITIALIZED;
|
||||
}
|
||||
|
||||
@ -405,13 +405,13 @@ AbilityLifecycleExecutor::LifecycleState Ability::GetState()
|
||||
|
||||
void Ability::StartAbility(const Want &want)
|
||||
{
|
||||
APP_LOGI("Ability::StartAbility called");
|
||||
HILOG_INFO("Ability::StartAbility called");
|
||||
AbilityContext::StartAbility(want, -1);
|
||||
}
|
||||
|
||||
void Ability::TerminateAbility()
|
||||
{
|
||||
APP_LOGI("Ability::TerminateAbility called");
|
||||
HILOG_INFO("Ability::TerminateAbility called");
|
||||
AbilityContext::TerminateAbility();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "ability_context.h"
|
||||
#include "ability_manager_interface.h"
|
||||
#include "ability_scheduler_interface.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iremote_object.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "want.h"
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "values_bucket.h"
|
||||
#include "data_ability_impl.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
const int returnValueOpenfile = 11;
|
||||
const int returnValueInsert = 22;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_form_supply_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -40,7 +40,7 @@ sptr<MockFormSupplyCallback> MockFormSupplyCallback::GetInstance()
|
||||
*/
|
||||
int MockFormSupplyCallback::OnAcquire(const FormProviderInfo &formProviderInfo, const Want& want)
|
||||
{
|
||||
APP_LOGI("MockFormSupplyCallback::OnAcquire called.");
|
||||
HILOG_INFO("MockFormSupplyCallback::OnAcquire called.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ int MockFormSupplyCallback::OnAcquire(const FormProviderInfo &formProviderInfo,
|
||||
*/
|
||||
int MockFormSupplyCallback::OnEventHandle(const Want& want)
|
||||
{
|
||||
APP_LOGI("MockFormSupplyCallback::OnEventHandle called.");
|
||||
HILOG_INFO("MockFormSupplyCallback::OnEventHandle called.");
|
||||
return 1;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "ability_impl.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "ability_local_record.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -24,35 +24,35 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
std::shared_ptr<Ability> &ability, std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token,
|
||||
std::shared_ptr<ContextDeal> &contextDeal)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::init begin");
|
||||
HILOG_INFO("AbilityImpl::init begin");
|
||||
|
||||
if (token == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, token is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::init failed, token is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (application == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, application is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::init failed, application is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (record == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, record is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::init failed, record is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ability == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, ability is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::init failed, ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (token == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, token is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::init failed, token is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (contextDeal == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, contextDeal is nullptr");
|
||||
HILOG_ERROR("AbilityImpl::init failed, contextDeal is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
abilityLifecycleCallbacks_ = application;
|
||||
contextDeal_ = contextDeal;
|
||||
APP_LOGI("AbilityImpl::init end");
|
||||
HILOG_INFO("AbilityImpl::init end");
|
||||
}
|
||||
|
||||
void AbilityImpl::Start(const Want &want)
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "ability.h"
|
||||
#include "ability_impl.h"
|
||||
#include "ability_state.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "context_deal.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "ohos_application.h"
|
||||
#include "page_ability_impl.h"
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "ability_impl.h"
|
||||
#include "ability.h"
|
||||
#include "ability_state.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "context_deal.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "mock_page_ability.h"
|
||||
#include "mock_ability_impl.h"
|
||||
|
@ -18,11 +18,11 @@
|
||||
#include "ability_thread.h"
|
||||
#include "ability_state.h"
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "ability_impl_factory.h"
|
||||
#include "ability_impl.h"
|
||||
#include "ability.h"
|
||||
#include "context_deal.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_page_ability.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "mock_ability_lifecycle_callbacks.h"
|
||||
|
@ -18,11 +18,11 @@
|
||||
#include "ability_thread.h"
|
||||
#include "ability_state.h"
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "ability_impl_factory.h"
|
||||
#include "ability.h"
|
||||
#include "ability_impl.h"
|
||||
#include "context_deal.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_page_ability.h"
|
||||
#include "mock_service_ability.h"
|
||||
#include "mock_ability_token.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "ability_impl.h"
|
||||
#include "ability_state.h"
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "context_deal.h"
|
||||
#include "continuation_manager.h"
|
||||
#include "continuation_handler.h"
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "mock_data_ability.h"
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "mock_data_ability.h"
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "ability_loader.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "mock_data_ability.h"
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "app_log_wrapper.h"
|
||||
#include "context_deal.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_service_ability.h"
|
||||
#include "mock_ability_token.h"
|
||||
#include "service_ability_impl.h"
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "task_handler_client.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
@ -16,20 +16,13 @@ import("//foundation/aafwk/standard/aafwk.gni")
|
||||
|
||||
config("appkit_config") {
|
||||
defines = [
|
||||
"APP_LOG_TAG = \"AppkitNative\"",
|
||||
"LOG_DOMAIN = 0xD001150",
|
||||
"AMS_LOG_TAG = \"AppkitNative\"",
|
||||
"AMS_LOG_DOMAIN = 0xD001150",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"${aafwk_path}/interfaces/innerkits/intent/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr",
|
||||
"${aafwk_path}/interfaces/innerkits/want/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"${aafwk_path}/interfaces/innerkits/app_manager/include/appmgr",
|
||||
"${aafwk_path}/frameworks/kits/ability/native/include",
|
||||
"${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content",
|
||||
"//third_party/json/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -46,10 +39,9 @@ config("appkit_public_config") {
|
||||
#build bin
|
||||
ohos_executable("appexec") {
|
||||
include_dirs = [
|
||||
"${aafwk_path}/services/common/include",
|
||||
"${appexecfwk_path}/common/log/include",
|
||||
"${aafwk_path}/interfaces/innerkits/app_manager/include/appmgr",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler/include",
|
||||
"${aafwk_path}/frameworks/kits/ability/native/include",
|
||||
"${aafwk_path}/interfaces/innerkits/base/include",
|
||||
"${aafwk_path}/interfaces/innerkits/ability_manager/include",
|
||||
@ -58,9 +50,6 @@ ohos_executable("appexec") {
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/app",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/context",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/app/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//utils/native/base/include",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
]
|
||||
|
||||
configs = [ ":appkit_config" ]
|
||||
@ -73,8 +62,15 @@ ohos_executable("appexec") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
install_enable = true
|
||||
@ -84,13 +80,10 @@ ohos_executable("appexec") {
|
||||
# build so
|
||||
ohos_shared_library("appkit_native") {
|
||||
include_dirs = [
|
||||
"${aafwk_path}/services/common/include",
|
||||
"${appexecfwk_path}/common/log/include",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_base/include",
|
||||
"${aafwk_path}/interfaces/innerkits/app_manager/include/appmgr",
|
||||
"${aafwk_path}/interfaces/innerkits/uri/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler/include",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/app/include",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/app",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/context",
|
||||
@ -98,16 +91,12 @@ ohos_shared_library("appkit_native") {
|
||||
"${aafwk_path}/frameworks/kits/ability/native/include",
|
||||
"${aafwk_path}/interfaces/innerkits/ability_manager/include",
|
||||
"${aafwk_path}/services/abilitymgr/include",
|
||||
"//utils/native/base/include",
|
||||
"${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk_L2/content",
|
||||
|
||||
"${aafwk_path}/common/task_dispatcher/include/dispatcher",
|
||||
"${aafwk_path}/common/task_dispatcher/include/task",
|
||||
"${aafwk_path}/common/task_dispatcher/include/threading",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/app/include/task",
|
||||
"//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common",
|
||||
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/faultloggerd_client/include",
|
||||
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher/include",
|
||||
]
|
||||
|
||||
configs = [ ":appkit_config" ]
|
||||
@ -140,21 +129,10 @@ ohos_shared_library("appkit_native") {
|
||||
deps = [
|
||||
":appkit_delegator",
|
||||
"${aafwk_path}/common/task_dispatcher:task_dispatcher",
|
||||
"${aafwk_path}/frameworks/kits/ability/native:abilitykit_native",
|
||||
"${aafwk_path}/frameworks/kits/appkit:app_context",
|
||||
"${aafwk_path}/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"${aafwk_path}/interfaces/innerkits/app_manager:app_manager",
|
||||
"${aafwk_path}/interfaces/innerkits/want:want",
|
||||
"${appexecfwk_path}/common:libappexecfwk_common",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"${innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher",
|
||||
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/faultloggerd_client:libfaultloggerd",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
@ -163,14 +141,25 @@ ohos_shared_library("appkit_native") {
|
||||
]
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"bytrace_standard:bytrace_core",
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:lib_dfx_dump_catcher",
|
||||
"faultloggerd:libfaultloggerd",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"multimodalinput_base:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
part_name = "ability_runtime"
|
||||
@ -179,15 +168,8 @@ ohos_shared_library("appkit_native") {
|
||||
# build so
|
||||
ohos_shared_library("app_context") {
|
||||
include_dirs = [
|
||||
"//base/account/os_account/frameworks/common/account_error/include",
|
||||
"//base/account/os_account/frameworks/common/database/include",
|
||||
"//base/account/os_account/frameworks/common/log/include",
|
||||
"//base/account/os_account/interfaces/innerkits/osaccount/native/include",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/app/include",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/context",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
]
|
||||
|
||||
configs = [ ":appkit_config" ]
|
||||
@ -207,17 +189,11 @@ ohos_shared_library("app_context") {
|
||||
}
|
||||
deps = [
|
||||
"${appexecfwk_path}/common:libappexecfwk_common",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
|
||||
# "${aafwk_path}/frameworks/kits/ability/native:abilitykit_native",
|
||||
"${aafwk_path}/common/task_dispatcher:task_dispatcher",
|
||||
"${aafwk_path}/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//base/hiviewdfx/hiview/adapter/utility:hiview_adapter_utility",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
@ -227,13 +203,22 @@ ohos_shared_library("app_context") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"multimodalinput_base:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
"os_account_standard:os_account_innerkits",
|
||||
"resmgr_standard:resmgr_napi_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
part_name = "ability_runtime"
|
||||
@ -242,15 +227,14 @@ ohos_shared_library("app_context") {
|
||||
# build so
|
||||
ohos_shared_library("appkit_delegator") {
|
||||
include_dirs = [
|
||||
"${aafwk_path}/services/common/include",
|
||||
"${appexecfwk_path}/common/log/include",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_core/include/bundlemgr",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/app",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_runtime/context",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native",
|
||||
"${aafwk_path}/frameworks/kits/ability/native/include",
|
||||
"${aafwk_path}/frameworks/kits/appkit/native/ability_delegator/include",
|
||||
"${aafwk_path}/interfaces/innerkits/ability_manager/include",
|
||||
"//utils/native/base/include",
|
||||
]
|
||||
|
||||
configs = [ ":appkit_config" ]
|
||||
@ -277,23 +261,25 @@ ohos_shared_library("appkit_delegator") {
|
||||
|
||||
deps = [
|
||||
"${aafwk_path}/frameworks/kits/appkit:app_context",
|
||||
"${aafwk_path}/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"${aafwk_path}/interfaces/innerkits/app_manager:app_manager",
|
||||
"${aafwk_path}/interfaces/innerkits/want:want",
|
||||
"${appexecfwk_path}/common:libappexecfwk_common",
|
||||
"${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
"${appexecfwk_path}/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"bytrace_standard:bytrace_core",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"utils_base:utils",
|
||||
]
|
||||
|
||||
public_deps = [ "//foundation/ace/napi:ace_napi" ]
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "ability_delegator.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ohos_application.h"
|
||||
#include "ability_manager_client.h"
|
||||
#include "ability_delegator_registry.h"
|
||||
@ -34,14 +34,14 @@ AbilityDelegator::~AbilityDelegator()
|
||||
void AbilityDelegator::AddAbilityMonitor(const std::shared_ptr<IAbilityMonitor> &monitor)
|
||||
{
|
||||
if (!monitor) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
auto pos = std::find(abilityMonitors_.begin(), abilityMonitors_.end(), monitor);
|
||||
if (pos != abilityMonitors_.end()) {
|
||||
APP_LOGW("Monitor has been added");
|
||||
HILOG_WARN("Monitor has been added");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ void AbilityDelegator::AddAbilityMonitor(const std::shared_ptr<IAbilityMonitor>
|
||||
void AbilityDelegator::RemoveAbilityMonitor(const std::shared_ptr<IAbilityMonitor> &monitor)
|
||||
{
|
||||
if (!monitor) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ size_t AbilityDelegator::GetMonitorsNum()
|
||||
sptr<IRemoteObject> AbilityDelegator::WaitAbilityMonitor(const std::shared_ptr<IAbilityMonitor> &monitor)
|
||||
{
|
||||
if (!monitor) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ sptr<IRemoteObject> AbilityDelegator::WaitAbilityMonitor(const std::shared_ptr<I
|
||||
|
||||
auto obtainedAbility = monitor->waitForAbility();
|
||||
if (!obtainedAbility) {
|
||||
APP_LOGW("Invalid obtained ability");
|
||||
HILOG_WARN("Invalid obtained ability");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ sptr<IRemoteObject> AbilityDelegator::WaitAbilityMonitor(
|
||||
const std::shared_ptr<IAbilityMonitor> &monitor, const int64_t timeoutMs)
|
||||
{
|
||||
if (!monitor) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ sptr<IRemoteObject> AbilityDelegator::WaitAbilityMonitor(
|
||||
|
||||
auto obtainedAbility = monitor->waitForAbility(timeoutMs);
|
||||
if (!obtainedAbility) {
|
||||
APP_LOGW("Invalid obtained ability");
|
||||
HILOG_WARN("Invalid obtained ability");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -119,14 +119,14 @@ std::shared_ptr<AbilityRuntime::Context> AbilityDelegator::GetAppContext() const
|
||||
AbilityDelegator::AbilityState AbilityDelegator::GetAbilityState(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (!token) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return AbilityDelegator::AbilityState::UNINITIALIZED;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexAbilityProperties_);
|
||||
auto existedProperty = DoesPropertyExist(token);
|
||||
if (!existedProperty) {
|
||||
APP_LOGW("Unknown ability token");
|
||||
HILOG_WARN("Unknown ability token");
|
||||
return AbilityDelegator::AbilityState::UNINITIALIZED;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ sptr<IRemoteObject> AbilityDelegator::GetCurrentTopAbility()
|
||||
{
|
||||
sptr<IRemoteObject> topAbilityToken;
|
||||
if (AAFwk::AbilityManagerClient::GetInstance()->GetCurrentTopAbility(topAbilityToken)) {
|
||||
APP_LOGE("Failed to get top ability");
|
||||
HILOG_ERROR("Failed to get top ability");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -151,52 +151,52 @@ std::string AbilityDelegator::GetThreadName() const
|
||||
|
||||
void AbilityDelegator::Prepare()
|
||||
{
|
||||
APP_LOGI("Enter");
|
||||
HILOG_INFO("Enter");
|
||||
if (!testRunner_) {
|
||||
APP_LOGW("Invalid TestRunner");
|
||||
HILOG_WARN("Invalid TestRunner");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("Call TestRunner::Prepare()");
|
||||
HILOG_INFO("Call TestRunner::Prepare()");
|
||||
testRunner_->Prepare();
|
||||
|
||||
if (!delegatorThread_) {
|
||||
delegatorThread_ = std::make_unique<DelegatorThread>(true);
|
||||
if (!delegatorThread_) {
|
||||
APP_LOGE("Create delegatorThread failed");
|
||||
HILOG_ERROR("Create delegatorThread failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto runTask = [this]() { this->OnRun(); };
|
||||
if (!delegatorThread_->Run(runTask)) {
|
||||
APP_LOGE("Run task on delegatorThread failed");
|
||||
HILOG_ERROR("Run task on delegatorThread failed");
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityDelegator::OnRun()
|
||||
{
|
||||
APP_LOGI("Enter");
|
||||
HILOG_INFO("Enter");
|
||||
if (!testRunner_) {
|
||||
APP_LOGW("Invalid TestRunner");
|
||||
HILOG_WARN("Invalid TestRunner");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("Call TestRunner::Run(), Start run");
|
||||
HILOG_INFO("Call TestRunner::Run(), Start run");
|
||||
testRunner_->Run();
|
||||
APP_LOGI("Run finished");
|
||||
HILOG_INFO("Run finished");
|
||||
}
|
||||
|
||||
bool AbilityDelegator::DoAbilityForeground(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (!token) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->DelegatorDoAbilityForeground(token);
|
||||
if (ret) {
|
||||
APP_LOGE("Failed to call DelegatorDoAbilityForeground, reson : %{public}d", ret);
|
||||
HILOG_ERROR("Failed to call DelegatorDoAbilityForeground, reson : %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -206,13 +206,13 @@ bool AbilityDelegator::DoAbilityForeground(const sptr<IRemoteObject> &token)
|
||||
bool AbilityDelegator::DoAbilityBackground(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (!token) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->DelegatorDoAbilityBackground(token);
|
||||
if (ret) {
|
||||
APP_LOGE("Failed to call DelegatorDoAbilityBackground, reson : %{public}d", ret);
|
||||
HILOG_ERROR("Failed to call DelegatorDoAbilityBackground, reson : %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -221,16 +221,16 @@ bool AbilityDelegator::DoAbilityBackground(const sptr<IRemoteObject> &token)
|
||||
|
||||
std::unique_ptr<ShellCmdResult> AbilityDelegator::ExecuteShellCommand(const std::string &cmd, const int64_t timeoutMs)
|
||||
{
|
||||
APP_LOGI("command : %{public}s, timeout : %{public}" PRId64, cmd.data(), timeoutMs);
|
||||
HILOG_INFO("command : %{public}s, timeout : %{public}" PRId64, cmd.data(), timeoutMs);
|
||||
|
||||
if (cmd.empty()) {
|
||||
APP_LOGE("Invalid cmd");
|
||||
HILOG_ERROR("Invalid cmd");
|
||||
return {};
|
||||
}
|
||||
|
||||
auto testObserver = iface_cast<ITestObserver>(observer_);
|
||||
if (!testObserver) {
|
||||
APP_LOGW("Invalid testObserver");
|
||||
HILOG_WARN("Invalid testObserver");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -240,10 +240,10 @@ std::unique_ptr<ShellCmdResult> AbilityDelegator::ExecuteShellCommand(const std:
|
||||
|
||||
void AbilityDelegator::Print(const std::string &msg)
|
||||
{
|
||||
APP_LOGI("message to print : %{public}s", msg.data());
|
||||
HILOG_INFO("message to print : %{public}s", msg.data());
|
||||
auto testObserver = iface_cast<ITestObserver>(observer_);
|
||||
if (!testObserver) {
|
||||
APP_LOGW("Invalid testObserver");
|
||||
HILOG_WARN("Invalid testObserver");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ void AbilityDelegator::Print(const std::string &msg)
|
||||
void AbilityDelegator::PostPerformStart(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ void AbilityDelegator::PostPerformStart(const std::shared_ptr<ADelegatorAbilityP
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ void AbilityDelegator::PostPerformStart(const std::shared_ptr<ADelegatorAbilityP
|
||||
void AbilityDelegator::PostPerformScenceCreated(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ void AbilityDelegator::PostPerformScenceCreated(const std::shared_ptr<ADelegator
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ void AbilityDelegator::PostPerformScenceCreated(const std::shared_ptr<ADelegator
|
||||
void AbilityDelegator::PostPerformScenceRestored(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ void AbilityDelegator::PostPerformScenceRestored(const std::shared_ptr<ADelegato
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ void AbilityDelegator::PostPerformScenceRestored(const std::shared_ptr<ADelegato
|
||||
void AbilityDelegator::PostPerformScenceDestroyed(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ void AbilityDelegator::PostPerformScenceDestroyed(const std::shared_ptr<ADelegat
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ void AbilityDelegator::PostPerformScenceDestroyed(const std::shared_ptr<ADelegat
|
||||
void AbilityDelegator::PostPerformForeground(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ void AbilityDelegator::PostPerformForeground(const std::shared_ptr<ADelegatorAbi
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ void AbilityDelegator::PostPerformForeground(const std::shared_ptr<ADelegatorAbi
|
||||
void AbilityDelegator::PostPerformBackground(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ void AbilityDelegator::PostPerformBackground(const std::shared_ptr<ADelegatorAbi
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ void AbilityDelegator::PostPerformBackground(const std::shared_ptr<ADelegatorAbi
|
||||
void AbilityDelegator::PostPerformStop(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@ void AbilityDelegator::PostPerformStop(const std::shared_ptr<ADelegatorAbilityPr
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexMonitor_);
|
||||
if (abilityMonitors_.empty()) {
|
||||
APP_LOGW("Empty abilityMonitors");
|
||||
HILOG_WARN("Empty abilityMonitors");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -450,7 +450,7 @@ AbilityDelegator::AbilityState AbilityDelegator::ConvertAbilityState(
|
||||
abilityState = AbilityDelegator::AbilityState::STOPPED;
|
||||
break;
|
||||
default:
|
||||
APP_LOGE("Unknown lifecycleState");
|
||||
HILOG_ERROR("Unknown lifecycleState");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -460,11 +460,11 @@ AbilityDelegator::AbilityState AbilityDelegator::ConvertAbilityState(
|
||||
void AbilityDelegator::ProcessAbilityProperties(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
|
||||
{
|
||||
if (!ability) {
|
||||
APP_LOGW("Invalid ability property");
|
||||
HILOG_WARN("Invalid ability property");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGW("ability property : name : %{public}s, state : %{public}d",
|
||||
HILOG_WARN("ability property : name : %{public}s, state : %{public}d",
|
||||
ability->name_.data(), ability->lifecycleState_);
|
||||
|
||||
std::unique_lock<std::mutex> lck(mutexAbilityProperties_);
|
||||
@ -481,18 +481,18 @@ void AbilityDelegator::ProcessAbilityProperties(const std::shared_ptr<ADelegator
|
||||
std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::DoesPropertyExist(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (!token) {
|
||||
APP_LOGW("Invalid input parameter");
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
return {};
|
||||
}
|
||||
|
||||
for (auto &it : abilityProperties_) {
|
||||
if (!it) {
|
||||
APP_LOGW("Invalid ability property");
|
||||
HILOG_WARN("Invalid ability property");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (token == it->token_) {
|
||||
APP_LOGI("Porperty exists");
|
||||
HILOG_INFO("Porperty exists");
|
||||
return it;
|
||||
}
|
||||
}
|
||||
@ -502,23 +502,23 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::DoesPropertyExist(c
|
||||
|
||||
void AbilityDelegator::FinishUserTest(const std::string &msg, const int32_t resultCode)
|
||||
{
|
||||
APP_LOGI("Enter");
|
||||
HILOG_INFO("Enter");
|
||||
|
||||
if (!observer_) {
|
||||
APP_LOGE("Invalid observer");
|
||||
HILOG_ERROR("Invalid observer");
|
||||
return;
|
||||
}
|
||||
|
||||
auto delegatorArgs = AbilityDelegatorRegistry::GetArguments();
|
||||
if (!delegatorArgs) {
|
||||
APP_LOGE("Invalid delegator args");
|
||||
HILOG_ERROR("Invalid delegator args");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto &bundleName = delegatorArgs->GetTestBundleName();
|
||||
auto err = AAFwk::AbilityManagerClient::GetInstance()->FinishUserTest(msg, resultCode, bundleName);
|
||||
if (err) {
|
||||
APP_LOGE("MainThread::FinishUserTest is failed %{public}d", err);
|
||||
HILOG_ERROR("MainThread::FinishUserTest is failed %{public}d", err);
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user