mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-27 01:10:52 +00:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into ets_utils
Signed-off-by: jiangzhijun8 <jiangzhijun7@huawei.com>
This commit is contained in:
commit
c8d6d0b7be
@ -92,8 +92,8 @@ access_token_path = "//base/security/access_token"
|
||||
declare_args() {
|
||||
background_task_mgr_continuous_task_enable = true
|
||||
resource_schedule_service_enable = true
|
||||
ability_runtime_power = true
|
||||
ability_runtime_feature_sandboxmanager = false
|
||||
ability_runtime_power = true
|
||||
ability_runtime_relational = true
|
||||
ability_runtime_ces = true
|
||||
ability_runtime_resource = true
|
||||
|
@ -411,6 +411,7 @@ void* CJEnvironment::LoadCJLibrary(const char* dlName)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
isLoadCJLibrary_ = true;
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -437,9 +438,15 @@ void* CJEnvironment::LoadCJLibrary(OHOS::CJEnvironment::LibraryKind kind, const
|
||||
LOGE("load cj library failed: %{public}s", DynamicGetError());
|
||||
return nullptr;
|
||||
}
|
||||
isLoadCJLibrary_ = true;
|
||||
return handle;
|
||||
}
|
||||
|
||||
bool CJEnvironment::CheckLoadCJLibrary()
|
||||
{
|
||||
return isLoadCJLibrary_;
|
||||
}
|
||||
|
||||
void CJEnvironment::UnLoadCJLibrary(void* handle)
|
||||
{
|
||||
DynamicFreeLibrary(handle);
|
||||
@ -516,6 +523,9 @@ CJ_EXPORT extern "C" CJEnvMethods* OHOS_GetCJEnvInstance()
|
||||
},
|
||||
.setSanitizerKindRuntimeVersion = [](SanitizerKind kind) {
|
||||
return CJEnvironment::GetInstance()->SetSanitizerKindRuntimeVersion(kind);
|
||||
},
|
||||
.checkLoadCJLibrary = []() {
|
||||
return CJEnvironment::GetInstance()->CheckLoadCJLibrary();
|
||||
}
|
||||
};
|
||||
return &gCJEnvMethods;
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
return isUISchedulerStarted_;
|
||||
}
|
||||
bool StartUIScheduler();
|
||||
bool CheckLoadCJLibrary();
|
||||
void StopUIScheduler();
|
||||
enum LibraryKind {
|
||||
SYSTEM,
|
||||
@ -86,6 +87,7 @@ private:
|
||||
bool LoadRuntimeApis();
|
||||
static CJRuntimeAPI lazyApis_;
|
||||
bool isRuntimeStarted_{false};
|
||||
bool isLoadCJLibrary_{false};
|
||||
bool isUISchedulerStarted_{false};
|
||||
void* uiScheduler_ {nullptr};
|
||||
SanitizerKind sanitizerKind_ {SanitizerKind::NONE};
|
||||
|
@ -51,6 +51,7 @@ struct CJEnvMethods {
|
||||
bool (*startDebugger)() = nullptr;
|
||||
void (*registerCJUncaughtExceptionHandler)(const CJUncaughtExceptionInfo& uncaughtExceptionInfo) = nullptr;
|
||||
void (*setSanitizerKindRuntimeVersion)(SanitizerKind kind) = nullptr;
|
||||
bool (*checkLoadCJLibrary)() = nullptr;
|
||||
};
|
||||
|
||||
class CJEnv {
|
||||
|
@ -19,5 +19,6 @@ group("cj_ability_packages") {
|
||||
"${ability_runtime_path}/frameworks/cj/ffi:cj_ability_ffi",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi/app/errormanager:cj_errormanager_ffi",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi/ark_interop_helper:ark_interop_helper_ffi",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi/want_agent:cj_want_agent_ffi",
|
||||
]
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ WantHandle FFICJWantCreateWithWantInfo(CJWantParams params)
|
||||
want->SetUri(params.uri);
|
||||
want->SetAction(params.action);
|
||||
want->SetType(params.wantType);
|
||||
want->SetParams(OHOS::AAFwk::WantParamWrapper::ParseWantParams(params.parameters));
|
||||
want->SetParams(OHOS::AAFwk::WantParamWrapper::ParseWantParamsWithBrackets(params.parameters));
|
||||
|
||||
return want;
|
||||
}
|
||||
|
64
frameworks/cj/ffi/want_agent/BUILD.gn
Normal file
64
frameworks/cj/ffi/want_agent/BUILD.gn
Normal file
@ -0,0 +1,64 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
import("//foundation/ability/ability_runtime/cj_environment/cj_environment.gni")
|
||||
|
||||
ohos_shared_library("cj_want_agent_ffi") {
|
||||
defines = [
|
||||
"AMS_LOG_TAG = \"CJ_ABILITY_FFI\"",
|
||||
"AMS_LOG_DOMAIN = 0xD001150",
|
||||
]
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi/want_agent",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
"${ability_runtime_path}/frameworks/cj/ffi:cj_ability_ffi",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"napi:cj_bind_ffi",
|
||||
"napi:cj_bind_native",
|
||||
]
|
||||
|
||||
sources = [ "cj_want_agent_ffi.cpp" ]
|
||||
|
||||
cflags = [
|
||||
"-fstack-protector-all",
|
||||
"-fstack-protector-strong",
|
||||
"-O2",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
]
|
||||
|
||||
cflags_cc = cflags
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
249
frameworks/cj/ffi/want_agent/cj_want_agent_ffi.cpp
Normal file
249
frameworks/cj/ffi/want_agent/cj_want_agent_ffi.cpp
Normal file
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "want_agent_helper.h"
|
||||
#include "want_params_wrapper.h"
|
||||
#include "start_options.h"
|
||||
#include "cj_want_agent_ffi.h"
|
||||
#include "cj_ability_runtime_error.h"
|
||||
#include "cj_utils_ffi.h"
|
||||
#include "cj_lambda.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace FfiWantAgent {
|
||||
|
||||
using namespace OHOS::AbilityRuntime;
|
||||
|
||||
constexpr int32_t BUSINESS_ERROR_CODE_OK = 0;
|
||||
constexpr int32_t NOTEQ = -1;
|
||||
|
||||
CJTriggerCompleteCallBack::CJTriggerCompleteCallBack()
|
||||
{}
|
||||
|
||||
CJTriggerCompleteCallBack::~CJTriggerCompleteCallBack()
|
||||
{}
|
||||
|
||||
void CJTriggerCompleteCallBack::SetCallbackInfo(std::function<void(CJCompleteData)> callback)
|
||||
{
|
||||
callback_ = callback;
|
||||
}
|
||||
|
||||
void CJTriggerCompleteCallBack::SetWantAgentInstance(int64_t wantAgent)
|
||||
{
|
||||
wantAgent_ = wantAgent;
|
||||
}
|
||||
|
||||
void CJTriggerCompleteCallBack::OnSendFinished(
|
||||
const AAFwk::Want &want, int resultCode, const std::string &resultData, const AAFwk::WantParams &resultExtras)
|
||||
{
|
||||
CJCompleteData data = { .info = wantAgent_, .want = new (std::nothrow) AAFwk::Want(want),
|
||||
.finalCode = resultCode, .finalData = CreateCStringFromString(resultData),
|
||||
.extraInfo = CreateCStringFromString(OHOS::AAFwk::WantParamWrapper(resultExtras).ToString())};
|
||||
callback_(data);
|
||||
}
|
||||
|
||||
std::string CJWantAgent::OnGetBundleName(int32_t *errCode)
|
||||
{
|
||||
std::string bundleName = "";
|
||||
*errCode = WantAgentHelper::GetBundleName(wantAgent_, bundleName);
|
||||
return bundleName;
|
||||
}
|
||||
|
||||
int32_t CJWantAgent::OnGetUid(int32_t *errCode)
|
||||
{
|
||||
int uid = -1;
|
||||
*errCode = WantAgentHelper::GetUid(wantAgent_, uid);
|
||||
return uid;
|
||||
}
|
||||
|
||||
void CJWantAgent::OnCancel(int32_t *errCode)
|
||||
{
|
||||
*errCode = WantAgentHelper::Cancel(wantAgent_);
|
||||
}
|
||||
|
||||
void CJWantAgent::OnTrigger(CJTriggerInfo cjTriggerInfo, std::function<void(CJCompleteData)> callback, int32_t *errCode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "called");
|
||||
std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent = nullptr;
|
||||
TriggerInfo triggerInfo;
|
||||
auto triggerObj = std::make_shared<CJTriggerCompleteCallBack>();
|
||||
*errCode = UnWrapTriggerInfoParam(cjTriggerInfo, callback, wantAgent, triggerInfo, triggerObj);
|
||||
if (*errCode != NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "called");
|
||||
WantAgentHelper::TriggerWantAgent(wantAgent, triggerObj, triggerInfo);
|
||||
}
|
||||
|
||||
int32_t CJWantAgent::UnWrapTriggerInfoParam(CJTriggerInfo cjTriggerInfo, std::function<void(CJCompleteData)> callback,
|
||||
std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> &wantAgent, TriggerInfo &triggerInfo,
|
||||
std::shared_ptr<CJTriggerCompleteCallBack> &triggerObj)
|
||||
{
|
||||
wantAgent = wantAgent_;
|
||||
std::shared_ptr<AAFwk::Want> want = nullptr;
|
||||
if (cjTriggerInfo.hasWant) {
|
||||
auto actualWant = reinterpret_cast<AAFwk::Want*>(cjTriggerInfo.want);
|
||||
want = std::make_shared<AAFwk::Want>(*actualWant);
|
||||
}
|
||||
std::string permission = std::string(cjTriggerInfo.permission);
|
||||
std::shared_ptr<AAFwk::WantParams> extraInfo = nullptr;
|
||||
if (cjTriggerInfo.extraInfos != nullptr) {
|
||||
extraInfo = std::make_shared<AAFwk::WantParams>(
|
||||
OHOS::AAFwk::WantParamWrapper::ParseWantParamsWithBrackets(cjTriggerInfo.extraInfos));
|
||||
}
|
||||
std::shared_ptr<AAFwk::StartOptions> startOptions = std::make_shared<AAFwk::StartOptions>();
|
||||
|
||||
TriggerInfo triggerInfoData(permission, extraInfo, want, startOptions, cjTriggerInfo.code);
|
||||
triggerInfo = triggerInfoData;
|
||||
if (triggerObj != nullptr) {
|
||||
triggerObj->SetCallbackInfo(callback);
|
||||
triggerObj->SetWantAgentInstance(GetID());
|
||||
}
|
||||
return BUSINESS_ERROR_CODE_OK;
|
||||
}
|
||||
|
||||
int32_t CJWantAgent::OnGetOperationType(int32_t *errCode)
|
||||
{
|
||||
int32_t operType;
|
||||
*errCode = WantAgentHelper::GetType(wantAgent_, operType);
|
||||
return operType;
|
||||
}
|
||||
|
||||
bool CJWantAgent::OnEqual(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> second, int32_t *errCode)
|
||||
{
|
||||
*errCode = WantAgentHelper::IsEquals(wantAgent_, second);
|
||||
if (*errCode == BUSINESS_ERROR_CODE_OK) {
|
||||
return true;
|
||||
} else if (*errCode == NOTEQ) {
|
||||
*errCode = BUSINESS_ERROR_CODE_OK;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int64_t FfiWantAgentGetWantAgent(CJWantAgentInfo info, int32_t *errCode)
|
||||
{
|
||||
std::shared_ptr<AAFwk::WantParams> extraInfo =
|
||||
std::make_shared<AAFwk::WantParams>(
|
||||
OHOS::AAFwk::WantParamWrapper::ParseWantParamsWithBrackets(info.extraInfos));
|
||||
std::vector<WantAgentConstant::Flags> wantAgentFlags;
|
||||
for (int64_t i = 0; i < info.actionFlags.size; i++) {
|
||||
wantAgentFlags.emplace_back(static_cast<WantAgentConstant::Flags>(info.actionFlags.head[i]));
|
||||
}
|
||||
std::vector<std::shared_ptr<AAFwk::Want>> wants;
|
||||
for (int64_t i = 0; i < info.wants.size; i++) {
|
||||
auto actualWant = reinterpret_cast<AAFwk::Want*>(info.wants.head[i]);
|
||||
wants.emplace_back(std::make_shared<AAFwk::Want>(*actualWant));
|
||||
}
|
||||
WantAgentInfo wantAgentInfo(info.requestCode,
|
||||
static_cast<WantAgentConstant::OperationType>(info.actionType),
|
||||
wantAgentFlags,
|
||||
wants,
|
||||
extraInfo);
|
||||
auto context = Context::GetApplicationContext();
|
||||
std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent = nullptr;
|
||||
ErrCode result = WantAgentHelper::GetWantAgent(context, wantAgentInfo, wantAgent);
|
||||
if (result != NO_ERROR) {
|
||||
*errCode = result;
|
||||
return -1;
|
||||
} else {
|
||||
OHOS::AbilityRuntime::WantAgent::WantAgent* pWantAgent = nullptr;
|
||||
if (wantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return -1;
|
||||
} else {
|
||||
pWantAgent = new (std::nothrow) OHOS::AbilityRuntime::WantAgent::WantAgent(
|
||||
wantAgent->GetPendingWant());
|
||||
}
|
||||
if (pWantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return -1;
|
||||
} else {
|
||||
auto nativeWantAgent = OHOS::FFI::FFIData::Create<CJWantAgent>(
|
||||
std::make_shared<OHOS::AbilityRuntime::WantAgent::WantAgent>(*pWantAgent));
|
||||
return nativeWantAgent->GetID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char* FfiWantAgentGetBoundleName(int64_t cjWantAgent, int32_t *errCode)
|
||||
{
|
||||
auto nativeWantAgent = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgent);
|
||||
if (nativeWantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return nullptr;
|
||||
}
|
||||
std::string bundleName = nativeWantAgent->OnGetBundleName(errCode);
|
||||
if (*errCode != NO_ERROR) {
|
||||
return nullptr;
|
||||
}
|
||||
return CreateCStringFromString(bundleName);
|
||||
}
|
||||
|
||||
int32_t FfiWantAgentGetUid(int64_t cjWantAgent, int32_t *errCode)
|
||||
{
|
||||
auto nativeWantAgent = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgent);
|
||||
if (nativeWantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return -1;
|
||||
}
|
||||
return nativeWantAgent->OnGetUid(errCode);
|
||||
}
|
||||
|
||||
void FfiWantAgentCancel(int64_t cjWantAgent, int32_t *errCode)
|
||||
{
|
||||
auto nativeWantAgent = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgent);
|
||||
if (nativeWantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return;
|
||||
}
|
||||
return nativeWantAgent->OnCancel(errCode);
|
||||
}
|
||||
|
||||
void FfiWantAgentTrigger(int64_t cjWantAgent, CJTriggerInfo triggerInfo,
|
||||
void (*callback)(CJCompleteData), int32_t *errCode)
|
||||
{
|
||||
auto nativeWantAgent = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgent);
|
||||
if (nativeWantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return;
|
||||
}
|
||||
return nativeWantAgent->OnTrigger(triggerInfo, CJLambda::Create(callback), errCode);
|
||||
}
|
||||
|
||||
int32_t FfiWantAgentGetOperationType(int64_t cjWantAgent, int32_t *errCode)
|
||||
{
|
||||
auto nativeWantAgent = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgent);
|
||||
if (nativeWantAgent == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return -1;
|
||||
}
|
||||
return nativeWantAgent->OnGetOperationType(errCode);
|
||||
}
|
||||
|
||||
bool FfiWantAgentEqual(int64_t cjWantAgentFirst, int64_t cjWantAgentSecond, int32_t *errCode)
|
||||
{
|
||||
auto nativeWantAgentFirst = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgentFirst);
|
||||
auto nativeWantAgentSecond = OHOS::FFI::FFIData::GetData<CJWantAgent>(cjWantAgentSecond);
|
||||
if (nativeWantAgentFirst == nullptr || nativeWantAgentSecond == nullptr) {
|
||||
*errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
return false;
|
||||
}
|
||||
return nativeWantAgentFirst->OnEqual(nativeWantAgentSecond->wantAgent_, errCode);
|
||||
}
|
||||
}
|
||||
} // namespace FfiWantAgent
|
||||
} // namespace OHOS
|
86
frameworks/cj/ffi/want_agent/cj_want_agent_ffi.h
Normal file
86
frameworks/cj/ffi/want_agent/cj_want_agent_ffi.h
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CJ_WANT_AGENT_FFI_H
|
||||
#define CJ_WANT_AGENT_FFI_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "application_context.h"
|
||||
#include "want.h"
|
||||
#include "want_agent.h"
|
||||
#include "want_agent_constant.h"
|
||||
#include "want_params.h"
|
||||
#include "cj_common_ffi.h"
|
||||
#include "cj_want_agent_utils.h"
|
||||
#include "ffi_remote_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace FfiWantAgent {
|
||||
|
||||
using namespace OHOS::AbilityRuntime::WantAgent;
|
||||
|
||||
class CJTriggerCompleteCallBack : public CompletedCallback {
|
||||
public:
|
||||
CJTriggerCompleteCallBack();
|
||||
virtual ~CJTriggerCompleteCallBack();
|
||||
|
||||
public:
|
||||
void OnSendFinished(const AAFwk::Want &want, int resultCode, const std::string &resultData,
|
||||
const AAFwk::WantParams &resultExtras) override;
|
||||
void SetCallbackInfo(std::function<void(CJCompleteData)> callback);
|
||||
void SetWantAgentInstance(int64_t wantAgent);
|
||||
|
||||
private:
|
||||
std::function<void(CJCompleteData)> callback_;
|
||||
int64_t wantAgent_;
|
||||
};
|
||||
|
||||
class CJWantAgent : public OHOS::FFI::FFIData {
|
||||
DECL_TYPE(CJWantAgent, OHOS::FFI::FFIData)
|
||||
public:
|
||||
explicit CJWantAgent(std::shared_ptr<WantAgent> wantAgent)
|
||||
: wantAgent_(wantAgent) {};
|
||||
|
||||
std::string OnGetBundleName(int32_t *errCode);
|
||||
int32_t OnGetUid(int32_t *errCode);
|
||||
void OnCancel(int32_t *errCode);
|
||||
void OnTrigger(CJTriggerInfo triggerInfo, std::function<void(CJCompleteData)> callback, int32_t *errCode);
|
||||
int32_t OnGetOperationType(int32_t *errCode);
|
||||
bool OnEqual(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> second, int32_t *errCode);
|
||||
|
||||
private:
|
||||
int32_t UnWrapTriggerInfoParam(CJTriggerInfo cjTriggerInfo, std::function<void(CJCompleteData)> callback,
|
||||
std::shared_ptr<WantAgent> &wantAgent, TriggerInfo &triggerInfo,
|
||||
std::shared_ptr<CJTriggerCompleteCallBack> &triggerObj);
|
||||
|
||||
public:
|
||||
std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent_;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
FFI_EXPORT int64_t FfiWantAgentGetWantAgent(CJWantAgentInfo info, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiWantAgentGetBoundleName(int64_t cjWantAgent, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiWantAgentGetUid(int64_t cjWantAgent, int32_t *errCode);
|
||||
FFI_EXPORT void FfiWantAgentCancel(int64_t cjWantAgent, int32_t *errCode);
|
||||
FFI_EXPORT void FfiWantAgentTrigger(int64_t cjWantAgent, CJTriggerInfo triggerInfo,
|
||||
void (*callback)(CJCompleteData), int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiWantAgentGetOperationType(int64_t cjWantAgent, int32_t *errCode);
|
||||
FFI_EXPORT bool FfiWantAgentEqual(int64_t cjWantAgentFirst, int64_t cjWantAgentSecond, int32_t *errCode);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif // CJ_WANT_AGENT_FFI_H
|
63
frameworks/cj/ffi/want_agent/cj_want_agent_utils.h
Normal file
63
frameworks/cj/ffi/want_agent/cj_want_agent_utils.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CJ_WANT_AGENT_UTILS_FFI_H
|
||||
#define CJ_WANT_AGENT_UTILS_FFI_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "want_agent_constant.h"
|
||||
#include "want_agent_helper.h"
|
||||
#include "cj_want_ffi.h"
|
||||
#include "cj_common_ffi.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace FfiWantAgent {
|
||||
|
||||
struct CJWantArr {
|
||||
WantHandle* head;
|
||||
int64_t size;
|
||||
};
|
||||
|
||||
struct CJWantAgentInfo {
|
||||
CJWantArr wants;
|
||||
int32_t actionType;
|
||||
int32_t requestCode;
|
||||
CArrI32 actionFlags;
|
||||
// Record<string, Object>
|
||||
char* extraInfos;
|
||||
};
|
||||
|
||||
struct CJTriggerInfo {
|
||||
int32_t code;
|
||||
WantHandle want;
|
||||
bool hasWant;
|
||||
char* permission;
|
||||
// Record<string, Object>
|
||||
char* extraInfos;
|
||||
};
|
||||
|
||||
struct CJCompleteData {
|
||||
int64_t info;
|
||||
WantHandle want;
|
||||
int32_t finalCode;
|
||||
char* finalData;
|
||||
// Record<string, Object>
|
||||
char* extraInfo;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif // CJ_WANT_AGENT_UTILS_FFI_H
|
@ -14,11 +14,15 @@
|
||||
*/
|
||||
let Callee = requireNapi('application.Callee');
|
||||
let AbilityConstant = requireNapi('app.ability.AbilityConstant');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class Ability {
|
||||
constructor() {
|
||||
this.callee = new Callee('rpc.application.callee');
|
||||
console.log('Ability::constructor callee is ' + typeof this.callee + ' ' + this.callee);
|
||||
hilog.sLogI(domainID, TAG, 'Ability::constructor callee is ' + typeof this.callee + ' ' + this.callee);
|
||||
}
|
||||
onCreate(want) { }
|
||||
onDestroy() { }
|
||||
@ -32,7 +36,7 @@ class Ability {
|
||||
onMemoryLevel(level) { }
|
||||
onWindowStageRestore(windowStage) { }
|
||||
onCallRequest() {
|
||||
console.log('Ability::onCallRequest callee is ' + typeof this.callee + ' ' + this.callee);
|
||||
hilog.sLogI(domainID, TAG, 'Ability::onCallRequest callee is ' + typeof this.callee + ' ' + this.callee);
|
||||
return this.callee;
|
||||
}
|
||||
onContinue(wantParams) { }
|
||||
|
@ -12,6 +12,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const URI_SPLIT = '/';
|
||||
|
||||
const ERROR_CODE_INVALID_PARAM = 401;
|
||||
@ -39,7 +44,7 @@ class DataUriError extends Error {
|
||||
|
||||
let dataUriUtils = {
|
||||
getId: (uri) => {
|
||||
console.debug('DataUriUtils getId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils getId called.');
|
||||
if (typeof uri !== 'string') {
|
||||
throw new DataUriError(ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
@ -54,7 +59,7 @@ let dataUriUtils = {
|
||||
return Number(ret);
|
||||
},
|
||||
updateId: (uri, id) => {
|
||||
console.debug('DataUriUtils updateId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils updateId called.');
|
||||
if (typeof uri !== 'string' || typeof id !== 'number') {
|
||||
throw new DataUriError(ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
@ -65,7 +70,7 @@ let dataUriUtils = {
|
||||
return ret + URI_SPLIT + id;
|
||||
},
|
||||
deleteId: (uri) => {
|
||||
console.debug('DataUriUtils deleteId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils deleteId called.');
|
||||
if (typeof uri !== 'string') {
|
||||
throw new DataUriError(ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
@ -80,7 +85,7 @@ let dataUriUtils = {
|
||||
return uri.substring(0, index);
|
||||
},
|
||||
attachId: (uri, id) => {
|
||||
console.debug('DataUriUtils attachId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils attachId called.');
|
||||
if (typeof uri !== 'string' || typeof id !== 'number') {
|
||||
throw new DataUriError(ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
|
@ -15,6 +15,10 @@
|
||||
|
||||
let Context = requireNapi('application.Context');
|
||||
let Caller = requireNapi('application.Caller');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const ERROR_CODE_INVALID_PARAM = 401;
|
||||
const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.';
|
||||
@ -61,7 +65,7 @@ class AbilityContext extends Context {
|
||||
startAbilityByCall(want) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (typeof want !== 'object' || want == null) {
|
||||
console.log('AbilityContext::startAbilityByCall input param error');
|
||||
hilog.sLogI(domainID, TAG, 'AbilityContext::startAbilityByCall input param error');
|
||||
reject(new ParamError('Parse param want failed, want must be Want'));
|
||||
return;
|
||||
}
|
||||
@ -70,13 +74,13 @@ class AbilityContext extends Context {
|
||||
try {
|
||||
callee = await this.__context_impl__.startAbilityByCall(want);
|
||||
} catch (error) {
|
||||
console.log('AbilityContext::startAbilityByCall Obtain remoteObject failed');
|
||||
hilog.sLogI(domainID, TAG, 'AbilityContext::startAbilityByCall Obtain remoteObject failed');
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(new Caller(callee));
|
||||
console.log('AbilityContext::startAbilityByCall success');
|
||||
hilog.sLogI(domainID, TAG, 'AbilityContext::startAbilityByCall success');
|
||||
return;
|
||||
});
|
||||
}
|
||||
@ -84,7 +88,7 @@ class AbilityContext extends Context {
|
||||
startAbilityByCallWithAccount(want, accountId) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (typeof want !== 'object' || want == null || typeof accountId !== 'number') {
|
||||
console.log('AbilityContext::startAbilityByCall With accountId input param error');
|
||||
hilog.sLogI(domainID, TAG, 'AbilityContext::startAbilityByCall With accountId input param error');
|
||||
reject(new ParamError(
|
||||
'Parse param want or accountId failed, want must be Want and accountId must be number'));
|
||||
return;
|
||||
@ -94,13 +98,13 @@ class AbilityContext extends Context {
|
||||
try {
|
||||
callee = await this.__context_impl__.startAbilityByCall(want, accountId);
|
||||
} catch (error) {
|
||||
console.log('AbilityContext::startAbilityByCall With accountId Obtain remoteObject failed');
|
||||
hilog.sLogI(domainID, TAG, 'AbilityContext::startAbilityByCall With accountId Obtain remoteObject failed');
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(new Caller(callee));
|
||||
console.log('AbilityContext::startAbilityByCall With accountId success');
|
||||
hilog.sLogI(domainID, TAG, 'AbilityContext::startAbilityByCall With accountId success');
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
@ -12,96 +12,100 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class AbilityLifecycleCallback {
|
||||
constructor() {}
|
||||
|
||||
onAbilityCreate(ability) {
|
||||
console.log('onAbilityCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityCreate');
|
||||
}
|
||||
|
||||
onWindowStageCreate(ability, windowStage) {
|
||||
console.log('onWindowStageCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageCreate');
|
||||
}
|
||||
|
||||
onWindowStageActive(ability, windowStage) {
|
||||
console.log('onWindowStageActive');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageActive');
|
||||
}
|
||||
|
||||
onWindowStageInactive(ability, windowStage) {
|
||||
console.log('onWindowStageInactive');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageInactive');
|
||||
}
|
||||
|
||||
onWindowStageDestroy(ability, windowStage) {
|
||||
console.log('onWindowStageDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onAbilityDestroy(ability) {
|
||||
console.log('onAbilityDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityDestroy');
|
||||
}
|
||||
|
||||
onAbilityForeground(ability) {
|
||||
console.log('onAbilityForeground');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityForeground');
|
||||
}
|
||||
|
||||
onAbilityBackground(ability) {
|
||||
console.log('onAbilityBackground');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityBackground');
|
||||
}
|
||||
|
||||
onAbilityContinue(ability) {
|
||||
console.log('onAbilityContinue');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityContinue');
|
||||
}
|
||||
|
||||
onNewWant(ability) {
|
||||
console.log('onNewWant');
|
||||
hilog.sLogI(domainID, TAG, 'onNewWant');
|
||||
}
|
||||
|
||||
onWillNewWant(ability) {
|
||||
console.log('onWillNewWant');
|
||||
hilog.sLogI(domainID, TAG, 'onWillNewWant');
|
||||
}
|
||||
|
||||
onAbilityWillCreate(ability) {
|
||||
console.log('onAbilityWillCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityWillCreate');
|
||||
}
|
||||
|
||||
onWindowStageWillCreate(ability, windowStage) {
|
||||
console.log('onWindowStageWillCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageWillCreate');
|
||||
}
|
||||
|
||||
onWindowStageWillDestroy(ability, windowStage) {
|
||||
console.log('onWindowStageWillDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageWillDestroy');
|
||||
}
|
||||
|
||||
onAbilityWillDestroy(ability) {
|
||||
console.log('onAbilityWillDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityWillDestroy');
|
||||
}
|
||||
|
||||
onAbilityWillForeground(ability) {
|
||||
console.log('onAbilityWillForeground');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityWillForeground');
|
||||
}
|
||||
|
||||
onAbilityWillBackground(ability) {
|
||||
console.log('onAbilityWillBackground');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityWillBackground');
|
||||
}
|
||||
|
||||
onAbilityWillContinue(ability) {
|
||||
console.log('onAbilityWillContinue');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityWillContinue');
|
||||
}
|
||||
|
||||
onWindowStageWillRestore(ability, windowStage) {
|
||||
console.log('onWindowStageWillRestore');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageWillRestore');
|
||||
}
|
||||
|
||||
onWindowStageRestore(ability, windowStage) {
|
||||
console.log('onWindowStageRestore');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageRestore');
|
||||
}
|
||||
|
||||
onAbilityWillSaveState(ability) {
|
||||
console.log('onAbilityWillSaveState');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilityWillSaveState');
|
||||
}
|
||||
|
||||
onAbilitySaveState(ability) {
|
||||
console.log('onAbilitySaveState');
|
||||
hilog.sLogI(domainID, TAG, 'onAbilitySaveState');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,15 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class AbilityStage {
|
||||
constructor() { }
|
||||
onCreate() { }
|
||||
onDestroy() { }
|
||||
onAcceptWant(want) {
|
||||
console.log('onAcceptWant, want:' + want.abilityName);
|
||||
hilog.sLogI(domainID, TAG, 'onAcceptWant, want:' + want.abilityName);
|
||||
}
|
||||
onNewProcessRequest(want) {
|
||||
console.log('onNewProcessRequest, want:' + want.abilityName);
|
||||
hilog.sLogI(domainID, TAG, 'onNewProcessRequest, want:' + want.abilityName);
|
||||
}
|
||||
onConfigurationUpdated(config) { }
|
||||
onConfigurationUpdate(newConfig) { }
|
||||
|
@ -13,15 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class ApplicationStateChangeCallback {
|
||||
constructor() {}
|
||||
|
||||
onApplicationForeground() {
|
||||
console.log('onApplicationForeground');
|
||||
hilog.sLogI(domainID, TAG, 'onApplicationForeground');
|
||||
}
|
||||
|
||||
onApplicationBackground() {
|
||||
console.log('onApplicationBackground');
|
||||
hilog.sLogI(domainID, TAG, 'onApplicationBackground');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,15 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class EnvironmentCallback {
|
||||
constructor() {}
|
||||
|
||||
onConfigurationUpdated(config) {
|
||||
console.log('onConfigurationUpdated');
|
||||
hilog.sLogI(domainID, TAG, 'onConfigurationUpdated');
|
||||
}
|
||||
|
||||
onMemoryLevel(level) {
|
||||
console.log('onMemoryLevel');
|
||||
hilog.sLogI(domainID, TAG, 'onMemoryLevel');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,13 +111,22 @@ napi_value CreateJsBaseContextFromSendable(napi_env env, void* wrapped)
|
||||
}
|
||||
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<Context>(contextPtr);
|
||||
auto status = napi_wrap(env, object, workContext,
|
||||
auto status = napi_coerce_to_native_binding_object(env, object, DetachCallbackFunc, AttachBaseContext,
|
||||
workContext, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "coerce context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
status = napi_wrap(env, object, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "finalizer for weak_ptr context");
|
||||
delete static_cast<std::weak_ptr<Context> *>(data);
|
||||
}, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "wrap context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -160,13 +169,22 @@ napi_value CreateJsApplicationContextFromSendable(napi_env env, void* wrapped)
|
||||
}
|
||||
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<ApplicationContext>(applicationContext);
|
||||
auto status = napi_wrap(env, object, workContext,
|
||||
auto status = napi_coerce_to_native_binding_object(env, object, DetachCallbackFunc, AttachApplicationContext,
|
||||
workContext, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "coerce application context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
status = napi_wrap(env, object, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "finalizer for weak_ptr application context");
|
||||
delete static_cast<std::weak_ptr<ApplicationContext> *>(data);
|
||||
}, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "wrap application context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -209,13 +227,22 @@ napi_value CreateJsAbilityStageContextFromSendable(napi_env env, void* wrapped)
|
||||
}
|
||||
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityStageContext>(abilitystageContext);
|
||||
auto status = napi_wrap(env, object, workContext,
|
||||
auto status = napi_coerce_to_native_binding_object(env, object, DetachCallbackFunc, AttachAbilityStageContext,
|
||||
workContext, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "coerce ability stage context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
status = napi_wrap(env, object, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "finalizer for weak_ptr ability stage context");
|
||||
delete static_cast<std::weak_ptr<AbilityStageContext> *>(data);
|
||||
}, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "wrap ability stage context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -258,13 +285,22 @@ napi_value CreateJsUIAbilityContextFromSendable(napi_env env, void* wrapped)
|
||||
}
|
||||
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityContext>(uiAbilityContext);
|
||||
auto status = napi_wrap(env, object, workContext,
|
||||
auto status = napi_coerce_to_native_binding_object(env, object, DetachCallbackFunc, AttachJsUIAbilityContext,
|
||||
workContext, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "coerce ui ability context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
status = napi_wrap(env, object, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "finalizer for weak_ptr ui ability context");
|
||||
delete static_cast<std::weak_ptr<AbilityContext> *>(data);
|
||||
}, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "wrap ui ability context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,9 @@
|
||||
async function concurrentFunc(startup, asyncCallback, context, startupName): void {
|
||||
'use concurrent';
|
||||
console.log('concurrentFunc start.');
|
||||
let startupResult;
|
||||
await startup.init(context).then((result: Object) => {
|
||||
startupResult = result;
|
||||
let taskPool = requireNapi('taskpool');
|
||||
taskPool.Task.sendData(asyncCallback, startupName, startupResult);
|
||||
});
|
||||
let startupResult = await startup.init(context);
|
||||
let taskPool = requireNapi('taskpool');
|
||||
taskPool.Task.sendData(asyncCallback, startupName, startupResult);
|
||||
console.log('concurrentFunc end.');
|
||||
}
|
||||
|
||||
|
@ -14,38 +14,42 @@
|
||||
*/
|
||||
|
||||
let ExtensionAbility = requireNapi('app.ability.ExtensionAbility');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class AutoFillExtensionAbility extends ExtensionAbility {
|
||||
onCreate() {
|
||||
console.log('onCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onCreate');
|
||||
}
|
||||
|
||||
onFillRequest(session, request, callback) {
|
||||
console.log('onFillRequest');
|
||||
hilog.sLogI(domainID, TAG, 'onFillRequest');
|
||||
}
|
||||
|
||||
onSaveRequest(session, request, callback) {
|
||||
console.log('onSaveRequest');
|
||||
hilog.sLogI(domainID, TAG, 'onSaveRequest');
|
||||
}
|
||||
|
||||
onUpdateRequest(request) {
|
||||
console.log('onUpdateRequest');
|
||||
hilog.sLogI(domainID, TAG, 'onUpdateRequest');
|
||||
}
|
||||
|
||||
onSessionDestroy(session) {
|
||||
console.log('onSessionDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onSessionDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
console.log('onForeground');
|
||||
hilog.sLogI(domainID, TAG, 'onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
console.log('onBackground');
|
||||
hilog.sLogI(domainID, TAG, 'onBackground');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log('onDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onDestroy');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
*/
|
||||
let rpc = requireNapi('rpc');
|
||||
let accessControl = requireNapi('abilityAccessCtrl');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const EVENT_CALL_NOTIFY = 1;
|
||||
const REQUEST_SUCCESS = 0;
|
||||
@ -63,9 +67,9 @@ class Callee extends rpc.RemoteObject {
|
||||
super(des);
|
||||
this.callList = new Map();
|
||||
this.startUpNewRule = false;
|
||||
console.log('Callee constructor is OK ' + typeof des);
|
||||
hilog.sLogI(domainID, TAG, 'Callee constructor is OK ' + typeof des);
|
||||
} else {
|
||||
console.log('Callee constructor error, des is ' + typeof des);
|
||||
hilog.sLogI(domainID, TAG, 'Callee constructor error, des is ' + typeof des);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -75,31 +79,31 @@ class Callee extends rpc.RemoteObject {
|
||||
}
|
||||
|
||||
onRemoteMessageRequest(code, data, reply, option) {
|
||||
console.log('Callee onRemoteMessageRequest code [' + typeof code + ' ' + code + ']');
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest code [' + typeof code + ' ' + code + ']');
|
||||
if (!this.StartUpRuleCheck()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof code !== 'number' || typeof data !== 'object' ||
|
||||
typeof reply !== 'object' || typeof option !== 'object') {
|
||||
console.log('Callee onRemoteMessageRequest error, code is [' +
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest error, code is [' +
|
||||
typeof code + '], data is [' + typeof data + '], reply is [' +
|
||||
typeof reply + '], option is [' + typeof option + ']');
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log('Callee onRemoteMessageRequest code proc');
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest code proc');
|
||||
if (code === EVENT_CALL_NOTIFY) {
|
||||
if (this.callList == null) {
|
||||
console.log('Callee onRemoteMessageRequest error, this.callList is nullptr');
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest error, this.callList is nullptr');
|
||||
return false;
|
||||
}
|
||||
|
||||
let method = data.readString();
|
||||
console.log('Callee onRemoteMessageRequest method [' + method + ']');
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest method [' + method + ']');
|
||||
let func = this.callList.get(method);
|
||||
if (typeof func !== 'function') {
|
||||
console.log('Callee onRemoteMessageRequest error, get func is ' + typeof func);
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest error, get func is ' + typeof func);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -108,71 +112,72 @@ class Callee extends rpc.RemoteObject {
|
||||
reply.writeInt(REQUEST_SUCCESS);
|
||||
reply.writeString(typeof result);
|
||||
reply.writeParcelable(result);
|
||||
console.log('Callee onRemoteMessageRequest code proc Packed data');
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest code proc Packed data');
|
||||
} else {
|
||||
reply.writeInt(REQUEST_FAILED);
|
||||
reply.writeString(typeof result);
|
||||
console.log('Callee onRemoteMessageRequest error, retval is ' + REQUEST_FAILED + ', type is ' + typeof result);
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest error, retval is ' +
|
||||
REQUEST_FAILED + ', type is ' + typeof result, REQUEST_FAILED, typeof result);
|
||||
}
|
||||
} else {
|
||||
console.log('Callee onRemoteMessageRequest error, code is ' + code);
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest error, code is ' + code);
|
||||
return false;
|
||||
}
|
||||
console.log('Callee onRemoteMessageRequest code proc success');
|
||||
hilog.sLogI(domainID, TAG, 'Callee onRemoteMessageRequest code proc success');
|
||||
return true;
|
||||
}
|
||||
|
||||
on(method, callback) {
|
||||
if (typeof method !== 'string' || method === '' || typeof callback !== 'function') {
|
||||
console.log(
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Callee on error, method is [' + typeof method + '], typeof callback [' + typeof callback + ']');
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get method or callback.' +
|
||||
'method must be a non-empty string, callback must be a function.');
|
||||
}
|
||||
|
||||
if (this.callList == null) {
|
||||
console.log('Callee on error, this.callList is nullptr');
|
||||
hilog.sLogI(domainID, TAG, 'Callee on error, this.callList is nullptr');
|
||||
throw new BusinessError(ERROR_CODE_INNER_ERROR);
|
||||
}
|
||||
|
||||
if (this.callList.has(method)) {
|
||||
console.log('Callee on error, [' + method + '] has registered');
|
||||
hilog.sLogI(domainID, TAG, 'Callee on error, [' + method + '] has registered');
|
||||
throw new BusinessError(ERROR_CODE_FUNC_REGISTERED);
|
||||
}
|
||||
|
||||
this.callList.set(method, callback);
|
||||
console.log('Callee on method [' + method + ']');
|
||||
hilog.sLogI(domainID, TAG, 'Callee on method [' + method + ']');
|
||||
}
|
||||
|
||||
off(method) {
|
||||
if (typeof method !== 'string' || method === '') {
|
||||
console.log('Callee off error, method is [' + typeof method + ']');
|
||||
hilog.sLogI(domainID, TAG, 'Callee off error, method is [' + typeof method + ']');
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get method, must be a string.');
|
||||
}
|
||||
|
||||
if (this.callList == null) {
|
||||
console.log('Callee off error, this.callList is null');
|
||||
hilog.sLogI(domainID, TAG, 'Callee off error, this.callList is null');
|
||||
throw new BusinessError(ERROR_CODE_INNER_ERROR);
|
||||
}
|
||||
|
||||
if (!this.callList.has(method)) {
|
||||
console.log('Callee off error, this.callList not found ' + method);
|
||||
hilog.sLogI(domainID, TAG, 'Callee off error, this.callList not found ' + method);
|
||||
throw new BusinessError(ERROR_CODE_FUNC_NOT_EXIST);
|
||||
}
|
||||
|
||||
this.callList.delete(method);
|
||||
console.log('Callee off method [' + method + ']');
|
||||
hilog.sLogI(domainID, TAG, 'Callee off method [' + method + ']');
|
||||
}
|
||||
|
||||
StartUpRuleCheck() {
|
||||
if (this.startUpNewRule && rpc.IPCSkeleton.isLocalCalling()) {
|
||||
console.log('Use new start up rule, check caller permission.');
|
||||
hilog.sLogI(domainID, TAG, 'Use new start up rule, check caller permission.');
|
||||
let accessManger = accessControl.createAtManager();
|
||||
let accessTokenId = rpc.IPCSkeleton.getCallingTokenId();
|
||||
let grantStatus =
|
||||
accessManger.verifyAccessTokenSync(accessTokenId, PERMISSION_ABILITY_BACKGROUND_COMMUNICATION);
|
||||
if (grantStatus === accessControl.GrantStatus.PERMISSION_DENIED) {
|
||||
console.log(
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Callee onRemoteMessageRequest error, the Caller does not have PERMISSION_ABILITY_BACKGROUND_COMMUNICATION');
|
||||
return false;
|
||||
}
|
||||
|
@ -13,6 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
let rpc = requireNapi('rpc');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const EVENT_CALL_NOTIFY = 1;
|
||||
const REQUEST_SUCCESS = 0;
|
||||
@ -56,7 +60,7 @@ class ThrowInvalidParamError extends Error {
|
||||
|
||||
class Caller {
|
||||
constructor(obj) {
|
||||
console.log('Caller::constructor obj is ' + typeof obj);
|
||||
hilog.sLogI(domainID, TAG, 'Caller::constructor obj is ' + typeof obj);
|
||||
this.__call_obj__ = obj;
|
||||
this.releaseState = false;
|
||||
}
|
||||
@ -69,7 +73,7 @@ class Caller {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Caller call msgData rpc.MessageSequence create');
|
||||
hilog.sLogI(domainID, TAG, 'Caller call msgData rpc.MessageSequence create');
|
||||
let msgData = this.buildMsgData(method, data);
|
||||
let msgReply = rpc.MessageSequence.create();
|
||||
|
||||
@ -77,16 +81,16 @@ class Caller {
|
||||
try {
|
||||
retData = await this.__call_obj__.callee.sendMessageRequest(EVENT_CALL_NOTIFY, msgData, msgReply,
|
||||
rpc.MessageOption());
|
||||
console.log('Caller call msgData rpc.sendMessageRequest called');
|
||||
hilog.sLogI(domainID, TAG, 'Caller call msgData rpc.sendMessageRequest called');
|
||||
if (retData.errCode !== 0) {
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
console.log('Caller call return errCode ' + retData.errCode);
|
||||
hilog.sLogI(domainID, TAG, 'Caller call return errCode ' + retData.errCode);
|
||||
reject(new BusinessError(retData.errCode));
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Caller call msgData rpc.sendMessageRequest error ' + e);
|
||||
hilog.sLogI(domainID, TAG, 'Caller call msgData rpc.sendMessageRequest error ' + e);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -96,21 +100,22 @@ class Caller {
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
} else {
|
||||
console.log('Caller call retval is [' + retval + '], str [' + str + ']');
|
||||
hilog.sLogD(domainID, TAG,
|
||||
'Caller call retval is [' + retval + '], str [' + str + ']');
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
reject(new BusinessError(retval));
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Caller call msgData sendMessageRequest retval error');
|
||||
hilog.sLogI(domainID, TAG, 'Caller call msgData sendMessageRequest retval error');
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
reject(new BusinessError(ERROR_CODE_INNER_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Caller call msgData sendMessageRequest end');
|
||||
hilog.sLogI(domainID, TAG, 'Caller call msgData sendMessageRequest end');
|
||||
resolve(undefined);
|
||||
return;
|
||||
});
|
||||
@ -118,14 +123,14 @@ class Caller {
|
||||
|
||||
callWithResult(method, data) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
console.log('Caller callWithResult method [' + method + ']');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callWithResult method [' + method + ']');
|
||||
const checkError = this.callCheck(method, data);
|
||||
if (checkError != null) {
|
||||
reject(checkError);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Caller callWithResult msgData rpc.MessageSequence create');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callWithResult msgData rpc.MessageSequence create');
|
||||
let msgData = this.buildMsgData(method, data);
|
||||
let msgReply = rpc.MessageSequence.create();
|
||||
|
||||
@ -134,16 +139,16 @@ class Caller {
|
||||
try {
|
||||
retData = await this.__call_obj__.callee.sendMessageRequest(EVENT_CALL_NOTIFY, msgData, msgReply,
|
||||
rpc.MessageOption());
|
||||
console.log('Caller callWithResult msgData rpc.sendMessageRequest called');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callWithResult msgData rpc.sendMessageRequest called');
|
||||
if (retData.errCode !== 0) {
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
console.log('Caller callWithResult return errCode ' + retData.errCode);
|
||||
hilog.sLogI(domainID, TAG, 'Caller callWithResult return errCode ' + retData.errCode);
|
||||
reject(new BusinessError(retData.errCode));
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Caller call msgData rpc.MessageSequence error ' + e);
|
||||
hilog.sLogI(domainID, TAG, 'Caller call msgData rpc.MessageSequence error ' + e);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -153,35 +158,36 @@ class Caller {
|
||||
msgData.reclaim();
|
||||
reply = retData.reply;
|
||||
} else {
|
||||
console.log('Caller callWithResult retval is [' + retval + '], str [' + str + ']');
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Caller callWithResult retval is [' + retval + '], str [' + str + ']');
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
reject(new BusinessError(retval));
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Caller callWithResult msgData sendMessageRequest retval error');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callWithResult msgData sendMessageRequest retval error');
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
reject(new BusinessError(ERROR_CODE_INNER_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Caller callWithResult msgData sendMessageRequest end');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callWithResult msgData sendMessageRequest end');
|
||||
resolve(reply);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
release() {
|
||||
console.log('Caller release js called.');
|
||||
hilog.sLogI(domainID, TAG, 'Caller release js called.');
|
||||
if (this.releaseState === true) {
|
||||
console.log('Caller release remoteObj releaseState is true');
|
||||
hilog.sLogI(domainID, TAG, 'Caller release remoteObj releaseState is true');
|
||||
throw new BusinessError(ERROR_CODE_CALLER_RELEASED);
|
||||
}
|
||||
|
||||
if (this.__call_obj__.callee == null) {
|
||||
console.log('Caller release call remoteObj is released');
|
||||
hilog.sLogI(domainID, TAG, 'Caller release call remoteObj is released');
|
||||
throw new BusinessError(ERROR_CODE_CLAAEE_INVALID);
|
||||
}
|
||||
|
||||
@ -190,14 +196,14 @@ class Caller {
|
||||
}
|
||||
|
||||
onRelease(callback) {
|
||||
console.log('Caller onRelease jscallback called.');
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease jscallback called.');
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Caller onRelease ' + typeof callback);
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease ' + typeof callback);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
console.log('Caller onRelease remoteObj releaseState is true');
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease remoteObj releaseState is true');
|
||||
throw new BusinessError(ERROR_CODE_CALLER_RELEASED);
|
||||
}
|
||||
|
||||
@ -205,14 +211,14 @@ class Caller {
|
||||
}
|
||||
|
||||
onRemoteStateChange(callback) {
|
||||
console.log('Caller onRemoteStateChange jscallback called.');
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRemoteStateChange jscallback called.');
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Caller onRemoteStateChange ' + typeof callback);
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRemoteStateChange ' + typeof callback);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
console.log('Caller onRemoteStateChange remoteObj releaseState is true');
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRemoteStateChange remoteObj releaseState is true');
|
||||
throw new BusinessError(ERROR_CODE_CALLER_RELEASED);
|
||||
}
|
||||
|
||||
@ -220,20 +226,20 @@ class Caller {
|
||||
}
|
||||
|
||||
on(type, callback) {
|
||||
console.log('Caller onRelease jscallback called.');
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease jscallback called.');
|
||||
if (typeof type !== 'string' || type !== 'release') {
|
||||
console.log(
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Caller onRelease error, input [type] is invalid.');
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get type, must be string type release.');
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Caller onRelease error ' + typeof callback);
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease error ' + typeof callback);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
console.log('Caller onRelease error, remoteObj releaseState is true');
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease error, remoteObj releaseState is true');
|
||||
throw new BusinessError(ERROR_CODE_CALLER_RELEASED);
|
||||
}
|
||||
|
||||
@ -242,13 +248,13 @@ class Caller {
|
||||
|
||||
off(type, callback) {
|
||||
if (typeof type !== 'string' || type !== 'release') {
|
||||
console.log(
|
||||
'Caller onRelease error, input [type] is invalid.');
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Caller onRelease error, input [type] is invalid.');
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get type, must be string type release.');
|
||||
}
|
||||
|
||||
if (callback && typeof callback !== 'function') {
|
||||
console.log('Caller onRelease error ' + typeof callback);
|
||||
hilog.sLogI(domainID, TAG, 'Caller onRelease error ' + typeof callback);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
// Empty
|
||||
@ -256,23 +262,25 @@ class Caller {
|
||||
|
||||
callCheck(method, data) {
|
||||
if (typeof method !== 'string' || typeof data !== 'object') {
|
||||
console.log('Caller callCheck ' + typeof method + ' ' + typeof data);
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Caller callCheck ' + typeof method + ' ' + typeof data);
|
||||
return new ThrowInvalidParamError('Parameter error: Failed to get method or data, ' +
|
||||
'method must be a string, data must be a rpc.Parcelable');
|
||||
}
|
||||
|
||||
if (method === '' || data == null) {
|
||||
console.log('Caller callCheck ' + method + ', ' + data);
|
||||
hilog.sLogI(domainID, TAG,
|
||||
'Caller callCheck ' + method + ', ' + data);
|
||||
return new ThrowInvalidParamError('Parameter error: method or data is empty, Please check it.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
console.log('Caller callCheck this.callee release');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callCheck this.callee release');
|
||||
return new BusinessError(ERROR_CODE_CALLER_RELEASED);
|
||||
}
|
||||
|
||||
if (this.__call_obj__.callee == null) {
|
||||
console.log('Caller callCheck this.callee is nullptr');
|
||||
hilog.sLogI(domainID, TAG, 'Caller callCheck this.callee is nullptr');
|
||||
return new BusinessError(ERROR_CODE_CLAAEE_INVALID);
|
||||
}
|
||||
return null;
|
||||
|
@ -12,11 +12,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const URI_SPLIT = '/';
|
||||
|
||||
let dataUriUtils = {
|
||||
getId: (uri) => {
|
||||
console.debug('DataUriUtils getId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils getId called.');
|
||||
if (typeof uri !== 'string') {
|
||||
return -1;
|
||||
}
|
||||
@ -31,7 +37,7 @@ let dataUriUtils = {
|
||||
return Number(ret);
|
||||
},
|
||||
updateId: (uri, id) => {
|
||||
console.debug('DataUriUtils updateId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils updateId called.');
|
||||
if (typeof uri !== 'string' || typeof id !== 'number') {
|
||||
return uri;
|
||||
}
|
||||
@ -42,7 +48,7 @@ let dataUriUtils = {
|
||||
return ret + URI_SPLIT + id;
|
||||
},
|
||||
deleteId: (uri) => {
|
||||
console.debug('DataUriUtils deleteId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils deleteId called.');
|
||||
if (typeof uri !== 'string') {
|
||||
return uri;
|
||||
}
|
||||
@ -57,7 +63,7 @@ let dataUriUtils = {
|
||||
return uri.substring(0, index);
|
||||
},
|
||||
attachId: (uri, id) => {
|
||||
console.debug('DataUriUtils attachId called.');
|
||||
hilog.sLogD(domainID, TAG, 'DataUriUtils attachId called.');
|
||||
if (typeof uri !== 'string' || typeof id !== 'number') {
|
||||
return uri;
|
||||
}
|
||||
|
@ -13,14 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class ExtensionAbility {
|
||||
|
||||
onConfigurationUpdate(config) {
|
||||
console.log('onConfigurationUpdate');
|
||||
hilog.sLogI(domainID, TAG, 'onConfigurationUpdate');
|
||||
}
|
||||
|
||||
onMemoryLevel(level) {
|
||||
console.log('onMemoryLevel');
|
||||
hilog.sLogI(domainID, TAG, 'onMemoryLevel');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,5 +22,5 @@
|
||||
#include "napi_common_util.h"
|
||||
#include "napi_common_want.h"
|
||||
#include "napi_common_start_options.h"
|
||||
#include "./open_link/napi_common_open_link_options.h"
|
||||
#include "open_link/napi_common_open_link_options.h"
|
||||
#endif // OHOS_ABILITY_RUNTIME_NAPI_COMMON_H
|
||||
|
@ -13,32 +13,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class InsightIntentExecutor {
|
||||
constructor() {}
|
||||
|
||||
onExecuteInUIAbilityForegroundMode(name, param, pageLoader) {
|
||||
console.log(`onExecuteInUIAbilityForegroundMode ${name}`);
|
||||
hilog.sLogI(domainID, TAG, `onExecuteInUIAbilityForegroundMode ${name}`);
|
||||
return {
|
||||
'code': 0
|
||||
};
|
||||
}
|
||||
|
||||
onExecuteInUIAbilityBackgroundMode(name, param) {
|
||||
console.log(`onExecuteInUIAbilityForegroundMode ${name}`);
|
||||
hilog.sLogI(domainID, TAG, `onExecuteInUIAbilityForegroundMode ${name}`);
|
||||
return {
|
||||
'code': 0
|
||||
};
|
||||
}
|
||||
|
||||
onExecuteInUIExtensionAbility(name, param, pageLoader) {
|
||||
console.log(`onExecuteInUIExtensionAbility ${name}`);
|
||||
hilog.sLogI(domainID, TAG, `onExecuteInUIExtensionAbility ${name}`);
|
||||
return {
|
||||
'code': 0
|
||||
};
|
||||
}
|
||||
|
||||
onExecuteInServiceExtensionAbility(name, param) {
|
||||
console.log(`onExecuteInServiceExtensionAbility ${name}`);
|
||||
hilog.sLogI(domainID, TAG, `onExecuteInServiceExtensionAbility ${name}`);
|
||||
return {
|
||||
'code': 0
|
||||
};
|
||||
|
@ -13,13 +13,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class InsightIntentContext {
|
||||
constructor(obj) {
|
||||
this.__context_impl__ = obj;
|
||||
}
|
||||
|
||||
startAbility(want, callback) {
|
||||
console.log('startAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startAbility');
|
||||
return this.__context_impl__.startAbility(want, callback);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,10 @@
|
||||
*/
|
||||
|
||||
let UIExtensionContext = requireNapi('application.UIExtensionContext');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
export class PhotoEditorExtensionContext extends UIExtensionContext {
|
||||
constructor(obj) {
|
||||
@ -21,12 +25,12 @@ export class PhotoEditorExtensionContext extends UIExtensionContext {
|
||||
}
|
||||
|
||||
saveEditedContentWithUri(uri, asyncCallback) {
|
||||
console.log('saveEditedContent with uri: ' + uri);
|
||||
hilog.sLogI(domainID, TAG, 'saveEditedContent with uri: ' + uri);
|
||||
return this.__context_impl__.saveEditedContentWithUri(uri, asyncCallback);
|
||||
}
|
||||
|
||||
saveEditedContentWithImage(image, option, asyncCallback) {
|
||||
console.log('saveEditedContent with image pixmap.');
|
||||
hilog.sLogI(domainID, TAG, 'saveEditedContent with image pixmap.');
|
||||
return this.__context_impl__.saveEditedContentWithImage(image, option, asyncCallback);
|
||||
}
|
||||
}
|
@ -14,26 +14,30 @@
|
||||
*/
|
||||
|
||||
let ExtensionAbility = requireNapi('app.ability.ExtensionAbility');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class ServiceExtensionAbility extends ExtensionAbility {
|
||||
onCreate(want) {
|
||||
console.log('onCreate, want:' + want.abilityName);
|
||||
hilog.sLogI(domainID, TAG, 'onCreate, want:' + want.abilityName);
|
||||
}
|
||||
|
||||
onRequest(want, startId) {
|
||||
console.log('onRequest, want:' + want.abilityName + ', startId:' + startId);
|
||||
hilog.sLogI(domainID, TAG, 'onRequest, want:' + want.abilityName + ', startId:' + startId);
|
||||
}
|
||||
|
||||
onConnect(want) {
|
||||
console.log('onConnect, want:' + want.abilityName);
|
||||
hilog.sLogI(domainID, TAG, 'onConnect, want:' + want.abilityName);
|
||||
}
|
||||
|
||||
onDisconnect(want) {
|
||||
console.log('onDisconnect');
|
||||
hilog.sLogI(domainID, TAG, 'onDisconnect');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log('onDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onDestroy');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,10 @@
|
||||
|
||||
let ExtensionContext = requireNapi('application.ExtensionContext');
|
||||
let Caller = requireNapi('application.Caller');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const ERROR_CODE_INVALID_PARAM = 401;
|
||||
const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.';
|
||||
@ -31,82 +35,82 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
}
|
||||
|
||||
startAbility(want, options, callback) {
|
||||
console.log('startAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startAbility');
|
||||
return this.__context_impl__.startAbility(want, options, callback);
|
||||
}
|
||||
|
||||
openLink(link, options) {
|
||||
console.log('openLink');
|
||||
hilog.sLogI(domainID, TAG, 'openLink');
|
||||
return this.__context_impl__.openLink(link, options);
|
||||
}
|
||||
|
||||
startAbilityAsCaller(want, options, callback) {
|
||||
console.log('startAbilityAsCaller');
|
||||
hilog.sLogI(domainID, TAG, 'startAbilityAsCaller');
|
||||
return this.__context_impl__.startAbilityAsCaller(want, options, callback);
|
||||
}
|
||||
|
||||
startRecentAbility(want, options, callback) {
|
||||
console.log('startRecentAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startRecentAbility');
|
||||
return this.__context_impl__.startRecentAbility(want, options, callback);
|
||||
}
|
||||
|
||||
connectServiceExtensionAbility(want, options) {
|
||||
console.log('connectServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'connectServiceExtensionAbility');
|
||||
return this.__context_impl__.connectServiceExtensionAbility(want, options);
|
||||
}
|
||||
|
||||
startAbilityWithAccount(want, accountId, options, callback) {
|
||||
console.log('startAbilityWithAccount');
|
||||
hilog.sLogI(domainID, TAG, 'startAbilityWithAccount');
|
||||
return this.__context_impl__.startAbilityWithAccount(want, accountId, options, callback);
|
||||
}
|
||||
|
||||
startServiceExtensionAbility(want, callback) {
|
||||
console.log('startServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startServiceExtensionAbility');
|
||||
return this.__context_impl__.startServiceExtensionAbility(want, callback);
|
||||
}
|
||||
|
||||
startUIServiceExtensionAbility(want, callback) {
|
||||
console.log('startUIServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startUIServiceExtensionAbility');
|
||||
return this.__context_impl__.startUIServiceExtensionAbility(want, callback);
|
||||
}
|
||||
|
||||
startServiceExtensionAbilityWithAccount(want, accountId, callback) {
|
||||
console.log('startServiceExtensionAbilityWithAccount');
|
||||
hilog.sLogI(domainID, TAG, 'startServiceExtensionAbilityWithAccount');
|
||||
return this.__context_impl__.startServiceExtensionAbilityWithAccount(want, accountId, callback);
|
||||
}
|
||||
|
||||
stopServiceExtensionAbility(want, callback) {
|
||||
console.log('stopServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'stopServiceExtensionAbility');
|
||||
return this.__context_impl__.stopServiceExtensionAbility(want, callback);
|
||||
}
|
||||
|
||||
stopServiceExtensionAbilityWithAccount(want, accountId, callback) {
|
||||
console.log('stopServiceExtensionAbilityWithAccount');
|
||||
hilog.sLogI(domainID, TAG, 'stopServiceExtensionAbilityWithAccount');
|
||||
return this.__context_impl__.stopServiceExtensionAbilityWithAccount(want, accountId, callback);
|
||||
}
|
||||
|
||||
connectAbilityWithAccount(want, accountId, options) {
|
||||
console.log('connectAbilityWithAccount');
|
||||
hilog.sLogI(domainID, TAG, 'connectAbilityWithAccount');
|
||||
return this.__context_impl__.connectAbilityWithAccount(want, accountId, options);
|
||||
}
|
||||
|
||||
connectServiceExtensionAbilityWithAccount(want, accountId, options) {
|
||||
console.log('connectServiceExtensionAbilityWithAccount');
|
||||
hilog.sLogI(domainID, TAG, 'connectServiceExtensionAbilityWithAccount');
|
||||
return this.__context_impl__.connectServiceExtensionAbilityWithAccount(want, accountId, options);
|
||||
}
|
||||
|
||||
disconnectAbility(connection, callback) {
|
||||
console.log('disconnectAbility');
|
||||
hilog.sLogI(domainID, TAG, 'disconnectAbility');
|
||||
return this.__context_impl__.disconnectAbility(connection, callback);
|
||||
}
|
||||
|
||||
disconnectServiceExtensionAbility(connection, callback) {
|
||||
console.log('disconnectServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'disconnectServiceExtensionAbility');
|
||||
return this.__context_impl__.disconnectServiceExtensionAbility(connection, callback);
|
||||
}
|
||||
|
||||
terminateSelf(callback) {
|
||||
console.log('terminateSelf');
|
||||
hilog.sLogI(domainID, TAG, 'terminateSelf');
|
||||
return this.__context_impl__.terminateSelf(callback);
|
||||
}
|
||||
|
||||
@ -117,7 +121,7 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
startAbilityByCall(want) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (typeof want !== 'object' || want == null) {
|
||||
console.log('ServiceExtensionContext::startAbilityByCall input param error');
|
||||
hilog.sLogI(domainID, TAG, 'ServiceExtensionContext::startAbilityByCall input param error');
|
||||
reject(new ParamError());
|
||||
return;
|
||||
}
|
||||
@ -126,13 +130,13 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
try {
|
||||
callee = await this.__context_impl__.startAbilityByCall(want);
|
||||
} catch (error) {
|
||||
console.log('ServiceExtensionContext::startAbilityByCall Obtain remoteObject failed');
|
||||
hilog.sLogI(domainID, TAG, 'ServiceExtensionContext::startAbilityByCall Obtain remoteObject failed');
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(new Caller(callee));
|
||||
console.log('ServiceExtensionContext::startAbilityByCall success');
|
||||
hilog.sLogI(domainID, TAG, 'ServiceExtensionContext::startAbilityByCall success');
|
||||
return;
|
||||
});
|
||||
}
|
||||
@ -140,7 +144,7 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
startAbilityByCallWithAccount(want, accountId) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (typeof want !== 'object' || want == null || typeof accountId !== 'number') {
|
||||
console.log('ServiceExtensionContext::startAbilityByCall With accountId input param error');
|
||||
hilog.sLogI(domainID, TAG, 'ServiceExtensionContext::startAbilityByCall With accountId input param error');
|
||||
reject(new ParamError());
|
||||
return;
|
||||
}
|
||||
@ -149,19 +153,19 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
try {
|
||||
callee = await this.__context_impl__.startAbilityByCall(want, accountId);
|
||||
} catch (error) {
|
||||
console.log('ServiceExtensionContext::startAbilityByCall With accountId Obtain remoteObject failed');
|
||||
hilog.sLogI(domainID, TAG, 'ServiceExtensionContext::startAbilityByCall With accountId Obtain remoteObject failed');
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(new Caller(callee));
|
||||
console.log('ServiceExtensionContext::startAbilityByCall With accountId success');
|
||||
hilog.sLogI(domainID, TAG, 'ServiceExtensionContext::startAbilityByCall With accountId success');
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
preStartMission(bundleName, moduleName, abilityName, startTime) {
|
||||
console.log('preStartMission');
|
||||
hilog.sLogI(domainID, TAG, 'preStartMission');
|
||||
return this.__context_impl__.preStartMission(bundleName, moduleName, abilityName, startTime);
|
||||
}
|
||||
}
|
||||
|
@ -14,18 +14,22 @@
|
||||
*/
|
||||
|
||||
let ExtensionAbility = requireNapi('app.ability.ExtensionAbility');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class UIExtensionAbility extends ExtensionAbility {
|
||||
onCreate(launchParam, want) {
|
||||
console.log('onCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onCreate');
|
||||
}
|
||||
|
||||
onRequest(want, startId) {
|
||||
console.log('onRequest, want:' + want.abilityName + ', startId:' + startId);
|
||||
hilog.sLogI(domainID, TAG, 'onRequest, want:' + want.abilityName + ', startId:' + startId);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log('onDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onDestroy');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
*/
|
||||
|
||||
let ExtensionContext = requireNapi('application.ExtensionContext');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
const ERROR_CODE_INVALID_PARAM = 401;
|
||||
const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.';
|
||||
@ -30,12 +34,12 @@ class UIExtensionContext extends ExtensionContext {
|
||||
}
|
||||
|
||||
startAbility(want, options, callback) {
|
||||
console.log('startAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startAbility');
|
||||
return this.__context_impl__.startAbility(want, options, callback);
|
||||
}
|
||||
|
||||
startUIServiceExtensionAbility(want, callback) {
|
||||
console.log('startUIServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startUIServiceExtensionAbility');
|
||||
return this.__context_impl__.startUIServiceExtensionAbility(want, callback);
|
||||
}
|
||||
|
||||
@ -48,27 +52,27 @@ class UIExtensionContext extends ExtensionContext {
|
||||
}
|
||||
|
||||
openLink(link, options, callback) {
|
||||
console.log('openLink');
|
||||
hilog.sLogI(domainID, TAG, 'openLink');
|
||||
return this.__context_impl__.openLink(link, options, callback);
|
||||
}
|
||||
|
||||
terminateSelf(callback) {
|
||||
console.log('terminateSelf');
|
||||
hilog.sLogI(domainID, TAG, 'terminateSelf');
|
||||
return this.__context_impl__.terminateSelf(callback);
|
||||
}
|
||||
|
||||
startAbilityForResult(want, options, callback) {
|
||||
console.log('startAbilityForResult');
|
||||
hilog.sLogI(domainID, TAG, 'startAbilityForResult');
|
||||
return this.__context_impl__.startAbilityForResult(want, options, callback);
|
||||
}
|
||||
|
||||
startAbilityForResultAsCaller(want, options, callback) {
|
||||
console.log('startAbilityForResultAsCaller');
|
||||
hilog.sLogI(domainID, TAG, 'startAbilityForResultAsCaller');
|
||||
return this.__context_impl__.startAbilityForResultAsCaller(want, options, callback);
|
||||
}
|
||||
|
||||
terminateSelfWithResult(abilityResult, callback) {
|
||||
console.log('terminateSelfWithResult');
|
||||
hilog.sLogI(domainID, TAG, 'terminateSelfWithResult');
|
||||
return this.__context_impl__.terminateSelfWithResult(abilityResult, callback);
|
||||
}
|
||||
|
||||
|
@ -14,38 +14,42 @@
|
||||
*/
|
||||
|
||||
let ExtensionAbility = requireNapi('app.ability.ExtensionAbility');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class UIServiceExtensionAbility extends ExtensionAbility {
|
||||
onCreate(want) {
|
||||
console.log('onCreate, want:' + want.abilityName);
|
||||
hilog.sLogI(domainID, TAG, 'onCreate, want:' + want.abilityName);
|
||||
}
|
||||
|
||||
onRequest(want, startId) {
|
||||
console.log('onRequest, want:' + want.abilityName + ', startId:' + startId);
|
||||
hilog.sLogI(domainID, TAG, 'onRequest, want:' + want.abilityName + ', startId:' + startId);
|
||||
}
|
||||
|
||||
onConnect(want, proxy) {
|
||||
console.log('onConnect, want:' + want.abilityName + '');
|
||||
hilog.sLogI(domainID, TAG, 'onConnect, want:' + want.abilityName + '');
|
||||
}
|
||||
|
||||
onDisconnect(want, proxy) {
|
||||
console.log('onDisconnect');
|
||||
hilog.sLogI(domainID, TAG, 'onDisconnect');
|
||||
}
|
||||
|
||||
onWindowWillCreate(config) {
|
||||
console.log('onWindowStageWillCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageWillCreate');
|
||||
}
|
||||
|
||||
onWindowDidCreate(window) {
|
||||
console.log('onWindowStageDidCreate');
|
||||
hilog.sLogI(domainID, TAG, 'onWindowStageDidCreate');
|
||||
}
|
||||
|
||||
onData(data) {
|
||||
console.log('onData');
|
||||
hilog.sLogI(domainID, TAG, 'onData');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log('onDestroy');
|
||||
hilog.sLogI(domainID, TAG, 'onDestroy');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
*/
|
||||
|
||||
let ExtensionContext = requireNapi('application.ExtensionContext');
|
||||
let hilog = requireNapi('hilog');
|
||||
|
||||
let domainID = 0xD001320;
|
||||
let TAG = 'JSENV';
|
||||
|
||||
class UIServiceExtensionContext extends ExtensionContext {
|
||||
constructor(obj) {
|
||||
@ -21,27 +25,27 @@ class UIServiceExtensionContext extends ExtensionContext {
|
||||
}
|
||||
|
||||
startAbility(want, options) {
|
||||
console.log('startAbility');
|
||||
hilog.sLogI(domainID, TAG, 'startAbility');
|
||||
return this.__context_impl__.startAbility(want, options);
|
||||
}
|
||||
|
||||
terminateSelf() {
|
||||
console.log('terminateSelf');
|
||||
hilog.sLogI(domainID, TAG, 'terminateSelf');
|
||||
return this.__context_impl__.terminateSelf();
|
||||
}
|
||||
|
||||
startAbilityByType(type, wantParam, abilityStartCallback) {
|
||||
console.log('startAbilityByType');
|
||||
hilog.sLogI(domainID, TAG, 'startAbilityByType');
|
||||
return this.__context_impl__.startAbilityByType(type, wantParam, abilityStartCallback);
|
||||
}
|
||||
|
||||
connectServiceExtensionAbility(want, options) {
|
||||
console.log('connectServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'connectServiceExtensionAbility');
|
||||
return this.__context_impl__.connectServiceExtensionAbility(want, options);
|
||||
}
|
||||
|
||||
disconnectServiceExtensionAbility(connection, callback) {
|
||||
console.log('disconnectServiceExtensionAbility');
|
||||
hilog.sLogI(domainID, TAG, 'disconnectServiceExtensionAbility');
|
||||
return this.__context_impl__.disconnectServiceExtensionAbility(connection, callback);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ ohos_shared_library("wantagent") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"./",
|
||||
]
|
||||
@ -33,6 +34,7 @@ ohos_shared_library("wantagent") {
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
]
|
||||
|
@ -18,6 +18,7 @@ ohos_shared_library("wantagent_napi") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"./",
|
||||
"../",
|
||||
@ -34,6 +35,7 @@ ohos_shared_library("wantagent_napi") {
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
]
|
||||
|
@ -160,7 +160,7 @@ auto OnSendFinishedUvAfterWorkCallback = [](uv_work_t* work, int status) {
|
||||
napi_set_named_property(dataWorkerData->env, objValueSecond, "want",
|
||||
CreateJsWant(dataWorkerData->env, dataWorkerData->want));
|
||||
napi_set_named_property(dataWorkerData->env, objValueSecond, "finalCode",
|
||||
CreateJsValue(dataWorkerData->env, dataWorkerData->resultCode));
|
||||
CreateJsValue(dataWorkerData->env, GetJsErrorCodeByNativeError(dataWorkerData->resultCode)));
|
||||
napi_set_named_property(dataWorkerData->env, objValueSecond, "finalData",
|
||||
CreateJsValue(dataWorkerData->env, dataWorkerData->resultData));
|
||||
napi_set_named_property(dataWorkerData->env, objValueSecond, "extraInfo",
|
||||
|
@ -677,7 +677,7 @@ void AbilityContextImpl::RegisterAbilityCallback(std::weak_ptr<AppExecFwk::IAbil
|
||||
abilityCallback_ = abilityCallback;
|
||||
}
|
||||
|
||||
ErrCode AbilityContextImpl::RequestDialogService(napi_env env, AAFwk::Want &want, RequestDialogResultTask &&task)
|
||||
void AbilityContextImpl::SetWindowRectangleParams(AAFwk::Want &want)
|
||||
{
|
||||
want.SetParam(RequestConstants::REQUEST_TOKEN_KEY, token_);
|
||||
#ifdef SUPPORT_SCREEN
|
||||
@ -691,6 +691,11 @@ ErrCode AbilityContextImpl::RequestDialogService(napi_env env, AAFwk::Want &want
|
||||
want.SetParam(RequestConstants::WINDOW_RECTANGLE_WIDTH_KEY, width);
|
||||
want.SetParam(RequestConstants::WINDOW_RECTANGLE_HEIGHT_KEY, height);
|
||||
#endif // SUPPORT_SCREEN
|
||||
}
|
||||
|
||||
ErrCode AbilityContextImpl::RequestDialogService(napi_env env, AAFwk::Want &want, RequestDialogResultTask &&task)
|
||||
{
|
||||
SetWindowRectangleParams(want);
|
||||
auto resultTask =
|
||||
[env, outTask = std::move(task)](int32_t resultCode, const AAFwk::Want &resultWant) {
|
||||
auto retData = new (std::nothrow) RequestResult();
|
||||
@ -740,17 +745,7 @@ ErrCode AbilityContextImpl::RequestDialogService(napi_env env, AAFwk::Want &want
|
||||
|
||||
ErrCode AbilityContextImpl::RequestDialogService(AAFwk::Want &want, RequestDialogResultTask &&task)
|
||||
{
|
||||
want.SetParam(RequestConstants::REQUEST_TOKEN_KEY, token_);
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
GetWindowRect(left, top, width, height);
|
||||
want.SetParam(RequestConstants::WINDOW_RECTANGLE_LEFT_KEY, left);
|
||||
want.SetParam(RequestConstants::WINDOW_RECTANGLE_TOP_KEY, top);
|
||||
want.SetParam(RequestConstants::WINDOW_RECTANGLE_WIDTH_KEY, width);
|
||||
want.SetParam(RequestConstants::WINDOW_RECTANGLE_HEIGHT_KEY, height);
|
||||
|
||||
SetWindowRectangleParams(want);
|
||||
sptr<IRemoteObject> remoteObject = sptr<DialogRequestCallbackImpl>::MakeSptr(std::move(task));
|
||||
want.SetParam(RequestConstants::REQUEST_CALLBACK_KEY, remoteObject);
|
||||
|
||||
@ -772,6 +767,12 @@ void AbilityContextImpl::RequestDialogResultJSThreadWorker(uv_work_t* work, int
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "null work");
|
||||
return;
|
||||
}
|
||||
if (work->data == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "null work data");
|
||||
delete work;
|
||||
work = nullptr;
|
||||
return;
|
||||
}
|
||||
RequestResult* retCB = static_cast<RequestResult*>(work->data);
|
||||
if (retCB == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "null retCB");
|
||||
|
@ -34,6 +34,7 @@ config("ability_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
|
||||
"${ability_runtime_innerkits_path}/uri/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include/continuation",
|
||||
@ -130,6 +131,7 @@ ohos_shared_library("abilitykit_utils") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
"${ability_runtime_innerkits_path}/wantagent/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
@ -206,6 +208,7 @@ ohos_shared_library("configuration_helper") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
"${ability_runtime_innerkits_path}/wantagent/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
@ -570,6 +573,7 @@ config("uiability_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/recovery/",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
]
|
||||
|
||||
@ -1057,6 +1061,7 @@ ohos_shared_library("ui_service_extension_module") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/recovery/",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
|
||||
"${ability_runtime_innerkits_path}/uri/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include/continuation",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
@ -1699,6 +1704,7 @@ config("embedded_ui_extension_module_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
|
||||
"${ability_runtime_innerkits_path}/uri/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
|
@ -870,7 +870,7 @@ void Ability::PostTask(std::function<void()> task, long delayTime)
|
||||
|
||||
int32_t Ability::OnContinue(WantParams &wantParams)
|
||||
{
|
||||
return ContinuationManager::OnContinueResult::REJECT;
|
||||
return ContinuationManager::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
|
||||
void Ability::ContinueAbilityWithStack(const std::string &deviceId, uint32_t versionCode)
|
||||
|
@ -132,7 +132,7 @@ std::string AbilityContext::GetCallingBundle()
|
||||
return callingBundleName_;
|
||||
}
|
||||
|
||||
std::shared_ptr<ElementName> AbilityContext::GetElementName()
|
||||
std::shared_ptr<AppExecFwk::ElementName> AbilityContext::GetElementName()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "called");
|
||||
std::shared_ptr<AbilityInfo> info = GetAbilityInfo();
|
||||
@ -141,11 +141,8 @@ std::shared_ptr<ElementName> AbilityContext::GetElementName()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ElementName> elementName = std::make_shared<ElementName>();
|
||||
elementName->SetAbilityName(info->name);
|
||||
elementName->SetBundleName(info->bundleName);
|
||||
elementName->SetDeviceID(info->deviceId);
|
||||
elementName->SetModuleName(info->moduleName);
|
||||
std::shared_ptr<ElementName> elementName =
|
||||
std::make_shared<ElementName>(info->deviceId, info->bundleName, info->name, info->moduleName);
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "end");
|
||||
return elementName;
|
||||
}
|
||||
@ -153,11 +150,8 @@ std::shared_ptr<ElementName> AbilityContext::GetElementName()
|
||||
std::shared_ptr<ElementName> AbilityContext::GetCallingAbility()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "called");
|
||||
std::shared_ptr<ElementName> elementName = std::make_shared<ElementName>();
|
||||
elementName->SetAbilityName(callingAbilityName_);
|
||||
elementName->SetBundleName(callingBundleName_);
|
||||
elementName->SetDeviceID(callingDeviceId_);
|
||||
elementName->SetModuleName(callingModuleName_);
|
||||
std::shared_ptr<ElementName> elementName = std::make_shared<ElementName>(
|
||||
callingDeviceId_, callingBundleName_, callingAbilityName_, callingModuleName_);
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "end");
|
||||
return elementName;
|
||||
}
|
||||
|
@ -640,6 +640,7 @@ void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
||||
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||
if (ret == ERR_OK) {
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -662,6 +663,7 @@ void AbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
||||
AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||
if (ret == ERR_OK) {
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ int32_t CJAbilityObject::OnContinue(AAFwk::WantParams& wantParams) const
|
||||
{
|
||||
if (g_cjAbilityFuncs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null cjAbilityFunc");
|
||||
return ContinuationManager::OnContinueResult::REJECT;
|
||||
return ContinuationManager::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ int32_t CJUIAbility::OnContinue(WantParams &wantParams, bool &isAsyncOnContinue,
|
||||
{
|
||||
if (!cjAbilityObj_) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null cjAbilityObj_");
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
if (applicationContext != nullptr) {
|
||||
|
@ -754,19 +754,19 @@ int32_t JsAbility::OnContinue(WantParams &wantParams)
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
if (jsAbilityObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "AbilityStage object");
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
napi_value obj = jsAbilityObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Ability object");
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
|
||||
napi_value methodOnCreate = nullptr;
|
||||
napi_get_named_property(env, obj, "onContinue", &methodOnCreate);
|
||||
if (methodOnCreate == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "get 'onContinue'");
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
|
||||
napi_value jsWantParams = OHOS::AppExecFwk::WrapWantParams(env, wantParams);
|
||||
@ -778,7 +778,7 @@ int32_t JsAbility::OnContinue(WantParams &wantParams)
|
||||
int32_t numberResult = 0;
|
||||
if (!ConvertFromJsValue(env, result, numberResult)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "'onContinue' not implemented");
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManager::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
|
@ -2046,6 +2046,58 @@ napi_value CreateJsAbilityContext(napi_env env, std::shared_ptr<AbilityContext>
|
||||
return object;
|
||||
}
|
||||
|
||||
napi_value AttachJsUIAbilityContext(napi_env env, void *value, void *hint)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "attach uiability context");
|
||||
if (env == nullptr || value == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "invalid params");
|
||||
return nullptr;
|
||||
}
|
||||
auto ptr = reinterpret_cast<std::weak_ptr<AbilityContext> *>(value)->lock();
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "invalid context");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto object = CreateJsAbilityContext(env, ptr);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "null ability object");
|
||||
return nullptr;
|
||||
}
|
||||
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityContext", &object, 1);
|
||||
if (systemModule == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "load uiability context failed");
|
||||
return nullptr;
|
||||
}
|
||||
auto contextObj = systemModule->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "not napi object");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto status = napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachJsUIAbilityContext, value, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "coerce ability context failed: %{public}d", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityContext>(ptr);
|
||||
status = napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void *data, void*) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "finalizer for weak_ptr ui ability context");
|
||||
delete static_cast<std::weak_ptr<AbilityContext> *>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "wrap ability context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return contextObj;
|
||||
}
|
||||
|
||||
JSAbilityConnection::JSAbilityConnection(napi_env env) : env_(env) {}
|
||||
|
||||
JSAbilityConnection::~JSAbilityConnection()
|
||||
|
@ -842,7 +842,7 @@ void JsUIAbility::DoOnForegroundForSceneIsNull(const Want &want)
|
||||
displayId = strtol(strDisplayId.c_str(), nullptr, BASE_DISPLAY_ID_NUM);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "displayId: %{public}d", displayId);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "formatRegex: [%{public}s] failed", strDisplayId.c_str());
|
||||
TAG_LOGW(AAFwkTag::UIABILITY, "formatRegex: [%{public}s] failed", strDisplayId.c_str());
|
||||
}
|
||||
}
|
||||
auto option = GetWindowOption(want);
|
||||
@ -858,6 +858,9 @@ void JsUIAbility::DoOnForegroundForSceneIsNull(const Want &want)
|
||||
}
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "init window scene failed");
|
||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, FreezeUtil::TimeoutState::FOREGROUND };
|
||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
||||
std::string("ERROR JsUIAbility::DoOnForegroundForSceneIsNull: ") + std::to_string(static_cast<int>(ret)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -896,8 +899,12 @@ void JsUIAbility::RequestFocus(const Want &want)
|
||||
void JsUIAbility::ContinuationRestore(const Want &want)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "called");
|
||||
if (!IsRestoredInContinuation() || scene_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "is not in continuation or null scene_");
|
||||
if (!IsRestoredInContinuation()) {
|
||||
TAG_LOGW(AAFwkTag::UIABILITY, "not in continuation");
|
||||
return;
|
||||
}
|
||||
if (scene_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null scene_");
|
||||
return;
|
||||
}
|
||||
RestorePageStack(want);
|
||||
@ -1076,12 +1083,12 @@ int32_t JsUIAbility::OnContinue(WantParams &wantParams, bool &isAsyncOnContinue,
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
if (jsAbilityObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null jsAbilityObj_");
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
napi_value obj = jsAbilityObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "failed get ability");
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
if (applicationContext != nullptr) {
|
||||
@ -1152,7 +1159,7 @@ int32_t JsUIAbility::OnContinueSyncCB(napi_value result, WantParams &wantParams,
|
||||
int32_t onContinueRes = 0;
|
||||
if (!ConvertFromJsValue(env, result, onContinueRes)) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "'onContinue' is not implemented");
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
OHOS::AppExecFwk::UnwrapWantParams(env, jsWantParams, wantParams);
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
@ -1651,5 +1658,24 @@ bool JsUIAbility::BackPressDefaultValue()
|
||||
{
|
||||
return CheckSatisfyTargetAPIVersion(API12) ? true : false;
|
||||
}
|
||||
|
||||
void JsUIAbility::OnAfterFocusedCommon(bool isFocused)
|
||||
{
|
||||
auto abilityContext = GetAbilityContext();
|
||||
if (abilityContext == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null abilityContext");
|
||||
return;
|
||||
}
|
||||
auto applicationContext = abilityContext->GetApplicationContext();
|
||||
if (applicationContext == nullptr || applicationContext->IsAbilityLifecycleCallbackEmpty()) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "null applicationContext or lifecycleCallback");
|
||||
return;
|
||||
}
|
||||
if (isFocused) {
|
||||
applicationContext->DispatchWindowStageFocus(GetJsAbility(), GetJsWindowStage());
|
||||
} else {
|
||||
applicationContext->DispatchWindowStageUnfocus(GetJsAbility(), GetJsWindowStage());
|
||||
}
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -70,6 +70,7 @@ void ConfigurationUtils::GetGlobalConfig(const Configuration &configuration,
|
||||
resourceConfig.SetMcc(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
resourceConfig.SetMnc(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
resourceConfig.SetThemeId(configuration.GetItem(AAFwk::GlobalConfigurationKey::THEME_ID));
|
||||
resourceConfig.SetThemeIcon(configuration.GetItem(AAFwk::GlobalConfigurationKey::THEME_ICON));
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
@ -36,6 +36,7 @@ const std::string SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME = "ohos.extra.param.
|
||||
const int32_t CONTINUE_ABILITY_REJECTED = 29360197;
|
||||
const int32_t CONTINUE_SAVE_DATA_FAILED = 29360198;
|
||||
const int32_t CONTINUE_ON_CONTINUE_FAILED = 29360199;
|
||||
const int32_t CONTINUE_ON_CONTINUE_HANDLE_FAILED = 29360300;
|
||||
const int32_t CONTINUE_ON_CONTINUE_MISMATCH = 29360204;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const int32_t CONTINUE_GET_CONTENT_FAILED = 29360200;
|
||||
@ -158,25 +159,31 @@ int32_t ContinuationManager::OnContinueAndGetContent(WantParams &wantParams)
|
||||
}
|
||||
|
||||
int32_t status = ability->OnContinue(wantParams);
|
||||
if (status != OnContinueResult::AGREE) {
|
||||
if (status == OnContinueResult::MISMATCH) {
|
||||
switch (status) {
|
||||
case OnContinueResult::AGREE:
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (IsContinuePageStack(wantParams)) {
|
||||
bool ret = GetContentInfo(wantParams);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "GetContentInfo failed");
|
||||
return CONTINUE_GET_CONTENT_FAILED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ERR_OK;
|
||||
case OnContinueResult::REJECT:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "app reject");
|
||||
return CONTINUE_ON_CONTINUE_FAILED;
|
||||
case OnContinueResult::MISMATCH:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "version mismatch");
|
||||
return CONTINUE_ON_CONTINUE_MISMATCH;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "OnContinue failed");
|
||||
return CONTINUE_ON_CONTINUE_FAILED;
|
||||
case OnContinueResult::ON_CONTINUE_ERR:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "OnContinue handle failed");
|
||||
return CONTINUE_ON_CONTINUE_HANDLE_FAILED;
|
||||
default:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "invalid status");
|
||||
return CONTINUE_ON_CONTINUE_HANDLE_FAILED;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (IsContinuePageStack(wantParams)) {
|
||||
bool ret = GetContentInfo(wantParams);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "GetContentInfo failed");
|
||||
return CONTINUE_GET_CONTENT_FAILED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t ContinuationManager::OnContinue(WantParams &wantParams)
|
||||
|
@ -37,6 +37,7 @@ const std::string SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME = "ohos.extra.param.
|
||||
const int32_t CONTINUE_ABILITY_REJECTED = 29360197;
|
||||
const int32_t CONTINUE_SAVE_DATA_FAILED = 29360198;
|
||||
const int32_t CONTINUE_ON_CONTINUE_FAILED = 29360199;
|
||||
const int32_t CONTINUE_ON_CONTINUE_HANDLE_FAILED = 29360300;
|
||||
const int32_t CONTINUE_ON_CONTINUE_MISMATCH = 29360204;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const int32_t CONTINUE_GET_CONTENT_FAILED = 29360200;
|
||||
@ -167,25 +168,31 @@ int32_t ContinuationManagerStage::OnContinueAndGetContent(WantParams &wantParams
|
||||
}
|
||||
|
||||
int32_t status = ability->OnContinue(wantParams, isAsyncOnContinue, abilityInfo);
|
||||
if (status != OnContinueResult::AGREE) {
|
||||
if (status == OnContinueResult::MISMATCH) {
|
||||
switch (status) {
|
||||
case OnContinueResult::AGREE:
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (IsContinuePageStack(wantParams)) {
|
||||
bool ret = GetContentInfo(wantParams);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "GetContentInfo failed");
|
||||
return CONTINUE_GET_CONTENT_FAILED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ERR_OK;
|
||||
case OnContinueResult::REJECT:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "app reject");
|
||||
return CONTINUE_ON_CONTINUE_FAILED;
|
||||
case OnContinueResult::MISMATCH:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "OnContinue version mismatch.");
|
||||
return CONTINUE_ON_CONTINUE_MISMATCH;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "OnContinue failed");
|
||||
return CONTINUE_ON_CONTINUE_FAILED;
|
||||
case OnContinueResult::ON_CONTINUE_ERR:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "OnContinue handle failed");
|
||||
return CONTINUE_ON_CONTINUE_HANDLE_FAILED;
|
||||
default:
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "invalid status");
|
||||
return CONTINUE_ON_CONTINUE_HANDLE_FAILED;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (IsContinuePageStack(wantParams)) {
|
||||
bool ret = GetContentInfo(wantParams);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::CONTINUATION, "GetContentInfo failed");
|
||||
return CONTINUE_GET_CONTENT_FAILED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t ContinuationManagerStage::OnContinue(WantParams &wantParams, bool &isAsyncOnContinue,
|
||||
|
@ -267,7 +267,7 @@ int32_t DistributedClient::RegisterMissionListener(const std::u16string& devId,
|
||||
}
|
||||
|
||||
int32_t DistributedClient::RegisterOnListener(const std::string& type,
|
||||
const sptr<IRemoteObject>& obj)
|
||||
const sptr<IRemoteObject>& obj, int32_t callingUid)
|
||||
{
|
||||
sptr<IRemoteObject> remote = GetDmsProxy();
|
||||
if (remote == nullptr) {
|
||||
@ -281,11 +281,12 @@ int32_t DistributedClient::RegisterOnListener(const std::string& type,
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, String, type);
|
||||
PARCEL_WRITE_HELPER(data, RemoteObject, obj);
|
||||
PARCEL_WRITE_HELPER(data, Int32, callingUid);
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, REGISTER_ON_LISTENER, data, reply);
|
||||
}
|
||||
|
||||
int32_t DistributedClient::RegisterOffListener(const std::string& type,
|
||||
const sptr<IRemoteObject>& obj)
|
||||
const sptr<IRemoteObject>& obj, int32_t callingUid)
|
||||
{
|
||||
sptr<IRemoteObject> remote = GetDmsProxy();
|
||||
if (remote == nullptr) {
|
||||
@ -300,6 +301,7 @@ int32_t DistributedClient::RegisterOffListener(const std::string& type,
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, String, type);
|
||||
PARCEL_WRITE_HELPER(data, RemoteObject, obj);
|
||||
PARCEL_WRITE_HELPER(data, Int32, callingUid);
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, REGISTER_OFF_LISTENER, data, reply);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ability_handler.h"
|
||||
#include "ability_loader.h"
|
||||
#include "ability_manager_client.h"
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "ui_extension_utils.h"
|
||||
@ -51,6 +52,7 @@ constexpr static char ENTERPRISE_ADMIN_EXTENSION[] = "EnterpriseAdminExtension";
|
||||
constexpr static char INPUTMETHOD_EXTENSION[] = "InputMethodExtensionAbility";
|
||||
constexpr static char APP_ACCOUNT_AUTHORIZATION_EXTENSION[] = "AppAccountAuthorizationExtension";
|
||||
constexpr static char FENCE_EXTENSION[] = "FenceExtension";
|
||||
constexpr static char CALLER_INFO_QUERY_EXTENSION[] = "CallerInfoQueryExtension";
|
||||
}
|
||||
|
||||
const std::map<AppExecFwk::ExtensionAbilityType, std::string> UI_EXTENSION_NAME_MAP = {
|
||||
@ -156,6 +158,9 @@ void ExtensionAbilityThread::CreateExtensionAbilityName(
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::FENCE) {
|
||||
abilityName = FENCE_EXTENSION;
|
||||
}
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::CALLER_INFO_QUERY) {
|
||||
abilityName = CALLER_INFO_QUERY_EXTENSION;
|
||||
}
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::SYSDIALOG_USERAUTH) {
|
||||
abilityName = USER_AUTH_EXTENSION;
|
||||
@ -263,6 +268,7 @@ void ExtensionAbilityThread::HandleAttachInner(const std::shared_ptr<AppExecFwk:
|
||||
if (err != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::EXT, "Attach err: %{public}d", err);
|
||||
}
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
|
||||
void ExtensionAbilityThread::HandleExtensionTransaction(
|
||||
|
@ -74,6 +74,7 @@ constexpr static char FILEACCESS_EXT_ABILITY[] = "FileAccessExtension";
|
||||
constexpr static char ENTERPRISE_ADMIN_EXTENSION[] = "EnterpriseAdminExtension";
|
||||
constexpr static char INPUTMETHOD_EXTENSION[] = "InputMethodExtensionAbility";
|
||||
constexpr static char APP_ACCOUNT_AUTHORIZATION_EXTENSION[] = "AppAccountAuthorizationExtension";
|
||||
constexpr static char CALLER_INFO_QUERY_EXTENSION[] = "CallerInfoQueryExtension";
|
||||
#ifdef WITH_DLP
|
||||
constexpr static char DLP_PARAMS_SANDBOX[] = "ohos.dlp.params.sandbox";
|
||||
#endif // WITH_DLP
|
||||
@ -188,6 +189,9 @@ void FAAbilityThread::CreateExtensionAbilityName(const std::shared_ptr<AppExecFw
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::APP_ACCOUNT_AUTHORIZATION) {
|
||||
abilityName = APP_ACCOUNT_AUTHORIZATION_EXTENSION;
|
||||
}
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::CALLER_INFO_QUERY) {
|
||||
abilityName = CALLER_INFO_QUERY_EXTENSION;
|
||||
}
|
||||
CreateExtensionAbilityNameSupportGraphics(abilityInfo, abilityName);
|
||||
TAG_LOGD(AAFwkTag::FA, "extension abilityName: %{public}s", abilityName.c_str());
|
||||
}
|
||||
@ -320,6 +324,7 @@ void FAAbilityThread::AttachInner(const std::shared_ptr<AppExecFwk::OHOSApplicat
|
||||
return;
|
||||
}
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
|
||||
void FAAbilityThread::AttachExtension(const std::shared_ptr<AppExecFwk::OHOSApplication> &application,
|
||||
|
@ -197,7 +197,8 @@ private:
|
||||
context->ClearFailedCallConnection(callback);
|
||||
}
|
||||
|
||||
void AddFreeInstallObserver(napi_env env, const AAFwk::Want &want, napi_value callback, napi_value* result)
|
||||
void AddFreeInstallObserver(napi_env env, const AAFwk::Want &want, napi_value callback,
|
||||
napi_value* result, bool isOpenLink = false)
|
||||
{
|
||||
// adapter free install async return install and start result
|
||||
int ret = 0;
|
||||
@ -213,14 +214,19 @@ private:
|
||||
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "AddFreeInstallObserver failed");
|
||||
} else {
|
||||
// build a callback observer with last param
|
||||
return;
|
||||
}
|
||||
std::string startTime = want.GetStringParam(Want::PARAM_RESV_START_TIME);
|
||||
// build a callback observer with last param
|
||||
if (!isOpenLink) {
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "AddJsObserverObject");
|
||||
std::string bundleName = want.GetElement().GetBundleName();
|
||||
std::string abilityName = want.GetElement().GetAbilityName();
|
||||
std::string startTime = want.GetStringParam(Want::PARAM_RESV_START_TIME);
|
||||
freeInstallObserver_->AddJsObserverObject(
|
||||
bundleName, abilityName, startTime, callback, result);
|
||||
}
|
||||
std::string url = want.GetUriString();
|
||||
freeInstallObserver_->AddJsObserverObject(startTime, url, callback, result);
|
||||
}
|
||||
|
||||
napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info, bool isStartRecent = false)
|
||||
@ -332,8 +338,17 @@ private:
|
||||
}
|
||||
|
||||
want.SetUri(linkValue);
|
||||
auto innerErrorCode = std::make_shared<int>(ERR_OK);
|
||||
std::string startTime = std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::
|
||||
system_clock::now().time_since_epoch()).count());
|
||||
want.SetParam(Want::PARAM_RESV_START_TIME, startTime);
|
||||
|
||||
return OnOpenLinkInner(env, want, startTime, linkValue);
|
||||
}
|
||||
|
||||
napi_value OnOpenLinkInner(napi_env env, const AAFwk::Want& want,
|
||||
const std::string& startTime, const std::string& url)
|
||||
{
|
||||
auto innerErrorCode = std::make_shared<int>(ERR_OK);
|
||||
NapiAsyncTask::ExecuteCallback execute = [weak = context_, want, innerErrorCode]() {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
@ -341,23 +356,35 @@ private:
|
||||
*innerErrorCode = static_cast<int>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
*innerErrorCode = context->StartAbilityWithAccount(want, -1);
|
||||
*innerErrorCode = context->OpenLink(want, -1);
|
||||
};
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete = [innerErrorCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
NapiAsyncTask::CompleteCallback complete = [innerErrorCode, startTime, url,
|
||||
freeInstallObserver = freeInstallObserver_](
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
if (*innerErrorCode == 0) {
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "OpenLink success");
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "OpenLink failed");
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode));
|
||||
return;
|
||||
}
|
||||
if (freeInstallObserver == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "freeInstallObserver_ is nullptr");
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode));
|
||||
return;
|
||||
}
|
||||
if (*innerErrorCode == AAFwk::ERR_OPEN_LINK_START_ABILITY_DEFAULT_OK) {
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "start ability by default succeeded");
|
||||
freeInstallObserver->OnInstallFinishedByUrl(startTime, url, ERR_OK);
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "OpenLink failed");
|
||||
freeInstallObserver->OnInstallFinishedByUrl(startTime, url, *innerErrorCode);
|
||||
};
|
||||
|
||||
napi_value result = nullptr;
|
||||
AddFreeInstallObserver(env, want, nullptr, &result, true);
|
||||
NapiAsyncTask::ScheduleHighQos("JSServiceExtensionContext::OnOpenLink", env,
|
||||
CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), &result));
|
||||
|
||||
CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), nullptr));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ void NewAbilityImpl::AbilityTransactionCallback(const AbilityLifeCycleState &sta
|
||||
if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,10 @@ void ResourceConfigHelper::SetThemeId(std::string themeId)
|
||||
{
|
||||
themeId_ = themeId;
|
||||
}
|
||||
void ResourceConfigHelper::SetThemeIcon(std::string themeIcon)
|
||||
{
|
||||
themeIcon_ = themeIcon;
|
||||
}
|
||||
|
||||
void ResourceConfigHelper::UpdateResConfig(
|
||||
const AppExecFwk::Configuration &configuration, std::shared_ptr<Global::Resource::ResourceManager> resourceManager)
|
||||
@ -147,6 +151,7 @@ void ResourceConfigHelper::UpdateResConfig(std::unique_ptr<Global::Resource::Res
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set themeId: %{public}u", resConfig->GetThemeId());
|
||||
}
|
||||
}
|
||||
resConfig->SetThemeIcon(!themeIcon_.empty());
|
||||
}
|
||||
|
||||
bool ResourceConfigHelper::ConvertStringToUint32(std::string source, uint32_t &result)
|
||||
|
@ -451,7 +451,7 @@ int32_t UIAbility::OnContinueAsyncCB(napi_value jsWantParams, int32_t status,
|
||||
int32_t UIAbility::OnContinue(AAFwk::WantParams &wantParams, bool &isAsyncOnContinue,
|
||||
const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::REJECT;
|
||||
return AppExecFwk::ContinuationManagerStage::OnContinueResult::ON_CONTINUE_ERR;
|
||||
}
|
||||
|
||||
void UIAbility::ContinueAbilityWithStack(const std::string &deviceId, uint32_t versionCode)
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "js_ui_ability.h"
|
||||
#include "ohos_application.h"
|
||||
#include "process_options.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
@ -179,6 +178,12 @@ void UIAbilityImpl::HandleAbilityTransaction(
|
||||
AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(
|
||||
token_, targetState.state, GetRestoreData());
|
||||
}
|
||||
if (ability_ != nullptr && targetState.state == AAFwk::ABILITY_STATE_BACKGROUND_NEW) {
|
||||
TAG_LOGW(AAFwkTag::UIABILITY, "OnBackground is called when current state is already background");
|
||||
Background();
|
||||
AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(
|
||||
token_, targetState.state, GetRestoreData());
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "Org lifeCycleState equals to dst lifeCycleState");
|
||||
return;
|
||||
}
|
||||
@ -213,14 +218,15 @@ void UIAbilityImpl::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleStat
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "called");
|
||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
||||
std::string entry = "AbilityManagerClient::AbilityTransitionDone; the transaction start.";
|
||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
||||
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_FOREGROUND_NEW;
|
||||
std::string entry = "AbilityManagerClient::AbilityTransitionDone; the transaction start.";
|
||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
||||
}
|
||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, state, GetRestoreData());
|
||||
if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,23 +401,7 @@ void UIAbilityImpl::AfterFocusedCommon(bool isFocused)
|
||||
return;
|
||||
}
|
||||
|
||||
auto abilityContext = impl->ability_->GetAbilityContext();
|
||||
if (abilityContext == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null abilityContext");
|
||||
return;
|
||||
}
|
||||
impl->ability_->OnAfterFocusedCommon(focuseMode);
|
||||
auto applicationContext = abilityContext->GetApplicationContext();
|
||||
if (applicationContext == nullptr || applicationContext->IsAbilityLifecycleCallbackEmpty()) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null applicationContext or lifecycleCallback");
|
||||
return;
|
||||
}
|
||||
auto &jsAbility = static_cast<JsUIAbility &>(*(impl->ability_));
|
||||
if (focuseMode) {
|
||||
applicationContext->DispatchWindowStageFocus(jsAbility.GetJsAbility(), jsAbility.GetJsWindowStage());
|
||||
} else {
|
||||
applicationContext->DispatchWindowStageUnfocus(jsAbility.GetJsAbility(), jsAbility.GetJsWindowStage());
|
||||
}
|
||||
};
|
||||
|
||||
if (handler_) {
|
||||
@ -455,6 +445,7 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
||||
token_, AAFwk::AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||
if (ret == ERR_OK) {
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,6 +463,7 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
||||
token_, AAFwk::AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||
if (ret == ERR_OK) {
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,6 +490,9 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterUnfocused()
|
||||
void UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type)
|
||||
{
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "scb call, ForegroundFailed");
|
||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
||||
std::string entry = "ERROR UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed; GoForeground failed.";
|
||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow, entry);
|
||||
AppExecFwk::PacMap restoreData;
|
||||
switch (type) {
|
||||
case static_cast<int32_t>(OHOS::Rosen::WMError::WM_ERROR_INVALID_OPERATION): {
|
||||
@ -604,7 +599,7 @@ bool UIAbilityImpl::AbilityTransaction(const AAFwk::Want &want, const AAFwk::Lif
|
||||
Background();
|
||||
} else {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "handleExecuteInsightIntentBackground");
|
||||
HandleExecuteInsightIntentBackground(want);
|
||||
ret = HandleExecuteInsightIntentBackground(want);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -770,7 +765,7 @@ void UIAbilityImpl::PostForegroundInsightIntent()
|
||||
}
|
||||
}
|
||||
|
||||
void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent)
|
||||
bool UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "called");
|
||||
auto executeParam = std::make_shared<InsightIntentExecuteParam>();
|
||||
@ -778,7 +773,7 @@ void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want
|
||||
if (!ret && !onlyExecuteIntent) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "invalid params");
|
||||
Background();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::UIABILITY,
|
||||
@ -792,14 +787,16 @@ void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want
|
||||
if (intentCb == nullptr && !onlyExecuteIntent) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "create async callback failed");
|
||||
Background();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "lifecycleState_: %{public}d", lifecycleState_);
|
||||
if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL
|
||||
|| lifecycleState_ == AAFwk::ABILITY_STATE_STARTED_NEW) {
|
||||
ExecuteInsightIntentBackgroundByColdBoot(want, executeParam, std::move(intentCb));
|
||||
return false;
|
||||
} else {
|
||||
ExecuteInsightIntentBackgroundAlreadyStart(want, executeParam, std::move(intentCb));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -818,6 +815,7 @@ void UIAbilityImpl::ExecuteInsightIntentBackgroundByColdBoot(const Want &want,
|
||||
}
|
||||
abilityImpl->Background();
|
||||
abilityImpl->ExecuteInsightIntentDone(intentId, result);
|
||||
abilityImpl->AbilityTransactionCallback(AAFwk::ABILITY_STATE_BACKGROUND_NEW);
|
||||
};
|
||||
callback->Push(asyncCallback);
|
||||
|
||||
|
@ -172,10 +172,13 @@ void UIAbilityThread::AttachInner(const std::shared_ptr<AppExecFwk::OHOSApplicat
|
||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
||||
ErrCode err = AbilityManagerClient::GetInstance()->AttachAbilityThread(this, token_);
|
||||
if (err != ERR_OK) {
|
||||
entry = std::string("AbilityThread::Attach failed ipc error: ") + std::to_string(err);
|
||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "err: %{public}d", err);
|
||||
return;
|
||||
}
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
}
|
||||
|
||||
void UIAbilityThread::Attach(const std::shared_ptr<AppExecFwk::OHOSApplication> &application,
|
||||
|
@ -66,28 +66,14 @@ napi_value AttachUIExtensionContext(napi_env env, void *value, void *extValue)
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid context");
|
||||
return nullptr;
|
||||
}
|
||||
auto screenModePtr = reinterpret_cast<std::weak_ptr<int32_t> *>(extValue)->lock();
|
||||
if (screenModePtr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Invalid screenModePtr");
|
||||
napi_value object = JsUIExtensionContext::CreateJsUIExtensionContext(env, ptr);
|
||||
auto contextRef = JsRuntime::LoadSystemModuleByEngine(env, "application.UIExtensionContext",
|
||||
&object, 1);
|
||||
if (contextRef == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "Failed to load module");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value contextObj = nullptr;
|
||||
if (*screenModePtr == AAFwk::IDLE_SCREEN_MODE) {
|
||||
auto uiExtObject = JsUIExtensionContext::CreateJsUIExtensionContext(env, ptr);
|
||||
CHECK_POINTER_AND_RETURN(uiExtObject, nullptr);
|
||||
auto contextRef = JsRuntime::LoadSystemModuleByEngine(env, "application.UIExtensionContext",
|
||||
&uiExtObject, 1);
|
||||
CHECK_POINTER_AND_RETURN(contextRef, nullptr);
|
||||
contextObj = contextRef->GetNapiValue();
|
||||
} else {
|
||||
auto emUIObject = JsEmbeddableUIAbilityContext::CreateJsEmbeddableUIAbilityContext(env,
|
||||
nullptr, ptr, *screenModePtr);
|
||||
CHECK_POINTER_AND_RETURN(emUIObject, nullptr);
|
||||
auto contextRef = JsRuntime::LoadSystemModuleByEngine(env, "application.EmbeddableUIAbilityContext",
|
||||
&emUIObject, 1);
|
||||
CHECK_POINTER_AND_RETURN(contextRef, nullptr);
|
||||
contextObj = contextRef->GetNapiValue();
|
||||
}
|
||||
auto contextObj = contextRef->GetNapiValue();
|
||||
if (contextObj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "load context error");
|
||||
return nullptr;
|
||||
|
@ -104,11 +104,7 @@ bool CheckConnectionParam(napi_env env, napi_value value, sptr<JSUIExtensionConn
|
||||
key.want = want;
|
||||
connection->SetConnectionId(key.id);
|
||||
g_connects.emplace(key, connection);
|
||||
if (g_serialNumber < INT32_MAX) {
|
||||
g_serialNumber++;
|
||||
} else {
|
||||
g_serialNumber = 0;
|
||||
}
|
||||
g_serialNumber = (g_serialNumber + 1) % INT32_MAX;
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "not find connection, create a new connection");
|
||||
return true;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ sptr<Rosen::WindowOption> UIServiceExtension::GetWindowOption(
|
||||
}
|
||||
option->SetWindowType(Rosen::WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
|
||||
option->SetParentId(hostWindowId);
|
||||
option->SetExtensionTag(true);
|
||||
option->SetIsUIExtFirstSubWindow(true);
|
||||
option->SetSubWindowTitle(extensionWindowConfig->subWindowOptions.title);
|
||||
option->SetSubWindowDecorEnable(extensionWindowConfig->subWindowOptions.decorEnabled);
|
||||
if (extensionWindowConfig->subWindowOptions.isModal) {
|
||||
|
@ -88,6 +88,7 @@ ohos_shared_library("appkit_native") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/recovery",
|
||||
"${ability_runtime_path}/utils/global/time/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_napi_path}/inner/napi_common",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
|
@ -51,41 +51,6 @@ constexpr const char* CONFIG_ENTRY = "configEntry";
|
||||
constexpr const char *TASKPOOL = "taskPool";
|
||||
constexpr const char *TASKPOOL_LOWER = "taskpool";
|
||||
|
||||
napi_value AttachAbilityStageContext(napi_env env, void *value, void *)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "AttachAbilityStageContext");
|
||||
if (env == nullptr || value == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "invalid parameter, env or value is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
auto ptr = reinterpret_cast<std::weak_ptr<AbilityContext> *>(value)->lock();
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "invalid context");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value object = CreateJsAbilityStageContext(env, ptr);
|
||||
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &object, 1);
|
||||
if (systemModule == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "invalid systemModule");
|
||||
return nullptr;
|
||||
}
|
||||
auto contextObj = systemModule->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "LoadSystemModuleByEngine or ConvertNativeValueTo failed");
|
||||
return nullptr;
|
||||
}
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, value, nullptr);
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityRuntime::Context>(ptr);
|
||||
napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Finalizer context is called");
|
||||
delete static_cast<std::weak_ptr<AbilityRuntime::Context> *>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
return contextObj;
|
||||
}
|
||||
|
||||
bool JsAbilityStage::UseCommonChunk(const AppExecFwk::HapModuleInfo& hapModuleInfo)
|
||||
{
|
||||
for (auto &md: hapModuleInfo.metadata) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "js_ability_stage_context.h"
|
||||
|
||||
#include "ability_runtime/context/context.h"
|
||||
#include "ability_stage_context.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "js_context_utils.h"
|
||||
#include "js_data_struct_converter.h"
|
||||
@ -65,5 +66,57 @@ napi_value CreateJsAbilityStageContext(napi_env env, std::shared_ptr<AbilityRunt
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
|
||||
napi_value AttachAbilityStageContext(napi_env env, void *value, void *hint)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "attach ability stage context");
|
||||
if (env == nullptr || value == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "invalid params");
|
||||
return nullptr;
|
||||
}
|
||||
auto ptr = reinterpret_cast<std::weak_ptr<AbilityStageContext> *>(value)->lock();
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "invalid context");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto object = CreateJsAbilityStageContext(env, ptr);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "null ability stage object");
|
||||
return nullptr;
|
||||
}
|
||||
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &object, 1);
|
||||
if (systemModule == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "load ability stage context failed");
|
||||
return nullptr;
|
||||
}
|
||||
auto contextObj = systemModule->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "not napi object");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto status = napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, value, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "coerce ability stage context failed: %{public}d", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityStageContext>(ptr);
|
||||
status = napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "finalizer for weak_ptr ability stage context");
|
||||
delete static_cast<std::weak_ptr<AbilityStageContext> *>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "wrap ability stage context failed: %{public}d", status);
|
||||
delete workContext;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return contextObj;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -1019,13 +1019,15 @@ void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceMana
|
||||
}
|
||||
#endif
|
||||
resConfig->SetDeviceType(GetDeviceType());
|
||||
std::string mcc = config_->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC);
|
||||
std::string mnc = config_->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC);
|
||||
try {
|
||||
resConfig->SetMcc(static_cast<uint32_t>(std::stoi(mcc)));
|
||||
resConfig->SetMnc(static_cast<uint32_t>(std::stoi(mnc)));
|
||||
} catch (...) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Set mcc,mnc failed mcc:%{public}s mnc:%{public}s", mcc.c_str(), mnc.c_str());
|
||||
if (config_) {
|
||||
std::string mcc = config_->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC);
|
||||
std::string mnc = config_->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC);
|
||||
try {
|
||||
resConfig->SetMcc(static_cast<uint32_t>(std::stoi(mcc)));
|
||||
resConfig->SetMnc(static_cast<uint32_t>(std::stoi(mnc)));
|
||||
} catch (...) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Set mcc,mnc failed mcc:%{public}s mnc:%{public}s", mcc.c_str(), mnc.c_str());
|
||||
}
|
||||
}
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
}
|
||||
|
@ -263,5 +263,12 @@ ErrCode ServiceExtensionContext::PreStartMission(const std::string& bundleName,
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
ErrCode ServiceExtensionContext::OpenLink(const AAFwk::Want& want, int requestCode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
return AAFwk::AbilityManagerClient::GetInstance()->OpenLink(want, token_, -1, requestCode);
|
||||
}
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -79,19 +79,21 @@ void ApplicationCleaner::ClearTempData()
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Get root dir error");
|
||||
return;
|
||||
}
|
||||
auto cleanTemp = [self = shared_from_this(), rootDir]() {
|
||||
if (self == nullptr || self->context_ == nullptr) {
|
||||
auto weakThis = weak_from_this();
|
||||
auto cleanTemp = [weakThis, rootDir]() {
|
||||
auto sharedThis = weakThis.lock();
|
||||
if (sharedThis == nullptr || sharedThis->context_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Invalid shared pointer");
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> temps;
|
||||
if (self->GetObsoleteBundleTempPath(rootDir, temps) != RESULT_OK) {
|
||||
if (sharedThis->GetObsoleteBundleTempPath(rootDir, temps) != RESULT_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Get bundle temp file list is false");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &temp : temps) {
|
||||
if (self->RemoveDir(temp) == false) {
|
||||
if (sharedThis->RemoveDir(temp) == false) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Clean bundle data dir failed, path: %{private}s", temp.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,6 @@ AAFwk::UserStatus AssertFaultTaskThread::HandleAssertCallback(const std::string
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Invalid client object");
|
||||
break;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lockAssertResult(assertResultMutex_);
|
||||
AAFwk::WantParams wantParams;
|
||||
wantParams.SetParam(ASSERT_FAULT_DETAIL, AAFwk::String::Box(exprStr));
|
||||
@ -158,7 +157,6 @@ AAFwk::UserStatus AssertFaultTaskThread::HandleAssertCallback(const std::string
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Request assert fault dialog failed");
|
||||
break;
|
||||
}
|
||||
|
||||
assertResultCV_.wait(lockAssertResult);
|
||||
assertResult = assertFaultCallback->GetAssertResult();
|
||||
} while (false);
|
||||
@ -175,4 +173,4 @@ void AssertFaultTaskThread::NotifyReleaseLongWaiting()
|
||||
assertResultCV_.notify_one();
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -213,7 +213,7 @@ std::string ContextContainer::GetAppType()
|
||||
}
|
||||
}
|
||||
|
||||
void ContextContainer::SetPattern(int patternId)
|
||||
void ContextContainer::SetPattern(int32_t patternId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
baseContext_->SetPattern(patternId);
|
||||
|
@ -132,17 +132,19 @@ bool IdleTime::GetNeedStop()
|
||||
|
||||
IdleNotifyStatusCallback IdleTime::GetIdleNotifyFunc()
|
||||
{
|
||||
IdleNotifyStatusCallback cb = [this](bool needStop) {
|
||||
if (this->GetNeedStop() == needStop) {
|
||||
auto weakThis = weak_from_this();
|
||||
IdleNotifyStatusCallback cb = [weakThis](bool needStop) {
|
||||
auto sharedThis = weakThis.lock();
|
||||
if (sharedThis == nullptr || sharedThis->GetNeedStop() == needStop) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->SetNeedStop(needStop);
|
||||
sharedThis->SetNeedStop(needStop);
|
||||
if (needStop == false) {
|
||||
this->Start();
|
||||
sharedThis->Start();
|
||||
}
|
||||
};
|
||||
return cb;
|
||||
}
|
||||
} // AppExecFwk
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -413,6 +413,7 @@ std::shared_ptr<EventHandler> MainThread::GetMainHandler() const
|
||||
bool MainThread::ScheduleForegroundApplication()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "ScheduleForegroundApplication");
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak]() {
|
||||
@ -640,6 +641,7 @@ void MainThread::ScheduleLaunchApplication(const AppLaunchData &data, const Conf
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "ScheduleLaunchApplication");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak, data, config]() {
|
||||
auto appThread = weak.promote();
|
||||
@ -747,6 +749,8 @@ void MainThread::ScheduleLaunchAbility(const AbilityInfo &info, const sptr<IRemo
|
||||
void MainThread::ScheduleCleanAbility(const sptr<IRemoteObject> &token, bool isCacheProcess)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called, with isCacheProcess =%{public}d.", isCacheProcess);
|
||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(token);
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak, token, isCacheProcess]() {
|
||||
auto appThread = weak.promote();
|
||||
@ -1280,6 +1284,7 @@ CJUncaughtExceptionInfo MainThread::CreateCjExceptionInfo(const std::string &bun
|
||||
void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, const Configuration &config)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleLaunchApplication:begin");
|
||||
if (!CheckForHandleLaunchApplication(appLaunchData)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "CheckForHandleLaunchApplication failed");
|
||||
return;
|
||||
@ -1338,7 +1343,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
}
|
||||
#ifdef CJ_FRONTEND
|
||||
if (!entryHapModuleInfo.abilityInfos.empty()) {
|
||||
isCJApp = AbilityRuntime::CJRuntime::IsCJAbility(entryHapModuleInfo.abilityInfos.front().srcEntrance);
|
||||
auto srcEntrancenName = entryHapModuleInfo.abilityInfos.front().srcEntrance;
|
||||
isCJApp = AbilityRuntime::CJRuntime::IsCJAbility(srcEntrancenName);
|
||||
AbilityRuntime::CJRuntime::SetPackageName(srcEntrancenName);
|
||||
}
|
||||
#endif
|
||||
moduelJson = entryHapModuleInfo.isModuleJson;
|
||||
@ -1579,7 +1586,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
int result = HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::FRAMEWORK, "PROCESS_KILL",
|
||||
HiviewDFX::HiSysEvent::EventType::FAULT, "PID", pid, "PROCESS_NAME", processName,
|
||||
"MSG", KILL_REASON);
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "hisysevent write result=%{public}d, send event [FRAMEWORK,PROCESS_KILL],"
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "hisysevent write result=%{public}d, send event [FRAMEWORK,PROCESS_KILL],"
|
||||
" pid=%{public}d, processName=%{public}s, msg=%{public}s", result, pid, processName.c_str(),
|
||||
KILL_REASON);
|
||||
|
||||
@ -1725,6 +1732,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_->PerformAppReady failed");
|
||||
return;
|
||||
}
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleLaunchApplication:end");
|
||||
// L1 needs to add corresponding interface
|
||||
ApplicationEnvImpl *pAppEvnIml = ApplicationEnvImpl::GetInstance();
|
||||
|
||||
@ -1819,13 +1827,17 @@ void MainThread::LoadNativeLibrary(const BundleInfo &bundleInfo, std::string &na
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "No native library");
|
||||
return;
|
||||
}
|
||||
|
||||
char resolvedPath[PATH_MAX] = {0};
|
||||
void *handleAbilityLib = nullptr;
|
||||
for (auto fileEntry : nativeFileEntries_) {
|
||||
if (fileEntry.empty()) {
|
||||
if (fileEntry.empty() || fileEntry.size() >= PATH_MAX) {
|
||||
continue;
|
||||
}
|
||||
handleAbilityLib = dlopen(fileEntry.c_str(), RTLD_NOW | RTLD_GLOBAL);
|
||||
if (realpath(fileEntry.c_str(), resolvedPath) == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get realpath, errno = %{public}d", errno);
|
||||
continue;
|
||||
}
|
||||
handleAbilityLib = dlopen(resolvedPath, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (handleAbilityLib == nullptr) {
|
||||
if (fileEntry.find("libformrender.z.so") == std::string::npos) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "fail to dlopen %{public}s, [%{public}s]",
|
||||
@ -1904,6 +1916,10 @@ void MainThread::HandleAbilityStage(const HapModuleInfo &abilityStage)
|
||||
wptr<MainThread> weak = this;
|
||||
auto callback = [weak]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr");
|
||||
return;
|
||||
}
|
||||
if (!appThread->appMgr_ || !appThread->applicationImpl_) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appMgr_ is nullptr");
|
||||
return;
|
||||
@ -2194,6 +2210,7 @@ void MainThread::HandleCleanAbility(const sptr<IRemoteObject> &token, bool isCac
|
||||
void MainThread::HandleForegroundApplication()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleForegroundApplication");
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "called");
|
||||
if ((application_ == nullptr) || (appMgr_ == nullptr)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "handleForegroundApplication error!");
|
||||
@ -2201,6 +2218,7 @@ void MainThread::HandleForegroundApplication()
|
||||
}
|
||||
|
||||
if (!applicationImpl_->PerformForeground()) {
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleForegroundApplication fail");
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_->PerformForeground() failed");
|
||||
}
|
||||
|
||||
@ -2222,7 +2240,7 @@ void MainThread::HandleBackgroundApplication()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "start");
|
||||
|
||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleBackgroundApplication");
|
||||
if ((application_ == nullptr) || (appMgr_ == nullptr)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "error");
|
||||
return;
|
||||
|
@ -189,7 +189,7 @@ void OHOSApplication::SetApplicationContext(
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr.");
|
||||
return;
|
||||
}
|
||||
applicationSptr->OnFontUpdated(config);
|
||||
applicationSptr->OnUpdateConfigurationForAll(config);
|
||||
});
|
||||
}
|
||||
|
||||
@ -264,8 +264,6 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config, AbilityRuntim
|
||||
#endif
|
||||
|
||||
abilityRuntimeContext_->DispatchConfigurationUpdated(*configuration_);
|
||||
abilityRuntimeContext_->SetMcc(configuration_->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
abilityRuntimeContext_->SetMnc(configuration_->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
abilityRuntimeContext_->SetConfiguration(configuration_);
|
||||
}
|
||||
|
||||
@ -275,7 +273,7 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config, AbilityRuntim
|
||||
*
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
void OHOSApplication::OnFontUpdated(Configuration config)
|
||||
void OHOSApplication::OnUpdateConfigurationForAll(Configuration config)
|
||||
{
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// Notify Window
|
||||
@ -292,7 +290,7 @@ void OHOSApplication::OnFontUpdated(Configuration config)
|
||||
*
|
||||
* @param level Indicates the memory trim level, which shows the current memory usage status.
|
||||
*/
|
||||
void OHOSApplication::OnMemoryLevel(int level)
|
||||
void OHOSApplication::OnMemoryLevel(int32_t level)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
if (abilityRuntimeContext_ == nullptr) {
|
||||
@ -434,19 +432,34 @@ const std::function<void()> OHOSApplication::CreateAutoStartupCallback(
|
||||
const std::function<void(const std::shared_ptr<AbilityRuntime::Context>&)>& callback)
|
||||
{
|
||||
const std::shared_ptr<AbilityInfo> &abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null abilityInfo");
|
||||
return nullptr;
|
||||
}
|
||||
if (!IsMainProcess(abilityInfo->bundleName, abilityInfo->applicationInfo.process)) {
|
||||
return nullptr;
|
||||
}
|
||||
std::string moduleName = abilityInfo->moduleName;
|
||||
auto application = std::static_pointer_cast<OHOSApplication>(shared_from_this());
|
||||
std::weak_ptr<OHOSApplication> weak = application;
|
||||
|
||||
auto autoStartupCallback = [weak, abilityStage, abilityRecord, moduleName, callback]() {
|
||||
auto autoStartupCallback = [weak, abilityStage, abilityRecord, callback]() {
|
||||
auto ohosApplication = weak.lock();
|
||||
if (ohosApplication == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null ohosApplication");
|
||||
return;
|
||||
}
|
||||
if (abilityRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null abilityRecord");
|
||||
return;
|
||||
}
|
||||
|
||||
auto abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null abilityInfo");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string moduleName = abilityInfo->moduleName;
|
||||
ohosApplication->AutoStartupDone(abilityRecord, abilityStage, moduleName);
|
||||
if (callback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null callback");
|
||||
@ -464,6 +477,10 @@ const std::function<void()> OHOSApplication::CreateAutoStartupCallback(
|
||||
const std::function<void()>& callback)
|
||||
{
|
||||
auto applicationInfo = abilityRuntimeContext_->GetApplicationInfo();
|
||||
if (applicationInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null applicationInfo");
|
||||
return nullptr;
|
||||
}
|
||||
if (!IsMainProcess(hapModuleInfo.bundleName, applicationInfo->process)) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -636,7 +653,7 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::GetAppContext() const
|
||||
return abilityRuntimeContext_;
|
||||
}
|
||||
|
||||
const std::unique_ptr<AbilityRuntime::Runtime>& OHOSApplication::GetRuntime()
|
||||
const std::unique_ptr<AbilityRuntime::Runtime>& OHOSApplication::GetRuntime() const
|
||||
{
|
||||
return runtime_;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "hisysevent.h"
|
||||
#include "parameter.h"
|
||||
#include "xcollie/watchdog.h"
|
||||
#include "time_util.h"
|
||||
@ -86,6 +85,62 @@ bool AppfreezeInner::IsHandleAppfreeze()
|
||||
return !isAppDebug_;
|
||||
}
|
||||
|
||||
void AppfreezeInner::GetMainHandlerDump(std::string& msgContent)
|
||||
{
|
||||
auto mainHandler = appMainHandler_.lock();
|
||||
if (mainHandler == nullptr) {
|
||||
msgContent += "mainHandler is destructed!";
|
||||
} else {
|
||||
MainHandlerDumper handlerDumper;
|
||||
msgContent += "mainHandler dump is:\n";
|
||||
mainHandler->Dump(handlerDumper);
|
||||
msgContent += handlerDumper.GetDumpInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void AppfreezeInner::ChangeFaultDateInfo(FaultData& faultData, const std::string& msgContent)
|
||||
{
|
||||
faultData.errorObject.message += msgContent;
|
||||
faultData.faultType = FaultDataType::APP_FREEZE;
|
||||
faultData.notifyApp = false;
|
||||
faultData.waitSaveState = false;
|
||||
faultData.forceExit = false;
|
||||
bool isExit = IsExitApp(faultData.errorObject.name);
|
||||
if (isExit) {
|
||||
faultData.forceExit = true;
|
||||
faultData.waitSaveState = AppRecovery::GetInstance().IsEnabled();
|
||||
AAFwk::ExitReason exitReason = {REASON_APP_FREEZE, "Kill Reason:" + faultData.errorObject.name};
|
||||
AbilityManagerClient::GetInstance()->RecordAppExitReason(exitReason);
|
||||
}
|
||||
NotifyANR(faultData);
|
||||
if (isExit) {
|
||||
AppFreezeRecovery();
|
||||
}
|
||||
}
|
||||
|
||||
void AppfreezeInner::AppfreezeHandleOverReportCount(bool isSixSecondEvent)
|
||||
{
|
||||
FaultData faultData;
|
||||
faultData.errorObject.message =
|
||||
"\nFault time:" + AbilityRuntime::TimeUtil::FormatTime("%Y/%m/%d-%H:%M:%S") + "\n";
|
||||
faultData.errorObject.message += "App main thread is not response!";
|
||||
faultData.faultType = FaultDataType::APP_FREEZE;
|
||||
faultData.timeoutMarkers = "";
|
||||
if (isSixSecondEvent) {
|
||||
faultData.errorObject.name = AppFreezeType::THREAD_BLOCK_6S;
|
||||
} else {
|
||||
faultData.errorObject.name = AppFreezeType::THREAD_BLOCK_3S;
|
||||
}
|
||||
if (!IsHandleAppfreeze()) {
|
||||
NotifyANR(faultData);
|
||||
return;
|
||||
}
|
||||
std::string msgContent;
|
||||
GetMainHandlerDump(msgContent);
|
||||
ChangeFaultDateInfo(faultData, msgContent);
|
||||
return;
|
||||
}
|
||||
|
||||
int AppfreezeInner::AppfreezeHandle(const FaultData& faultData, bool onlyMainThread)
|
||||
{
|
||||
if (!IsHandleAppfreeze()) {
|
||||
@ -120,36 +175,12 @@ bool AppfreezeInner::IsExitApp(const std::string& name)
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppfreezeInner::SendProcessKillEvent(const std::string& killReason)
|
||||
{
|
||||
auto applicationInfo = applicationInfo_.lock();
|
||||
if (applicationInfo != nullptr) {
|
||||
int32_t pid = static_cast<int32_t>(getpid());
|
||||
std::string processName = applicationInfo->process;
|
||||
int result = HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::FRAMEWORK, "PROCESS_KILL",
|
||||
HiviewDFX::HiSysEvent::EventType::FAULT, EVENT_PID, pid,
|
||||
EVENT_PROCESS_NAME, processName, EVENT_MESSAGE, killReason);
|
||||
TAG_LOGI(AAFwkTag::APPDFR, "result:%{public}d,"
|
||||
" pid:%{public}d, processName:%{public}s, msg:%{public}s", result, pid, processName.c_str(),
|
||||
killReason.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
int AppfreezeInner::AcquireStack(const FaultData& info, bool onlyMainThread)
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_APP, "AppfreezeInner::AcquireStack name:%s", info.errorObject.name.c_str());
|
||||
std::string stack = "";
|
||||
std::string msgContent;
|
||||
|
||||
auto mainHandler = appMainHandler_.lock();
|
||||
if (mainHandler == nullptr) {
|
||||
msgContent += "mainHandler is destructed!";
|
||||
} else {
|
||||
MainHandlerDumper handlerDumper;
|
||||
msgContent += "mainHandler dump is:\n";
|
||||
mainHandler->Dump(handlerDumper);
|
||||
msgContent += handlerDumper.GetDumpInfo();
|
||||
}
|
||||
GetMainHandlerDump(msgContent);
|
||||
|
||||
std::lock_guard<std::mutex> lock(handlingMutex_);
|
||||
for (auto it = handlinglist_.begin(); it != handlinglist_.end(); it = handlinglist_.erase(it)) {
|
||||
@ -159,29 +190,14 @@ int AppfreezeInner::AcquireStack(const FaultData& info, bool onlyMainThread)
|
||||
if (it->state != 0) {
|
||||
FreezeUtil::LifecycleFlow flow = { it->token, static_cast<FreezeUtil::TimeoutState>(it->state) };
|
||||
faultData.errorObject.message += "client:\n" +
|
||||
FreezeUtil::GetInstance().GetLifecycleEvent(flow) + "\n";
|
||||
FreezeUtil::GetInstance().GetLifecycleEvent(flow) + "\nclient app:\n" +
|
||||
FreezeUtil::GetInstance().GetAppLifecycleEvent(0) + "\n";
|
||||
}
|
||||
faultData.errorObject.message += msgContent;
|
||||
faultData.errorObject.stack = stack;
|
||||
faultData.errorObject.name = it->errorObject.name;
|
||||
faultData.faultType = FaultDataType::APP_FREEZE;
|
||||
faultData.timeoutMarkers = it->timeoutMarkers;
|
||||
faultData.notifyApp = false;
|
||||
faultData.waitSaveState = false;
|
||||
faultData.forceExit = false;
|
||||
faultData.eventId = it->eventId;
|
||||
bool isExit = IsExitApp(it->errorObject.name);
|
||||
if (isExit) {
|
||||
faultData.forceExit = true;
|
||||
faultData.waitSaveState = AppRecovery::GetInstance().IsEnabled();
|
||||
AAFwk::ExitReason exitReason = {REASON_APP_FREEZE, "Kill Reason:" + faultData.errorObject.name};
|
||||
AbilityManagerClient::GetInstance()->RecordAppExitReason(exitReason);
|
||||
SendProcessKillEvent("Kill Reason:" + faultData.errorObject.name);
|
||||
}
|
||||
NotifyANR(faultData);
|
||||
if (isExit) {
|
||||
AppFreezeRecovery();
|
||||
}
|
||||
ChangeFaultDateInfo(faultData, msgContent);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ constexpr uint32_t CHECK_MAIN_THREAD_IS_ALIVE = 1;
|
||||
constexpr int RESET_RATIO = 2;
|
||||
|
||||
constexpr int32_t BACKGROUND_REPORT_COUNT_MAX = 5;
|
||||
constexpr int32_t WATCHDOG_REPORT_COUNT_MAX = 5;
|
||||
#ifdef SUPPORT_ASAN
|
||||
constexpr uint32_t CHECK_INTERVAL_TIME = 45000;
|
||||
#else
|
||||
@ -107,6 +108,7 @@ void Watchdog::AllowReportEvent()
|
||||
needReport_.store(true);
|
||||
isSixSecondEvent_.store(false);
|
||||
backgroundReportCount_.store(0);
|
||||
watchdogReportCount_.store(0);
|
||||
}
|
||||
|
||||
bool Watchdog::IsReportEvent()
|
||||
@ -139,7 +141,19 @@ void Watchdog::Timer()
|
||||
return;
|
||||
}
|
||||
if (!needReport_) {
|
||||
TAG_LOGE(AAFwkTag::APPDFR, "timeout, wait to recover");
|
||||
watchdogReportCount_++;
|
||||
TAG_LOGE(AAFwkTag::APPDFR, "timeout, wait to recover, wait count: %{public}d",
|
||||
watchdogReportCount_.load());
|
||||
if (watchdogReportCount_.load() >= WATCHDOG_REPORT_COUNT_MAX) {
|
||||
#ifndef APP_NO_RESPONSE_DIALOG
|
||||
AppExecFwk::AppfreezeInner::GetInstance()->AppfreezeHandleOverReportCount(true);
|
||||
#endif
|
||||
watchdogReportCount_.store(0);
|
||||
} else if (watchdogReportCount_.load() >= (WATCHDOG_REPORT_COUNT_MAX - 1)) {
|
||||
#ifndef APP_NO_RESPONSE_DIALOG
|
||||
AppExecFwk::AppfreezeInner::GetInstance()->AppfreezeHandleOverReportCount(false);
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,8 @@ CJEnvMethods* CJEnv::LoadInstance()
|
||||
}
|
||||
AppLibPathVec CJRuntime::appLibPaths_;
|
||||
|
||||
std::string CJRuntime::packageName_;
|
||||
|
||||
std::unique_ptr<CJRuntime> CJRuntime::Create(const Options& options)
|
||||
{
|
||||
auto instance = std::make_unique<CJRuntime>();
|
||||
@ -152,10 +154,13 @@ bool CJRuntime::LoadCJAppLibrary(const AppLibPathVec& appLibPaths)
|
||||
return false;
|
||||
}
|
||||
void* handle = nullptr;
|
||||
// According to the OHOS rule, the format of the SO name is as follows
|
||||
auto targetSoName = "lib" + packageName_ + ".so";
|
||||
|
||||
for (const auto& libPath : appLibPaths) {
|
||||
for (auto& itor : std::filesystem::directory_iterator(libPath)) {
|
||||
// According to the convention, the names of cj generated products must contain the following keywords
|
||||
if (itor.path().string().find("ohos_app_cangjie") == std::string::npos) {
|
||||
if (itor.path().string().find(targetSoName) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
handle = cjEnv->loadCJLibrary(itor.path().c_str());
|
||||
@ -171,6 +176,13 @@ bool CJRuntime::LoadCJAppLibrary(const AppLibPathVec& appLibPaths)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CJRuntime::SetPackageName(std::string srcEntryName)
|
||||
{
|
||||
// According to the srcEntry rule in the Cangjie application,
|
||||
// the last '.' The previous strings were all package names
|
||||
packageName_ = srcEntryName.substr(0, srcEntryName.find_last_of("."));
|
||||
}
|
||||
|
||||
void CJRuntime::SetSanitizerVersion(SanitizerKind kind)
|
||||
{
|
||||
auto cjEnv = OHOS::CJEnv::LoadInstance();
|
||||
|
@ -16,11 +16,11 @@
|
||||
#include "ohos_js_environment_impl.h"
|
||||
|
||||
#include "console.h"
|
||||
#include "timer/timer.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "js_utils.h"
|
||||
#include "js_worker.h"
|
||||
#include "ohos_loop_handler.h"
|
||||
#include "sys_timer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
@ -119,6 +119,7 @@ ohos_shared_library("ability_simulator_inner") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ace_engine:ace_uicontent",
|
||||
"window_manager:previewer_window",
|
||||
"window_manager:previewer_window_napi",
|
||||
]
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "ability_context.h"
|
||||
#include "ability_stage_context.h"
|
||||
#include "bundle_container.h"
|
||||
#include "timer/timer.h"
|
||||
#include "console.h"
|
||||
#include "declarative_module_preloader.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "js_ability_context.h"
|
||||
#include "js_ability_stage_context.h"
|
||||
@ -42,6 +42,7 @@
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
#include "resource_manager.h"
|
||||
#include "window_scene.h"
|
||||
#include "sys_timer.h"
|
||||
|
||||
extern const char _binary_jsMockSystemPlugin_abc_start[];
|
||||
extern const char _binary_jsMockSystemPlugin_abc_end[];
|
||||
@ -55,6 +56,7 @@ constexpr size_t DEFAULT_GC_THREAD_NUM = 7;
|
||||
constexpr size_t DEFAULT_LONG_PAUSE_TIME = 40;
|
||||
|
||||
constexpr char BUNDLE_INSTALL_PATH[] = "/data/storage/el1/bundle/";
|
||||
constexpr char MERGE_ABC_PATH[] = "/ets/modules.abc";
|
||||
const std::string PACKAGE_NAME = "packageName";
|
||||
const std::string BUNDLE_NAME = "bundleName";
|
||||
const std::string MODULE_NAME = "moduleName";
|
||||
@ -125,6 +127,7 @@ private:
|
||||
void LoadJsMock(const std::string &fileName);
|
||||
void ReportJsError(napi_value obj);
|
||||
std::string GetNativeStrFromJsTaggedObj(napi_value obj, const char* key);
|
||||
void CreateStageContext();
|
||||
|
||||
panda::ecmascript::EcmaVM *CreateJSVM();
|
||||
Options options_;
|
||||
@ -133,6 +136,7 @@ private:
|
||||
DebuggerTask debuggerTask_;
|
||||
napi_env nativeEngine_ = nullptr;
|
||||
TerminateCallback terminateCallback_;
|
||||
bool isOhmUrl_ = false;
|
||||
|
||||
int64_t currentId_ = 0;
|
||||
std::unordered_map<int64_t, std::shared_ptr<NativeReference>> abilities_;
|
||||
@ -243,7 +247,13 @@ void CallObjectMethod(napi_env env, napi_value obj, const char *name, napi_value
|
||||
|
||||
napi_value SimulatorImpl::LoadScript(const std::string &srcPath)
|
||||
{
|
||||
panda::Local<panda::ObjectRef> objRef = panda::JSNApi::GetExportObject(vm_, srcPath, "default");
|
||||
panda::Local<panda::ObjectRef> objRef;
|
||||
if (isOhmUrl_) {
|
||||
objRef = panda::JSNApi::GetExportObjectFromOhmUrl(vm_, srcPath, "default");
|
||||
} else {
|
||||
objRef = panda::JSNApi::GetExportObject(vm_, srcPath, "default");
|
||||
}
|
||||
|
||||
if (objRef->IsNull()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Get export object failed");
|
||||
return nullptr;
|
||||
@ -312,7 +322,7 @@ bool SimulatorImpl::ParseAbilityInfo(const std::string &abilitySrcPath, const st
|
||||
abilityInfo_ = AppExecFwk::BundleContainer::GetInstance().GetAbilityInfo(
|
||||
options_.moduleName, abilityNameFromPath);
|
||||
}
|
||||
|
||||
|
||||
if (abilityInfo_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "ability info parse failed");
|
||||
return false;
|
||||
@ -332,14 +342,7 @@ int64_t SimulatorImpl::StartAbility(
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (stageContext_ == nullptr) {
|
||||
stageContext_ = std::make_shared<AbilityStageContext>();
|
||||
stageContext_->SetOptions(options_);
|
||||
stageContext_->SetConfiguration(options_.configuration);
|
||||
stageContext_->SetApplicationInfo(appInfo_);
|
||||
stageContext_->SetHapModuleInfo(moduleInfo_);
|
||||
}
|
||||
|
||||
CreateStageContext();
|
||||
std::ifstream stream(options_.modulePath, std::ios::ate | std::ios::binary);
|
||||
if (!stream.is_open()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "open:%{public}s failed", options_.modulePath.c_str());
|
||||
@ -358,13 +361,24 @@ int64_t SimulatorImpl::StartAbility(
|
||||
return -1;
|
||||
}
|
||||
|
||||
abilityPath_ = BUNDLE_INSTALL_PATH + options_.moduleName + "/" + abilitySrcPath;
|
||||
if (!reinterpret_cast<NativeEngine*>(nativeEngine_)->RunScriptBuffer(abilityPath_, buf, len, false)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "run script:%{public}s failed", abilityPath_.c_str());
|
||||
return -1;
|
||||
isOhmUrl_ = panda::JSNApi::IsOhmUrl(abilitySrcPath);
|
||||
napi_value instanceValue = nullptr;
|
||||
if (isOhmUrl_) {
|
||||
std::string srcFilename = "";
|
||||
srcFilename = BUNDLE_INSTALL_PATH + options_.moduleName + MERGE_ABC_PATH;
|
||||
if (!panda::JSNApi::ExecuteSecureWithOhmUrl(vm_, buf, len, srcFilename, abilitySrcPath)) {
|
||||
return -1;
|
||||
}
|
||||
instanceValue = LoadScript(abilitySrcPath);
|
||||
} else {
|
||||
abilityPath_ = BUNDLE_INSTALL_PATH + options_.moduleName + "/" + abilitySrcPath;
|
||||
if (!reinterpret_cast<NativeEngine*>(nativeEngine_)->RunScriptBuffer(abilityPath_, buf, len, false)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "run script:%{public}s failed", abilityPath_.c_str());
|
||||
return -1;
|
||||
}
|
||||
instanceValue = LoadScript(abilityPath_);
|
||||
}
|
||||
|
||||
napi_value instanceValue = LoadScript(abilityPath_);
|
||||
if (instanceValue == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "create object instance failed");
|
||||
return -1;
|
||||
@ -715,6 +729,7 @@ bool SimulatorImpl::OnInit()
|
||||
self->terminateCallback_(self->currentId_);
|
||||
};
|
||||
nativeEngine->RegisterNapiUncaughtExceptionHandler(uncaughtTask);
|
||||
Ace::DeclarativeModulePreloader::Preload(*nativeEngine);
|
||||
|
||||
napi_value globalObj;
|
||||
napi_get_global(env, &globalObj);
|
||||
@ -985,5 +1000,16 @@ void SimulatorImpl::ReportJsError(napi_value obj)
|
||||
summary += "Stacktrace:\n" + errorStack;
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "summary:\n%{public}s", summary.c_str());
|
||||
}
|
||||
|
||||
void SimulatorImpl::CreateStageContext()
|
||||
{
|
||||
if (stageContext_ == nullptr) {
|
||||
stageContext_ = std::make_shared<AbilityStageContext>();
|
||||
stageContext_->SetOptions(options_);
|
||||
stageContext_->SetConfiguration(options_.configuration);
|
||||
stageContext_->SetApplicationInfo(appInfo_);
|
||||
stageContext_->SetHapModuleInfo(moduleInfo_);
|
||||
}
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -129,6 +129,7 @@ ohos_shared_library("ability_manager") {
|
||||
":process_options",
|
||||
":start_window_option",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_path}/utils/global/freeze:freeze_util",
|
||||
"${ability_runtime_services_path}/abilitymgr:wantagent_manager",
|
||||
]
|
||||
|
||||
@ -383,6 +384,7 @@ ohos_shared_library("ability_connect_callback_stub") {
|
||||
include_dirs = [
|
||||
"include/",
|
||||
"${ability_base_kits_path}/want/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
static bool IsAttachToStatusBarMode(ProcessMode value);
|
||||
static bool IsValidProcessMode(ProcessMode value);
|
||||
static bool IsNoAttachmentMode(ProcessMode value);
|
||||
static bool IsAttachToStatusBarItemMode(ProcessMode value);
|
||||
|
||||
ProcessMode processMode = ProcessMode::UNSPECIFIED;
|
||||
StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED;
|
||||
|
@ -171,16 +171,19 @@ public:
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @param userId, userId.
|
||||
* @param reason, caller function name.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int KillApplicationByUid(const std::string &bundleName, const int uid) = 0;
|
||||
virtual int KillApplicationByUid(const std::string &bundleName, const int uid,
|
||||
const std::string& reason = "KillApplicationByUid") = 0;
|
||||
|
||||
/**
|
||||
* Kill the application self.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = false)
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = false,
|
||||
const std::string& reason = "KillApplicationSelf")
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -162,11 +162,14 @@ public:
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @param uid, uid.
|
||||
* @param reason, caller function name.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid) override;
|
||||
virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid,
|
||||
const std::string& reason = "KillApplicationByUid") override;
|
||||
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = false) override;
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = false,
|
||||
const std::string& reason = "KillApplicationSelf") override;
|
||||
|
||||
/**
|
||||
* Get application info by process id.
|
||||
|
@ -185,16 +185,19 @@ public:
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @param uid, uid.
|
||||
* @param reason, caller function name.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode KillApplicationByUid(const std::string &bundleName, const int uid);
|
||||
virtual AppMgrResultCode KillApplicationByUid(const std::string &bundleName, const int uid,
|
||||
const std::string& reason = "KillApplicationByUid");
|
||||
|
||||
/**
|
||||
* Kill the application self.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual AppMgrResultCode KillApplicationSelf(const bool clearPageStack = false);
|
||||
virtual AppMgrResultCode KillApplicationSelf(const bool clearPageStack = false,
|
||||
const std::string& reason = "KillApplicationSelf");
|
||||
|
||||
/**
|
||||
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||
|
@ -729,11 +729,11 @@ public:
|
||||
|
||||
/**
|
||||
* @brief mark a process which is going restart.
|
||||
* @param bundleName the bundleName of the process.
|
||||
* @param uid the uid of the process.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SignRestartAppFlag(const std::string &bundleName)
|
||||
virtual int32_t SignRestartAppFlag(int32_t uid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -854,6 +854,17 @@ public:
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetSupportedProcessCachePids(const std::string &bundleName, std::vector<int32_t> &pidList) = 0;
|
||||
|
||||
/**
|
||||
* Get appIndex of pid.
|
||||
* @param pid The pid.
|
||||
* @param appIndex appIndex of pid.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetAppIndexByPid(pid_t pid, int32_t &appIndex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -117,6 +117,7 @@ enum class AppMgrInterfaceCode {
|
||||
CHECK_IS_KIA_PROCESS = 91,
|
||||
GET_All_RUNNING_INSTANCE_KEYS_BY_BUNDLENAME = 92,
|
||||
GET_All_RUNNING_INSTANCE_KEYS_BY_SELF = 93,
|
||||
GET_APP_INDEX_BY_PID = 94,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
|
@ -640,11 +640,11 @@ public:
|
||||
|
||||
/**
|
||||
* @brief mark a process which is going restart.
|
||||
* @param bundleName the bundleName of the process.
|
||||
* @param uid the uid of the process.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t SignRestartAppFlag(const std::string &bundleName) override;
|
||||
int32_t SignRestartAppFlag(int32_t uid) override;
|
||||
|
||||
/**
|
||||
* Get appRunningUniqueId by pid.
|
||||
@ -739,6 +739,8 @@ public:
|
||||
*/
|
||||
virtual int32_t GetSupportedProcessCachePids(const std::string &bundleName,
|
||||
std::vector<int32_t> &pidList) override;
|
||||
|
||||
virtual int32_t GetAppIndexByPid(pid_t pid, int32_t &appIndex) override;
|
||||
private:
|
||||
bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply);
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
@ -158,6 +158,7 @@ private:
|
||||
int32_t HandleNotifyProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleKillProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleRestartResidentProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAppIndexByPid(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnRemoteRequestInner(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t OnRemoteRequestInnerFirst(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option);
|
||||
|
@ -67,6 +67,7 @@ struct ProcessData : public Parcelable {
|
||||
int32_t exitReason = 0;
|
||||
std::string exitMsg = "";
|
||||
int32_t childUid = -1;
|
||||
bool isPreload = false;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -466,7 +466,8 @@ int32_t AmsMgrProxy::UpdateApplicationInfoInstalled(const std::string &bundleNam
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AmsMgrProxy::KillApplicationByUid(const std::string &bundleName, const int uid)
|
||||
int32_t AmsMgrProxy::KillApplicationByUid(const std::string &bundleName, const int uid,
|
||||
const std::string& reason)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "start");
|
||||
MessageParcel data;
|
||||
@ -476,13 +477,17 @@ int32_t AmsMgrProxy::KillApplicationByUid(const std::string &bundleName, const i
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
if (!data.WriteString(bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteString failed");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed to write bundle name");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(uid)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write uid");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteString(reason)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failedto write reason");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
int32_t ret =
|
||||
SendTransactCmd(static_cast<uint32_t>(IAmsMgr::Message::KILL_APPLICATION_BYUID), data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
@ -492,7 +497,7 @@ int32_t AmsMgrProxy::KillApplicationByUid(const std::string &bundleName, const i
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AmsMgrProxy::KillApplicationSelf(const bool clearPageStack)
|
||||
int32_t AmsMgrProxy::KillApplicationSelf(const bool clearPageStack, const std::string& reason)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "call");
|
||||
MessageParcel data;
|
||||
@ -507,6 +512,11 @@ int32_t AmsMgrProxy::KillApplicationSelf(const bool clearPageStack)
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
if (!data.WriteString(reason)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed to write reason");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
int32_t ret =
|
||||
SendTransactCmd(static_cast<uint32_t>(IAmsMgr::Message::KILL_APPLICATION_SELF), data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
|
@ -400,8 +400,9 @@ ErrCode AmsMgrStub::HandleKillApplicationByUid(MessageParcel &data, MessageParce
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::string bundleName = data.ReadString();
|
||||
int uid = data.ReadInt32();
|
||||
std::string reason = data.ReadString();
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "KillApplicationByUid,callingPid=%{public}d", IPCSkeleton::GetCallingPid());
|
||||
int32_t result = KillApplicationByUid(bundleName, uid);
|
||||
int32_t result = KillApplicationByUid(bundleName, uid, reason);
|
||||
reply.WriteInt32(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
@ -411,7 +412,8 @@ ErrCode AmsMgrStub::HandleKillApplicationSelf(MessageParcel &data, MessageParcel
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "KillApplicationSelf,callingPid=%{public}d", IPCSkeleton::GetCallingPid());
|
||||
bool clearPageStack = data.ReadBool();
|
||||
int32_t result = KillApplicationSelf(clearPageStack);
|
||||
std::string reason = data.ReadString();
|
||||
int32_t result = KillApplicationSelf(clearPageStack, reason);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "result write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
@ -323,13 +323,14 @@ AppMgrResultCode AppMgrClient::KillProcessesByAccessTokenId(const uint32_t acces
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::KillApplicationByUid(const std::string &bundleName, const int uid)
|
||||
AppMgrResultCode AppMgrClient::KillApplicationByUid(const std::string &bundleName, const int uid,
|
||||
const std::string& reason)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||
if (amsService != nullptr) {
|
||||
int32_t result = amsService->KillApplicationByUid(bundleName, uid);
|
||||
int32_t result = amsService->KillApplicationByUid(bundleName, uid, reason);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
@ -339,13 +340,13 @@ AppMgrResultCode AppMgrClient::KillApplicationByUid(const std::string &bundleNam
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::KillApplicationSelf(const bool clearPageStack)
|
||||
AppMgrResultCode AppMgrClient::KillApplicationSelf(const bool clearPageStack, const std::string& reason)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||
if (amsService != nullptr) {
|
||||
int32_t result = amsService->KillApplicationSelf(clearPageStack);
|
||||
int32_t result = amsService->KillApplicationSelf(clearPageStack, reason);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
@ -1750,7 +1750,7 @@ int32_t AppMgrProxy::UpdateRenderState(pid_t renderPid, int32_t state)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::SignRestartAppFlag(const std::string &bundleName)
|
||||
int32_t AppMgrProxy::SignRestartAppFlag(int32_t uid)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
MessageParcel data;
|
||||
@ -1760,7 +1760,7 @@ int32_t AppMgrProxy::SignRestartAppFlag(const std::string &bundleName)
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
||||
return IPC_PROXY_ERR;
|
||||
}
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, String, bundleName);
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, Int32, uid);
|
||||
|
||||
PARCEL_UTIL_SENDREQ_RET_INT(AppMgrInterfaceCode::SIGN_RESTART_APP_FLAG, data, reply, option);
|
||||
return reply.ReadInt32();
|
||||
@ -2072,5 +2072,26 @@ int32_t AppMgrProxy::CheckIsKiaProcess(pid_t pid, bool &isKia)
|
||||
isKia = reply.ReadBool();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetAppIndexByPid(pid_t pid, int32_t &appIndex)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, Int32, pid);
|
||||
|
||||
PARCEL_UTIL_SENDREQ_RET_INT(AppMgrInterfaceCode::GET_APP_INDEX_BY_PID, data, reply, option);
|
||||
int32_t ret = reply.ReadInt32();
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed,ret=%{public}d.", ret);
|
||||
return ret;
|
||||
}
|
||||
appIndex = reply.ReadInt32();
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -345,6 +345,8 @@ int32_t AppMgrStub::OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel &da
|
||||
return HandleRegisterKiaInterceptor(data, reply);
|
||||
case static_cast<uint32_t>(AppMgrInterfaceCode::CHECK_IS_KIA_PROCESS):
|
||||
return HandleCheckIsKiaProcess(data, reply);
|
||||
case static_cast<uint32_t>(AppMgrInterfaceCode::GET_APP_INDEX_BY_PID):
|
||||
return HandleGetAppIndexByPid(data, reply);
|
||||
}
|
||||
return INVALID_FD;
|
||||
}
|
||||
@ -1465,8 +1467,8 @@ int32_t AppMgrStub::HandleUpdateRenderState(MessageParcel &data, MessageParcel &
|
||||
int32_t AppMgrStub::HandleSignRestartAppFlag(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
std::string bundleName = data.ReadString();
|
||||
auto ret = SignRestartAppFlag(bundleName);
|
||||
auto uid = data.ReadInt32();
|
||||
auto ret = SignRestartAppFlag(uid);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write ret error.");
|
||||
return IPC_STUB_ERR;
|
||||
@ -1688,5 +1690,22 @@ int32_t AppMgrStub::HandleCheckIsKiaProcess(MessageParcel &data, MessageParcel &
|
||||
reply.WriteBool(isKia);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetAppIndexByPid(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "call");
|
||||
auto pid = data.ReadInt32();
|
||||
int32_t appIndex = -1;
|
||||
int32_t result = GetAppIndexByPid(pid, appIndex);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "fail to write GetAppIndexByPid result.");
|
||||
return IPC_STUB_ERR;
|
||||
}
|
||||
if (!reply.WriteInt32(appIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "fail to write appIndex.");
|
||||
return IPC_STUB_ERR;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "app_scheduler_proxy.h"
|
||||
|
||||
#include "app_exception_manager.h"
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "ipc_types.h"
|
||||
@ -192,7 +193,7 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
|
||||
return;
|
||||
}
|
||||
data.WriteParcelable(&info);
|
||||
|
||||
AbilityRuntime::FreezeUtil::LifecycleFlow flow = {token, AbilityRuntime::FreezeUtil::TimeoutState::LOAD};
|
||||
if (token) {
|
||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag and token");
|
||||
@ -207,6 +208,8 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
|
||||
|
||||
if (!data.WriteParcelable(want.get())) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "write want fail.");
|
||||
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
||||
"ERROR AppLifeCycleDeal::LaunchAbility; write want fail");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(abilityRecordId)) {
|
||||
@ -217,7 +220,7 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
|
||||
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_ABILITY_TRANSACTION), data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||
AppExceptionManager::GetInstance().LaunchAbilityFailed(token, std::string("SendRequest is failed") +
|
||||
AppExceptionManager::GetInstance().LaunchAbilityFailed(token, std::string("SendRequest failed") +
|
||||
std::to_string(ret));
|
||||
}
|
||||
}
|
||||
@ -257,7 +260,7 @@ void AppSchedulerProxy::ScheduleLaunchApplication(const AppLaunchData &launchDat
|
||||
|
||||
if (!data.WriteParcelable(&launchData)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteParcelable launchData failed");
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&config)) {
|
||||
|
@ -31,7 +31,7 @@ bool ProcessData::Marshalling(Parcel &parcel) const
|
||||
parcel.WriteInt32(static_cast<int32_t>(processType)) && parcel.WriteInt32(static_cast<int32_t>(extensionType))
|
||||
&& parcel.WriteInt32(renderUid) && parcel.WriteUint32(accessTokenId) &&
|
||||
parcel.WriteBool(isTestMode) && parcel.WriteInt32(exitReason) && parcel.WriteString16(Str8ToStr16(exitMsg)) &&
|
||||
parcel.WriteInt32(childUid));
|
||||
parcel.WriteInt32(childUid) && parcel.WriteBool(isPreload));
|
||||
}
|
||||
|
||||
bool ProcessData::ReadFromParcel(Parcel &parcel)
|
||||
@ -56,6 +56,7 @@ bool ProcessData::ReadFromParcel(Parcel &parcel)
|
||||
exitReason = parcel.ReadInt32();
|
||||
exitMsg = Str16ToStr8(parcel.ReadString16());
|
||||
childUid = parcel.ReadInt32();
|
||||
isPreload = parcel.ReadBool();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -345,6 +345,12 @@ bool AutoFillManager::IsPreviousRequestFinished(Ace::UIContent *uiContent)
|
||||
extensionCallback->GetInstanceId() == uiContent->GetInstanceId()) {
|
||||
return false;
|
||||
}
|
||||
if (extensionCallback->GetWindowType() == AutoFill::AutoFillWindowType::POPUP_WINDOW &&
|
||||
extensionCallback->GetInstanceId() == uiContent->GetInstanceId()) {
|
||||
TAG_LOGI(AAFwkTag::AUTOFILLMGR, "autofill popup window exist!");
|
||||
extensionCallback->CloseUIExtension();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ config("extension_manager_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_services_path}/abilitymgr/include/utils",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
@ -105,7 +105,6 @@ ohos_shared_library("runtime") {
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"ets_utils:console",
|
||||
"ets_utils:timer",
|
||||
"ets_utils:worker",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"hilog:libhilog",
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
static void SetAppLibPath(const AppLibPathMap& appLibPaths);
|
||||
static bool IsCJAbility(const std::string& info);
|
||||
static void SetSanitizerVersion(SanitizerKind kind);
|
||||
static void SetPackageName(std::string srcEntryName);
|
||||
~CJRuntime() override = default;
|
||||
|
||||
Language GetLanguage() const override
|
||||
@ -78,6 +79,7 @@ private:
|
||||
std::string bundleName_;
|
||||
uint32_t instanceId_ = 0;
|
||||
static AppLibPathVec appLibPaths_;
|
||||
static std::string packageName_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user