mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-27 01:10:52 +00:00
merge conflict
Signed-off-by: donglin <donglin9@huawei.com> Change-Id: I70e378105835b1f137f7ef7a37af81f5267905fd
This commit is contained in:
commit
40ec2b7c9e
@ -144,13 +144,6 @@ declare_args() {
|
||||
accessibility_enable = false
|
||||
}
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.bundlemanager_ecological_rule_manager)) {
|
||||
ecologic_rule_enabled = true
|
||||
} else {
|
||||
ecologic_rule_enabled = false
|
||||
}
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.hiviewdfx_hichecker)) {
|
||||
hichecker_enabled = true
|
||||
|
@ -29,6 +29,7 @@ group("napi_packages") {
|
||||
"${ability_runtime_napi_path}/action_extension_ability:actionextensionability_napi",
|
||||
"${ability_runtime_napi_path}/app/ability_delegator:abilitydelegatorregistry",
|
||||
"${ability_runtime_napi_path}/app/ability_delegator:abilitydelegatorregistry_napi",
|
||||
"${ability_runtime_napi_path}/app/ability_lifecycle_callback:abilitylifecyclecallback",
|
||||
"${ability_runtime_napi_path}/app/ability_stage:abilitystage",
|
||||
"${ability_runtime_napi_path}/app/ability_stage:abilitystage_napi",
|
||||
"${ability_runtime_napi_path}/app/ability_stage_context:abilitystagecontext_napi",
|
||||
|
@ -46,7 +46,7 @@ void JsAbilityAutoStartupCallBack::Register(napi_value value)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
std::lock_guard<std::mutex> lock(mutexlock);
|
||||
for (auto callback : callbacks_) {
|
||||
for (const auto &callback : callbacks_) {
|
||||
if (IsJsCallbackEquals(callback, value)) {
|
||||
HILOG_ERROR("The current callback already exists.");
|
||||
return;
|
||||
@ -128,7 +128,8 @@ void JsAbilityAutoStartupCallBack::JSCallFunctionWorker(const AutoStartupInfo &i
|
||||
}
|
||||
}
|
||||
|
||||
bool JsAbilityAutoStartupCallBack::IsJsCallbackEquals(std::shared_ptr<NativeReference> callback, napi_value value)
|
||||
bool JsAbilityAutoStartupCallBack::IsJsCallbackEquals(const std::shared_ptr<NativeReference> &callback,
|
||||
napi_value value)
|
||||
{
|
||||
if (callback == nullptr) {
|
||||
HILOG_ERROR("Invalid jsCallback.");
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
private:
|
||||
void JSCallFunction(const AutoStartupInfo &info, const std::string &methodName);
|
||||
void JSCallFunctionWorker(const AutoStartupInfo &info, const std::string &methodName);
|
||||
bool IsJsCallbackEquals(std::shared_ptr<NativeReference> callback, napi_value value);
|
||||
bool IsJsCallbackEquals(const std::shared_ptr<NativeReference> &callback, napi_value value);
|
||||
|
||||
napi_env env_;
|
||||
std::vector<std::shared_ptr<NativeReference>> callbacks_;
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
napi_value OnSetApplicationAutoStartup(napi_env env, NapiCallbackInfo &info);
|
||||
napi_value OnCancelApplicationAutoStartup(napi_env env, NapiCallbackInfo &info);
|
||||
napi_value OnQueryAllAutoStartupApplications(napi_env env, const NapiCallbackInfo &info);
|
||||
bool CheckCallerIsSystemApp();
|
||||
static bool CheckCallerIsSystemApp();
|
||||
|
||||
sptr<JsAbilityAutoStartupCallBack> jsAutoStartupCallback_;
|
||||
};
|
||||
|
50
frameworks/js/napi/app/ability_lifecycle_callback/BUILD.gn
Normal file
50
frameworks/js/napi/app/ability_lifecycle_callback/BUILD.gn
Normal file
@ -0,0 +1,50 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
es2abc_gen_abc("gen_ability_lifecycle_callback_abc") {
|
||||
src_js = rebase_path("ability_lifecycle_callback.js")
|
||||
dst_file = rebase_path(target_out_dir + "/ability_lifecycle_callback.abc")
|
||||
in_puts = [ "ability_lifecycle_callback.js" ]
|
||||
out_puts = [ target_out_dir + "/ability_lifecycle_callback.abc" ]
|
||||
extra_args = [ "--module" ]
|
||||
}
|
||||
|
||||
gen_js_obj("ability_lifecycle_callback_js") {
|
||||
input = "ability_lifecycle_callback.js"
|
||||
output = target_out_dir + "/ability_lifecycle_callback.o"
|
||||
}
|
||||
|
||||
gen_js_obj("ability_lifecycle_callback_abc") {
|
||||
input = get_label_info(":gen_ability_lifecycle_callback_abc",
|
||||
"target_out_dir") + "/ability_lifecycle_callback.abc"
|
||||
output = target_out_dir + "/ability_lifecycle_callback_abc.o"
|
||||
dep = ":gen_ability_lifecycle_callback_abc"
|
||||
}
|
||||
|
||||
ohos_shared_library("abilitylifecyclecallback") {
|
||||
sources = [ "ability_lifecycle_callback_module.cpp" ]
|
||||
|
||||
deps = [
|
||||
":ability_lifecycle_callback_abc",
|
||||
":ability_lifecycle_callback_js",
|
||||
]
|
||||
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
|
||||
relative_install_dir = "module/app/ability"
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class AbilityLifecycleCallback {
|
||||
constructor() {}
|
||||
|
||||
onAbilityCreate(ability) {
|
||||
console.log('onAbilityCreate');
|
||||
}
|
||||
|
||||
onWindowStageCreate(ability, windowStage) {
|
||||
console.log('onWindowStageCreate');
|
||||
}
|
||||
|
||||
onWindowStageActive(ability, windowStage) {
|
||||
console.log('onWindowStageActive');
|
||||
}
|
||||
|
||||
onWindowStageInactive(ability, windowStage) {
|
||||
console.log('onWindowStageInactive');
|
||||
}
|
||||
|
||||
onWindowStageDestroy(ability, windowStage) {
|
||||
console.log('onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onAbilityDestroy(ability) {
|
||||
console.log('onAbilityDestroy');
|
||||
}
|
||||
|
||||
onAbilityForeground(ability) {
|
||||
console.log('onAbilityForeground');
|
||||
}
|
||||
|
||||
onAbilityBackground(ability) {
|
||||
console.log('onAbilityBackground');
|
||||
}
|
||||
|
||||
onAbilityContinue(ability) {
|
||||
console.log('onAbilityContinue');
|
||||
}
|
||||
}
|
||||
|
||||
export default AbilityLifecycleCallback;
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "native_engine/native_engine.h"
|
||||
|
||||
extern const char _binary_ability_lifecycle_callback_js_start[];
|
||||
extern const char _binary_ability_lifecycle_callback_js_end[];
|
||||
extern const char _binary_ability_lifecycle_callback_abc_start[];
|
||||
extern const char _binary_ability_lifecycle_callback_abc_end[];
|
||||
|
||||
static napi_module _module = {
|
||||
.nm_version = 0,
|
||||
.nm_filename = "app/ability/libabilitylifecyclecallback.so/ability_lifecycle_callback.js",
|
||||
.nm_modname = "app.ability.AbilityLifecycleCallback",
|
||||
};
|
||||
extern "C" __attribute__((constructor))
|
||||
void NAPI_app_ability_AbilityLifecycleCallback_AutoRegister()
|
||||
{
|
||||
napi_module_register(&_module);
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
void NAPI_app_ability_AbilityLifecycleCallback_GetJSCode(const char **buf, int *bufLen)
|
||||
{
|
||||
if (buf != nullptr) {
|
||||
*buf = _binary_ability_lifecycle_callback_js_start;
|
||||
}
|
||||
|
||||
if (bufLen != nullptr) {
|
||||
*bufLen = _binary_ability_lifecycle_callback_js_end - _binary_ability_lifecycle_callback_js_start;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
void NAPI_app_ability_AbilityLifecycleCallback_GetABCCode(const char **buf, int *buflen)
|
||||
{
|
||||
if (buf != nullptr) {
|
||||
*buf = _binary_ability_lifecycle_callback_abc_start;
|
||||
}
|
||||
if (buflen != nullptr) {
|
||||
*buflen = _binary_ability_lifecycle_callback_abc_end - _binary_ability_lifecycle_callback_abc_start;
|
||||
}
|
||||
}
|
@ -28,8 +28,6 @@ JSAppStateObserver::~JSAppStateObserver() = default;
|
||||
|
||||
void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appStateData)
|
||||
{
|
||||
HILOG_DEBUG("onForegroundApplicationChanged bundleName:%{public}s, uid:%{public}d, state:%{public}d",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([jsObserver, appStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@ -44,12 +42,11 @@ void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appS
|
||||
std::unique_ptr<NapiAsyncTask::ExecuteCallback> execute = nullptr;
|
||||
NapiAsyncTask::Schedule("JSAppStateObserver::OnForegroundApplicationChanged",
|
||||
env_, std::make_unique<NapiAsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
HILOG_DEBUG("OnForegroundApplicationChanged end");
|
||||
}
|
||||
|
||||
void JSAppStateObserver::HandleOnForegroundApplicationChanged(const AppStateData &appStateData)
|
||||
{
|
||||
HILOG_DEBUG("HandleOnForegroundApplicationChanged bundleName:%{public}s, uid:%{public}d, state:%{public}d.",
|
||||
HILOG_INFO("HandleOnForegroundApplicationChanged bundleName:%{public}s, uid:%{public}d, state:%{public}d.",
|
||||
appStateData.bundleName.c_str(), appStateData.uid, appStateData.state);
|
||||
auto tmpMap = jsObserverObjectMap_;
|
||||
for (auto &item : tmpMap) {
|
||||
@ -61,7 +58,6 @@ void JSAppStateObserver::HandleOnForegroundApplicationChanged(const AppStateData
|
||||
|
||||
void JSAppStateObserver::OnAbilityStateChanged(const AbilityStateData &abilityStateData)
|
||||
{
|
||||
HILOG_INFO("OnAbilityStateChanged start");
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([jsObserver, abilityStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@ -91,7 +87,6 @@ void JSAppStateObserver::HandleOnAbilityStateChanged(const AbilityStateData &abi
|
||||
|
||||
void JSAppStateObserver::OnExtensionStateChanged(const AbilityStateData &abilityStateData)
|
||||
{
|
||||
HILOG_INFO("OnExtensionStateChanged start");
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([jsObserver, abilityStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@ -121,7 +116,6 @@ void JSAppStateObserver::HandleOnExtensionStateChanged(const AbilityStateData &a
|
||||
|
||||
void JSAppStateObserver::OnProcessCreated(const ProcessData &processData)
|
||||
{
|
||||
HILOG_INFO("OnProcessCreated start");
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([jsObserver, processData](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@ -151,7 +145,6 @@ void JSAppStateObserver::HandleOnProcessCreated(const ProcessData &processData)
|
||||
|
||||
void JSAppStateObserver::OnProcessStateChanged(const ProcessData &processData)
|
||||
{
|
||||
HILOG_INFO("OnProcessStateChanged start");
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([jsObserver, processData](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@ -181,7 +174,6 @@ void JSAppStateObserver::HandleOnProcessStateChanged(const ProcessData &processD
|
||||
|
||||
void JSAppStateObserver::OnProcessDied(const ProcessData &processData)
|
||||
{
|
||||
HILOG_INFO("OnProcessDied begin");
|
||||
wptr<JSAppStateObserver> jsObserver = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([jsObserver, processData](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
|
@ -391,24 +391,25 @@ private:
|
||||
napi_value OnOffForeground(napi_env env, size_t argc, napi_value *argv)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
if (observerForeground_ == nullptr || appManager_ == nullptr) {
|
||||
HILOG_ERROR("Observer or appManager nullptr.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc < ARGC_ONE) {
|
||||
HILOG_ERROR("Not enough params when off.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
HILOG_ERROR("Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (observerForeground_ == nullptr || appManager_ == nullptr) {
|
||||
HILOG_ERROR("Observer or appManager nullptr.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (argc == ARGC_ONE) {
|
||||
observerForeground_->RemoveAllJsObserverObjects();
|
||||
} else if (argc == ARGC_TWO) {
|
||||
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
HILOG_ERROR("Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
observerForeground_->RemoveJsObserverObject(argv[INDEX_ONE]);
|
||||
}
|
||||
if (observerForeground_->IsEmpty()) {
|
||||
|
@ -52,7 +52,6 @@ void JsSaveRequestCallback::OnSaveRequestFailed()
|
||||
void JsSaveRequestCallback::Register(napi_value value)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
std::lock_guard<std::mutex> lock(callbackMutex_);
|
||||
if (IsJsCallbackEquals(callback_, value)) {
|
||||
HILOG_ERROR("The current callback already exists.");
|
||||
return;
|
||||
@ -65,9 +64,13 @@ void JsSaveRequestCallback::Register(napi_value value)
|
||||
|
||||
void JsSaveRequestCallback::JSCallFunction(const std::string &methodName)
|
||||
{
|
||||
NapiAsyncTask::CompleteCallback complete = [this, methodName](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
JSCallFunctionWorker(methodName);
|
||||
};
|
||||
auto thisPtr = shared_from_this();
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[thisPtr, methodName](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (thisPtr) {
|
||||
thisPtr->JSCallFunctionWorker(methodName);
|
||||
}
|
||||
};
|
||||
|
||||
NapiAsyncTask::Schedule("JsSaveRequestCallback::JSCallFunction:" + methodName,
|
||||
env_,
|
||||
@ -76,7 +79,6 @@ void JsSaveRequestCallback::JSCallFunction(const std::string &methodName)
|
||||
|
||||
void JsSaveRequestCallback::JSCallFunctionWorker(const std::string &methodName)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(callbackMutex_);
|
||||
if (callback_ == nullptr) {
|
||||
HILOG_ERROR("callback is nullptr.");
|
||||
return;
|
||||
|
@ -23,7 +23,8 @@ class NativeReference;
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
using AutoFillManagerFunc = std::function<void(int32_t)>;
|
||||
class JsSaveRequestCallback : public ISaveRequestCallback {
|
||||
class JsSaveRequestCallback : public ISaveRequestCallback,
|
||||
public std::enable_shared_from_this<JsSaveRequestCallback> {
|
||||
public:
|
||||
JsSaveRequestCallback(napi_env env, int32_t instanceId, AutoFillManagerFunc autoFillManagerFunc);
|
||||
virtual ~JsSaveRequestCallback();
|
||||
@ -37,10 +38,9 @@ private:
|
||||
void JSCallFunctionWorker(const std::string &methodName);
|
||||
bool IsJsCallbackEquals(std::shared_ptr<NativeReference> callback, napi_value value);
|
||||
|
||||
napi_env env_;
|
||||
napi_env env_ = nullptr;
|
||||
std::shared_ptr<NativeReference> callback_;
|
||||
std::mutex callbackMutex_;
|
||||
int32_t instanceId_;
|
||||
int32_t instanceId_ = -1;
|
||||
AutoFillManagerFunc autoFillManagerFunc_ = nullptr;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -46,6 +46,18 @@ static napi_value InitColorModeObject(napi_env env)
|
||||
return object;
|
||||
}
|
||||
|
||||
static napi_value InitTimeFormatObject(napi_env env)
|
||||
{
|
||||
napi_value object;
|
||||
NAPI_CALL(env, napi_create_object(env, &object));
|
||||
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "HOUR_NOT_SET", Global::Resource::HOUR_NOT_SET));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "HOUR_12", Global::Resource::HOUR_12));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "HOUR_24", Global::Resource::HOUR_24));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static napi_value InitDirectionObject(napi_env env)
|
||||
{
|
||||
napi_value object;
|
||||
@ -82,6 +94,9 @@ static napi_value ConfigurationConstantInit(napi_env env, napi_value exports)
|
||||
napi_value colorMode = InitColorModeObject(env);
|
||||
NAPI_ASSERT(env, colorMode != nullptr, "failed to create color mode object");
|
||||
|
||||
napi_value time24 = InitTimeFormatObject(env);
|
||||
NAPI_ASSERT(env, time24 != nullptr, "failed to create time format object");
|
||||
|
||||
napi_value direction = InitDirectionObject(env);
|
||||
NAPI_ASSERT(env, direction != nullptr, "failed to create direction object");
|
||||
|
||||
@ -90,6 +105,7 @@ static napi_value ConfigurationConstantInit(napi_env env, napi_value exports)
|
||||
|
||||
napi_property_descriptor exportObjs[] = {
|
||||
DECLARE_NAPI_PROPERTY("ColorMode", colorMode),
|
||||
DECLARE_NAPI_PROPERTY("Time24", time24),
|
||||
DECLARE_NAPI_PROPERTY("Direction", direction),
|
||||
DECLARE_NAPI_PROPERTY("ScreenDensity", screenDensity),
|
||||
};
|
||||
|
@ -1314,8 +1314,6 @@ napi_value JsWantAgentInit(napi_env env, napi_value exportObj)
|
||||
|
||||
napi_set_named_property(env, exportObj, "WantAgentFlags", WantAgentFlagsInit(env));
|
||||
napi_set_named_property(env, exportObj, "OperationType", WantAgentOperationTypeInit(env));
|
||||
napi_set_named_property(env, exportObj, "actionFlags", WantAgentFlagsInit(env));
|
||||
napi_set_named_property(env, exportObj, "actionType", WantAgentOperationTypeInit(env));
|
||||
|
||||
HILOG_DEBUG("JsWantAgentInit BindNativeFunction called");
|
||||
const char* moduleName = "JsWantAgent";
|
||||
|
@ -929,6 +929,8 @@ config("ui_extension_public_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ability_runtime",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/insight_intent_executor",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ui_extension_ability",
|
||||
"${windowmanager_path}/interfaces/kits/napi/extension_window",
|
||||
"${windowmanager_path}/wm/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -969,6 +971,7 @@ ohos_shared_library("ui_extension") {
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"window_manager:extensionwindow_napi",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -175,57 +175,13 @@ void Ability::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
HILOG_INFO("AbilityName is %{public}s.", abilityInfo_->name.c_str());
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (abilityInfo_->type == AppExecFwk::AbilityType::PAGE) {
|
||||
int32_t defualtDisplayId = static_cast<int32_t>(Rosen::DisplayManager::GetInstance().GetDefaultDisplayId());
|
||||
int32_t displayId = want.GetIntParam(Want::PARAM_RESV_DISPLAY_ID, defualtDisplayId);
|
||||
int32_t defualtDisplayId = static_cast<int32_t>(Rosen::DisplayManager::GetInstance().GetDefaultDisplayId());
|
||||
int32_t displayId = want.GetIntParam(Want::PARAM_RESV_DISPLAY_ID, defualtDisplayId);
|
||||
HILOG_DEBUG("abilityName:%{public}s, displayId:%{public}d", abilityInfo_->name.c_str(), displayId);
|
||||
if (!abilityInfo_->isStageBasedModel) {
|
||||
auto option = GetWindowOption(want);
|
||||
InitWindow(displayId, option);
|
||||
}
|
||||
InitFAWindow(want, displayId);
|
||||
|
||||
if (abilityWindow_ != nullptr) {
|
||||
HILOG_DEBUG("Get window from abilityWindow.");
|
||||
auto window = abilityWindow_->GetWindow();
|
||||
if (window) {
|
||||
HILOG_DEBUG("Call RegisterDisplayMoveListener, windowId: %{public}d", window->GetWindowId());
|
||||
abilityDisplayMoveListener_ = new AbilityDisplayMoveListener(weak_from_this());
|
||||
window->RegisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
}
|
||||
|
||||
// Update resMgr, Configuration
|
||||
HILOG_DEBUG("Get display by displayId %{public}d.", displayId);
|
||||
auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId);
|
||||
if (display) {
|
||||
float density = display->GetVirtualPixelRatio();
|
||||
int32_t width = display->GetWidth();
|
||||
int32_t height = display->GetHeight();
|
||||
std::shared_ptr<Configuration> configuration = nullptr;
|
||||
if (application_) {
|
||||
configuration = application_->GetConfiguration();
|
||||
}
|
||||
if (configuration) {
|
||||
std::string direction = GetDirectionStr(height, width);
|
||||
configuration->AddItem(displayId, ConfigurationInner::APPLICATION_DIRECTION, direction);
|
||||
configuration->AddItem(displayId, ConfigurationInner::APPLICATION_DENSITYDPI, GetDensityStr(density));
|
||||
configuration->AddItem(ConfigurationInner::APPLICATION_DISPLAYID, std::to_string(displayId));
|
||||
UpdateContextConfiguration();
|
||||
}
|
||||
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
HILOG_ERROR("Create resource config failed.");
|
||||
return;
|
||||
}
|
||||
auto resourceManager = GetResourceManager();
|
||||
if (resourceManager != nullptr) {
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
resConfig->SetScreenDensity(density);
|
||||
resConfig->SetDirection(ConvertDirection(height, width));
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
HILOG_DEBUG("Notify ResourceManager, Density: %{public}f, Direction: %{public}d.",
|
||||
resConfig->GetScreenDensity(), resConfig->GetDirection());
|
||||
}
|
||||
if (!UpdateResMgrAndConfiguration(displayId)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1123,8 +1079,7 @@ void Ability::ExecuteOperation(std::shared_ptr<DataAbilityOperation> &operation,
|
||||
return;
|
||||
}
|
||||
if (index < 0) {
|
||||
HILOG_ERROR(
|
||||
"exec operation result index should not below zero, current index: %{public}d", index);
|
||||
HILOG_ERROR("exec operation result index should not below zero, current index: %{public}d", index);
|
||||
return;
|
||||
}
|
||||
if (operation == nullptr) {
|
||||
@ -1135,8 +1090,7 @@ void Ability::ExecuteOperation(std::shared_ptr<DataAbilityOperation> &operation,
|
||||
|
||||
int numRows = 0;
|
||||
std::shared_ptr<NativeRdb::ValuesBucket> valuesBucket = ParseValuesBucketReference(results, operation, index);
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates =
|
||||
ParsePredictionArgsReference(results, operation, index);
|
||||
auto predicates = ParsePredictionArgsReference(results, operation, index);
|
||||
if (operation->IsInsertOperation()) {
|
||||
HILOG_DEBUG("exec IsInsertOperation");
|
||||
numRows = Insert(*(operation->GetUri().get()), *valuesBucket);
|
||||
@ -1149,34 +1103,18 @@ void Ability::ExecuteOperation(std::shared_ptr<DataAbilityOperation> &operation,
|
||||
} else if (operation->IsAssertOperation() && predicates) {
|
||||
HILOG_DEBUG("exec IsAssertOperation");
|
||||
std::vector<std::string> columns;
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> queryResult =
|
||||
Query(*(operation->GetUri().get()), columns, *predicates);
|
||||
auto queryResult = Query(*(operation->GetUri().get()), columns, *predicates);
|
||||
if (queryResult == nullptr) {
|
||||
HILOG_ERROR("exec Query retval is nullptr");
|
||||
results.push_back(std::make_shared<DataAbilityResult>(0));
|
||||
return;
|
||||
}
|
||||
if (queryResult->GetRowCount(numRows) != 0) {
|
||||
HILOG_ERROR("exec queryResult->GetRowCount(numRows) != E_OK");
|
||||
}
|
||||
if (!CheckAssertQueryResult(queryResult, operation->GetValuesBucket())) {
|
||||
if (queryResult != nullptr) {
|
||||
queryResult->Close();
|
||||
}
|
||||
HILOG_ERROR("Query Result is not equal to expected value.");
|
||||
}
|
||||
|
||||
if (queryResult != nullptr) {
|
||||
queryResult->Close();
|
||||
}
|
||||
(void)CheckAssertQueryResult(queryResult, operation->GetValuesBucket());
|
||||
queryResult->Close();
|
||||
} else {
|
||||
HILOG_ERROR("exec Expected bad type %{public}d", operation->GetType());
|
||||
}
|
||||
if (operation->GetExpectedCount() != numRows) {
|
||||
HILOG_ERROR("exec Expected %{public}d rows but actual %{public}d",
|
||||
operation->GetExpectedCount(),
|
||||
numRows);
|
||||
} else {
|
||||
if (operation->GetExpectedCount() == numRows) {
|
||||
if (operation->GetUri() != nullptr) {
|
||||
results.push_back(std::make_shared<DataAbilityResult>(*operation->GetUri(), numRows));
|
||||
} else {
|
||||
@ -1238,21 +1176,17 @@ std::shared_ptr<NativeRdb::ValuesBucket> Ability::ParseValuesBucketReference(
|
||||
std::vector<std::shared_ptr<DataAbilityResult>> &results, std::shared_ptr<DataAbilityOperation> &operation,
|
||||
int numRefs)
|
||||
{
|
||||
NativeRdb::ValuesBucket retValueBucket;
|
||||
if (operation == nullptr) {
|
||||
HILOG_ERROR("intput is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (operation->GetValuesBucketReferences() == nullptr) {
|
||||
return operation->GetValuesBucket();
|
||||
}
|
||||
|
||||
NativeRdb::ValuesBucket retValueBucket;
|
||||
retValueBucket.Clear();
|
||||
if (operation->GetValuesBucket() == nullptr) {
|
||||
HILOG_DEBUG("operation->GetValuesBucket is nullptr");
|
||||
} else {
|
||||
HILOG_DEBUG("operation->GetValuesBucket is nullptr");
|
||||
if (operation->GetValuesBucket() != nullptr) {
|
||||
retValueBucket = *operation->GetValuesBucket();
|
||||
}
|
||||
|
||||
@ -1261,80 +1195,99 @@ std::shared_ptr<NativeRdb::ValuesBucket> Ability::ParseValuesBucketReference(
|
||||
|
||||
for (auto itermap : valuesMapReferences) {
|
||||
std::string key = itermap.first;
|
||||
HILOG_DEBUG("key is %{public}s", key.c_str());
|
||||
NativeRdb::ValueObject obj;
|
||||
if (!operation->GetValuesBucketReferences()->GetObject(key, obj)) {
|
||||
HILOG_ERROR("operation->GetValuesBucketReferences()->GetObject error");
|
||||
continue;
|
||||
}
|
||||
switch (obj.GetType()) {
|
||||
case NativeRdb::ValueObjectType::TYPE_INT: {
|
||||
int val = 0;
|
||||
if (obj.GetInt(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetInt() error");
|
||||
break;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutInt(%{public}s, %{public}d)",
|
||||
key.c_str(),
|
||||
val);
|
||||
retValueBucket.PutInt(key, val);
|
||||
} break;
|
||||
case NativeRdb::ValueObjectType::TYPE_DOUBLE: {
|
||||
double val = 0.0;
|
||||
if (obj.GetDouble(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetDouble() error");
|
||||
break;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutDouble(%{public}s, %{public}f)",
|
||||
key.c_str(),
|
||||
val);
|
||||
retValueBucket.PutDouble(key, val);
|
||||
} break;
|
||||
case NativeRdb::ValueObjectType::TYPE_STRING: {
|
||||
std::string val = "";
|
||||
if (obj.GetString(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetString() error");
|
||||
break;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutString(%{public}s, %{public}s)",
|
||||
key.c_str(),
|
||||
val.c_str());
|
||||
retValueBucket.PutString(key, val);
|
||||
} break;
|
||||
case NativeRdb::ValueObjectType::TYPE_BLOB: {
|
||||
std::vector<uint8_t> val;
|
||||
if (obj.GetBlob(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetBlob() error");
|
||||
break;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutBlob(%{public}s, %{public}zu)",
|
||||
key.c_str(),
|
||||
val.size());
|
||||
retValueBucket.PutBlob(key, val);
|
||||
} break;
|
||||
case NativeRdb::ValueObjectType::TYPE_BOOL: {
|
||||
bool val = false;
|
||||
if (obj.GetBool(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetBool() error");
|
||||
break;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutBool(%{public}s, %{public}s)",
|
||||
key.c_str(),
|
||||
val ? "true" : "false");
|
||||
retValueBucket.PutBool(key, val);
|
||||
} break;
|
||||
default: {
|
||||
HILOG_DEBUG("retValueBucket->PutNull(%{public}s)", key.c_str());
|
||||
case NativeRdb::ValueObjectType::TYPE_INT:
|
||||
ParseIntValue(obj, key, retValueBucket);
|
||||
break;
|
||||
case NativeRdb::ValueObjectType::TYPE_DOUBLE:
|
||||
ParseDoubleValue(obj, key, retValueBucket);
|
||||
break;
|
||||
case NativeRdb::ValueObjectType::TYPE_STRING:
|
||||
ParseStringValue(obj, key, retValueBucket);
|
||||
break;
|
||||
case NativeRdb::ValueObjectType::TYPE_BLOB:
|
||||
ParseBlobValue(obj, key, retValueBucket);
|
||||
break;
|
||||
case NativeRdb::ValueObjectType::TYPE_BOOL:
|
||||
ParseBoolValue(obj, key, retValueBucket);
|
||||
break;
|
||||
default:
|
||||
retValueBucket.PutNull(key);
|
||||
} break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, NativeRdb::ValueObject> valuesMap;
|
||||
retValueBucket.GetAll(valuesMap);
|
||||
|
||||
return std::make_shared<NativeRdb::ValuesBucket>(valuesMap);
|
||||
}
|
||||
|
||||
void Ability::ParseIntValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const
|
||||
{
|
||||
int val = 0;
|
||||
if (obj.GetInt(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetInt() error");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutInt(%{public}s, %{public}d)", key.c_str(), val);
|
||||
retValueBucket.PutInt(key, val);
|
||||
}
|
||||
|
||||
void Ability::ParseDoubleValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const
|
||||
{
|
||||
double val = 0.0;
|
||||
if (obj.GetDouble(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetDouble() error");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutDouble(%{public}s, %{public}f)", key.c_str(), val);
|
||||
retValueBucket.PutDouble(key, val);
|
||||
}
|
||||
|
||||
void Ability::ParseStringValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const
|
||||
{
|
||||
std::string val = "";
|
||||
if (obj.GetString(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetString() error");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutString(%{public}s, %{public}s)", key.c_str(), val.c_str());
|
||||
retValueBucket.PutString(key, val);
|
||||
}
|
||||
|
||||
void Ability::ParseBlobValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const
|
||||
{
|
||||
std::vector<uint8_t> val;
|
||||
if (obj.GetBlob(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetBlob() error");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutBlob(%{public}s, %{public}zu)", key.c_str(), val.size());
|
||||
retValueBucket.PutBlob(key, val);
|
||||
}
|
||||
|
||||
void Ability::ParseBoolValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const
|
||||
{
|
||||
bool val = false;
|
||||
if (obj.GetBool(val) != 0) {
|
||||
HILOG_ERROR("ValueObject->GetBool() error");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("retValueBucket->PutBool(%{public}s, %{public}s)", key.c_str(), val ? "true" : "false");
|
||||
retValueBucket.PutBool(key, val);
|
||||
}
|
||||
|
||||
int Ability::ChangeRef2Value(std::vector<std::shared_ptr<DataAbilityResult>> &results, int numRefs, int index)
|
||||
{
|
||||
int retval = -1;
|
||||
@ -2132,7 +2085,64 @@ void Ability::UpdateSessionToken(sptr<IRemoteObject> sessionToken)
|
||||
HILOG_ERROR("Ability window is nullptr.");
|
||||
return;
|
||||
}
|
||||
abilityWindow_->SetSessionToken(sessionToken_);
|
||||
abilityWindow_->SetSessionToken(sessionToken);
|
||||
}
|
||||
|
||||
void Ability::InitFAWindow(const Want &want, int32_t displayId)
|
||||
{
|
||||
if (!abilityInfo_->isStageBasedModel) {
|
||||
auto option = GetWindowOption(want);
|
||||
InitWindow(displayId, option);
|
||||
}
|
||||
|
||||
if (abilityWindow_ != nullptr) {
|
||||
HILOG_DEBUG("Get window from abilityWindow.");
|
||||
auto window = abilityWindow_->GetWindow();
|
||||
if (window) {
|
||||
HILOG_DEBUG("Call RegisterDisplayMoveListener, windowId: %{public}d", window->GetWindowId());
|
||||
abilityDisplayMoveListener_ = new AbilityDisplayMoveListener(weak_from_this());
|
||||
window->RegisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Ability::UpdateResMgrAndConfiguration(int32_t displayId)
|
||||
{
|
||||
auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId);
|
||||
if (!display) {
|
||||
HILOG_INFO("The display is invliad.");
|
||||
return true;
|
||||
}
|
||||
float density = display->GetVirtualPixelRatio();
|
||||
int32_t width = display->GetWidth();
|
||||
int32_t height = display->GetHeight();
|
||||
std::shared_ptr<Configuration> configuration = nullptr;
|
||||
if (application_) {
|
||||
configuration = application_->GetConfiguration();
|
||||
}
|
||||
if (configuration) {
|
||||
std::string direction = GetDirectionStr(height, width);
|
||||
configuration->AddItem(displayId, ConfigurationInner::APPLICATION_DIRECTION, direction);
|
||||
configuration->AddItem(displayId, ConfigurationInner::APPLICATION_DENSITYDPI, GetDensityStr(density));
|
||||
configuration->AddItem(ConfigurationInner::APPLICATION_DISPLAYID, std::to_string(displayId));
|
||||
UpdateContextConfiguration();
|
||||
}
|
||||
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
HILOG_ERROR("Create resource config failed.");
|
||||
return false;
|
||||
}
|
||||
auto resourceManager = GetResourceManager();
|
||||
if (resourceManager != nullptr) {
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
resConfig->SetScreenDensity(density);
|
||||
resConfig->SetDirection(ConvertDirection(height, width));
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
HILOG_DEBUG("Notify ResourceManager, Density: %{public}f, Direction: %{public}d.",
|
||||
resConfig->GetScreenDensity(), resConfig->GetDirection());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
} // namespace AppExecFwk
|
||||
|
@ -122,6 +122,33 @@ void JsAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
HILOG_ERROR("abilityInfo is nullptr");
|
||||
return;
|
||||
}
|
||||
auto srcPath = GenerateSrcPath(abilityInfo);
|
||||
if (srcPath.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string moduleName(abilityInfo->moduleName);
|
||||
moduleName.append("::").append(abilityInfo->name);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
|
||||
jsAbilityObj_ = jsRuntime_.LoadModule(
|
||||
moduleName, srcPath, abilityInfo->hapPath, abilityInfo->compileMode == AppExecFwk::CompileMode::ES_MODULE);
|
||||
if (jsAbilityObj_ == nullptr) {
|
||||
HILOG_ERROR("Failed to get AbilityStage object");
|
||||
return;
|
||||
}
|
||||
|
||||
BindContext();
|
||||
}
|
||||
|
||||
std::string JsAbility::GenerateSrcPath(std::shared_ptr<AbilityInfo> abilityInfo) const
|
||||
{
|
||||
if (abilityInfo == nullptr) {
|
||||
HILOG_ERROR("abilityInfo is nullptr");
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string srcPath(abilityInfo->package);
|
||||
if (!abilityInfo->isModuleJson) {
|
||||
/* temporary compatibility api8 + config.json */
|
||||
@ -133,7 +160,7 @@ void JsAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
} else {
|
||||
if (abilityInfo->srcEntrance.empty()) {
|
||||
HILOG_ERROR("abilityInfo srcEntrance is empty");
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
srcPath.append("/");
|
||||
srcPath.append(abilityInfo->srcEntrance);
|
||||
@ -141,20 +168,12 @@ void JsAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
srcPath.append(".abc");
|
||||
HILOG_INFO("JsAbility srcPath is %{public}s", srcPath.c_str());
|
||||
}
|
||||
return srcPath;
|
||||
}
|
||||
|
||||
std::string moduleName(abilityInfo->moduleName);
|
||||
moduleName.append("::").append(abilityInfo->name);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
void JsAbility::BindContext()
|
||||
{
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
jsAbilityObj_ = jsRuntime_.LoadModule(
|
||||
moduleName, srcPath, abilityInfo->hapPath, abilityInfo->compileMode == AppExecFwk::CompileMode::ES_MODULE);
|
||||
if (jsAbilityObj_ == nullptr) {
|
||||
HILOG_ERROR("Failed to get AbilityStage object");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value obj = jsAbilityObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
HILOG_ERROR("Failed to check type");
|
||||
@ -165,6 +184,10 @@ void JsAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
napi_value contextObj = CreateJsAbilityContext(env, context);
|
||||
shellContextRef_ = std::shared_ptr<NativeReference>(JsRuntime::LoadSystemModuleByEngine(
|
||||
env, "application.AbilityContext", &contextObj, 1).release());
|
||||
if (shellContextRef_ == nullptr) {
|
||||
HILOG_ERROR("Failed to load module");
|
||||
return;
|
||||
}
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
HILOG_ERROR("Failed to get ability native object");
|
||||
@ -195,10 +218,6 @@ void JsAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
HILOG_WARN("Not found Ability.js");
|
||||
return;
|
||||
}
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
if (applicationContext != nullptr) {
|
||||
applicationContext->DispatchOnAbilityCreate(jsAbilityObj_);
|
||||
}
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
@ -232,6 +251,10 @@ void JsAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
HILOG_DEBUG("Call AbilityDelegator::PostPerformStart");
|
||||
delegator->PostPerformStart(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
if (applicationContext != nullptr) {
|
||||
applicationContext->DispatchOnAbilityCreate(jsAbilityObj_);
|
||||
}
|
||||
HILOG_DEBUG("OnStart end, ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
@ -612,40 +635,9 @@ void JsAbility::DoOnForeground(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (scene_ == nullptr) {
|
||||
if ((abilityContext_ == nullptr) || (sceneListener_ == nullptr)) {
|
||||
HILOG_ERROR("Ability::OnForeground error. abilityContext_ or sceneListener_ is nullptr!");
|
||||
if (!InitWindowScene(want)) {
|
||||
return;
|
||||
}
|
||||
scene_ = std::make_shared<Rosen::WindowScene>();
|
||||
int32_t displayId = static_cast<int32_t>(Rosen::DisplayManager::GetInstance().GetDefaultDisplayId());
|
||||
if (setting_ != nullptr) {
|
||||
std::string strDisplayId =
|
||||
setting_->GetProperty(OHOS::AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY);
|
||||
std::regex formatRegex("[0-9]{0,9}$");
|
||||
std::smatch sm;
|
||||
bool flag = std::regex_match(strDisplayId, sm, formatRegex);
|
||||
if (flag && !strDisplayId.empty()) {
|
||||
int base = 10; // Numerical base (radix) that determines the valid characters and their interpretation.
|
||||
displayId = strtol(strDisplayId.c_str(), nullptr, base);
|
||||
HILOG_DEBUG("%{public}s success. displayId is %{public}d", __func__, displayId);
|
||||
} else {
|
||||
HILOG_WARN("%{public}s failed to formatRegex:[%{public}s]", __func__, strDisplayId.c_str());
|
||||
}
|
||||
}
|
||||
auto option = GetWindowOption(want);
|
||||
Rosen::WMError ret = Rosen::WMError::WM_OK;
|
||||
auto sessionToken = GetSessionToken();
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() && sessionToken != nullptr) {
|
||||
abilityContext_->SetWeakSessionToken(sessionToken);
|
||||
ret = scene_->Init(displayId, abilityContext_, sceneListener_, option, sessionToken);
|
||||
} else {
|
||||
ret = scene_->Init(displayId, abilityContext_, sceneListener_, option);
|
||||
}
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
HILOG_ERROR("%{public}s error. failed to init window scene!", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
AbilityContinuationOrRecover(want);
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window) {
|
||||
@ -674,6 +666,48 @@ void JsAbility::DoOnForeground(const Want &want)
|
||||
HILOG_DEBUG("%{public}s end scene_->GoForeground.", __func__);
|
||||
}
|
||||
|
||||
bool JsAbility::InitWindowScene(const Want &want)
|
||||
{
|
||||
if ((abilityContext_ == nullptr) || (sceneListener_ == nullptr)) {
|
||||
HILOG_ERROR("abilityContext_ or sceneListener_ is nullptr!");
|
||||
return false;
|
||||
}
|
||||
scene_ = std::make_shared<Rosen::WindowScene>();
|
||||
int32_t displayId = static_cast<int32_t>(Rosen::DisplayManager::GetInstance().GetDefaultDisplayId());
|
||||
if (setting_ != nullptr) {
|
||||
std::string strDisplayId =
|
||||
setting_->GetProperty(OHOS::AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY);
|
||||
std::regex formatRegex("[0-9]{0,9}$");
|
||||
std::smatch sm;
|
||||
bool flag = std::regex_match(strDisplayId, sm, formatRegex);
|
||||
if (flag && !strDisplayId.empty()) {
|
||||
int base = 10; // Numerical base (radix) that determines the valid characters and their interpretation.
|
||||
displayId = strtol(strDisplayId.c_str(), nullptr, base);
|
||||
HILOG_DEBUG("The displayId is %{public}d", displayId);
|
||||
} else {
|
||||
HILOG_WARN("Failed to formatRegex:[%{public}s]", strDisplayId.c_str());
|
||||
}
|
||||
}
|
||||
auto option = GetWindowOption(want);
|
||||
Rosen::WMError ret = Rosen::WMError::WM_OK;
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
auto sessionToken = GetSessionToken();
|
||||
if (sessionToken == nullptr) {
|
||||
HILOG_ERROR("The sessionToken is nullptr!");
|
||||
return false;
|
||||
}
|
||||
abilityContext_->SetWeakSessionToken(sessionToken);
|
||||
ret = scene_->Init(displayId, abilityContext_, sceneListener_, option, sessionToken);
|
||||
} else {
|
||||
ret = scene_->Init(displayId, abilityContext_, sceneListener_, option);
|
||||
}
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
HILOG_ERROR("Failed to init window scene!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void JsAbility::RequestFocus(const Want &want)
|
||||
{
|
||||
HILOG_INFO("Lifecycle: begin.");
|
||||
@ -1054,37 +1088,44 @@ void JsAbility::Dump(const std::vector<std::string> ¶ms, std::vector<std::st
|
||||
Ability::Dump(params, info);
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
// create js array object of params
|
||||
napi_value argv[] = { CreateNativeArray(env, params) };
|
||||
|
||||
if (!jsAbilityObj_) {
|
||||
HILOG_WARN("Not found .js");
|
||||
return;
|
||||
}
|
||||
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
napi_value obj = jsAbilityObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
HILOG_ERROR("Failed to get object");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AddDumpInfo(env, obj, params, info, "dump")) {
|
||||
return;
|
||||
}
|
||||
if (!AddDumpInfo(env, obj, params, info, "onDump")) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Dump info size: %{public}zu", info.size());
|
||||
}
|
||||
|
||||
bool JsAbility::AddDumpInfo(napi_env env, napi_value obj, const std::vector<std::string> ¶ms,
|
||||
std::vector<std::string> &info, const std::string &methodName) const
|
||||
{
|
||||
// create js array object of params
|
||||
napi_value argv[] = { CreateNativeArray(env, params) };
|
||||
|
||||
napi_value method = nullptr;
|
||||
napi_get_named_property(env, obj, "dump", &method);
|
||||
napi_value onDumpMethod = nullptr;
|
||||
napi_get_named_property(env, obj, "onDump", &onDumpMethod);
|
||||
napi_get_named_property(env, obj, methodName.c_str(), &method);
|
||||
|
||||
napi_value dumpInfo = nullptr;
|
||||
if (method != nullptr) {
|
||||
napi_call_function(env, obj, method, 1, argv, &dumpInfo);
|
||||
}
|
||||
|
||||
napi_value onDumpInfo = nullptr;
|
||||
if (onDumpMethod != nullptr) {
|
||||
napi_call_function(env, obj, onDumpMethod, 1, argv, &onDumpInfo);
|
||||
}
|
||||
|
||||
if (dumpInfo != nullptr) {
|
||||
if (dumpInfo == nullptr) {
|
||||
uint32_t len = 0;
|
||||
napi_get_array_length(env, dumpInfo, &len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
@ -1093,28 +1134,12 @@ void JsAbility::Dump(const std::vector<std::string> ¶ms, std::vector<std::st
|
||||
napi_get_element(env, dumpInfo, i, &element);
|
||||
if (!ConvertFromJsValue(env, element, dumpInfoStr)) {
|
||||
HILOG_ERROR("Parse dumpInfoStr failed");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
info.push_back(dumpInfoStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (onDumpInfo != nullptr) {
|
||||
uint32_t len = 0;
|
||||
napi_get_array_length(env, onDumpInfo, &len);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
std::string dumpInfoStr;
|
||||
napi_value element = nullptr;
|
||||
napi_get_element(env, onDumpInfo, i, &element);
|
||||
if (!ConvertFromJsValue(env, element, dumpInfoStr)) {
|
||||
HILOG_ERROR("Parse dumpInfoStr from onDumpInfoNative failed");
|
||||
return;
|
||||
}
|
||||
info.push_back(dumpInfoStr);
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Dump info size: %{public}zu", info.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> JsAbility::GetJsAbility()
|
||||
|
@ -54,7 +54,7 @@ constexpr size_t ARGC_TWO = 2;
|
||||
constexpr size_t ARGC_THREE = 3;
|
||||
constexpr int32_t TRACE_ATOMIC_SERVICE_ID = 201;
|
||||
const std::string TRACE_ATOMIC_SERVICE = "StartAtomicService";
|
||||
|
||||
constexpr int32_t CALLER_TIME_OUT = 10; // 10s
|
||||
namespace {
|
||||
static std::map<ConnectionKey, sptr<JSAbilityConnection>, KeyCompare> g_connects;
|
||||
int64_t g_serialNumber = 0;
|
||||
@ -76,7 +76,7 @@ void RemoveConnection(int64_t connectId)
|
||||
HILOG_DEBUG("remove connection ability not exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StartAbilityByCallParameters {
|
||||
public:
|
||||
int err = 0;
|
||||
@ -86,6 +86,93 @@ public:
|
||||
std::condition_variable condition;
|
||||
};
|
||||
|
||||
void GenerateCallerCallBack(std::shared_ptr<StartAbilityByCallParameters> calls,
|
||||
std::shared_ptr<CallerCallBack> callerCallBack)
|
||||
{
|
||||
if (calls == nullptr) {
|
||||
HILOG_ERROR("calls is nullptr");
|
||||
return;
|
||||
}
|
||||
if (callerCallBack == nullptr) {
|
||||
HILOG_ERROR("callerCallBack is nullptr");
|
||||
return;
|
||||
}
|
||||
auto callBackDone = [calldata = calls] (const sptr<IRemoteObject> &obj) {
|
||||
HILOG_DEBUG("OnStartAbilityByCall callBackDone mutexlock");
|
||||
std::unique_lock<std::mutex> lock(calldata->mutexlock);
|
||||
HILOG_DEBUG("OnStartAbilityByCall callBackDone remoteCallee assignment");
|
||||
calldata->remoteCallee = obj;
|
||||
calldata->condition.notify_all();
|
||||
HILOG_DEBUG("OnStartAbilityByCall callBackDone is called end");
|
||||
};
|
||||
|
||||
auto releaseListen = [](const std::string &str) {
|
||||
HILOG_INFO("OnStartAbilityByCall releaseListen is called %{public}s", str.c_str());
|
||||
};
|
||||
|
||||
callerCallBack->SetCallBack(callBackDone);
|
||||
callerCallBack->SetOnRelease(releaseListen);
|
||||
}
|
||||
|
||||
void StartAbilityByCallExecuteDone(std::shared_ptr<StartAbilityByCallParameters> calldata)
|
||||
{
|
||||
if (calldata == nullptr) {
|
||||
HILOG_ERROR("calldata is nullptr.");
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(calldata->mutexlock);
|
||||
if (calldata->remoteCallee != nullptr) {
|
||||
HILOG_INFO("OnStartAbilityByCall callExecute callee isn`t nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (calldata->condition.wait_for(lock, std::chrono::seconds(CALLER_TIME_OUT)) == std::cv_status::timeout) {
|
||||
HILOG_ERROR("OnStartAbilityByCall callExecute waiting callee timeout");
|
||||
calldata->err = -1;
|
||||
}
|
||||
HILOG_DEBUG("OnStartAbilityByCall callExecute end");
|
||||
}
|
||||
|
||||
void StartAbilityByCallComplete(napi_env env, NapiAsyncTask& task, std::weak_ptr<AbilityContext> abilityContext,
|
||||
std::shared_ptr<StartAbilityByCallParameters> calldata, std::shared_ptr<CallerCallBack> callerCallBack)
|
||||
{
|
||||
if (calldata == nullptr) {
|
||||
HILOG_ERROR("calldata is nullptr.");
|
||||
return;
|
||||
}
|
||||
if (calldata->err != 0) {
|
||||
HILOG_ERROR("OnStartAbilityByCall callComplete err is %{public}d", calldata->err);
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
HILOG_DEBUG("clear failed call of startup is called.");
|
||||
auto context = abilityContext.lock();
|
||||
if (context == nullptr || callerCallBack == nullptr) {
|
||||
HILOG_ERROR("clear failed call of startup input param is nullptr.");
|
||||
return;
|
||||
}
|
||||
context->ClearFailedCallConnection(callerCallBack);
|
||||
return;
|
||||
}
|
||||
auto context = abilityContext.lock();
|
||||
if (context == nullptr || callerCallBack == nullptr || calldata->remoteCallee == nullptr) {
|
||||
HILOG_ERROR("OnStartAbilityByCall callComplete params error %{public}s is nullptr",
|
||||
context == nullptr ? "context" : (calldata->remoteCallee == nullptr ? "remoteCallee" : "callerCallBack"));
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
HILOG_DEBUG("OnStartAbilityByCall callComplete end");
|
||||
return;
|
||||
}
|
||||
auto releaseCallAbilityFunc = [abilityContext] (const std::shared_ptr<CallerCallBack> &callback) -> ErrCode {
|
||||
auto contextForRelease = abilityContext.lock();
|
||||
if (contextForRelease == nullptr) {
|
||||
HILOG_ERROR("releaseCallAbilityFunction, context is nullptr");
|
||||
return -1;
|
||||
}
|
||||
return contextForRelease->ReleaseCall(callback);
|
||||
};
|
||||
task.Resolve(env, CreateJsCallerComplex(env, releaseCallAbilityFunc, calldata->remoteCallee, callerCallBack));
|
||||
HILOG_DEBUG("OnStartAbilityByCall callComplete end");
|
||||
}
|
||||
}
|
||||
|
||||
void JsAbilityContext::Finalizer(napi_env env, void* data, void* hint)
|
||||
{
|
||||
HILOG_INFO("JsAbilityContext::Finalizer is called");
|
||||
@ -421,112 +508,71 @@ napi_value JsAbilityContext::OnStartAbilityWithAccount(napi_env env, NapiCallbac
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::OnStartAbilityByCall(napi_env env, NapiCallbackInfo& info)
|
||||
bool JsAbilityContext::CheckStartAbilityByCallParams(napi_env env, NapiCallbackInfo& info,
|
||||
AAFwk::Want &want, int32_t &userId, napi_value &lastParam)
|
||||
{
|
||||
HILOG_DEBUG("JsAbilityContext::%{public}s, called", __func__);
|
||||
if (info.argc < ARGC_ONE) {
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
return false;
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_object) ||
|
||||
!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
HILOG_ERROR("Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
return false;
|
||||
}
|
||||
|
||||
InheritWindowMode(want);
|
||||
|
||||
std::shared_ptr<StartAbilityByCallParameters> calls = std::make_shared<StartAbilityByCallParameters>();
|
||||
napi_value lastParam = nullptr;
|
||||
napi_value retsult = nullptr;
|
||||
int32_t userId = DEFAULT_INVAL_VALUE;
|
||||
if (info.argc > ARGC_ONE) {
|
||||
if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_number)) {
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ONE], userId)) {
|
||||
HILOG_ERROR("Failed to parse accountId!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
} else if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) {
|
||||
lastParam = info.argv[INDEX_ONE];
|
||||
} else {
|
||||
HILOG_ERROR("Failed, input param type invalid");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (info.argc == ARGC_ONE) {
|
||||
return true;
|
||||
}
|
||||
bool paramOneIsNumber = CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_number);
|
||||
bool paramOneIsFunction = CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function);
|
||||
if (!paramOneIsNumber && !paramOneIsFunction) {
|
||||
HILOG_ERROR("Failed, input param type invalid");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return false;
|
||||
}
|
||||
if (paramOneIsNumber && !ConvertFromJsValue(env, info.argv[INDEX_ONE], userId)) {
|
||||
HILOG_ERROR("Failed to parse accountId!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return false;
|
||||
}
|
||||
if (paramOneIsFunction) {
|
||||
lastParam = info.argv[INDEX_ONE];
|
||||
}
|
||||
|
||||
if (info.argc > ARGC_TWO && CheckTypeForNapiValue(env, info.argv[INDEX_TWO], napi_function)) {
|
||||
lastParam = info.argv[INDEX_TWO];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
auto callBackDone = [calldata = calls] (const sptr<IRemoteObject> &obj) {
|
||||
HILOG_DEBUG("OnStartAbilityByCall callBackDone mutexlock");
|
||||
std::unique_lock<std::mutex> lock(calldata->mutexlock);
|
||||
HILOG_DEBUG("OnStartAbilityByCall callBackDone remoteCallee assignment");
|
||||
calldata->remoteCallee = obj;
|
||||
calldata->condition.notify_all();
|
||||
HILOG_DEBUG("OnStartAbilityByCall callBackDone is called end");
|
||||
};
|
||||
|
||||
auto releaseListen = [](const std::string &str) {
|
||||
HILOG_INFO("OnStartAbilityByCall releaseListen is called %{public}s", str.c_str());
|
||||
};
|
||||
|
||||
auto callExecute = [calldata = calls] () {
|
||||
constexpr int CALLER_TIME_OUT = 10; // 10s
|
||||
std::unique_lock<std::mutex> lock(calldata->mutexlock);
|
||||
if (calldata->remoteCallee != nullptr) {
|
||||
HILOG_INFO("OnStartAbilityByCall callExecute callee isn`t nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (calldata->condition.wait_for(lock, std::chrono::seconds(CALLER_TIME_OUT)) == std::cv_status::timeout) {
|
||||
HILOG_ERROR("OnStartAbilityByCall callExecute waiting callee timeout");
|
||||
calldata->err = -1;
|
||||
}
|
||||
HILOG_DEBUG("OnStartAbilityByCall callExecute end");
|
||||
};
|
||||
napi_value JsAbilityContext::OnStartAbilityByCall(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("JsAbilityContext::%{public}s, called", __func__);
|
||||
// 1. check params
|
||||
napi_value lastParam = nullptr;
|
||||
int32_t userId = DEFAULT_INVAL_VALUE;
|
||||
AAFwk::Want want;
|
||||
if (!CheckStartAbilityByCallParams(env, info, want, userId, lastParam)) {
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
// 2. create CallBack function
|
||||
std::shared_ptr<StartAbilityByCallParameters> calls = std::make_shared<StartAbilityByCallParameters>();
|
||||
auto callExecute = [calldata = calls] () { StartAbilityByCallExecuteDone(calldata); };
|
||||
auto callerCallBack = std::make_shared<CallerCallBack>();
|
||||
GenerateCallerCallBack(calls, callerCallBack);
|
||||
auto callComplete = [weak = context_, calldata = calls, callerCallBack] (
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
if (calldata->err != 0) {
|
||||
HILOG_ERROR("OnStartAbilityByCall callComplete err is %{public}d", calldata->err);
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
ClearFailedCallConnection(weak, callerCallBack);
|
||||
return;
|
||||
}
|
||||
|
||||
auto context = weak.lock();
|
||||
if (context != nullptr && callerCallBack != nullptr && calldata->remoteCallee != nullptr) {
|
||||
auto releaseCallAbilityFunc = [weak] (
|
||||
const std::shared_ptr<CallerCallBack> &callback) -> ErrCode {
|
||||
auto contextForRelease = weak.lock();
|
||||
if (contextForRelease == nullptr) {
|
||||
HILOG_ERROR("releaseCallAbilityFunction, context is nullptr");
|
||||
return -1;
|
||||
}
|
||||
return contextForRelease->ReleaseCall(callback);
|
||||
};
|
||||
task.Resolve(env,
|
||||
CreateJsCallerComplex(
|
||||
env, releaseCallAbilityFunc, calldata->remoteCallee, callerCallBack));
|
||||
} else {
|
||||
HILOG_ERROR("OnStartAbilityByCall callComplete params error %{public}s is nullptr",
|
||||
context == nullptr ? "context" :
|
||||
(calldata->remoteCallee == nullptr ? "remoteCallee" : "callerCallBack"));
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OnStartAbilityByCall callComplete end");
|
||||
StartAbilityByCallComplete(env, task, weak, calldata, callerCallBack);
|
||||
};
|
||||
|
||||
callerCallBack->SetCallBack(callBackDone);
|
||||
callerCallBack->SetOnRelease(releaseListen);
|
||||
|
||||
// 3. StartAbilityByCall
|
||||
napi_value retsult = nullptr;
|
||||
auto context = context_.lock();
|
||||
if (context == nullptr) {
|
||||
HILOG_ERROR("OnStartAbilityByCall context is nullptr");
|
||||
|
@ -260,10 +260,6 @@ void JsUIAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo
|
||||
HILOG_ERROR("Not found Ability.js.");
|
||||
return;
|
||||
}
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
if (applicationContext != nullptr) {
|
||||
applicationContext->DispatchOnAbilityCreate(jsAbilityObj_);
|
||||
}
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
@ -300,6 +296,10 @@ void JsUIAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo
|
||||
HILOG_DEBUG("Call PostPerformStart.");
|
||||
delegator->PostPerformStart(CreateADelegatorAbilityProperty());
|
||||
}
|
||||
auto applicationContext = AbilityRuntime::Context::GetApplicationContext();
|
||||
if (applicationContext != nullptr) {
|
||||
applicationContext->DispatchOnAbilityCreate(jsAbilityObj_);
|
||||
}
|
||||
HILOG_DEBUG("End ability is %{public}s.", GetAbilityName().c_str());
|
||||
}
|
||||
|
||||
|
@ -75,16 +75,14 @@ int32_t AutoStartupCallBackStub::OnAutoStartupOnInner(MessageParcel &data, Messa
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler =
|
||||
std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner());
|
||||
wptr<AutoStartupCallBackStub> weak = this;
|
||||
if (handler) {
|
||||
handler->PostSyncTask([weak, info]() {
|
||||
auto autoStartUpCallBackStub = weak.promote();
|
||||
if (autoStartUpCallBackStub == nullptr) {
|
||||
HILOG_ERROR("autoStartUpCallBackStub is nullptr.");
|
||||
return;
|
||||
}
|
||||
autoStartUpCallBackStub->OnAutoStartupOn(*info);
|
||||
});
|
||||
}
|
||||
handler->PostSyncTask([weak, info]() {
|
||||
auto autoStartUpCallBackStub = weak.promote();
|
||||
if (autoStartUpCallBackStub == nullptr) {
|
||||
HILOG_ERROR("autoStartUpCallBackStub is nullptr.");
|
||||
return;
|
||||
}
|
||||
autoStartUpCallBackStub->OnAutoStartupOn(*info);
|
||||
});
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@ -100,16 +98,14 @@ int32_t AutoStartupCallBackStub::OnAutoStartupOffInner(MessageParcel &data, Mess
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler =
|
||||
std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner());
|
||||
wptr<AutoStartupCallBackStub> weak = this;
|
||||
if (handler) {
|
||||
handler->PostSyncTask([weak, info]() {
|
||||
auto autoStartUpCallBackStub = weak.promote();
|
||||
if (autoStartUpCallBackStub == nullptr) {
|
||||
HILOG_ERROR("autoStartUpCallBackStub is nullptr.");
|
||||
return;
|
||||
}
|
||||
autoStartUpCallBackStub->OnAutoStartupOff(*info);
|
||||
});
|
||||
}
|
||||
handler->PostSyncTask([weak, info]() {
|
||||
auto autoStartUpCallBackStub = weak.promote();
|
||||
if (autoStartUpCallBackStub == nullptr) {
|
||||
HILOG_ERROR("autoStartUpCallBackStub is nullptr.");
|
||||
return;
|
||||
}
|
||||
autoStartUpCallBackStub->OnAutoStartupOff(*info);
|
||||
});
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ void ChildProcessManager::HandleSigChild(int32_t signo)
|
||||
|
||||
ChildProcessManagerErrorCode ChildProcessManager::PreCheck()
|
||||
{
|
||||
if (!AAFwk::AppUtils::GetInstance().JudgePCDevice()) {
|
||||
if (!AAFwk::AppUtils::GetInstance().isMultiProcessModel()) {
|
||||
HILOG_ERROR("Multi process model is not enabled");
|
||||
return ChildProcessManagerErrorCode::ERR_MULTI_PROCESS_MODEL_DISABLED;
|
||||
}
|
||||
@ -246,7 +246,7 @@ bool ChildProcessManager::GetHapModuleInfo(const AppExecFwk::BundleInfo &bundleI
|
||||
}
|
||||
HILOG_DEBUG("hapModueInfos size: %{public}zu", bundleInfo.hapModuleInfos.size());
|
||||
bool result = false;
|
||||
for (auto info : bundleInfo.hapModuleInfos) {
|
||||
for (const auto &info : bundleInfo.hapModuleInfos) {
|
||||
if (info.moduleType == AppExecFwk::ModuleType::ENTRY) {
|
||||
result = true;
|
||||
hapModuleInfo = info;
|
||||
|
@ -230,6 +230,11 @@ std::map<int, int> DataAbilityOperation::GetDataAbilityPredicatesBackReferences(
|
||||
HILOG_DEBUG("DataAbilityOperation::GetDataAbilityPredicatesBackReferences");
|
||||
return dataAbilityPredicatesBackReferences_;
|
||||
}
|
||||
bool DataAbilityOperation::IsValidOperation() const
|
||||
{
|
||||
HILOG_DEBUG("DataAbilityOperation::IsValidOperation: type is %{public}d", type_);
|
||||
return (type_ == TYPE_INSERT || type_ == TYPE_UPDATE || type_ == TYPE_DELETE || type_ == TYPE_ASSERT);
|
||||
}
|
||||
bool DataAbilityOperation::IsInsertOperation() const
|
||||
{
|
||||
HILOG_DEBUG("DataAbilityOperation::IsInsertOperation: %{public}d", type_ == TYPE_INSERT);
|
||||
@ -255,116 +260,123 @@ bool DataAbilityOperation::IsInterruptionAllowed() const
|
||||
HILOG_DEBUG("DataAbilityOperation::IsInterruptionAllowed: %{public}d", interrupted_);
|
||||
return interrupted_;
|
||||
}
|
||||
|
||||
bool DataAbilityOperation::WriteUri(Parcel &out) const
|
||||
{
|
||||
if (uri_ == nullptr) {
|
||||
HILOG_DEBUG("Uri is nullptr");
|
||||
return out.WriteInt32(VALUE_NULL);
|
||||
}
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("Write VALUE_OBJECT error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteParcelable(uri_.get())) {
|
||||
HILOG_ERROR("Write Uri error");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataAbilityOperation::WriteValuesBucket(Parcel &out) const
|
||||
{
|
||||
if (valuesBucket_ == nullptr) {
|
||||
HILOG_DEBUG("ValuesBucket is nullptr");
|
||||
return out.WriteInt32(VALUE_NULL);
|
||||
}
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("Write VALUE_OBJECT error");
|
||||
return false;
|
||||
}
|
||||
if (!valuesBucket_->Marshalling(out)) {
|
||||
HILOG_ERROR("Write ValuesBucket error");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataAbilityOperation::WritePredicates(Parcel &out) const
|
||||
{
|
||||
if (dataAbilityPredicates_ == nullptr) {
|
||||
HILOG_DEBUG("DataAbilityPredicates is nullptr");
|
||||
return out.WriteInt32(VALUE_NULL);
|
||||
}
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("Write VALUE_OBJECT error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteParcelable(dataAbilityPredicates_.get())) {
|
||||
HILOG_ERROR("Write DataAbilityPredicates error");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataAbilityOperation::WriteValuesBucketReferences(Parcel &out) const
|
||||
{
|
||||
if (valuesBucketReferences_ == nullptr) {
|
||||
HILOG_DEBUG("ValuesBucketReferences is nullptr");
|
||||
return out.WriteInt32(VALUE_NULL);
|
||||
}
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("Write VALUE_OBJECT error");
|
||||
return false;
|
||||
}
|
||||
if (!valuesBucketReferences_->Marshalling(out)) {
|
||||
HILOG_ERROR("ValuesBucketReferences Marshalling error");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataAbilityOperation::Marshalling(Parcel &out) const
|
||||
{
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling start");
|
||||
if (!out.WriteInt32(type_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(type_) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(type) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteInt32(expectedCount_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(expectedCount) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out.WriteBool(interrupted_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(interrupted) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uri_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!out.WriteParcelable(uri_.get())) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!out.WriteInt32(VALUE_NULL)) {
|
||||
return false;
|
||||
}
|
||||
if (!WriteUri(out) || !WriteValuesBucket(out) || !WritePredicates(out) || !WriteValuesBucketReferences(out)) {
|
||||
HILOG_ERROR("Marshalling error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (valuesBucket_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!valuesBucket_->Marshalling(out)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!out.WriteInt32(VALUE_NULL)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (dataAbilityPredicates_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteParcelable(dataAbilityPredicates_.get())) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!out.WriteInt32(VALUE_NULL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (valuesBucketReferences_ != nullptr) {
|
||||
if (!out.WriteInt32(VALUE_OBJECT)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!valuesBucketReferences_->Marshalling(out)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!out.WriteInt32(VALUE_NULL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int referenceSize = 0;
|
||||
if (!dataAbilityPredicatesBackReferences_.empty()) {
|
||||
referenceSize = (int)dataAbilityPredicatesBackReferences_.size();
|
||||
if (!out.WriteInt32(referenceSize)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (referenceSize >= REFERENCE_THRESHOLD) {
|
||||
HILOG_INFO("DataAbilityOperation::Marshalling referenceSize >= REFERENCE_THRESHOLD");
|
||||
return true;
|
||||
}
|
||||
for (auto it = dataAbilityPredicatesBackReferences_.begin(); it != dataAbilityPredicatesBackReferences_.end();
|
||||
it++) {
|
||||
if (!out.WriteInt32(it->first)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteInt32(it->second)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int referenceSize = (int)dataAbilityPredicatesBackReferences_.size();
|
||||
if (dataAbilityPredicatesBackReferences_.empty()) {
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_ is empty");
|
||||
if (!out.WriteInt32(referenceSize)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling end");
|
||||
return true;
|
||||
}
|
||||
if (!out.WriteInt32(referenceSize)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (referenceSize >= REFERENCE_THRESHOLD) {
|
||||
HILOG_INFO("DataAbilityOperation::Marshalling referenceSize >= REFERENCE_THRESHOLD");
|
||||
return true;
|
||||
}
|
||||
for (auto it = dataAbilityPredicatesBackReferences_.begin(); it != dataAbilityPredicatesBackReferences_.end();
|
||||
it++) {
|
||||
if (!out.WriteInt32(it->first)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
if (!out.WriteInt32(it->second)) {
|
||||
HILOG_ERROR("DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_DEBUG("DataAbilityOperation::Marshalling end");
|
||||
return true;
|
||||
}
|
||||
@ -380,69 +392,89 @@ DataAbilityOperation *DataAbilityOperation::Unmarshalling(Parcel &in)
|
||||
HILOG_DEBUG("DataAbilityOperation::Unmarshalling end");
|
||||
return dataAbilityOperation;
|
||||
}
|
||||
bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
{
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel start");
|
||||
if (!in.ReadInt32(type_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(type_) error");
|
||||
return false;
|
||||
}
|
||||
if (!in.ReadInt32(expectedCount_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
interrupted_ = in.ReadBool();
|
||||
|
||||
bool DataAbilityOperation::ReadUriFromParcel(Parcel &in)
|
||||
{
|
||||
int empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
if (empty == VALUE_OBJECT) {
|
||||
HILOG_DEBUG("empty is VALUE_OBJECT");
|
||||
uri_.reset(in.ReadParcelable<Uri>());
|
||||
} else {
|
||||
uri_.reset();
|
||||
return true;
|
||||
}
|
||||
uri_.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
empty = VALUE_NULL;
|
||||
bool DataAbilityOperation::ReadValuesBucketFromParcel(Parcel &in)
|
||||
{
|
||||
int empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
empty == VALUE_OBJECT ? "VALUE_OBJECT" : "VALUE_NULL");
|
||||
if (empty == VALUE_OBJECT) {
|
||||
HILOG_DEBUG("empty is VALUE_OBJECT");
|
||||
valuesBucket_ = std::make_shared<NativeRdb::ValuesBucket>(NativeRdb::ValuesBucket::Unmarshalling(in));
|
||||
} else {
|
||||
valuesBucket_.reset();
|
||||
return true;
|
||||
}
|
||||
valuesBucket_.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
empty = VALUE_NULL;
|
||||
bool DataAbilityOperation::ReadDataAbilityPredicatesFromParcel(Parcel &in)
|
||||
{
|
||||
int empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
empty == VALUE_OBJECT ? "VALUE_OBJECT" : "VALUE_NULL");
|
||||
if (empty == VALUE_OBJECT) {
|
||||
HILOG_DEBUG("empty is VALUE_OBJECT");
|
||||
dataAbilityPredicates_.reset(in.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
} else {
|
||||
dataAbilityPredicates_.reset();
|
||||
return true;
|
||||
}
|
||||
dataAbilityPredicates_.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
empty = VALUE_NULL;
|
||||
bool DataAbilityOperation::ReadValuesBucketReferencesFromParcel(Parcel &in)
|
||||
{
|
||||
int empty = VALUE_NULL;
|
||||
if (!in.ReadInt32(empty)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(empty) error");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel empty is %{public}s",
|
||||
(empty == VALUE_OBJECT) ? "VALUE_OBJECT" : "VALUE_NULL");
|
||||
if (empty == VALUE_OBJECT) {
|
||||
valuesBucketReferences_ = std::make_shared<NativeRdb::ValuesBucket>(NativeRdb::ValuesBucket::Unmarshalling(in));
|
||||
} else {
|
||||
valuesBucketReferences_.reset();
|
||||
HILOG_DEBUG("empty is VALUE_OBJECT");
|
||||
valuesBucketReferences_ = std::make_shared<NativeRdb::ValuesBucket>(
|
||||
NativeRdb::ValuesBucket::Unmarshalling(in));
|
||||
return true;
|
||||
}
|
||||
valuesBucketReferences_.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
{
|
||||
HILOG_DEBUG("DataAbilityOperation::ReadFromParcel start");
|
||||
if (!in.ReadInt32(type_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(type) error");
|
||||
return false;
|
||||
}
|
||||
if (!in.ReadInt32(expectedCount_)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel ReadInt32(expectedCount) error");
|
||||
return false;
|
||||
}
|
||||
interrupted_ = in.ReadBool();
|
||||
if (!ReadUriFromParcel(in) || !ReadValuesBucketFromParcel(in) || !ReadDataAbilityPredicatesFromParcel(in) ||
|
||||
!ReadValuesBucketReferencesFromParcel(in)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel error");
|
||||
return false;
|
||||
}
|
||||
int referenceSize = 0;
|
||||
if (!in.ReadInt32(referenceSize)) {
|
||||
HILOG_ERROR("DataAbilityOperation::ReadFromParcel end");
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"blocklist": {
|
||||
"ServiceExtension": [],
|
||||
"VpnExtension":[],
|
||||
"AdsServiceExtension": [
|
||||
"multimedia.camera",
|
||||
"multimedia.mediaLibrary",
|
||||
@ -166,7 +167,8 @@
|
||||
"application.formProvider",
|
||||
"prompt",
|
||||
"promptAction",
|
||||
"window"
|
||||
"window",
|
||||
"core.liveview.liveViewManager"
|
||||
],
|
||||
"DriverExtension": [
|
||||
"abilityAccessCtrl",
|
||||
@ -282,7 +284,8 @@
|
||||
"application.formProvider",
|
||||
"prompt",
|
||||
"promptAction",
|
||||
"window"
|
||||
"window",
|
||||
"core.liveview.liveViewManager"
|
||||
],
|
||||
"RemoteLocationExtension": [
|
||||
"notification",
|
||||
@ -309,4 +312,4 @@
|
||||
"application.formProvider"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,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 VPN_EXTENSION[] = "VpnExtension";
|
||||
}
|
||||
|
||||
ExtensionAbilityThread::ExtensionAbilityThread() : extensionImpl_(nullptr), currentExtension_(nullptr) {}
|
||||
@ -147,6 +148,9 @@ void ExtensionAbilityThread::CreateExtensionAbilityName(
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::SYSDIALOG_USERAUTH) {
|
||||
abilityName = USER_AUTH_EXTENSION;
|
||||
}
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::VPN) {
|
||||
abilityName = VPN_EXTENSION;
|
||||
}
|
||||
if (abilityInfo->extensionAbilityType == AppExecFwk::ExtensionAbilityType::UNSPECIFIED &&
|
||||
abilityInfo->type == AppExecFwk::AbilityType::EXTENSION) {
|
||||
abilityName = abilityInfo->extensionTypeName + CUSTOM_EXTENSION;
|
||||
@ -627,4 +631,4 @@ void ExtensionAbilityThread::DumpOtherInfo(std::vector<std::string> &info)
|
||||
info.push_back(dumpInfo);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -41,10 +41,12 @@ void ExtensionImpl::Init(const std::shared_ptr<AppExecFwk::OHOSApplication> &app
|
||||
|
||||
token_ = record->GetToken();
|
||||
extension_ = extension;
|
||||
if (record->GetAbilityInfo() != nullptr &&
|
||||
AAFwk::UIExtensionUtils::IsUIExtension(record->GetAbilityInfo()->extensionAbilityType)) {
|
||||
extension_->SetExtensionWindowLifeCycleListener(
|
||||
sptr<ExtensionWindowLifeCycleImpl>(new ExtensionWindowLifeCycleImpl(token_, shared_from_this())));
|
||||
if (record->GetAbilityInfo() != nullptr) {
|
||||
extensionType_ = record->GetAbilityInfo()->extensionAbilityType;
|
||||
if (AAFwk::UIExtensionUtils::IsUIExtension(extensionType_)) {
|
||||
extension_->SetExtensionWindowLifeCycleListener(
|
||||
sptr<ExtensionWindowLifeCycleImpl>(new ExtensionWindowLifeCycleImpl(token_, shared_from_this())));
|
||||
}
|
||||
}
|
||||
extension_->Init(record, application, handler, token);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
@ -108,13 +110,19 @@ void ExtensionImpl::HandleExtensionTransaction(const Want &want, const AAFwk::Li
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
if (ret && !UIExtensionAbilityExecuteInsightIntent(want)) {
|
||||
HILOG_INFO("call abilityms");
|
||||
AAFwk::PacMap restoreData;
|
||||
AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, restoreData);
|
||||
}
|
||||
}
|
||||
|
||||
bool ExtensionImpl::UIExtensionAbilityExecuteInsightIntent(const Want &want)
|
||||
{
|
||||
return AAFwk::UIExtensionUtils::IsUIExtension(extensionType_) &&
|
||||
AppExecFwk::InsightIntentExecuteParam::IsInsightIntentExecute(want);
|
||||
}
|
||||
|
||||
void ExtensionImpl::ScheduleUpdateConfiguration(const AppExecFwk::Configuration &config)
|
||||
{
|
||||
HILOG_INFO("call");
|
||||
@ -241,7 +249,7 @@ sptr<IRemoteObject> ExtensionImpl::ConnectExtension(const Want &want)
|
||||
HILOG_ERROR("ExtensionImpl::ConnectAbility extension_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
skipCommandExtensionWithIntent_ = true;
|
||||
sptr<IRemoteObject> object = extension_->OnConnect(want);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
|
@ -50,8 +50,13 @@ napi_value AttachFormExtensionContext(napi_env env, void* value, void*)
|
||||
return nullptr;
|
||||
}
|
||||
napi_value object = CreateJsFormExtensionContext(env, ptr);
|
||||
auto contextObj = JsRuntime::LoadSystemModuleByEngine(env,
|
||||
"application.FormExtensionContext", &object, 1)->GetNapiValue();
|
||||
auto sysModule = JsRuntime::LoadSystemModuleByEngine(env,
|
||||
"application.FormExtensionContext", &object, 1);
|
||||
if (sysModule == nullptr) {
|
||||
HILOG_WARN("load module failed");
|
||||
return nullptr;
|
||||
}
|
||||
auto contextObj = sysModule->GetNapiValue();
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachFormExtensionContext, value, nullptr);
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<FormExtensionContext>(ptr);
|
||||
@ -130,6 +135,10 @@ void JsFormExtension::BindContext(napi_env env, napi_value obj)
|
||||
HILOG_INFO("call");
|
||||
napi_value contextObj = CreateJsFormExtensionContext(env, context);
|
||||
shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.FormExtensionContext", &contextObj, 1);
|
||||
if (shellContextRef_ == nullptr) {
|
||||
HILOG_ERROR("Failed to load module");
|
||||
return;
|
||||
}
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
HILOG_ERROR("Failed to get context native object");
|
||||
|
@ -95,8 +95,13 @@ napi_value AttachServiceExtensionContext(napi_env env, void *value, void *)
|
||||
return nullptr;
|
||||
}
|
||||
napi_value object = CreateJsServiceExtensionContext(env, ptr);
|
||||
auto contextObj = JsRuntime::LoadSystemModuleByEngine(env,
|
||||
"application.ServiceExtensionContext", &object, 1)->GetNapiValue();
|
||||
auto sysModule = JsRuntime::LoadSystemModuleByEngine(env,
|
||||
"application.ServiceExtensionContext", &object, 1);
|
||||
if (sysModule == nullptr) {
|
||||
HILOG_WARN("load module failed.");
|
||||
return nullptr;
|
||||
}
|
||||
auto contextObj = sysModule->GetNapiValue();
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachServiceExtensionContext, value, nullptr);
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<ServiceExtensionContext>(ptr);
|
||||
@ -227,6 +232,10 @@ void JsServiceExtension::BindContext(napi_env env, napi_value obj)
|
||||
napi_value contextObj = CreateJsServiceExtensionContext(env, context);
|
||||
shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.ServiceExtensionContext",
|
||||
&contextObj, ARGC_ONE);
|
||||
if (shellContextRef_ == nullptr) {
|
||||
HILOG_ERROR("Failed to load module");
|
||||
return;
|
||||
}
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
HILOG_ERROR("Failed to get context native object");
|
||||
|
@ -162,6 +162,10 @@ void JsUIExtension::Init(const std::shared_ptr<AbilityLocalRecord> &record,
|
||||
HILOG_ERROR("JsUIExtension Init abilityInfo error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (record != nullptr) {
|
||||
token_ = record->GetToken();
|
||||
}
|
||||
std::string srcPath(Extension::abilityInfo_->moduleName + "/");
|
||||
srcPath.append(Extension::abilityInfo_->srcEntrance);
|
||||
srcPath.erase(srcPath.rfind('.'));
|
||||
@ -418,7 +422,7 @@ void JsUIExtension::OnCommandWindow(const AAFwk::Want &want, const sptr<AAFwk::S
|
||||
HILOG_DEBUG("begin. persistentId: %{private}d, winCmd: %{public}d", sessionInfo->persistentId, winCmd);
|
||||
Extension::OnCommandWindow(want, sessionInfo, winCmd);
|
||||
if (InsightIntentExecuteParam::IsInsightIntentExecute(want) && winCmd == AAFwk::WIN_CMD_FOREGROUND) {
|
||||
bool finish = ForegroundWindowWithInsightIntent(want, sessionInfo);
|
||||
bool finish = ForegroundWindowWithInsightIntent(want, sessionInfo, false);
|
||||
if (finish) {
|
||||
return;
|
||||
}
|
||||
@ -441,7 +445,7 @@ void JsUIExtension::OnCommandWindow(const AAFwk::Want &want, const sptr<AAFwk::S
|
||||
}
|
||||
|
||||
bool JsUIExtension::ForegroundWindowWithInsightIntent(const AAFwk::Want &want,
|
||||
const sptr<AAFwk::SessionInfo> &sessionInfo)
|
||||
const sptr<AAFwk::SessionInfo> &sessionInfo, bool needForeground)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
if (!HandleSessionCreate(want, sessionInfo)) {
|
||||
@ -455,14 +459,16 @@ bool JsUIExtension::ForegroundWindowWithInsightIntent(const AAFwk::Want &want,
|
||||
HILOG_ERROR("Create async callback failed.");
|
||||
return false;
|
||||
}
|
||||
executorCallback->Push([weak = weak_from_this(), sessionInfo](AppExecFwk::InsightIntentExecuteResult result) {
|
||||
auto extension = weak.lock();
|
||||
if (extension == nullptr) {
|
||||
|
||||
auto uiExtension = std::static_pointer_cast<JsUIExtension>(shared_from_this());
|
||||
executorCallback->Push([uiExtension, sessionInfo, needForeground](AppExecFwk::InsightIntentExecuteResult result) {
|
||||
HILOG_INFO("Execute post insightintent.");
|
||||
if (uiExtension == nullptr) {
|
||||
HILOG_ERROR("UI extension is nullptr.");
|
||||
return;
|
||||
}
|
||||
extension->OnCommandWindowDone(sessionInfo, AAFwk::WIN_CMD_FOREGROUND);
|
||||
extension->OnInsightIntentExecuteDone(sessionInfo, result);
|
||||
|
||||
uiExtension->PostInsightIntentExecuted(sessionInfo, result, needForeground);
|
||||
});
|
||||
|
||||
auto context = GetContext();
|
||||
@ -489,6 +495,30 @@ bool JsUIExtension::ForegroundWindowWithInsightIntent(const AAFwk::Want &want,
|
||||
return true;
|
||||
}
|
||||
|
||||
void JsUIExtension::PostInsightIntentExecuted(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result, bool needForeground)
|
||||
{
|
||||
HILOG_DEBUG("Post insightintent executed.");
|
||||
if (needForeground) {
|
||||
// If uiextensionability is started for the first time or need move background to foreground.
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
CallObjectMethod("onForeground");
|
||||
}
|
||||
|
||||
OnInsightIntentExecuteDone(sessionInfo, result);
|
||||
|
||||
if (needForeground) {
|
||||
// If need foreground, that means triggered by onForeground.
|
||||
HILOG_INFO("call abilityms");
|
||||
AAFwk::PacMap restoreData;
|
||||
AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, AAFwk::ABILITY_STATE_FOREGROUND_NEW,
|
||||
restoreData);
|
||||
} else {
|
||||
// If uiextensionability has displayed in the foreground.
|
||||
OnCommandWindowDone(sessionInfo, AAFwk::WIN_CMD_FOREGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
void JsUIExtension::OnCommandWindowDone(const sptr<AAFwk::SessionInfo> &sessionInfo, AAFwk::WindowCommand winCmd)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
@ -573,8 +603,14 @@ void JsUIExtension::OnForeground(const Want &want, sptr<AAFwk::SessionInfo> sess
|
||||
HILOG_DEBUG("JsUIExtension OnForeground begin.");
|
||||
Extension::OnForeground(want, sessionInfo);
|
||||
|
||||
ForegroundWindow(want, sessionInfo);
|
||||
if (InsightIntentExecuteParam::IsInsightIntentExecute(want)) {
|
||||
bool finish = ForegroundWindowWithInsightIntent(want, sessionInfo, true);
|
||||
if (finish) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ForegroundWindow(want, sessionInfo);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
CallObjectMethod("onForeground");
|
||||
HILOG_DEBUG("JsUIExtension OnForeground end.");
|
||||
|
@ -119,6 +119,10 @@ std::shared_ptr<JsExtensionCommon> JsUIExtensionBase::Init(const std::shared_ptr
|
||||
HILOG_ERROR("abilityInfo srcEntrance is empty");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (record != nullptr) {
|
||||
token_ = record->GetToken();
|
||||
}
|
||||
std::string srcPath(abilityInfo_->moduleName + "/");
|
||||
srcPath.append(abilityInfo_->srcEntrance);
|
||||
srcPath.erase(srcPath.rfind('.'));
|
||||
@ -211,7 +215,7 @@ void JsUIExtensionBase::OnCommandWindow(
|
||||
return;
|
||||
}
|
||||
if (InsightIntentExecuteParam::IsInsightIntentExecute(want) && winCmd == AAFwk::WIN_CMD_FOREGROUND) {
|
||||
bool finish = ForegroundWindowWithInsightIntent(want, sessionInfo);
|
||||
bool finish = ForegroundWindowWithInsightIntent(want, sessionInfo, false);
|
||||
if (finish) {
|
||||
return;
|
||||
}
|
||||
@ -234,7 +238,7 @@ void JsUIExtensionBase::OnCommandWindow(
|
||||
}
|
||||
|
||||
bool JsUIExtensionBase::ForegroundWindowWithInsightIntent(const AAFwk::Want &want,
|
||||
const sptr<AAFwk::SessionInfo> &sessionInfo)
|
||||
const sptr<AAFwk::SessionInfo> &sessionInfo, bool needForeground)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
if (!HandleSessionCreate(want, sessionInfo)) {
|
||||
@ -248,16 +252,17 @@ bool JsUIExtensionBase::ForegroundWindowWithInsightIntent(const AAFwk::Want &wan
|
||||
HILOG_ERROR("Create async callback failed.");
|
||||
return false;
|
||||
}
|
||||
executorCallback->Push([weak = weak_from_this(), sessionInfo](AppExecFwk::InsightIntentExecuteResult result) {
|
||||
HILOG_DEBUG("Begin UI extension transaction callback.");
|
||||
auto extension = weak.lock();
|
||||
if (extension == nullptr) {
|
||||
HILOG_ERROR("UI extension is nullptr.");
|
||||
return;
|
||||
}
|
||||
extension->OnCommandWindowDone(sessionInfo, AAFwk::WIN_CMD_FOREGROUND);
|
||||
extension->OnInsightIntentExecuteDone(sessionInfo, result);
|
||||
});
|
||||
executorCallback->Push(
|
||||
[weak = weak_from_this(), sessionInfo, needForeground](AppExecFwk::InsightIntentExecuteResult result) {
|
||||
HILOG_DEBUG("Begin UI extension transaction callback.");
|
||||
auto extension = weak.lock();
|
||||
if (extension == nullptr) {
|
||||
HILOG_ERROR("UI extension is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
extension->PostInsightIntentExecuted(sessionInfo, result, needForeground);
|
||||
});
|
||||
|
||||
InsightIntentExecutorInfo executorInfo;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = context_->GetAbilityInfo();
|
||||
@ -282,6 +287,30 @@ bool JsUIExtensionBase::ForegroundWindowWithInsightIntent(const AAFwk::Want &wan
|
||||
return true;
|
||||
}
|
||||
|
||||
void JsUIExtensionBase::PostInsightIntentExecuted(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result, bool needForeground)
|
||||
{
|
||||
HILOG_DEBUG("Post insightintent executed.");
|
||||
if (needForeground) {
|
||||
// If uiextensionability is started for the first time or need move background to foreground.
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
CallObjectMethod("onForeground");
|
||||
}
|
||||
|
||||
OnInsightIntentExecuteDone(sessionInfo, result);
|
||||
|
||||
if (needForeground) {
|
||||
// If need foreground, that means triggered by onForeground.
|
||||
HILOG_INFO("call abilityms");
|
||||
AAFwk::PacMap restoreData;
|
||||
AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, AAFwk::ABILITY_STATE_FOREGROUND_NEW,
|
||||
restoreData);
|
||||
} else {
|
||||
// If uiextensionability has displayed in the foreground.
|
||||
OnCommandWindowDone(sessionInfo, AAFwk::WIN_CMD_FOREGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
void JsUIExtensionBase::OnCommandWindowDone(const sptr<AAFwk::SessionInfo> &sessionInfo, AAFwk::WindowCommand winCmd)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
@ -369,6 +398,13 @@ void JsUIExtensionBase::OnCommand(const AAFwk::Want &want, bool restart, int32_t
|
||||
void JsUIExtensionBase::OnForeground(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
if (InsightIntentExecuteParam::IsInsightIntentExecute(want)) {
|
||||
bool finish = ForegroundWindowWithInsightIntent(want, sessionInfo, true);
|
||||
if (finish) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ForegroundWindow(want, sessionInfo);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
CallObjectMethod("onForeground");
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "hitrace_meter.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "js_error_utils.h"
|
||||
#include "js_extension_window.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "js_ui_extension_context.h"
|
||||
#include "string_wrapper.h"
|
||||
@ -132,6 +133,11 @@ napi_value JsUIExtensionContentSession::StartAbilityAsCaller(napi_env env, napi_
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContentSession, OnStartAbilityAsCaller);
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::GetUIExtensionHostWindowProxy(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContentSession, OnGetUIExtensionHostWindowProxy);
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::StartAbilityForResult(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContentSession, OnStartAbilityForResult);
|
||||
@ -231,6 +237,20 @@ napi_value JsUIExtensionContentSession::OnStartAbility(napi_env env, NapiCallbac
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::OnGetUIExtensionHostWindowProxy(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("OnGetUIExtensionHostWindowProxy is called");
|
||||
CHECK_IS_SYSTEM_APP;
|
||||
napi_value jsExtensionWindow = Rosen::JsExtensionWindow::CreateJsExtensionWindow(env, uiWindow_);
|
||||
if (jsExtensionWindow == nullptr) {
|
||||
HILOG_ERROR("Failed to create jsExtensionWindow object.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto value = JsRuntime::LoadSystemModuleByEngine(env, "application.extensionWindow", &jsExtensionWindow, 1);
|
||||
return value->GetNapiValue();
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::OnStartAbilityAsCaller(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@ -793,6 +813,7 @@ napi_value JsUIExtensionContentSession::CreateJsUIExtensionContentSession(napi_e
|
||||
BindNativeFunction(env, object, "startAbilityForResult", moduleName, StartAbilityForResult);
|
||||
BindNativeFunction(env, object, "startAbilityByType", moduleName, StartAbilityByType);
|
||||
BindNativeFunction(env, object, "startAbilityAsCaller", moduleName, StartAbilityAsCaller);
|
||||
BindNativeFunction(env, object, "getUIExtensionHostWindowProxy", moduleName, GetUIExtensionHostWindowProxy);
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -824,6 +845,7 @@ napi_value JsUIExtensionContentSession::CreateJsUIExtensionContentSession(napi_e
|
||||
BindNativeFunction(env, object, "startAbilityForResult", moduleName, StartAbilityForResult);
|
||||
BindNativeFunction(env, object, "startAbilityByType", moduleName, StartAbilityByType);
|
||||
BindNativeFunction(env, object, "startAbilityAsCaller", moduleName, StartAbilityAsCaller);
|
||||
BindNativeFunction(env, object, "getUIExtensionHostWindowProxy", moduleName, GetUIExtensionHostWindowProxy);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ std::shared_ptr<AbilityStage> JsAbilityStage::Create(
|
||||
srcPath.append(".abc");
|
||||
moduleObj = jsRuntime.LoadModule(moduleName, srcPath, hapModuleInfo.hapPath,
|
||||
hapModuleInfo.compileMode == AppExecFwk::CompileMode::ES_MODULE, commonChunkFlag);
|
||||
HILOG_INFO("JsAbilityStage srcPath is %{public}s", srcPath.c_str());
|
||||
HILOG_INFO("srcPath is %{public}s", srcPath.c_str());
|
||||
}
|
||||
return std::make_shared<JsAbilityStage>(jsRuntime, std::move(moduleObj));
|
||||
}
|
||||
@ -121,7 +121,7 @@ JsAbilityStage::JsAbilityStage(JsRuntime& jsRuntime, std::unique_ptr<NativeRefer
|
||||
|
||||
JsAbilityStage::~JsAbilityStage()
|
||||
{
|
||||
HILOG_DEBUG("Js ability stage destructor.");
|
||||
HILOG_DEBUG("called");
|
||||
auto context = GetContext();
|
||||
if (context) {
|
||||
context->Unbind();
|
||||
@ -181,7 +181,7 @@ void JsAbilityStage::Init(const std::shared_ptr<Context> &context)
|
||||
|
||||
void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
|
||||
{
|
||||
HILOG_DEBUG("JsAbilityStage::OnCreate come");
|
||||
HILOG_DEBUG("called");
|
||||
AbilityStage::OnCreate(want);
|
||||
|
||||
if (!jsAbilityStageObj_) {
|
||||
@ -194,7 +194,7 @@ void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
|
||||
|
||||
napi_value obj = jsAbilityStageObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
HILOG_ERROR("OnCreate, Failed to get AbilityStage object");
|
||||
HILOG_ERROR("Failed to get AbilityStage object");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -208,14 +208,14 @@ void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
|
||||
|
||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (delegator) {
|
||||
HILOG_DEBUG("Call AbilityDelegator::PostPerformStageStart");
|
||||
HILOG_DEBUG("Call PostPerformStageStart");
|
||||
delegator->PostPerformStageStart(CreateStageProperty());
|
||||
}
|
||||
}
|
||||
|
||||
std::string JsAbilityStage::OnAcceptWant(const AAFwk::Want &want)
|
||||
{
|
||||
HILOG_DEBUG("JsAbilityStage::OnAcceptWant come");
|
||||
HILOG_DEBUG("called");
|
||||
AbilityStage::OnAcceptWant(want);
|
||||
|
||||
if (!jsAbilityStageObj_) {
|
||||
@ -249,7 +249,7 @@ std::string JsAbilityStage::OnAcceptWant(const AAFwk::Want &want)
|
||||
|
||||
std::string JsAbilityStage::OnNewProcessRequest(const AAFwk::Want &want)
|
||||
{
|
||||
HILOG_DEBUG("JsAbilityStage::OnNewProcessRequest come");
|
||||
HILOG_DEBUG("called");
|
||||
AbilityStage::OnNewProcessRequest(want);
|
||||
|
||||
if (!jsAbilityStageObj_) {
|
||||
@ -282,7 +282,7 @@ std::string JsAbilityStage::OnNewProcessRequest(const AAFwk::Want &want)
|
||||
|
||||
void JsAbilityStage::OnConfigurationUpdated(const AppExecFwk::Configuration& configuration)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
HILOG_DEBUG("called");
|
||||
AbilityStage::OnConfigurationUpdated(configuration);
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
@ -303,7 +303,7 @@ void JsAbilityStage::OnConfigurationUpdated(const AppExecFwk::Configuration& con
|
||||
|
||||
void JsAbilityStage::OnMemoryLevel(int32_t level)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
HILOG_DEBUG("called");
|
||||
AbilityStage::OnMemoryLevel(level);
|
||||
|
||||
if (!jsAbilityStageObj_) {
|
||||
@ -323,12 +323,12 @@ void JsAbilityStage::OnMemoryLevel(int32_t level)
|
||||
napi_value jsLevel = CreateJsValue(env, level);
|
||||
napi_value argv[] = { jsLevel };
|
||||
CallObjectMethod("onMemoryLevel", argv, ArraySize(argv));
|
||||
HILOG_DEBUG("%{public}s end.", __func__);
|
||||
HILOG_DEBUG("end");
|
||||
}
|
||||
|
||||
napi_value JsAbilityStage::CallObjectMethod(const char* name, napi_value const * argv, size_t argc)
|
||||
{
|
||||
HILOG_DEBUG("JsAbilityStage::CallObjectMethod %{public}s", name);
|
||||
HILOG_DEBUG("call %{public}s", name);
|
||||
if (!jsAbilityStageObj_) {
|
||||
HILOG_WARN("Not found AbilityStage.js");
|
||||
return nullptr;
|
||||
@ -382,7 +382,7 @@ std::string JsAbilityStage::GetHapModuleProp(const std::string &propName) const
|
||||
if (propName.compare("srcEntrance") == 0) {
|
||||
return hapModuleInfo->srcEntrance;
|
||||
}
|
||||
HILOG_ERROR("Failed to GetHapModuleProp name = %{public}s", propName.c_str());
|
||||
HILOG_ERROR("name = %{public}s", propName.c_str());
|
||||
return std::string();
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -27,15 +27,15 @@ namespace AbilityRuntime {
|
||||
void JsAbilityStageContext::ConfigurationUpdated(napi_env env, std::shared_ptr<NativeReference> &jsContext,
|
||||
const std::shared_ptr<AppExecFwk::Configuration> &config)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
HILOG_INFO("called");
|
||||
if (!jsContext || !config) {
|
||||
HILOG_INFO("jsContext or config is nullptr.");
|
||||
HILOG_ERROR("jsContext or config is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value object = jsContext->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, object, napi_object)) {
|
||||
HILOG_INFO("object is nullptr.");
|
||||
HILOG_ERROR("object is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ void JsAbilityStageContext::ConfigurationUpdated(napi_env env, std::shared_ptr<N
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("JsAbilityStageContext call onUpdateConfiguration.");
|
||||
HILOG_DEBUG("call onUpdateConfiguration");
|
||||
napi_value argv[] = { CreateJsConfiguration(env, *config) };
|
||||
napi_call_function(env, object, method, 1, argv, nullptr);
|
||||
}
|
||||
@ -54,7 +54,7 @@ void JsAbilityStageContext::ConfigurationUpdated(napi_env env, std::shared_ptr<N
|
||||
napi_value CreateJsAbilityStageContext(napi_env env,
|
||||
std::shared_ptr<AbilityRuntime::Context> context, DetachCallback detach, NapiAttachCallback attach)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
HILOG_INFO("called.");
|
||||
napi_value objValue = CreateJsBaseContext(env, context);
|
||||
if (context == nullptr) {
|
||||
return objValue;
|
||||
|
@ -73,6 +73,8 @@ Global::Resource::DeviceType ContextImpl::deviceType_ = Global::Resource::Device
|
||||
const std::string OVERLAY_STATE_CHANGED = "usual.event.OVERLAY_STATE_CHANGED";
|
||||
const int32_t TYPE_RESERVE = 1;
|
||||
const int32_t TYPE_OTHERS = 2;
|
||||
const int32_t API11 = 11;
|
||||
const int32_t API_VERSION_MOD = 100;
|
||||
|
||||
std::string ContextImpl::GetBundleName() const
|
||||
{
|
||||
@ -96,7 +98,7 @@ std::string ContextImpl::GetBundleCodeDir()
|
||||
dir = LOCAL_CODE_PATH;
|
||||
}
|
||||
CreateDirIfNotExist(dir, MODE);
|
||||
HILOG_DEBUG("ContextImpl::GetBundleCodeDir:%{public}s", dir.c_str());
|
||||
HILOG_DEBUG("dir:%{public}s", dir.c_str());
|
||||
return dir;
|
||||
}
|
||||
|
||||
@ -104,7 +106,7 @@ std::string ContextImpl::GetCacheDir()
|
||||
{
|
||||
std::string dir = GetBaseDir() + CONTEXT_FILE_SEPARATOR + CONTEXT_CACHE;
|
||||
CreateDirIfNotExist(dir, MODE);
|
||||
HILOG_DEBUG("ContextImpl::GetCacheDir:%{public}s", dir.c_str());
|
||||
HILOG_DEBUG("dir:%{public}s", dir.c_str());
|
||||
return dir;
|
||||
}
|
||||
|
||||
@ -254,7 +256,7 @@ std::string ContextImpl::GetTempDir()
|
||||
{
|
||||
std::string dir = GetBaseDir() + CONTEXT_TEMP;
|
||||
CreateDirIfNotExist(dir, MODE);
|
||||
HILOG_DEBUG("ContextImpl::GetTempDir:%{public}s", dir.c_str());
|
||||
HILOG_DEBUG("dir:%{public}s", dir.c_str());
|
||||
return dir;
|
||||
}
|
||||
|
||||
@ -307,34 +309,39 @@ std::string ContextImpl::GetFilesDir()
|
||||
{
|
||||
std::string dir = GetBaseDir() + CONTEXT_FILES;
|
||||
CreateDirIfNotExist(dir, MODE);
|
||||
HILOG_DEBUG("ContextImpl::GetFilesDir:%{public}s", dir.c_str());
|
||||
HILOG_DEBUG("dir:%{public}s", dir.c_str());
|
||||
return dir;
|
||||
}
|
||||
|
||||
std::string ContextImpl::GetDistributedFilesDir()
|
||||
{
|
||||
HILOG_DEBUG("ContextImpl::GetDistributedFilesDir");
|
||||
HILOG_DEBUG("called");
|
||||
std::string dir;
|
||||
if (IsCreateBySystemApp()) {
|
||||
dir = CONTEXT_DISTRIBUTEDFILES_BASE_BEFORE + std::to_string(GetCurrentAccountId()) +
|
||||
CONTEXT_DISTRIBUTEDFILES_BASE_MIDDLE + GetBundleName();
|
||||
} else {
|
||||
dir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
if (currArea_ == CONTEXT_ELS[1] || currArea_ == CONTEXT_ELS[2] || currArea_ == CONTEXT_ELS[3]) {
|
||||
//when areamode swith to el3/el4, the distributedfiles dir should be always el2's distributedfilesdir dir
|
||||
dir = CONTEXT_DATA_STORAGE + CONTEXT_ELS[1] + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
} else {
|
||||
dir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
}
|
||||
}
|
||||
CreateDirIfNotExist(dir, 0);
|
||||
HILOG_DEBUG("ContextImpl::GetDistributedFilesDir:%{public}s", dir.c_str());
|
||||
HILOG_DEBUG("dir:%{public}s", dir.c_str());
|
||||
return dir;
|
||||
}
|
||||
|
||||
void ContextImpl::SwitchArea(int mode)
|
||||
{
|
||||
HILOG_DEBUG("ContextImpl::SwitchArea, mode:%{public}d.", mode);
|
||||
HILOG_DEBUG("mode:%{public}d.", mode);
|
||||
if (mode < 0 || mode >= (int)(sizeof(CONTEXT_ELS) / sizeof(CONTEXT_ELS[0]))) {
|
||||
HILOG_ERROR("ContextImpl::SwitchArea, mode is invalid.");
|
||||
return;
|
||||
}
|
||||
currArea_ = CONTEXT_ELS[mode];
|
||||
HILOG_DEBUG("ContextImpl::SwitchArea end, currArea:%{public}s.", currArea_.c_str());
|
||||
HILOG_DEBUG("currArea:%{public}s.", currArea_.c_str());
|
||||
}
|
||||
|
||||
std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &moduleName)
|
||||
@ -344,24 +351,13 @@ std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &mod
|
||||
|
||||
std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &bundleName, const std::string &moduleName)
|
||||
{
|
||||
HILOG_DEBUG("CreateModuleContext begin.");
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("ContextImpl::CreateModuleContext bundleName is empty");
|
||||
HILOG_DEBUG("begin.");
|
||||
if (bundleName.empty() || moduleName.empty()) {
|
||||
HILOG_ERROR("bundleName or moduleName is empty");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (moduleName.empty()) {
|
||||
HILOG_ERROR("ContextImpl::CreateModuleContext moduleName is empty");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int errCode = GetBundleManager();
|
||||
if (errCode != ERR_OK) {
|
||||
HILOG_ERROR("failed, errCode: %{public}d.", errCode);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("ContextImpl::CreateModuleContext length: %{public}zu, bundleName: %{public}s",
|
||||
HILOG_DEBUG("length: %{public}zu, bundleName: %{public}s",
|
||||
(size_t)bundleName.length(), bundleName.c_str());
|
||||
|
||||
int accountId = GetCurrentAccountId();
|
||||
@ -370,24 +366,12 @@ std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &bun
|
||||
}
|
||||
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (bundleName == GetBundleName()) {
|
||||
bundleMgr_->GetBundleInfoForSelf(
|
||||
(static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ABILITY) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo);
|
||||
} else {
|
||||
bundleMgr_->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, accountId);
|
||||
}
|
||||
|
||||
GetBundleInfo(bundleName, bundleInfo, accountId);
|
||||
if (bundleInfo.name.empty() || bundleInfo.applicationInfo.name.empty()) {
|
||||
HILOG_ERROR("ContextImpl::CreateModuleContext GetBundleInfo is error");
|
||||
HILOG_ERROR("GetBundleInfo is error");
|
||||
ErrCode ret = bundleMgr_->GetDependentBundleInfo(bundleName, bundleInfo);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("ContextImpl::CreateModuleContext GetDependentBundleInfo failed:%{public}d", ret);
|
||||
HILOG_ERROR("GetDependentBundleInfo failed:%{public}d", ret);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -400,7 +384,7 @@ std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &bun
|
||||
return hapModuleInfo.moduleName == moduleName;
|
||||
});
|
||||
if (info == bundleInfo.hapModuleInfos.end()) {
|
||||
HILOG_ERROR("ContextImpl::CreateModuleContext moduleName is error.");
|
||||
HILOG_ERROR("moduleName is error.");
|
||||
return nullptr;
|
||||
}
|
||||
appContext->InitHapModuleInfo(*info);
|
||||
@ -460,7 +444,7 @@ int32_t ContextImpl::GetBundleInfo(const std::string &bundleName, AppExecFwk::Bu
|
||||
|
||||
int errCode = GetBundleManager();
|
||||
if (errCode != ERR_OK) {
|
||||
HILOG_ERROR("GetBundleManager failed, errCode: %{public}d.", errCode);
|
||||
HILOG_ERROR("errCode: %{public}d.", errCode);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
@ -482,7 +466,7 @@ int32_t ContextImpl::GetBundleInfo(const std::string &bundleName, AppExecFwk::Bu
|
||||
}
|
||||
|
||||
if (bundleInfo.name.empty() || bundleInfo.applicationInfo.name.empty()) {
|
||||
HILOG_WARN("GetBundleInfo is error");
|
||||
HILOG_WARN("bundleInfo is empty");
|
||||
ErrCode ret = bundleMgr_->GetUninstalledBundleInfo(bundleName, bundleInfo);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("GetUninstalledBundleInfo failed:%{public}d", ret);
|
||||
@ -492,9 +476,35 @@ int32_t ContextImpl::GetBundleInfo(const std::string &bundleName, AppExecFwk::Bu
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void ContextImpl::GetBundleInfo(const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo,
|
||||
const int &accountId)
|
||||
{
|
||||
HILOG_DEBUG("begin");
|
||||
if (bundleMgr_ == nullptr) {
|
||||
int errCode = GetBundleManager();
|
||||
if (errCode != ERR_OK) {
|
||||
HILOG_ERROR("failed, errCode: %{public}d.", errCode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (bundleName == GetBundleName()) {
|
||||
bundleMgr_->GetBundleInfoForSelf(
|
||||
(static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ABILITY) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo);
|
||||
} else {
|
||||
bundleMgr_->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, accountId);
|
||||
}
|
||||
}
|
||||
|
||||
int ContextImpl::GetArea()
|
||||
{
|
||||
HILOG_DEBUG("ContextImpl::GetArea begin");
|
||||
HILOG_DEBUG("begin");
|
||||
int mode = -1;
|
||||
for (int i = 0; i < (int)(sizeof(CONTEXT_ELS) / sizeof(CONTEXT_ELS[0])); i++) {
|
||||
if (currArea_ == CONTEXT_ELS[i]) {
|
||||
@ -503,10 +513,10 @@ int ContextImpl::GetArea()
|
||||
}
|
||||
}
|
||||
if (mode == -1) {
|
||||
HILOG_ERROR("ContextImpl::GetArea not find mode.");
|
||||
HILOG_ERROR("not find mode.");
|
||||
return EL_DEFAULT;
|
||||
}
|
||||
HILOG_DEBUG("ContextImpl::GetArea end");
|
||||
HILOG_DEBUG("end");
|
||||
return mode;
|
||||
}
|
||||
|
||||
@ -524,7 +534,7 @@ std::string ContextImpl::GetBaseDir() const
|
||||
((GetHapModuleInfo() == nullptr) ? "" : GetHapModuleInfo()->moduleName);
|
||||
}
|
||||
|
||||
HILOG_DEBUG("ContextImpl::GetBaseDir:%{public}s", baseDir.c_str());
|
||||
HILOG_DEBUG("Dir:%{public}s", baseDir.c_str());
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
@ -555,12 +565,12 @@ int ContextImpl::GetCurrentActiveAccountId() const
|
||||
}
|
||||
|
||||
if (accountIds.size() == 0) {
|
||||
HILOG_ERROR("ContextImpl::GetCurrentActiveAccountId error, no accounts.");
|
||||
HILOG_ERROR("no accounts.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (accountIds.size() > 1) {
|
||||
HILOG_ERROR("ContextImpl::GetCurrentActiveAccountId error, no current now.");
|
||||
HILOG_ERROR("no current now.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -569,13 +579,13 @@ int ContextImpl::GetCurrentActiveAccountId() const
|
||||
|
||||
std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bundleName)
|
||||
{
|
||||
HILOG_DEBUG("CreateBundleContext begin.");
|
||||
HILOG_DEBUG("begin.");
|
||||
if (parentContext_ != nullptr) {
|
||||
return parentContext_->CreateBundleContext(bundleName);
|
||||
}
|
||||
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("ContextImpl::CreateBundleContext bundleName is empty");
|
||||
HILOG_ERROR("bundleName is empty");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -590,12 +600,12 @@ std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bun
|
||||
if (accountId == 0) {
|
||||
accountId = GetCurrentActiveAccountId();
|
||||
}
|
||||
HILOG_DEBUG("ContextImpl::CreateBundleContext length: %{public}zu, bundleName: %{public}s",
|
||||
HILOG_DEBUG("length: %{public}zu, bundleName: %{public}s",
|
||||
(size_t)bundleName.length(), bundleName.c_str());
|
||||
bundleMgr_->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, accountId);
|
||||
|
||||
if (bundleInfo.name.empty() || bundleInfo.applicationInfo.name.empty()) {
|
||||
HILOG_ERROR("ContextImpl::CreateBundleContext GetBundleInfo is error");
|
||||
HILOG_ERROR("bundleInfo is empty");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -612,7 +622,7 @@ std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bun
|
||||
void ContextImpl::InitResourceManager(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
const std::shared_ptr<ContextImpl> &appContext, bool currentBundle, const std::string& moduleName)
|
||||
{
|
||||
HILOG_DEBUG("InitResourceManager begin, bundleName:%{public}s, moduleName:%{public}s",
|
||||
HILOG_DEBUG("begin, bundleName:%{public}s, moduleName:%{public}s",
|
||||
bundleInfo.name.c_str(), moduleName.c_str());
|
||||
|
||||
if (appContext == nullptr) {
|
||||
@ -625,7 +635,7 @@ void ContextImpl::InitResourceManager(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager = InitOthersResourceManagerInner(
|
||||
bundleInfo, currentBundle, moduleName);
|
||||
if (resourceManager == nullptr) {
|
||||
HILOG_ERROR("ContextImpl::InitResourceManager create resourceManager failed");
|
||||
HILOG_ERROR("create resourceManager failed");
|
||||
return;
|
||||
}
|
||||
appContext->SetResourceManager(resourceManager);
|
||||
@ -748,9 +758,23 @@ void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceMana
|
||||
{
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
HILOG_ERROR("ContextImpl::InitResourceManager create ResConfig failed");
|
||||
HILOG_ERROR("create ResConfig failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetHapModuleInfo() != nullptr && GetApplicationInfo() != nullptr) {
|
||||
std::vector<AppExecFwk::Metadata> metadata = GetHapModuleInfo()->metadata;
|
||||
bool load = std::any_of(metadata.begin(), metadata.end(), [](const auto &metadataItem) {
|
||||
return metadataItem.name == "ContextResourceConfigLoadFromParentTemp" && metadataItem.value == "true";
|
||||
});
|
||||
if (load && GetApplicationInfo()->apiTargetVersion % API_VERSION_MOD >= API11) {
|
||||
std::shared_ptr<Global::Resource::ResourceManager> currentResMgr = GetResourceManager();
|
||||
if (currentResMgr != nullptr) {
|
||||
HILOG_DEBUG("apiVersion: %{public}d, load parent config.", GetApplicationInfo()->apiTargetVersion);
|
||||
currentResMgr->GetResConfig(*resConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(Global::I18n::LocaleConfig::GetSystemLanguage(), status);
|
||||
@ -787,7 +811,7 @@ ErrCode ContextImpl::GetBundleManager()
|
||||
void ContextImpl::SetApplicationInfo(const std::shared_ptr<AppExecFwk::ApplicationInfo> &info)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("ContextImpl::SetApplicationInfo failed, info is empty");
|
||||
HILOG_ERROR("info is empty");
|
||||
return;
|
||||
}
|
||||
applicationInfo_ = info;
|
||||
@ -795,9 +819,9 @@ void ContextImpl::SetApplicationInfo(const std::shared_ptr<AppExecFwk::Applicati
|
||||
|
||||
void ContextImpl::SetResourceManager(const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager)
|
||||
{
|
||||
HILOG_DEBUG("ContextImpl::initResourceManager. Start.");
|
||||
HILOG_DEBUG("Start.");
|
||||
resourceManager_ = resourceManager;
|
||||
HILOG_DEBUG("ContextImpl::initResourceManager. End.");
|
||||
HILOG_DEBUG("End.");
|
||||
}
|
||||
|
||||
std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::GetResourceManager() const
|
||||
@ -844,7 +868,7 @@ void ContextImpl::InitHapModuleInfo(const std::shared_ptr<AppExecFwk::AbilityInf
|
||||
|
||||
hapModuleInfo_ = std::make_shared<AppExecFwk::HapModuleInfo>();
|
||||
if (!bundleMgr_->GetHapModuleInfo(*abilityInfo.get(), *hapModuleInfo_)) {
|
||||
HILOG_ERROR("InitHapModuleInfo: GetHapModuleInfo failed, will retval false value");
|
||||
HILOG_ERROR("GetHapModuleInfo failed, will retval false value");
|
||||
}
|
||||
}
|
||||
|
||||
@ -856,7 +880,7 @@ void ContextImpl::InitHapModuleInfo(const AppExecFwk::HapModuleInfo &hapModuleIn
|
||||
std::shared_ptr<AppExecFwk::HapModuleInfo> ContextImpl::GetHapModuleInfo() const
|
||||
{
|
||||
if (hapModuleInfo_ == nullptr) {
|
||||
HILOG_DEBUG("ContextImpl::GetHapModuleInfo, hapModuleInfo is empty");
|
||||
HILOG_DEBUG("hapModuleInfo is empty");
|
||||
}
|
||||
return hapModuleInfo_;
|
||||
}
|
||||
@ -883,7 +907,7 @@ std::shared_ptr<ApplicationContext> Context::GetApplicationContext()
|
||||
void ContextImpl::SetToken(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (token == nullptr) {
|
||||
HILOG_DEBUG("ContextImpl::SetToken failed, application is nullptr");
|
||||
HILOG_DEBUG("application is nullptr");
|
||||
return;
|
||||
}
|
||||
token_ = token;
|
||||
@ -900,7 +924,7 @@ void ContextImpl::CreateDirIfNotExist(const std::string& dirPath, const mode_t&
|
||||
HILOG_DEBUG("ForceCreateDirectory, dir: %{public}s", dirPath.c_str());
|
||||
bool createDir = OHOS::ForceCreateDirectory(dirPath);
|
||||
if (!createDir) {
|
||||
HILOG_ERROR("createDir: create dir %{public}s failed, errno is %{public}d.", dirPath.c_str(), errno);
|
||||
HILOG_ERROR("create dir %{public}s failed, errno is %{public}d.", dirPath.c_str(), errno);
|
||||
return;
|
||||
}
|
||||
if (mode != 0) {
|
||||
@ -977,7 +1001,7 @@ int ContextImpl::GetOverlayModuleInfos(const std::string &bundleName, const std:
|
||||
[](const AppExecFwk::OverlayModuleInfo& lhs, const AppExecFwk::OverlayModuleInfo& rhs) -> bool {
|
||||
return lhs.priority > rhs.priority;
|
||||
});
|
||||
HILOG_DEBUG("GetOverlayPath end, the size of overlay is: %{public}zu", overlayModuleInfos.size());
|
||||
HILOG_DEBUG("the size of overlay is: %{public}zu", overlayModuleInfos.size());
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -1025,7 +1049,7 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data,
|
||||
const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager, const std::string &bundleName,
|
||||
const std::string &moduleName, const std::string &loadPath)
|
||||
{
|
||||
HILOG_DEBUG("OnOverlayChanged begin.");
|
||||
HILOG_DEBUG("begin.");
|
||||
auto want = data.GetWant();
|
||||
std::string action = want.GetAction();
|
||||
if (action != OVERLAY_STATE_CHANGED) {
|
||||
@ -1086,14 +1110,9 @@ void ContextImpl::ChangeToLocalPath(const std::string &bundleName,
|
||||
|
||||
void ContextImpl::ClearUpApplicationData()
|
||||
{
|
||||
std::string bundleName = GetBundleName();
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("Can not get bundle name");
|
||||
return;
|
||||
}
|
||||
int errCode = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->ClearUpApplicationData(bundleName);
|
||||
int errCode = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->ClearUpApplicationDataBySelf();
|
||||
if (errCode != ERR_OK) {
|
||||
HILOG_ERROR("Delete bundle side user data is fail, bundleName: %{public}s.", bundleName.c_str());
|
||||
HILOG_ERROR("Delete bundle side user data by self is fail.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ napi_value JsApplicationContextUtils::OnCreateBundleContext(napi_env env, NapiCa
|
||||
napi_coerce_to_native_binding_object(env, contextObj, DetachCallbackFunc, AttachBaseContext, workContext, nullptr);
|
||||
napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
HILOG_INFO("Finalizer for weak_ptr bundle context is called");
|
||||
HILOG_DEBUG("Finalizer for weak_ptr bundle context is called");
|
||||
delete static_cast<std::weak_ptr<Context> *>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
@ -116,7 +116,7 @@ napi_value JsApplicationContextUtils::OnCreateBundleContext(napi_env env, NapiCa
|
||||
|
||||
napi_value JsApplicationContextUtils::SwitchArea(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::SwitchArea is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnSwitchArea, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ napi_value JsApplicationContextUtils::OnCreateModuleContext(napi_env env, NapiCa
|
||||
std::string moduleName;
|
||||
std::shared_ptr<Context> moduleContext = nullptr;
|
||||
if (!ConvertFromJsValue(env, info.argv[1], moduleName)) {
|
||||
HILOG_INFO("Parse inner module name.");
|
||||
HILOG_DEBUG("Parse inner module name.");
|
||||
if (!ConvertFromJsValue(env, info.argv[0], moduleName)) {
|
||||
HILOG_ERROR("Parse moduleName failed");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
@ -222,7 +222,7 @@ napi_value JsApplicationContextUtils::OnCreateModuleContext(napi_env env, NapiCa
|
||||
napi_coerce_to_native_binding_object(env, contextObj, DetachCallbackFunc, AttachBaseContext, workContext, nullptr);
|
||||
napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
HILOG_INFO("Finalizer for weak_ptr module context is called");
|
||||
HILOG_DEBUG("Finalizer for weak_ptr module context is called");
|
||||
delete static_cast<std::weak_ptr<Context> *>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
@ -273,7 +273,7 @@ napi_value JsApplicationContextUtils::OnCreateModuleResourceManager(napi_env env
|
||||
|
||||
napi_value JsApplicationContextUtils::GetArea(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetArea is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnGetArea, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ napi_value JsApplicationContextUtils::OnGetArea(napi_env env, NapiCallbackInfo&
|
||||
|
||||
napi_value JsApplicationContextUtils::GetCacheDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetCacheDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnGetCacheDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ napi_value JsApplicationContextUtils::OnGetCacheDir(napi_env env, NapiCallbackIn
|
||||
|
||||
napi_value JsApplicationContextUtils::GetTempDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetTempDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnGetTempDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ napi_value JsApplicationContextUtils::OnGetTempDir(napi_env env, NapiCallbackInf
|
||||
|
||||
napi_value JsApplicationContextUtils::GetResourceDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetResourceDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnGetResourceDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ napi_value JsApplicationContextUtils::OnGetResourceDir(napi_env env, NapiCallbac
|
||||
|
||||
napi_value JsApplicationContextUtils::GetFilesDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetFilesDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnGetFilesDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ napi_value JsApplicationContextUtils::OnGetFilesDir(napi_env env, NapiCallbackIn
|
||||
|
||||
napi_value JsApplicationContextUtils::GetDistributedFilesDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetDistributedFilesDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils,
|
||||
OnGetDistributedFilesDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
@ -376,7 +376,7 @@ napi_value JsApplicationContextUtils::OnGetDistributedFilesDir(napi_env env, Nap
|
||||
|
||||
napi_value JsApplicationContextUtils::GetDatabaseDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetDatabaseDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnGetDatabaseDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ napi_value JsApplicationContextUtils::OnGetDatabaseDir(napi_env env, NapiCallbac
|
||||
|
||||
napi_value JsApplicationContextUtils::GetPreferencesDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetPreferencesDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(
|
||||
env, info, JsApplicationContextUtils, OnGetPreferencesDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
@ -452,7 +452,7 @@ napi_value JsApplicationContextUtils::OnGetGroupDir(napi_env env, NapiCallbackIn
|
||||
|
||||
napi_value JsApplicationContextUtils::GetBundleCodeDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::GetBundleCodeDir is called");
|
||||
HILOG_INFO("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(
|
||||
env, info, JsApplicationContextUtils, OnGetBundleCodeDir, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
@ -648,7 +648,7 @@ napi_value JsApplicationContextUtils::OnGetRunningProcessInformation(napi_env en
|
||||
|
||||
void JsApplicationContextUtils::Finalizer(napi_env env, void *data, void *hint)
|
||||
{
|
||||
HILOG_INFO("JsApplicationContextUtils::Finalizer is called");
|
||||
HILOG_INFO("called");
|
||||
std::unique_ptr<JsApplicationContextUtils>(static_cast<JsApplicationContextUtils *>(data));
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ napi_value JsApplicationContextUtils::UnregisterAbilityLifecycleCallback(
|
||||
napi_value JsApplicationContextUtils::OnRegisterAbilityLifecycleCallback(
|
||||
napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnRegisterAbilityLifecycleCallback is called");
|
||||
HILOG_DEBUG("called");
|
||||
// only support one params
|
||||
if (info.argc != ARGC_ONE) {
|
||||
HILOG_ERROR("Not enough params.");
|
||||
@ -687,14 +687,14 @@ napi_value JsApplicationContextUtils::OnRegisterAbilityLifecycleCallback(
|
||||
callback_ = std::make_shared<JsAbilityLifecycleCallback>(env);
|
||||
int32_t callbackId = callback_->Register(info.argv[INDEX_ZERO]);
|
||||
applicationContext->RegisterAbilityLifecycleCallback(callback_);
|
||||
HILOG_INFO("OnRegisterAbilityLifecycleCallback is end");
|
||||
HILOG_INFO("end");
|
||||
return CreateJsValue(env, callbackId);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::OnUnregisterAbilityLifecycleCallback(
|
||||
napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnUnregisterAbilityLifecycleCallback is called");
|
||||
HILOG_DEBUG("called");
|
||||
int32_t errCode = 0;
|
||||
auto applicationContext = applicationContext_.lock();
|
||||
if (applicationContext == nullptr) {
|
||||
@ -755,7 +755,7 @@ napi_value JsApplicationContextUtils::UnregisterEnvironmentCallback(
|
||||
napi_value JsApplicationContextUtils::OnRegisterEnvironmentCallback(
|
||||
napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("OnRegisterEnvironmentCallback is called");
|
||||
HILOG_DEBUG("called");
|
||||
// only support one params
|
||||
if (info.argc != ARGC_ONE) {
|
||||
HILOG_ERROR("Not enough params.");
|
||||
@ -774,14 +774,14 @@ napi_value JsApplicationContextUtils::OnRegisterEnvironmentCallback(
|
||||
envCallback_ = std::make_shared<JsEnvironmentCallback>(env);
|
||||
int32_t callbackId = envCallback_->Register(info.argv[INDEX_ZERO]);
|
||||
applicationContext->RegisterEnvironmentCallback(envCallback_);
|
||||
HILOG_DEBUG("OnRegisterEnvironmentCallback is end");
|
||||
HILOG_DEBUG("end");
|
||||
return CreateJsValue(env, callbackId);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::OnUnregisterEnvironmentCallback(
|
||||
napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("OnUnregisterEnvironmentCallback is called");
|
||||
HILOG_DEBUG("called");
|
||||
int32_t errCode = 0;
|
||||
auto applicationContext = applicationContext_.lock();
|
||||
if (applicationContext == nullptr) {
|
||||
@ -790,7 +790,7 @@ napi_value JsApplicationContextUtils::OnUnregisterEnvironmentCallback(
|
||||
}
|
||||
int32_t callbackId = -1;
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
HILOG_ERROR("OnUnregisterEnvironmentCallback, Not enough params");
|
||||
HILOG_ERROR("Not enough params");
|
||||
errCode = ERROR_CODE_ONE;
|
||||
} else {
|
||||
napi_get_value_int32(env, info.argv[INDEX_ZERO], &callbackId);
|
||||
@ -810,7 +810,7 @@ napi_value JsApplicationContextUtils::OnUnregisterEnvironmentCallback(
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OnUnregisterEnvironmentCallback begin");
|
||||
HILOG_DEBUG("begin");
|
||||
if (!env_callback->UnRegister(callbackId)) {
|
||||
HILOG_ERROR("call UnRegister failed!");
|
||||
task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "call UnRegister failed!"));
|
||||
@ -838,7 +838,7 @@ napi_value JsApplicationContextUtils::Off(napi_env env, napi_callback_info info)
|
||||
|
||||
napi_value JsApplicationContextUtils::OnOn(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnOn is called");
|
||||
HILOG_INFO("called");
|
||||
|
||||
if (info.argc != ARGC_TWO) {
|
||||
HILOG_ERROR("Not enough params.");
|
||||
@ -883,7 +883,7 @@ napi_value JsApplicationContextUtils::OnOn(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsApplicationContextUtils::OnOff(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnOff is called");
|
||||
HILOG_INFO("called");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("Not enough params");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
@ -957,7 +957,7 @@ napi_value JsApplicationContextUtils::OnOnAbilityLifecycle(
|
||||
callback_ = std::make_shared<JsAbilityLifecycleCallback>(env);
|
||||
int32_t callbackId = callback_->Register(info.argv[1], isSync);
|
||||
applicationContext->RegisterAbilityLifecycleCallback(callback_);
|
||||
HILOG_INFO("OnOnAbilityLifecycle is end");
|
||||
HILOG_INFO("end");
|
||||
return CreateJsValue(env, callbackId);
|
||||
}
|
||||
|
||||
@ -1176,7 +1176,7 @@ napi_value JsApplicationContextUtils::GetApplicationContext(napi_env env, napi_c
|
||||
|
||||
napi_value JsApplicationContextUtils::OnGetApplicationContext(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("GetApplicationContext start");
|
||||
HILOG_DEBUG("called");
|
||||
auto applicationContext = applicationContext_.lock();
|
||||
if (!applicationContext) {
|
||||
HILOG_WARN("applicationContext is already released");
|
||||
@ -1187,7 +1187,7 @@ napi_value JsApplicationContextUtils::OnGetApplicationContext(napi_env env, Napi
|
||||
napi_value value = CreateJsApplicationContext(env);
|
||||
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.ApplicationContext", &value, 1);
|
||||
if (systemModule == nullptr) {
|
||||
HILOG_WARN("OnGetApplicationContext, invalid systemModule.");
|
||||
HILOG_WARN("invalid systemModule.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -1202,7 +1202,7 @@ napi_value JsApplicationContextUtils::OnGetApplicationContext(napi_env env, Napi
|
||||
env, contextObj, DetachCallbackFunc, AttachApplicationContext, workContext, nullptr);
|
||||
napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void *data, void *) {
|
||||
HILOG_INFO("Finalizer for weak_ptr application context is called");
|
||||
HILOG_DEBUG("Finalizer for weak_ptr application context is called");
|
||||
delete static_cast<std::weak_ptr<ApplicationContext> *>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
@ -1220,7 +1220,7 @@ bool JsApplicationContextUtils::CheckCallerIsSystemApp()
|
||||
|
||||
napi_value JsApplicationContextUtils::CreateJsApplicationContext(napi_env env)
|
||||
{
|
||||
HILOG_DEBUG("CreateJsApplicationContext start");
|
||||
HILOG_DEBUG("start");
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
@ -1339,7 +1339,7 @@ napi_value JsApplicationContextUtils::IsAutoStartup(napi_env env, napi_callback_
|
||||
|
||||
napi_value JsApplicationContextUtils::OnRegisterAutoStartupCallback(napi_env env, NapiCallbackInfo &info)
|
||||
{
|
||||
HILOG_DEBUG("OnRegisterAutoStartupCallback Called.");
|
||||
HILOG_DEBUG("called.");
|
||||
if (info.argc < ARGC_TWO) {
|
||||
HILOG_ERROR("The param is invalid.");
|
||||
ThrowTooFewParametersError(env);
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
|
||||
void JsBaseContext::Finalizer(napi_env env, void* data, void* hint)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::Finalizer is called");
|
||||
HILOG_DEBUG("called");
|
||||
std::unique_ptr<JsBaseContext>(static_cast<JsBaseContext*>(data));
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ napi_value JsBaseContext::GetApplicationContext(napi_env env, napi_callback_info
|
||||
|
||||
napi_value JsBaseContext::SwitchArea(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::SwitchArea is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnSwitchArea, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ napi_value JsBaseContext::OnSwitchArea(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::CreateModuleContext(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::CreateModuleContext is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnCreateModuleContext, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ napi_value JsBaseContext::OnCreateModuleResourceManager(napi_env env, NapiCallba
|
||||
|
||||
napi_value JsBaseContext::GetArea(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsBaseContext::GetArea is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetArea, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ napi_value JsBaseContext::OnGetArea(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetCacheDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("JsBaseContext::GetCacheDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetCacheDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ napi_value JsBaseContext::OnGetCacheDir(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetTempDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetTempDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetTempDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ napi_value JsBaseContext::OnGetTempDir(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetResourceDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetResourceDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetResourceDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ napi_value JsBaseContext::OnGetResourceDir(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetFilesDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetFilesDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetFilesDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ napi_value JsBaseContext::OnGetFilesDir(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetDistributedFilesDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetDistributedFilesDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetDistributedFilesDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ napi_value JsBaseContext::OnGetDistributedFilesDir(napi_env env, NapiCallbackInf
|
||||
|
||||
napi_value JsBaseContext::GetDatabaseDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetDatabaseDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetDatabaseDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ napi_value JsBaseContext::OnGetDatabaseDir(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetPreferencesDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetPreferencesDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetPreferencesDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ napi_value JsBaseContext::OnGetGroupDir(napi_env env, NapiCallbackInfo& info)
|
||||
|
||||
napi_value JsBaseContext::GetBundleCodeDir(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG("JsBaseContext::GetBundleCodeDir is called");
|
||||
HILOG_DEBUG("called");
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsBaseContext, OnGetBundleCodeDir, BASE_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ napi_value JsBaseContext::OnCreateBundleContext(napi_env env, NapiCallbackInfo&
|
||||
|
||||
napi_value JsBaseContext::OnGetApplicationContext(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("GetApplicationContext start");
|
||||
HILOG_DEBUG("start");
|
||||
auto context = context_.lock();
|
||||
if (!context) {
|
||||
HILOG_WARN("context is already released");
|
||||
@ -575,7 +575,7 @@ bool JsBaseContext::CheckCallerIsSystemApp()
|
||||
|
||||
napi_value AttachBaseContext(napi_env env, void* value, void* hint)
|
||||
{
|
||||
HILOG_DEBUG("AttachBaseContext");
|
||||
HILOG_DEBUG("called");
|
||||
if (value == nullptr || env == nullptr) {
|
||||
HILOG_WARN("invalid parameter.");
|
||||
return nullptr;
|
||||
@ -610,7 +610,7 @@ napi_value AttachBaseContext(napi_env env, void* value, void* hint)
|
||||
|
||||
napi_value AttachApplicationContext(napi_env env, void* value, void* hint)
|
||||
{
|
||||
HILOG_DEBUG("AttachApplicationContext");
|
||||
HILOG_DEBUG("called");
|
||||
if (value == nullptr || env == nullptr) {
|
||||
HILOG_WARN("invalid parameter.");
|
||||
return nullptr;
|
||||
|
@ -36,7 +36,7 @@ sptr<IRemoteObject> AbilityRecordMgr::GetToken() const
|
||||
void AbilityRecordMgr::SetToken(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::SetToken failed, application is nullptr");
|
||||
HILOG_ERROR("application is nullptr");
|
||||
return;
|
||||
}
|
||||
tokens_ = token;
|
||||
@ -51,12 +51,12 @@ void AbilityRecordMgr::SetToken(const sptr<IRemoteObject> &token)
|
||||
void AbilityRecordMgr::SetEventRunner(const std::shared_ptr<EventRunner> &eventRunner)
|
||||
{
|
||||
if (eventRunner == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::SetEventRunner failed, eventRunner is nullptr");
|
||||
HILOG_ERROR("eventRunner is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> token = GetToken();
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::SetEventRunner failed, token is nullptr");
|
||||
HILOG_ERROR("token is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ void AbilityRecordMgr::SetEventRunner(const std::shared_ptr<EventRunner> &eventR
|
||||
if (abilityInstance != nullptr) {
|
||||
abilityInstance->SetEventRunner(eventRunner);
|
||||
} else {
|
||||
HILOG_WARN("AbilityRecordMgr::setEventRunner failed, ability record is not exists");
|
||||
HILOG_WARN("ability record is not exists");
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,12 +79,12 @@ void AbilityRecordMgr::AddAbilityRecord(
|
||||
const sptr<IRemoteObject> &token, const std::shared_ptr<AbilityLocalRecord> &abilityRecord)
|
||||
{
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::AddAbilityRecord failed, token is nullptr");
|
||||
HILOG_ERROR("token is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::AddAbilityRecord failed, abilityRecord is nullptr");
|
||||
HILOG_ERROR("abilityRecord is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ void AbilityRecordMgr::AddAbilityRecord(
|
||||
void AbilityRecordMgr::RemoveAbilityRecord(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::RemoveAbilityRecord failed, token is nullptr");
|
||||
HILOG_ERROR("token is nullptr");
|
||||
return;
|
||||
}
|
||||
abilityRecords_.erase(token);
|
||||
@ -126,16 +126,16 @@ int AbilityRecordMgr::GetRecordCount() const
|
||||
std::shared_ptr<AbilityLocalRecord> AbilityRecordMgr::GetAbilityItem(const sptr<IRemoteObject> &token) const
|
||||
{
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("AbilityRecordMgr::GetAbilityItem failed, token is nullptr");
|
||||
HILOG_ERROR("token is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto &iter = abilityRecords_.find(token);
|
||||
if (iter != abilityRecords_.end()) {
|
||||
HILOG_INFO("AbilityRecordMgr::GetAbilityItem : the ability found");
|
||||
HILOG_INFO("the ability found");
|
||||
return iter->second;
|
||||
}
|
||||
HILOG_INFO("AbilityRecordMgr::GetAbilityItem : the ability not found");
|
||||
HILOG_WARN("the ability not found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ ApplicationImpl::ApplicationImpl() : curState_(APP_STATE_CREATE), recordId_(0)
|
||||
void ApplicationImpl::SetApplication(const std::shared_ptr<OHOSApplication> &application)
|
||||
{
|
||||
if (application == nullptr) {
|
||||
HILOG_ERROR("ApplicationImpl::SetApplication failed, application is nullptr");
|
||||
HILOG_ERROR("application is nullptr");
|
||||
return;
|
||||
}
|
||||
this->application_ = application;
|
||||
@ -47,13 +47,13 @@ void ApplicationImpl::SetApplication(const std::shared_ptr<OHOSApplication> &app
|
||||
*/
|
||||
bool ApplicationImpl::PerformAppReady()
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::PerformAppReady called");
|
||||
HILOG_DEBUG("called");
|
||||
if (curState_ == APP_STATE_CREATE && application_ != nullptr) {
|
||||
application_->OnStart();
|
||||
curState_ = APP_STATE_READY;
|
||||
return true;
|
||||
}
|
||||
HILOG_ERROR("ApplicationImpl::PerformAppReady error! curState is %{public}d", curState_);
|
||||
HILOG_ERROR("curState is %{public}d", curState_);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -65,13 +65,13 @@ bool ApplicationImpl::PerformAppReady()
|
||||
*/
|
||||
bool ApplicationImpl::PerformForeground()
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::performForeground called");
|
||||
HILOG_DEBUG("called");
|
||||
if (((curState_ == APP_STATE_READY) || (curState_ == APP_STATE_BACKGROUND)) && application_ != nullptr) {
|
||||
application_->OnForeground();
|
||||
curState_ = APP_STATE_FOREGROUND;
|
||||
return true;
|
||||
}
|
||||
HILOG_ERROR("ApplicationImpl::performForeground error! curState is %{public}d", curState_);
|
||||
HILOG_ERROR("curState is %{public}d", curState_);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -83,13 +83,13 @@ bool ApplicationImpl::PerformForeground()
|
||||
*/
|
||||
bool ApplicationImpl::PerformBackground()
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::performBackground called");
|
||||
HILOG_DEBUG("called");
|
||||
if (curState_ == APP_STATE_FOREGROUND && application_ != nullptr) {
|
||||
application_->OnBackground();
|
||||
curState_ = APP_STATE_BACKGROUND;
|
||||
return true;
|
||||
}
|
||||
HILOG_ERROR("ApplicationImpl::performBackground error! curState is %{public}d", curState_);
|
||||
HILOG_ERROR("curState is %{public}d", curState_);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ bool ApplicationImpl::PerformBackground()
|
||||
*/
|
||||
bool ApplicationImpl::PerformTerminate(bool isLastProcess)
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::PerformTerminate called");
|
||||
HILOG_DEBUG("called");
|
||||
if (application_ == nullptr) {
|
||||
HILOG_ERROR("Application instance is nullptr");
|
||||
return false;
|
||||
@ -115,7 +115,7 @@ bool ApplicationImpl::PerformTerminate(bool isLastProcess)
|
||||
curState_ = APP_STATE_TERMINATED;
|
||||
return true;
|
||||
}
|
||||
HILOG_ERROR("ApplicationImpl::performTerminate error! curState is %{public}d", curState_);
|
||||
HILOG_ERROR("curState is %{public}d", curState_);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -127,9 +127,9 @@ bool ApplicationImpl::PerformTerminate(bool isLastProcess)
|
||||
*/
|
||||
void ApplicationImpl::PerformTerminateStrong()
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::PerformTerminateStrong called");
|
||||
HILOG_DEBUG("called");
|
||||
if (application_ == nullptr) {
|
||||
HILOG_ERROR("ApplicationImpl::PerformTerminateStrong: invalid application_.");
|
||||
HILOG_ERROR("invalid application_.");
|
||||
return;
|
||||
}
|
||||
application_->OnTerminate();
|
||||
@ -143,7 +143,7 @@ void ApplicationImpl::PerformTerminateStrong()
|
||||
*/
|
||||
void ApplicationImpl::PerformMemoryLevel(int level)
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::PerformMemoryLevel called");
|
||||
HILOG_DEBUG("called");
|
||||
if (application_ != nullptr) {
|
||||
application_->OnMemoryLevel(level);
|
||||
}
|
||||
@ -157,7 +157,7 @@ void ApplicationImpl::PerformMemoryLevel(int level)
|
||||
*/
|
||||
void ApplicationImpl::PerformConfigurationUpdated(const Configuration &config)
|
||||
{
|
||||
HILOG_DEBUG("ApplicationImpl::PerformConfigurationUpdated called");
|
||||
HILOG_DEBUG("called");
|
||||
if (application_ != nullptr) {
|
||||
application_->OnConfigurationUpdated(config);
|
||||
}
|
||||
|
@ -1294,6 +1294,11 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
options.arkNativeFilePath = bundleInfo.applicationInfo.arkNativeFilePath;
|
||||
options.uid = bundleInfo.applicationInfo.uid;
|
||||
options.apiTargetVersion = appInfo.apiTargetVersion;
|
||||
if (!bundleInfo.hapModuleInfos.empty()) {
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
options.hapModulePath[hapModuleInfo.moduleName] = hapModuleInfo.hapPath;
|
||||
}
|
||||
}
|
||||
auto runtime = AbilityRuntime::Runtime::Create(options);
|
||||
if (!runtime) {
|
||||
HILOG_ERROR("Failed to create runtime");
|
||||
@ -1378,7 +1383,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
// if app's callback has been registered, let app decide whether exit or not.
|
||||
HILOG_ERROR("\n%{public}s is about to exit due to RuntimeError\nError type:%{public}s\n%{public}s",
|
||||
bundleName.c_str(), errorObj.name.c_str(), summary.c_str());
|
||||
DelayedSingleton<AbilityManagerClient>::GetInstance()->RecordAppExitReason(REASON_JS_ERROR);
|
||||
AbilityManagerClient::GetInstance()->RecordAppExitReason(REASON_JS_ERROR);
|
||||
appThread->ScheduleProcessSecurityExit();
|
||||
};
|
||||
(static_cast<AbilityRuntime::JsRuntime&>(*runtime)).RegisterUncaughtExceptionHandler(uncaughtExceptionInfo);
|
||||
@ -1929,14 +1934,17 @@ void MainThread::HandleForegroundApplication()
|
||||
HILOG_ERROR("MainThread::handleForegroundApplication error!");
|
||||
return;
|
||||
}
|
||||
#ifdef IMAGE_PURGEABLE_PIXELMAP
|
||||
PurgeableMem::PurgeableResourceManager::GetInstance().BeginAccessPurgeableMem();
|
||||
#endif
|
||||
|
||||
if (!applicationImpl_->PerformForeground()) {
|
||||
HILOG_ERROR("MainThread::handleForegroundApplication error!, applicationImpl_->PerformForeground() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Start accessing PurgeableMem if the event of foreground is successful.
|
||||
#ifdef IMAGE_PURGEABLE_PIXELMAP
|
||||
PurgeableMem::PurgeableResourceManager::GetInstance().BeginAccessPurgeableMem();
|
||||
#endif
|
||||
|
||||
HILOG_DEBUG("to foreground success, recordId is %{public}d", applicationImpl_->GetRecordId());
|
||||
appMgr_->ApplicationForegrounded(applicationImpl_->GetRecordId());
|
||||
}
|
||||
@ -1955,13 +1963,17 @@ void MainThread::HandleBackgroundApplication()
|
||||
HILOG_ERROR("MainThread::handleBackgroundApplication error!");
|
||||
return;
|
||||
}
|
||||
#ifdef IMAGE_PURGEABLE_PIXELMAP
|
||||
PurgeableMem::PurgeableResourceManager::GetInstance().EndAccessPurgeableMem();
|
||||
#endif
|
||||
|
||||
if (!applicationImpl_->PerformBackground()) {
|
||||
HILOG_ERROR("MainThread::handleForegroundApplication error!, applicationImpl_->PerformBackground() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// End accessing PurgeableMem if the event of background is successful.
|
||||
#ifdef IMAGE_PURGEABLE_PIXELMAP
|
||||
PurgeableMem::PurgeableResourceManager::GetInstance().EndAccessPurgeableMem();
|
||||
#endif
|
||||
|
||||
appMgr_->ApplicationBackgrounded(applicationImpl_->GetRecordId());
|
||||
}
|
||||
|
||||
@ -2227,7 +2239,7 @@ void MainThread::Start()
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("LoadLifecycle: MainThread start come.");
|
||||
|
||||
if (AAFwk::AppUtils::GetInstance().JudgePCDevice()) {
|
||||
if (AAFwk::AppUtils::GetInstance().isMultiProcessModel()) {
|
||||
ChildProcessInfo info;
|
||||
if (IsStartChild(info)) {
|
||||
ChildMainThread::Start(info);
|
||||
@ -2857,7 +2869,7 @@ std::vector<std::string> MainThread::GetRemoveOverlayPaths(const std::vector<Ove
|
||||
|
||||
int32_t MainThread::ScheduleChangeAppGcState(int32_t state)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
HILOG_DEBUG("called, state is %{public}d.", state);
|
||||
if (mainHandler_ == nullptr) {
|
||||
HILOG_ERROR("mainHandler is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
@ -46,7 +46,7 @@ constexpr char MARK_SYMBOL[] = "_useless";
|
||||
|
||||
OHOSApplication::OHOSApplication()
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::OHOSApplication call constructor.");
|
||||
HILOG_DEBUG("called");
|
||||
abilityLifecycleCallbacks_.clear();
|
||||
elementsCallbacks_.clear();
|
||||
}
|
||||
@ -65,7 +65,7 @@ OHOSApplication::~OHOSApplication()
|
||||
|
||||
void OHOSApplication::DispatchAbilitySavedState(const PacMap &outState)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::dispatchAbilitySavedState: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilitySaveState(outState);
|
||||
@ -80,7 +80,7 @@ void OHOSApplication::DispatchAbilitySavedState(const PacMap &outState)
|
||||
*/
|
||||
void OHOSApplication::OnForeground()
|
||||
{
|
||||
HILOG_DEBUG("NotifyApplicationState::OnForeground begin");
|
||||
HILOG_DEBUG("begin");
|
||||
if (abilityRuntimeContext_) {
|
||||
abilityRuntimeContext_->NotifyApplicationForeground();
|
||||
}
|
||||
@ -100,7 +100,7 @@ void OHOSApplication::OnForeground()
|
||||
*/
|
||||
void OHOSApplication::OnBackground()
|
||||
{
|
||||
HILOG_DEBUG("NotifyApplicationState::OnBackground begin");
|
||||
HILOG_DEBUG("begin");
|
||||
if (abilityRuntimeContext_) {
|
||||
abilityRuntimeContext_->NotifyApplicationBackground();
|
||||
}
|
||||
@ -115,7 +115,7 @@ void OHOSApplication::OnBackground()
|
||||
|
||||
void OHOSApplication::DumpApplication()
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::Dump called");
|
||||
HILOG_DEBUG("called");
|
||||
// create and initialize abilityInfos
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = nullptr;
|
||||
std::shared_ptr<AbilityLocalRecord> record = nullptr;
|
||||
@ -164,13 +164,13 @@ void OHOSApplication::DumpApplication()
|
||||
*/
|
||||
void OHOSApplication::SetRuntime(std::unique_ptr<AbilityRuntime::Runtime>&& runtime)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::SetRuntime begin");
|
||||
HILOG_DEBUG("begin");
|
||||
if (runtime == nullptr) {
|
||||
HILOG_ERROR("OHOSApplication::SetRuntime failed, runtime is empty");
|
||||
return;
|
||||
}
|
||||
runtime_ = std::move(runtime);
|
||||
HILOG_DEBUG("OHOSApplication::SetRuntime end");
|
||||
HILOG_DEBUG("end");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +181,7 @@ void OHOSApplication::SetRuntime(std::unique_ptr<AbilityRuntime::Runtime>&& runt
|
||||
void OHOSApplication::SetApplicationContext(
|
||||
const std::shared_ptr<AbilityRuntime::ApplicationContext> &abilityRuntimeContext)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::SetApplicationContext");
|
||||
HILOG_DEBUG("called");
|
||||
if (abilityRuntimeContext == nullptr) {
|
||||
HILOG_ERROR("OHOSApplication::SetApplicationContext failed, context is empty");
|
||||
return;
|
||||
@ -206,7 +206,7 @@ void OHOSApplication::SetApplicationContext(
|
||||
*/
|
||||
void OHOSApplication::SetAbilityRecordMgr(const std::shared_ptr<AbilityRecordMgr> &abilityRecordMgr)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::SetAbilityRecordMgr");
|
||||
HILOG_DEBUG("called");
|
||||
if (abilityRecordMgr == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::SetAbilityRecordMgr failed, abilityRecordMgr is nullptr");
|
||||
return;
|
||||
@ -222,10 +222,10 @@ void OHOSApplication::SetAbilityRecordMgr(const std::shared_ptr<AbilityRecordMgr
|
||||
*/
|
||||
void OHOSApplication::RegisterAbilityLifecycleCallbacks(const std::shared_ptr<AbilityLifecycleCallbacks> &callBack)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::RegisterAbilityLifecycleCallbacks: called");
|
||||
HILOG_DEBUG("called");
|
||||
|
||||
if (callBack == nullptr) {
|
||||
HILOG_DEBUG("OHOSApplication::RegisterAbilityLifecycleCallbacks: observer is null");
|
||||
HILOG_DEBUG("observer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -240,10 +240,10 @@ void OHOSApplication::RegisterAbilityLifecycleCallbacks(const std::shared_ptr<Ab
|
||||
*/
|
||||
void OHOSApplication::UnregisterAbilityLifecycleCallbacks(const std::shared_ptr<AbilityLifecycleCallbacks> &callBack)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::UnregisterAbilityLifecycleCallbacks: called");
|
||||
HILOG_DEBUG("called");
|
||||
|
||||
if (callBack == nullptr) {
|
||||
HILOG_DEBUG("OHOSApplication::UnregisterAbilityLifecycleCallbacks: observer is null");
|
||||
HILOG_DEBUG("observer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -259,11 +259,11 @@ void OHOSApplication::UnregisterAbilityLifecycleCallbacks(const std::shared_ptr<
|
||||
void OHOSApplication::OnAbilityStart(const std::shared_ptr<AbilityRuntime::UIAbility> &ability)
|
||||
{
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::OnAbilityStart failed, ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnAbilityStart: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilityStart(ability);
|
||||
@ -280,11 +280,11 @@ void OHOSApplication::OnAbilityStart(const std::shared_ptr<AbilityRuntime::UIAbi
|
||||
void OHOSApplication::OnAbilityInactive(const std::shared_ptr<AbilityRuntime::UIAbility> &ability)
|
||||
{
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::OnAbilityInactive failed, ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnAbilityInactive: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilityInactive(ability);
|
||||
@ -301,11 +301,11 @@ void OHOSApplication::OnAbilityInactive(const std::shared_ptr<AbilityRuntime::UI
|
||||
void OHOSApplication::OnAbilityBackground(const std::shared_ptr<AbilityRuntime::UIAbility> &ability)
|
||||
{
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::OnAbilityBackground failed, ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnAbilityBackground: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilityBackground(ability);
|
||||
@ -322,11 +322,11 @@ void OHOSApplication::OnAbilityBackground(const std::shared_ptr<AbilityRuntime::
|
||||
void OHOSApplication::OnAbilityForeground(const std::shared_ptr<AbilityRuntime::UIAbility> &ability)
|
||||
{
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::OnAbilityForeground failed, ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnAbilityForeground: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilityForeground(ability);
|
||||
@ -343,11 +343,11 @@ void OHOSApplication::OnAbilityForeground(const std::shared_ptr<AbilityRuntime::
|
||||
void OHOSApplication::OnAbilityActive(const std::shared_ptr<AbilityRuntime::UIAbility> &ability)
|
||||
{
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::OnAbilityActive failed, ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnAbilityActive: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilityActive(ability);
|
||||
@ -364,11 +364,11 @@ void OHOSApplication::OnAbilityActive(const std::shared_ptr<AbilityRuntime::UIAb
|
||||
void OHOSApplication::OnAbilityStop(const std::shared_ptr<AbilityRuntime::UIAbility> &ability)
|
||||
{
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::OnAbilityStop failed, ability is nullptr");
|
||||
HILOG_ERROR("ability is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnAbilityStop: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : abilityLifecycleCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnAbilityStop(ability);
|
||||
@ -384,10 +384,10 @@ void OHOSApplication::OnAbilityStop(const std::shared_ptr<AbilityRuntime::UIAbil
|
||||
*/
|
||||
void OHOSApplication::RegisterElementsCallbacks(const std::shared_ptr<ElementsCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::RegisterElementsCallbacks: called");
|
||||
HILOG_DEBUG("called");
|
||||
|
||||
if (callback == nullptr) {
|
||||
HILOG_DEBUG("OHOSApplication::RegisterElementsCallbacks: observer is null");
|
||||
HILOG_DEBUG("observer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -402,10 +402,10 @@ void OHOSApplication::RegisterElementsCallbacks(const std::shared_ptr<ElementsCa
|
||||
*/
|
||||
void OHOSApplication::UnregisterElementsCallbacks(const std::shared_ptr<ElementsCallback> &callback)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::UnregisterElementsCallbacks: called");
|
||||
HILOG_DEBUG("called");
|
||||
|
||||
if (callback == nullptr) {
|
||||
HILOG_DEBUG("OHOSApplication::UnregisterElementsCallbacks: observer is null");
|
||||
HILOG_DEBUG("observer is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -420,7 +420,7 @@ void OHOSApplication::UnregisterElementsCallbacks(const std::shared_ptr<Elements
|
||||
*/
|
||||
void OHOSApplication::OnConfigurationUpdated(const Configuration &config)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::OnConfigurationUpdated: called");
|
||||
HILOG_DEBUG("called");
|
||||
if (!abilityRecordMgr_ || !configuration_) {
|
||||
HILOG_DEBUG("abilityRecordMgr_ or configuration_ is null");
|
||||
return;
|
||||
@ -461,7 +461,7 @@ void OHOSApplication::OnConfigurationUpdated(const Configuration &config)
|
||||
|
||||
// Notify all abilities
|
||||
HILOG_INFO(
|
||||
"Number of ability to be notified : [%{public}d]", static_cast<int>(abilityRecordMgr_->GetRecordCount()));
|
||||
"recordCount: [%{public}d]", static_cast<int>(abilityRecordMgr_->GetRecordCount()));
|
||||
for (const auto &abilityToken : abilityRecordMgr_->GetAllTokens()) {
|
||||
auto abilityRecord = abilityRecordMgr_->GetAbilityItem(abilityToken);
|
||||
if (abilityRecord && abilityRecord->GetAbilityThread()) {
|
||||
@ -470,7 +470,7 @@ void OHOSApplication::OnConfigurationUpdated(const Configuration &config)
|
||||
}
|
||||
|
||||
// Notify AbilityStage
|
||||
HILOG_INFO("Number of abilityStage to be notified : [%{public}zu]", abilityStages_.size());
|
||||
HILOG_INFO("abilityStages size: [%{public}zu]", abilityStages_.size());
|
||||
for (auto it = abilityStages_.begin(); it != abilityStages_.end(); it++) {
|
||||
auto abilityStage = it->second;
|
||||
if (abilityStage) {
|
||||
@ -504,7 +504,7 @@ void OHOSApplication::OnConfigurationUpdated(const Configuration &config)
|
||||
*/
|
||||
void OHOSApplication::OnMemoryLevel(int level)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::OnMemoryLevel: called");
|
||||
HILOG_DEBUG("called");
|
||||
|
||||
if (abilityRecordMgr_) {
|
||||
HILOG_DEBUG("Number of ability to be notified : [%{public}d]", abilityRecordMgr_->GetRecordCount());
|
||||
@ -524,7 +524,7 @@ void OHOSApplication::OnMemoryLevel(int level)
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_DEBUG("OHOSApplication::OnMemoryLevel: called");
|
||||
HILOG_DEBUG("called");
|
||||
for (auto callback : elementsCallbacks_) {
|
||||
if (callback != nullptr) {
|
||||
callback->OnMemoryLevel(level);
|
||||
@ -541,7 +541,7 @@ void OHOSApplication::OnMemoryLevel(int level)
|
||||
*/
|
||||
void OHOSApplication::OnStart()
|
||||
{
|
||||
HILOG_DEBUG("OnStart called.");
|
||||
HILOG_DEBUG("called");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -550,7 +550,7 @@ void OHOSApplication::OnStart()
|
||||
*/
|
||||
void OHOSApplication::OnTerminate()
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::OnTerminate: called");
|
||||
HILOG_DEBUG("called");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -570,12 +570,12 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("AddAbilityStage:abilityRecord is nullptr");
|
||||
HILOG_ERROR("abilityRecord is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
const std::shared_ptr<AbilityInfo> &abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
HILOG_ERROR("AddAbilityStage:abilityInfo is nullptr");
|
||||
HILOG_ERROR("abilityInfo is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
std::string moduleName = abilityInfo->moduleName;
|
||||
@ -588,7 +588,7 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
stageContext->SetConfiguration(GetConfiguration());
|
||||
std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfo = stageContext->GetHapModuleInfo();
|
||||
if (hapModuleInfo == nullptr) {
|
||||
HILOG_ERROR("AddAbilityStage:hapModuleInfo is nullptr");
|
||||
HILOG_ERROR("hapModuleInfo is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -612,7 +612,7 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
}
|
||||
const sptr<IRemoteObject> &token = abilityRecord->GetToken();
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("AddAbilityStage:token is null");
|
||||
HILOG_ERROR("token is null");
|
||||
return nullptr;
|
||||
}
|
||||
abilityStage->AddAbility(token, abilityRecord);
|
||||
@ -628,10 +628,10 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
*/
|
||||
void OHOSApplication::UpdateApplicationInfoInstalled(const AppExecFwk::ApplicationInfo &appInfo)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::UpdateApplicationInfoInstalled");
|
||||
HILOG_DEBUG("called");
|
||||
|
||||
if (abilityRuntimeContext_ == nullptr) {
|
||||
HILOG_ERROR("OHOSApplication::UpdateApplicationInfoInstalled abilityRuntimeContext_ is nullptr.");
|
||||
HILOG_ERROR("abilityRuntimeContext_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -640,19 +640,19 @@ void OHOSApplication::UpdateApplicationInfoInstalled(const AppExecFwk::Applicati
|
||||
|
||||
bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::AddAbilityStage");
|
||||
HILOG_DEBUG("called");
|
||||
if (abilityRuntimeContext_ == nullptr) {
|
||||
HILOG_ERROR("OHOSApplication::AddAbilityStage abilityRuntimeContext_ is nullptr.");
|
||||
HILOG_ERROR("abilityRuntimeContext_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (runtime_ == nullptr) {
|
||||
HILOG_ERROR("OHOSApplication::AddAbilityStage abilityRuntimeContext_ is nullptr.");
|
||||
HILOG_ERROR("runtime_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilityStages_.find(hapModuleInfo.moduleName) != abilityStages_.end()) {
|
||||
HILOG_ERROR("OHOSApplication::%{public}s: object already exists ", __func__);
|
||||
HILOG_ERROR("object already exists ");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -662,7 +662,7 @@ bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModule
|
||||
stageContext->SetConfiguration(GetConfiguration());
|
||||
auto moduleInfo = stageContext->GetHapModuleInfo();
|
||||
if (moduleInfo == nullptr) {
|
||||
HILOG_ERROR("OHOSApplication::%{public}s: moduleInfo is nullptr", __func__);
|
||||
HILOG_ERROR("moduleInfo is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModule
|
||||
Want want;
|
||||
abilityStage->OnCreate(want);
|
||||
abilityStages_[hapModuleInfo.moduleName] = abilityStage;
|
||||
HILOG_ERROR("OHOSApplication::%{public}s: abilityStage insert and initialization", __func__);
|
||||
HILOG_ERROR("abilityStage insert and initialization");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -684,11 +684,11 @@ void OHOSApplication::CleanAbilityStage(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<AbilityInfo> &abilityInfo)
|
||||
{
|
||||
if (abilityInfo == nullptr) {
|
||||
HILOG_ERROR("CleanAbilityStage:abilityInfo is nullptr");
|
||||
HILOG_ERROR("abilityInfo is nullptr");
|
||||
return;
|
||||
}
|
||||
if (token == nullptr) {
|
||||
HILOG_ERROR("CleanAbilityStage:token is nullptr");
|
||||
HILOG_ERROR("token is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string moduleName = abilityInfo->moduleName;
|
||||
@ -706,7 +706,7 @@ void OHOSApplication::CleanAbilityStage(const sptr<IRemoteObject> &token,
|
||||
|
||||
void OHOSApplication::DoCleanWorkAfterStageCleaned(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
HILOG_INFO("DoCleanWorkAfterStageCleaned language: %{public}s.", abilityInfo.srcLanguage.c_str());
|
||||
HILOG_INFO("language: %{public}s.", abilityInfo.srcLanguage.c_str());
|
||||
if (runtime_) {
|
||||
runtime_->DoCleanWorkAfterStageCleaned();
|
||||
}
|
||||
@ -731,7 +731,7 @@ void OHOSApplication::SetConfiguration(const Configuration &config)
|
||||
|
||||
void OHOSApplication::ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName, std::string &flag)
|
||||
{
|
||||
HILOG_DEBUG("OHOSApplication::ScheduleAcceptWant: called");
|
||||
HILOG_DEBUG("called");
|
||||
auto iter = abilityStages_.find(moduleName);
|
||||
if (iter != abilityStages_.end()) {
|
||||
auto abilityStage = iter->second;
|
||||
|
@ -204,7 +204,7 @@ int AppfreezeInner::NotifyANR(const FaultData& faultData)
|
||||
faultData.errorObject.name.c_str(), pid, applicationInfo->bundleName.c_str());
|
||||
|
||||
// move this call before force stop app ? such as merge to NotifyAppFault ?
|
||||
DelayedSingleton<AbilityManagerClient>::GetInstance()->RecordAppExitReason(REASON_APP_FREEZE);
|
||||
AbilityManagerClient::GetInstance()->RecordAppExitReason(REASON_APP_FREEZE);
|
||||
int ret = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->NotifyAppFault(faultData);
|
||||
if (ret != 0) {
|
||||
HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::AAFWK, faultData.errorObject.name,
|
||||
|
@ -93,6 +93,9 @@ napi_value CreateJsConfiguration(napi_env env, const AppExecFwk::Configuration&
|
||||
configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE)));
|
||||
napi_set_named_property(env, object, "colorMode", CreateJsValue(env,
|
||||
ConvertColorMode(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE))));
|
||||
|
||||
napi_set_named_property(env, object, "time24", CreateJsValue(env,
|
||||
ConvertTimeFormat(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_HOUR))));
|
||||
|
||||
int32_t displayId = ConvertDisplayId(configuration.GetItem(ConfigurationInner::APPLICATION_DISPLAYID));
|
||||
std::string direction = configuration.GetItem(displayId, ConfigurationInner::APPLICATION_DIRECTION);
|
||||
|
@ -160,6 +160,10 @@ std::string JsModuleReader::GetPresetAppHapPath(const std::string& inputPath, co
|
||||
}
|
||||
std::string tmpPath = inputPath.substr(inputPath.find_first_of("/") + 1);
|
||||
const std::string sharedBundleName = tmpPath.substr(0, tmpPath.find_first_of("/"));
|
||||
if (baseSharedBundleInfos.size() == 0) {
|
||||
presetAppHapPath = "/system/app/appServiceFwk/" + sharedBundleName + "/" + moduleName + ".hsp";
|
||||
return presetAppHapPath;
|
||||
}
|
||||
for (const auto &info : baseSharedBundleInfos) {
|
||||
if ((info.bundleName == sharedBundleName) && (info.moduleName == moduleName)) {
|
||||
presetAppHapPath = info.hapPath;
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
static constexpr char ABS_DATA_CODE_PATH[] = "/data/app/el1/bundle/public/";
|
||||
static constexpr char BUNDLE[] = "bundle/";
|
||||
static constexpr char MERGE_ABC_PATH[] = "ets/modules.abc";
|
||||
static constexpr char SYS_ABS_CODE_PATH[] = "/system/app/appServiceFwk/";
|
||||
static constexpr char SHARED_FILE_SUFFIX[] = ".hsp";
|
||||
JsModuleReader(const std::string& bundleName, const std::string& hapPath, bool isFormRender = false);
|
||||
~JsModuleReader() = default;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
|
||||
#include <atomic>
|
||||
@ -88,6 +89,13 @@ constexpr char MERGE_ABC_PATH[] = "/ets/modules.abc";
|
||||
constexpr char BUNDLE_INSTALL_PATH[] = "/data/storage/el1/bundle/";
|
||||
constexpr const char* PERMISSION_RUN_ANY_CODE = "ohos.permission.RUN_ANY_CODE";
|
||||
|
||||
const std::string SYSTEM_KITS_CONFIG_PATH = "/system/etc/system_kits_config.json";
|
||||
|
||||
const std::string SYSTEM_KITS = "systemkits";
|
||||
const std::string NAMESPACE = "namespace";
|
||||
const std::string TARGET_OHM = "targetohm";
|
||||
const std::string SINCE_VERSION = "sinceVersion";
|
||||
|
||||
static auto PermissionCheckFunc = []() {
|
||||
Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
|
||||
|
||||
@ -355,7 +363,7 @@ void JsRuntime::StartProfiler(
|
||||
}
|
||||
|
||||
HILOG_DEBUG("profiler:%{public}d interval:%{public}d.", profiler, interval);
|
||||
jsEnv_->StartProfiler(ARK_DEBUGGER_LIB_PATH, instanceId_, profiler, interval, gettid());
|
||||
jsEnv_->StartProfiler(ARK_DEBUGGER_LIB_PATH, instanceId_, profiler, interval, gettid(), isDebugApp);
|
||||
}
|
||||
|
||||
bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer)
|
||||
@ -489,7 +497,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(
|
||||
HILOG_DEBUG("JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
if (env == nullptr) {
|
||||
HILOG_INFO("JsRuntime::LoadSystemModule: invalid engine.");
|
||||
return std::unique_ptr<NativeReference>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value globalObj = nullptr;
|
||||
@ -516,7 +524,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(
|
||||
napi_new_instance(env, classValue, argc, argv, &instanceValue);
|
||||
if (instanceValue == nullptr) {
|
||||
HILOG_ERROR("Failed to create object instance");
|
||||
return std::unique_ptr<NativeReference>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_ref resultRef = nullptr;
|
||||
@ -638,6 +646,16 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
panda::JSNApi::SetHostResolveBufferTracker(
|
||||
vm, JsModuleReader(options.bundleName, options.hapPath, options.isUnique));
|
||||
isModular = !panda::JSNApi::IsBundle(vm);
|
||||
panda::JSNApi::SetSearchHapPathTracker(
|
||||
vm, [options](const std::string moduleName, std::string &hapPath) -> bool {
|
||||
if (options.hapModulePath.find(moduleName) == options.hapModulePath.end()) {
|
||||
return false;
|
||||
}
|
||||
hapPath = options.hapModulePath.find(moduleName)->second;
|
||||
return true;
|
||||
});
|
||||
std::vector<panda::HmsMap> systemKitsMap = GetSystemKitsMap(apiTargetVersion_);
|
||||
panda::JSNApi::SetHmsModuleList(vm, systemKitsMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1351,5 +1369,63 @@ void JsRuntime::SetDeviceDisconnectCallback(const std::function<bool()> &cb)
|
||||
CHECK_POINTER(jsEnv_);
|
||||
jsEnv_->SetDeviceDisconnectCallback(cb);
|
||||
}
|
||||
|
||||
std::vector<panda::HmsMap> JsRuntime::GetSystemKitsMap(uint32_t version)
|
||||
{
|
||||
std::vector<panda::HmsMap> systemKitsMap;
|
||||
nlohmann::json jsonBuf;
|
||||
if (access(SYSTEM_KITS_CONFIG_PATH.c_str(), F_OK) != 0) {
|
||||
return systemKitsMap;
|
||||
}
|
||||
|
||||
std::fstream in;
|
||||
char errBuf[256];
|
||||
errBuf[0] = '\0';
|
||||
in.open(SYSTEM_KITS_CONFIG_PATH, std::ios_base::in);
|
||||
if (!in.is_open()) {
|
||||
strerror_r(errno, errBuf, sizeof(errBuf));
|
||||
return systemKitsMap;
|
||||
}
|
||||
|
||||
in.seekg(0, std::ios::end);
|
||||
int64_t size = in.tellg();
|
||||
if (size <= 0) {
|
||||
HILOG_ERROR("the file is an empty file");
|
||||
in.close();
|
||||
return systemKitsMap;
|
||||
}
|
||||
|
||||
in.seekg(0, std::ios::beg);
|
||||
jsonBuf = nlohmann::json::parse(in, nullptr, false);
|
||||
in.close();
|
||||
if (jsonBuf.is_discarded()) {
|
||||
HILOG_ERROR("bad profile file");
|
||||
return systemKitsMap;
|
||||
}
|
||||
|
||||
if (!jsonBuf.contains(SYSTEM_KITS)) {
|
||||
HILOG_ERROR("json config doesn't contain systemkits.");
|
||||
return systemKitsMap;
|
||||
}
|
||||
for (auto &item : jsonBuf.at(SYSTEM_KITS).items()) {
|
||||
nlohmann::json& jsonObject = item.value();
|
||||
if (!jsonObject.contains(NAMESPACE) || !jsonObject.at(NAMESPACE).is_string() ||
|
||||
!jsonObject.contains(TARGET_OHM) || !jsonObject.at(TARGET_OHM).is_string() ||
|
||||
!jsonObject.contains(SINCE_VERSION) || !jsonObject.at(SINCE_VERSION).is_number()) {
|
||||
continue;
|
||||
}
|
||||
uint32_t sinceVersion = jsonObject.at(SINCE_VERSION).get<uint32_t>();
|
||||
if (version >= sinceVersion) {
|
||||
panda::HmsMap hmsMap = {
|
||||
.originalPath = jsonObject.at(NAMESPACE).get<std::string>(),
|
||||
.targetPath = jsonObject.at(TARGET_OHM).get<std::string>(),
|
||||
.sinceVersion = sinceVersion
|
||||
};
|
||||
systemKitsMap.emplace_back(hmsMap);
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("The size of the map is %{public}zu", systemKitsMap.size());
|
||||
return systemKitsMap;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -97,8 +97,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
};
|
||||
panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, needBreakPoint};
|
||||
auto vm = const_cast<EcmaVM*>(arkNativeEngine->GetEcmaVm());
|
||||
panda::JSNApi::NotifyDebugMode(
|
||||
instanceId, vm, ARK_DEBUGGER_LIB_PATH, debugOption, instanceId, workerPostTask, g_debugApp, needBreakPoint);
|
||||
panda::JSNApi::NotifyDebugMode(instanceId, vm, debugOption, instanceId, workerPostTask, g_debugApp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,8 @@
|
||||
#define ENV_LOG_TAG "JsEnv"
|
||||
#endif
|
||||
|
||||
#ifdef LOG_LABEL
|
||||
#undef LOG_LABEL
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
static constexpr HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, ENV_LOG_DOMAIN, ENV_LOG_TAG};
|
||||
void JsEnvLogger(JsEnv::JsEnvLogLevel level, const char* fileName, const char* functionName, int line,
|
||||
const char* fmt, ...)
|
||||
{
|
||||
@ -43,22 +38,28 @@ void JsEnvLogger(JsEnv::JsEnvLogLevel level, const char* fileName, const char* f
|
||||
va_start(printArgs, fmt);
|
||||
switch (level) {
|
||||
case JsEnv::JsEnvLogLevel::DEBUG:
|
||||
HiviewDFX::HiLog::Debug(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_DEBUG, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnv::JsEnvLogLevel::INFO:
|
||||
HiviewDFX::HiLog::Info(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_INFO, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnv::JsEnvLogLevel::WARN:
|
||||
HiviewDFX::HiLog::Warn(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_WARN, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnv::JsEnvLogLevel::ERROR:
|
||||
HiviewDFX::HiLog::Error(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_ERROR, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnv::JsEnvLogLevel::FATAL:
|
||||
HiviewDFX::HiLog::Fatal(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_FATAL, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
default:
|
||||
HiviewDFX::HiLog::Info(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_INFO, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
}
|
||||
va_end(printArgs);
|
||||
|
@ -33,11 +33,7 @@ void OHOSLoopHandler::OnTriggered()
|
||||
{
|
||||
HILOG_DEBUG("OHOSLoopHandler::OnTriggered is triggered");
|
||||
|
||||
auto fd = uv_backend_fd(uvLoop_);
|
||||
struct epoll_event ev;
|
||||
do {
|
||||
uv_run(uvLoop_, UV_RUN_NOWAIT);
|
||||
} while (epoll_wait(fd, &ev, 1, 0) > 0);
|
||||
uv_run(uvLoop_, UV_RUN_NOWAIT);
|
||||
|
||||
auto eventHandler = GetOwner();
|
||||
if (!eventHandler) {
|
||||
@ -74,4 +70,4 @@ void OHOSLoopHandler::OnTriggered()
|
||||
haveTimerTask_ = true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -20,8 +20,6 @@ ability_manager_headers = {
|
||||
"ability_manager_interface.h",
|
||||
"ability_running_info.h",
|
||||
"ability_scheduler_interface.h",
|
||||
"erms_mgr_interface.h",
|
||||
"erms_mgr_param.h",
|
||||
"extension_running_info.h",
|
||||
"lifecycle_state_info.h",
|
||||
"ability_state.h",
|
||||
|
@ -39,7 +39,6 @@ using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
|
||||
*/
|
||||
class AbilityManagerClient {
|
||||
public:
|
||||
AbilityManagerClient();
|
||||
virtual ~AbilityManagerClient();
|
||||
static std::shared_ptr<AbilityManagerClient> GetInstance();
|
||||
|
||||
@ -1381,6 +1380,9 @@ public:
|
||||
void UpdateSessionInfoBySCB(const std::vector<SessionInfo> &sessionInfos, int32_t userId);
|
||||
|
||||
private:
|
||||
AbilityManagerClient();
|
||||
DISALLOW_COPY_AND_MOVE(AbilityManagerClient);
|
||||
|
||||
class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
AbilityMgrDeathRecipient() = default;
|
||||
@ -1394,7 +1396,8 @@ private:
|
||||
void ResetProxy(wptr<IRemoteObject> remote);
|
||||
void HandleDlpApp(Want &want);
|
||||
|
||||
static std::recursive_mutex mutex_;
|
||||
static std::once_flag singletonFlag_;
|
||||
std::recursive_mutex mutex_;
|
||||
static std::shared_ptr<AbilityManagerClient> instance_;
|
||||
sptr<IAbilityManager> proxy_;
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_;
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_ERMS_MGR_INTERFACE_H
|
||||
#define OHOS_ABILITY_RUNTIME_ERMS_MGR_INTERFACE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "erms_mgr_param.h"
|
||||
#include "parcel.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
using AbilityInfo = OHOS::AppExecFwk::AbilityInfo;
|
||||
using ExtensionAbilityInfo = OHOS::AppExecFwk::ExtensionAbilityInfo;
|
||||
|
||||
// when AG support the SA, this file needs to be removed.
|
||||
class IEcologicalRuleManager : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
IEcologicalRuleManager() = default;
|
||||
virtual ~IEcologicalRuleManager() = default;
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IEcologicalRuleManagerService");
|
||||
|
||||
virtual int32_t QueryFreeInstallExperience(const Want &want,
|
||||
const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t EvaluateResolveInfos(const Want &want, const ErmsParams::CallerInfo &callerInfo, int32_t type,
|
||||
std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> extensionInfos)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t QueryStartExperience(const Want &want,
|
||||
const ErmsParams::CallerInfo &callerInfo, ErmsParams::ExperienceRule &rule)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t QueryPublishFormExperience(const Want &want, ErmsParams::ExperienceRule &rule)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t IsSupportPublishForm(const Want &want, const ErmsParams::CallerInfo &callerInfo,
|
||||
ErmsParams::ExperienceRule &rule)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual long QueryLastSyncTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_ERMS_MGR_INTERFACE_H
|
@ -128,7 +128,7 @@ struct AbilityTransitionInfo : public Parcelable {
|
||||
if (!parcel.WriteBool(true)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteObject(abilityToken_)) {
|
||||
if (!parcel.WriteRemoteObject(abilityToken_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ int32_t WindowManagerServiceHandlerProxy::GetFocusWindow(sptr<IRemoteObject>& ab
|
||||
}
|
||||
auto ret = reply.ReadInt32();
|
||||
if (ret == 0 && reply.ReadBool()) {
|
||||
abilityToken = reply.ReadObject<IRemoteObject>();
|
||||
abilityToken = reply.ReadRemoteObject();
|
||||
}
|
||||
HILOG_DEBUG("ending");
|
||||
return ret;
|
||||
@ -151,7 +151,7 @@ void WindowManagerServiceHandlerProxy::CancelStartingWindow(sptr<IRemoteObject>
|
||||
HILOG_ERROR("Write true failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteObject(abilityToken)) {
|
||||
if (!data.WriteRemoteObject(abilityToken)) {
|
||||
HILOG_ERROR("Write abilityToken failed.");
|
||||
return;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ int WindowManagerServiceHandlerStub::GetFocusWindowInner(MessageParcel &data, Me
|
||||
HILOG_ERROR("To write true failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
if (!reply.WriteObject(abilityToken)) {
|
||||
if (!reply.WriteRemoteObject(abilityToken)) {
|
||||
HILOG_ERROR("To write abilityToken failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
@ -152,7 +152,7 @@ int WindowManagerServiceHandlerStub::CancelStartingWindowInner(MessageParcel &da
|
||||
sptr<IRemoteObject> abilityToken = nullptr;
|
||||
if (data.ReadBool()) {
|
||||
HILOG_DEBUG("abilityToken is valid.");
|
||||
abilityToken = data.ReadObject<IRemoteObject>();
|
||||
abilityToken = data.ReadRemoteObject();
|
||||
}
|
||||
CancelStartingWindow(abilityToken);
|
||||
return ERR_OK;
|
||||
|
@ -181,6 +181,15 @@ public:
|
||||
virtual AppMgrResultCode ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1);
|
||||
|
||||
/**
|
||||
* ClearUpApplicationDataBySelf, call ClearUpApplicationDataBySelf() through proxy project,
|
||||
* clear the application data.
|
||||
*
|
||||
* @param userId, the user id.
|
||||
* @return
|
||||
*/
|
||||
virtual AppMgrResultCode ClearUpApplicationDataBySelf(int32_t userId = -1);
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
@ -539,6 +548,7 @@ public:
|
||||
/**
|
||||
* Register application or process state observer.
|
||||
* @param observer, ability token.
|
||||
* @param bundleNameList, the list of bundle names.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t RegisterApplicationStateObserver(const sptr<IApplicationStateObserver> &observer,
|
||||
|
@ -116,6 +116,15 @@ public:
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) = 0;
|
||||
|
||||
/**
|
||||
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||
* clear the application data.
|
||||
*
|
||||
* @param userId the user id.
|
||||
* @return
|
||||
*/
|
||||
virtual int32_t ClearUpApplicationDataBySelf(int32_t userId = -1) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
|
@ -84,6 +84,7 @@ enum class AppMgrInterfaceCode {
|
||||
ATTACH_CHILD_PROCESS,
|
||||
EXIT_CHILD_PROCESS_SAFELY,
|
||||
IS_FINAL_APP_PROCESS,
|
||||
APP_CLEAR_UP_APPLICATION_DATA_BY_SELF,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
|
@ -99,6 +99,15 @@ public:
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||
* clear the application data.
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return
|
||||
*/
|
||||
virtual int32_t ClearUpApplicationDataBySelf(int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
|
@ -121,6 +121,7 @@ private:
|
||||
int32_t HandleAttachChildProcess(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleExitChildProcessSafely(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsFinalAppProcess(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleClearUpApplicationDataBySelf(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AppMgrFunc> memberFuncMap_;
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "parcel.h"
|
||||
#include "iremote_object.h"
|
||||
#include "parcel.h"
|
||||
#include "running_process_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
@ -47,7 +47,7 @@ bool AbilityStateData::Marshalling(Parcel &parcel) const
|
||||
if (!parcel.WriteBool(true)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteObject(token)) {
|
||||
if (!parcel.WriteRemoteObject(token)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,9 @@ void AmsMgrStub::CreateMemberFuncMap()
|
||||
|
||||
int AmsMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_INFO("AmsMgrStub::OnReceived, code = %{public}u, flags= %{public}d.", code, option.GetFlags());
|
||||
if (code != static_cast<uint32_t>(IAmsMgr::Message::Get_BUNDLE_NAME_BY_PID)) {
|
||||
HILOG_INFO("AmsMgrStub::OnReceived, code = %{public}u, flags= %{public}d.", code, option.GetFlags());
|
||||
}
|
||||
std::u16string descriptor = AmsMgrStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
@ -118,7 +120,6 @@ int AmsMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
return (this->*memberFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
HILOG_INFO("AmsMgrStub::OnRemoteRequest end");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
|
@ -315,6 +315,19 @@ AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string &bundleN
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::ClearUpApplicationDataBySelf(int32_t userId)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
int32_t result = service->ClearUpApplicationDataBySelf(userId);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||
}
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::GetAllRunningProcesses(std::vector<RunningProcessInfo> &info)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
|
@ -178,6 +178,26 @@ int32_t AppMgrProxy::ClearUpApplicationData(const std::string &bundleName, const
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::ClearUpApplicationDataBySelf(int32_t userId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("userId write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t ret = SendRequest(AppMgrInterfaceCode::APP_CLEAR_UP_APPLICATION_DATA_BY_SELF, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_WARN("SendRequest is failed, error code: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetAllRunningProcesses(std::vector<RunningProcessInfo> &info)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -159,6 +159,8 @@ AppMgrStub::AppMgrStub()
|
||||
&AppMgrStub::HandleExitChildProcessSafely;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::IS_FINAL_APP_PROCESS)] =
|
||||
&AppMgrStub::HandleIsFinalAppProcess;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::APP_CLEAR_UP_APPLICATION_DATA_BY_SELF)] =
|
||||
&AppMgrStub::HandleClearUpApplicationDataBySelf;
|
||||
}
|
||||
|
||||
AppMgrStub::~AppMgrStub()
|
||||
@ -262,6 +264,15 @@ int32_t AppMgrStub::HandleClearUpApplicationData(MessageParcel &data, MessagePar
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleClearUpApplicationDataBySelf(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
int32_t userId = data.ReadInt32();
|
||||
int32_t result = ClearUpApplicationDataBySelf(userId);
|
||||
reply.WriteInt32(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
|
@ -272,12 +272,7 @@ int32_t ApplicationStateObserverProxy::SendTransactCmd(uint32_t code, MessagePar
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
auto ret = remote->SendRequest(code, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("Send request failed with error code: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
return remote->SendRequest(code, data, reply, option);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -29,6 +29,7 @@ void AutoFillExtensionCallback::OnResult(int32_t errCode, const AAFwk::Want &wan
|
||||
{
|
||||
HILOG_DEBUG("Called, result code is %{public}d.", errCode);
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
CloseModalUIExtension();
|
||||
|
||||
if (errCode == AutoFill::AUTO_FILL_SUCCESS) {
|
||||
SendAutoFillSucess(want);
|
||||
@ -43,12 +44,11 @@ void AutoFillExtensionCallback::OnRelease(int32_t errCode)
|
||||
{
|
||||
HILOG_DEBUG("Called, result code is %{public}d.", errCode);
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
CloseModalUIExtension();
|
||||
|
||||
if (errCode != 0) {
|
||||
SendAutoFillFailed(AutoFill::AUTO_FILL_RELEASE_FAILED);
|
||||
}
|
||||
|
||||
CloseModalUIExtension();
|
||||
}
|
||||
|
||||
void AutoFillExtensionCallback::OnError(int32_t errCode, const std::string &name, const std::string &message)
|
||||
@ -56,11 +56,11 @@ void AutoFillExtensionCallback::OnError(int32_t errCode, const std::string &name
|
||||
HILOG_DEBUG("Called, errcode is %{public}d, name is %{public}s, message is %{public}s",
|
||||
errCode, name.c_str(), message.c_str());
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
CloseModalUIExtension();
|
||||
|
||||
if (errCode != 0) {
|
||||
SendAutoFillFailed(AutoFill::AUTO_FILL_ON_ERROR);
|
||||
}
|
||||
CloseModalUIExtension();
|
||||
}
|
||||
|
||||
void AutoFillExtensionCallback::OnReceive(const AAFwk::WantParams &wantParams)
|
||||
@ -100,8 +100,8 @@ void AutoFillExtensionCallback::SetEventId(uint32_t eventId)
|
||||
|
||||
void AutoFillExtensionCallback::HandleTimeOut()
|
||||
{
|
||||
SendAutoFillFailed(AutoFill::AUTO_FILL_REQUEST_TIME_OUT);
|
||||
CloseModalUIExtension();
|
||||
SendAutoFillFailed(AutoFill::AUTO_FILL_REQUEST_TIME_OUT);
|
||||
}
|
||||
|
||||
void AutoFillExtensionCallback::SendAutoFillSucess(const AAFwk::Want &want)
|
||||
@ -132,10 +132,11 @@ void AutoFillExtensionCallback::SendAutoFillFailed(int32_t errCode)
|
||||
void AutoFillExtensionCallback::CloseModalUIExtension()
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
HILOG_ERROR("uiContent_ is nullptr.");
|
||||
HILOG_DEBUG("uiContent_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
uiContent_->CloseModalUIExtension(sessionId_);
|
||||
uiContent_ = nullptr;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -40,6 +40,7 @@ config("runtime_public_config") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ability_business_error",
|
||||
"include",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -85,6 +86,7 @@ ohos_shared_library("runtime") {
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
|
||||
"${ability_runtime_path}/js_environment/frameworks/js_environment:js_environment",
|
||||
"${third_party_path}/jsoncpp:jsoncpp",
|
||||
"${third_party_path}/zlib:shared_libz",
|
||||
]
|
||||
|
||||
|
@ -29,6 +29,9 @@
|
||||
namespace panda::ecmascript {
|
||||
class EcmaVM;
|
||||
} // namespace panda::ecmascript
|
||||
namespace panda {
|
||||
struct HmsMap;
|
||||
}
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class EventHandler;
|
||||
@ -163,6 +166,8 @@ private:
|
||||
void PostPreload(const Options& options);
|
||||
void LoadAotFile(const Options& options);
|
||||
void SetRequestAotCallback();
|
||||
|
||||
std::vector<panda::HmsMap> GetSystemKitsMap(uint32_t version);
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
std::string packagePathStr;
|
||||
std::vector<std::string> assetBasePathStr;
|
||||
std::shared_ptr<AppExecFwk::EventRunner> eventRunner;
|
||||
std::map<std::string, std::string> hapModulePath;
|
||||
bool loadAce = true;
|
||||
bool preload = false;
|
||||
bool isBundle = true;
|
||||
|
@ -57,6 +57,7 @@ namespace OHOS {
|
||||
namespace NativeRdb {
|
||||
class AbsSharedResultSet;
|
||||
class DataAbilityPredicates;
|
||||
class ValueObject;
|
||||
class ValuesBucket;
|
||||
} // namespace NativeRdb
|
||||
namespace AbilityRuntime {
|
||||
@ -1318,6 +1319,17 @@ private:
|
||||
void InitConfigurationProperties(const Configuration& changeConfiguration, std::string& language,
|
||||
std::string& colormode, std::string& hasPointerDevice);
|
||||
|
||||
void ParseIntValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const;
|
||||
void ParseDoubleValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const;
|
||||
void ParseStringValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const;
|
||||
void ParseBlobValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const;
|
||||
void ParseBoolValue(const NativeRdb::ValueObject &obj, const std::string &key,
|
||||
NativeRdb::ValuesBucket &retValueBucket) const;
|
||||
|
||||
std::shared_ptr<ContinuationHandler> continuationHandler_ = nullptr;
|
||||
std::shared_ptr<ContinuationManager> continuationManager_ = nullptr;
|
||||
std::shared_ptr<ContinuationRegisterManager> continuationRegisterManager_ = nullptr;
|
||||
@ -1349,6 +1361,9 @@ private:
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
private:
|
||||
void InitFAWindow(const Want &want, int32_t displayId);
|
||||
bool UpdateResMgrAndConfiguration(int32_t displayId);
|
||||
|
||||
std::shared_ptr<AbilityWindow> abilityWindow_ = nullptr;
|
||||
bool bWindowFocus_ = false;
|
||||
bool showOnLockScreen_ = false;
|
||||
|
@ -107,6 +107,11 @@ private:
|
||||
sptr<IRemoteObject> SetNewRuleFlagToCallee(napi_env env, napi_value remoteJsObj);
|
||||
void AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const;
|
||||
void AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const;
|
||||
std::string GenerateSrcPath(std::shared_ptr<AbilityInfo> abilityInfo) const;
|
||||
void BindContext();
|
||||
bool InitWindowScene(const Want &want);
|
||||
bool AddDumpInfo(napi_env env, napi_value obj, const std::vector<std::string> ¶ms,
|
||||
std::vector<std::string> &info, const std::string &methodName) const;
|
||||
|
||||
JsRuntime &jsRuntime_;
|
||||
std::shared_ptr<NativeReference> shellContextRef_;
|
||||
|
@ -116,6 +116,8 @@ private:
|
||||
static napi_value WrapRequestDialogResult(napi_env env, int32_t resultCode, const AAFwk::Want& want);
|
||||
void AddFreeInstallObserver(napi_env env, const AAFwk::Want &want, napi_value callback,
|
||||
bool isAbilityResult = false);
|
||||
bool CheckStartAbilityByCallParams(napi_env env, NapiCallbackInfo& info, AAFwk::Want &want,
|
||||
int32_t &userId, napi_value &lastParam);
|
||||
|
||||
std::weak_ptr<AbilityContext> context_;
|
||||
int curRequestCode_ = 0;
|
||||
|
@ -104,6 +104,11 @@ public:
|
||||
* @brief Checks whether an insert operation is created.
|
||||
* @return Returns true if it is an insert operation; returns false otherwise.
|
||||
*/
|
||||
bool IsValidOperation() const;
|
||||
/**
|
||||
* @brief Checks whether an operation is valid.
|
||||
* @return Returns true if it is an insert or delete or update or assert operation; returns false otherwise.
|
||||
*/
|
||||
bool IsInsertOperation() const;
|
||||
/**
|
||||
* @brief Checks whether an delete operation is created.
|
||||
@ -147,6 +152,14 @@ public:
|
||||
private:
|
||||
void PutMap(Parcel &in);
|
||||
bool ReadFromParcel(Parcel &in);
|
||||
bool ReadUriFromParcel(Parcel &in);
|
||||
bool ReadValuesBucketFromParcel(Parcel &in);
|
||||
bool ReadDataAbilityPredicatesFromParcel(Parcel &in);
|
||||
bool ReadValuesBucketReferencesFromParcel(Parcel &in);
|
||||
bool WriteUri(Parcel &out) const;
|
||||
bool WriteValuesBucket(Parcel &out) const;
|
||||
bool WritePredicates(Parcel &out) const;
|
||||
bool WriteValuesBucketReferences(Parcel &out) const;
|
||||
|
||||
private:
|
||||
// no object in parcel
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_EXTENSION_IMPL_H
|
||||
|
||||
#include "extension.h"
|
||||
#include "extension_ability_info.h"
|
||||
#include "lifecycle_state_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -192,10 +193,13 @@ protected:
|
||||
void Background();
|
||||
|
||||
private:
|
||||
inline bool UIExtensionAbilityExecuteInsightIntent(const Want &want);
|
||||
|
||||
int lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
sptr<IRemoteObject> token_;
|
||||
std::shared_ptr<Extension> extension_;
|
||||
bool skipCommandExtensionWithIntent_ = false;
|
||||
AppExecFwk::ExtensionAbilityType extensionType_ = AppExecFwk::ExtensionAbilityType::UNSPECIFIED;
|
||||
|
||||
class ExtensionWindowLifeCycleImpl : public Rosen::IWindowLifeCycle {
|
||||
public:
|
||||
|
@ -200,10 +200,13 @@ private:
|
||||
void DestroyWindow(const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
|
||||
void OnCommandWindowDone(const sptr<AAFwk::SessionInfo> &sessionInfo, AAFwk::WindowCommand winCmd) override;
|
||||
bool ForegroundWindowWithInsightIntent(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
bool ForegroundWindowWithInsightIntent(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
bool needForeground);
|
||||
bool HandleSessionCreate(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
void OnInsightIntentExecuteDone(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result) override;
|
||||
void PostInsightIntentExecuted(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result, bool needForeground);
|
||||
|
||||
JsRuntime& jsRuntime_;
|
||||
std::unique_ptr<NativeReference> jsObj_;
|
||||
@ -214,6 +217,7 @@ private:
|
||||
std::shared_ptr<AbilityResultListeners> abilityResultListeners_ = nullptr;
|
||||
int32_t screenMode_ = AAFwk::IDLE_SCREEN_MODE;
|
||||
std::shared_ptr<int32_t> screenModePtr_;
|
||||
sptr<IRemoteObject> token_ = nullptr;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -156,10 +156,13 @@ private:
|
||||
bool CallJsOnSessionCreate(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const sptr<Rosen::Window> &uiWindow, const uint64_t &uiExtensionComponentId);
|
||||
void OnCommandWindowDone(const sptr<AAFwk::SessionInfo> &sessionInfo, AAFwk::WindowCommand winCmd);
|
||||
bool ForegroundWindowWithInsightIntent(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
bool ForegroundWindowWithInsightIntent(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
bool needForeground);
|
||||
bool HandleSessionCreate(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
void OnInsightIntentExecuteDone(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result);
|
||||
void PostInsightIntentExecuted(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result, bool needForeground);
|
||||
|
||||
JsRuntime &jsRuntime_;
|
||||
std::unique_ptr<NativeReference> jsObj_;
|
||||
@ -169,6 +172,7 @@ private:
|
||||
std::map<uint64_t, std::shared_ptr<NativeReference>> contentSessions_;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo_;
|
||||
std::shared_ptr<UIExtensionContext> context_;
|
||||
sptr<IRemoteObject> token_ = nullptr;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
|
||||
static napi_value StartAbility(napi_env env, napi_callback_info info);
|
||||
static napi_value StartAbilityAsCaller(napi_env env, napi_callback_info info);
|
||||
static napi_value GetUIExtensionHostWindowProxy(napi_env env, napi_callback_info info);
|
||||
static napi_value StartAbilityForResult(napi_env env, napi_callback_info info);
|
||||
static napi_value TerminateSelf(napi_env env, napi_callback_info info);
|
||||
static napi_value TerminateSelfWithResult(napi_env env, napi_callback_info info);
|
||||
@ -74,6 +75,7 @@ public:
|
||||
protected:
|
||||
napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityAsCaller(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnGetUIExtensionHostWindowProxy(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityForResult(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnTerminateSelf(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnTerminateSelfWithResult(napi_env env, NapiCallbackInfo& info);
|
||||
@ -95,7 +97,7 @@ protected:
|
||||
napi_env env, NapiCallbackInfo& info, std::shared_ptr<int> &innerErrorCode);
|
||||
void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want,
|
||||
std::shared_ptr<NapiAsyncTask> asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions);
|
||||
|
||||
|
||||
private:
|
||||
sptr<AAFwk::SessionInfo> sessionInfo_;
|
||||
sptr<Rosen::Window> uiWindow_;
|
||||
|
@ -404,6 +404,7 @@ private:
|
||||
const AppExecFwk::BundleInfo &bundleInfo, bool currentBundle, const std::string& moduleName);
|
||||
void UpdateResConfig(std::shared_ptr<Global::Resource::ResourceManager> &resourceManager);
|
||||
int32_t GetBundleInfo(const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo, bool ¤tBundle);
|
||||
void GetBundleInfo(const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo, const int &accountId);
|
||||
|
||||
static Global::Resource::DeviceType deviceType_;
|
||||
std::shared_ptr<AppExecFwk::ApplicationInfo> applicationInfo_ = nullptr;
|
||||
|
@ -178,17 +178,7 @@ bool JsEnvironment::StartDebugger(
|
||||
JSENV_LOG_E("Abnormal parsing of tid results.");
|
||||
return false;
|
||||
}
|
||||
panda::JSNApi::DebugOption debugOption = {libraryPath, needBreakPoint};
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment:StartDebugger");
|
||||
};
|
||||
debugMode_ = panda::JSNApi::StartDebuggerForSocketPair(
|
||||
static_cast<uint32_t>(identifierId), debugOption, socketFd, debuggerPostTask);
|
||||
debugMode_ = panda::JSNApi::StartDebuggerForSocketPair(identifierId, socketFd);
|
||||
return debugMode_;
|
||||
}
|
||||
|
||||
@ -209,7 +199,7 @@ void JsEnvironment::StopDebugger(std::string& option)
|
||||
JSENV_LOG_E("Abnormal parsing of tid results.");
|
||||
return;
|
||||
}
|
||||
panda::JSNApi::StopDebugger(static_cast<uint32_t>(identifierId));
|
||||
panda::JSNApi::StopDebugger(identifierId);
|
||||
}
|
||||
|
||||
void JsEnvironment::InitConsoleModule()
|
||||
@ -260,7 +250,7 @@ bool JsEnvironment::LoadScript(const std::string& path, uint8_t* buffer, size_t
|
||||
}
|
||||
|
||||
void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId, PROFILERTYPE profiler,
|
||||
int32_t interval, uint32_t tid)
|
||||
int32_t interval, int tid, bool isDebugApp)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
@ -281,7 +271,7 @@ void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId,
|
||||
option.profilerType = ConvertProfilerType(profiler);
|
||||
option.interval = interval;
|
||||
|
||||
panda::DFXJSNApi::StartProfiler(vm_, option, tid, instanceId, debuggerPostTask);
|
||||
panda::DFXJSNApi::StartProfiler(vm_, option, tid, instanceId, debuggerPostTask, isDebugApp);
|
||||
}
|
||||
|
||||
void JsEnvironment::DestroyHeapProfiler()
|
||||
@ -325,13 +315,13 @@ void JsEnvironment::SetDeviceDisconnectCallback(const std::function<bool()> &cb)
|
||||
}
|
||||
|
||||
void JsEnvironment::NotifyDebugMode(
|
||||
uint32_t tid, const char* libraryPath, uint32_t instanceId, bool debug, bool debugMode)
|
||||
int tid, const char* libraryPath, uint32_t instanceId, bool debug, bool debugMode)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::JSNApi::DebugOption debugOption = {libraryPath, debugMode};
|
||||
panda::JSNApi::DebugOption debugOption = {libraryPath, debug ? debugMode : false};
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
@ -340,7 +330,7 @@ void JsEnvironment::NotifyDebugMode(
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment:NotifyDebugMode");
|
||||
};
|
||||
panda::JSNApi::NotifyDebugMode(tid, vm_, libraryPath, debugOption, instanceId, debuggerPostTask, debug, debugMode);
|
||||
panda::JSNApi::NotifyDebugMode(tid, vm_, debugOption, instanceId, debuggerPostTask, debug);
|
||||
}
|
||||
|
||||
int32_t JsEnvironment::ParseHdcRegisterOption(std::string& option)
|
||||
|
@ -85,8 +85,8 @@ public:
|
||||
|
||||
bool LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle);
|
||||
|
||||
void StartProfiler(
|
||||
const char* libraryPath, uint32_t instanceId, PROFILERTYPE profiler, int32_t interval, uint32_t tid);
|
||||
void StartProfiler(const char* libraryPath,
|
||||
uint32_t instanceId, PROFILERTYPE profiler, int32_t interval, int tid, bool isDebugApp);
|
||||
|
||||
void DestroyHeapProfiler();
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
|
||||
void SetDeviceDisconnectCallback(const std::function<bool()> &cb);
|
||||
|
||||
void NotifyDebugMode(uint32_t tid, const char* libraryPath, uint32_t instanceId, bool isDebugApp, bool debugMode);
|
||||
void NotifyDebugMode(int tid, const char* libraryPath, uint32_t instanceId, bool isDebugApp, bool debugMode);
|
||||
|
||||
bool GetDebugMode() const;
|
||||
|
||||
|
@ -31,13 +31,8 @@ using namespace testing::ext;
|
||||
#define ENV_LOG_TAG "JsEnv"
|
||||
#endif
|
||||
|
||||
#ifdef LOG_LABEL
|
||||
#undef LOG_LABEL
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace JsEnv {
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, ENV_LOG_DOMAIN, ENV_LOG_TAG};
|
||||
void Logger(JsEnvLogLevel level, const char* fileName, const char* functionName, int line,
|
||||
const char* fmt, ...)
|
||||
{
|
||||
@ -47,19 +42,24 @@ void Logger(JsEnvLogLevel level, const char* fileName, const char* functionName,
|
||||
va_start(printArgs, fmt);
|
||||
switch(level) {
|
||||
case JsEnvLogLevel::DEBUG:
|
||||
HiviewDFX::HiLog::Debug(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_DEBUG, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnvLogLevel::INFO:
|
||||
HiviewDFX::HiLog::Info(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_INFO, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnvLogLevel::WARN:
|
||||
HiviewDFX::HiLog::Warn(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_WARN, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnvLogLevel::ERROR:
|
||||
HiviewDFX::HiLog::Error(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_ERROR, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
case JsEnvLogLevel::FATAL:
|
||||
HiviewDFX::HiLog::Fatal(LOG_LABEL, cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
HILOG_IMPL(LOG_CORE, LOG_FATAL, ENV_LOG_DOMAIN, ENV_LOG_TAG,
|
||||
cFormat.c_str(), fileName, functionName, line, printArgs);
|
||||
break;
|
||||
}
|
||||
va_end(printArgs);
|
||||
|
@ -311,7 +311,7 @@ HWTEST_F(JsEnvironmentTest, StartProfiler_0100, TestSize.Level1)
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
|
||||
const char* libraryPath = "LIBRARYPATH";
|
||||
jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_CPU, 0, 0);
|
||||
jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_CPU, 0, 0, true);
|
||||
ASSERT_EQ(jsEnv->GetVM(), nullptr);
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ HWTEST_F(JsEnvironmentTest, StartProfiler_0200, TestSize.Level1)
|
||||
ASSERT_EQ(ret, true);
|
||||
|
||||
const char* libraryPath = "LIBRARYPATH";
|
||||
jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_HEAP, 0, 0);
|
||||
jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_HEAP, 0, 0, true);
|
||||
ASSERT_NE(jsEnv->GetVM(), nullptr);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
"uid" : "servicerouter",
|
||||
"start-mode" : "condition",
|
||||
"gid" : ["servicerouter"],
|
||||
"secon" : "u:r:service_router:s0"
|
||||
"secon" : "u:r:service_router:s0",
|
||||
"permission" : [
|
||||
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -79,7 +79,7 @@ void SrCommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &ev
|
||||
};
|
||||
eventHandler_->PostTask(task, "SrCommonEventSubscriber:DeleteBundleInfo");
|
||||
} else {
|
||||
APP_LOGW("warnning, invalid action.");
|
||||
APP_LOGW("invalid action.");
|
||||
}
|
||||
}
|
||||
} // AbilityRuntime
|
||||
|
@ -107,10 +107,6 @@ config("abilityms_config") {
|
||||
defines += [ "SUPPORT_ASAN" ]
|
||||
}
|
||||
|
||||
if (ecologic_rule_enabled) {
|
||||
defines += [ "SUPPORT_ERMS" ]
|
||||
}
|
||||
|
||||
cflags = []
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
@ -220,10 +216,6 @@ ohos_shared_library("abilityms") {
|
||||
]
|
||||
}
|
||||
|
||||
if (ecologic_rule_enabled) {
|
||||
external_deps += [ "ecological_rule_manager:erms_client" ]
|
||||
}
|
||||
|
||||
version_script = "libabilityms.map"
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
|
@ -38,6 +38,8 @@ abilityms_files = [
|
||||
"src/dialog_session_record.cpp",
|
||||
"src/lifecycle_deal.cpp",
|
||||
"src/ability_running_info.cpp",
|
||||
"src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp",
|
||||
"src/ecological_rule/ability_ecological_rule_mgr_service.cpp",
|
||||
"src/extension_config.cpp",
|
||||
"src/extension_running_info.cpp",
|
||||
"src/caller_info.cpp",
|
||||
|
@ -467,6 +467,8 @@ private:
|
||||
|
||||
void DoForegroundUIExtension(std::shared_ptr<AbilityRecord> abilityRecord, const AbilityRequest &abilityRequest);
|
||||
void SaveUIExtRequestSessionInfo(std::shared_ptr<AbilityRecord> abilityRecord, sptr<SessionInfo> sessionInfo);
|
||||
void DoBackgroundAbilityWindow(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const sptr<SessionInfo> &sessionInfo);
|
||||
|
||||
/**
|
||||
* When a service is under starting, enque the request and handle it after the service starting completes
|
||||
@ -514,6 +516,9 @@ private:
|
||||
inline void RemoveUIExtensionAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
int32_t GetOrCreateExtensionRecord(const AbilityRequest &abilityRequest, bool isCreatedByConnect,
|
||||
const std::string &hostBundleName, std::shared_ptr<AbilityRecord> &extensionRecord, bool &isLoaded);
|
||||
int32_t GetOrCreateTargetServiceRecord(
|
||||
const AbilityRequest &abilityRequest, const sptr<UIExtensionAbilityConnectInfo> &connectInfo,
|
||||
std::shared_ptr<AbilityRecord> &targetService, bool &isLoadedAbility);
|
||||
|
||||
private:
|
||||
const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask";
|
||||
|
@ -17,28 +17,17 @@
|
||||
#define OHOS_ABILITY_RUNTIME_ABILITY_INTERCEPTOR_H
|
||||
|
||||
#include "ability_util.h"
|
||||
#include "cpp/mutex.h"
|
||||
#ifdef SUPPORT_ERMS
|
||||
#include "ecological_rule_mgr_service_client.h"
|
||||
#else
|
||||
#include "erms_mgr_param.h"
|
||||
#include "erms_mgr_interface.h"
|
||||
#endif
|
||||
#include "disposed_observer.h"
|
||||
#include "ecological_rule/ability_ecological_rule_mgr_service.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class DisposedObserver;
|
||||
#ifdef SUPPORT_ERMS
|
||||
using ErmsCallerInfo = OHOS::EcologicalRuleMgrService::CallerInfo;
|
||||
using ExperienceRule = OHOS::EcologicalRuleMgrService::ExperienceRule;
|
||||
#else
|
||||
using ErmsCallerInfo = OHOS::AppExecFwk::ErmsParams::CallerInfo;
|
||||
using ExperienceRule = OHOS::AppExecFwk::ErmsParams::ExperienceRule;
|
||||
#endif
|
||||
using namespace OHOS::EcologicalRuleMgrService;
|
||||
using ErmsCallerInfo = OHOS::EcologicalRuleMgrService::AbilityCallerInfo;
|
||||
using ExperienceRule = OHOS::EcologicalRuleMgrService::AbilityExperienceRule;
|
||||
|
||||
class AbilityInterceptor {
|
||||
public:
|
||||
@ -97,6 +86,8 @@ private:
|
||||
bool CheckControl(const Want &want, int32_t userId, AppExecFwk::DisposedRule &disposedRule);
|
||||
bool CheckDisposedRule(const Want &want, AppExecFwk::DisposedRule &disposedRule);
|
||||
ErrCode StartNonBlockRule(const Want &want, AppExecFwk::DisposedRule &disposedRule);
|
||||
sptr<AppExecFwk::IAppMgr> GetAppMgr();
|
||||
ErrCode CreateModalUIExtension(const Want &want, const sptr<IRemoteObject> &callerToken);
|
||||
private:
|
||||
std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler_;
|
||||
std::map<std::string, sptr<DisposedObserver>> disposedObserverMap_;
|
||||
@ -114,11 +105,7 @@ public:
|
||||
return;
|
||||
};
|
||||
private:
|
||||
#ifdef SUPPORT_ERMS
|
||||
void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId);
|
||||
#else
|
||||
bool CheckRule(const Want &want, ErmsCallerInfo &callerInfo, ExperienceRule &rule);
|
||||
#endif
|
||||
};
|
||||
|
||||
// ability jump interceptor
|
||||
|
@ -925,7 +925,7 @@ public:
|
||||
sptr<DialogSessionInfo> &dialogSessionInfo) override;
|
||||
|
||||
bool GenerateDialogSessionRecord(AbilityRequest &abilityRequest, int32_t userId,
|
||||
std::string &dialogSessionId, std::vector<DialogAppInfo> &dialogAppInfos);
|
||||
std::string &dialogSessionId, std::vector<DialogAppInfo> &dialogAppInfos, bool isSelector);
|
||||
|
||||
int CreateModalDialog(const Want &replaceWant, sptr<IRemoteObject> callerToken, std::string dialogSessionId);
|
||||
|
||||
@ -1887,6 +1887,9 @@ private:
|
||||
bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord,
|
||||
const int32_t oriValidUserId);
|
||||
|
||||
void InitInterceptor();
|
||||
void InitPushTask();
|
||||
|
||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||
constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5;
|
||||
|
||||
|
@ -942,6 +942,9 @@ public:
|
||||
void SetURI(const std::string &uri);
|
||||
std::string GetURI() const;
|
||||
|
||||
void DoBackgroundAbilityWindowDelayed(bool needBackground);
|
||||
bool BackgroundAbilityWindowDelayed();
|
||||
|
||||
protected:
|
||||
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1);
|
||||
|
||||
@ -1144,6 +1147,7 @@ private:
|
||||
bool isAttachDebug_ = false;
|
||||
bool isAppAutoStartup_ = false;
|
||||
bool isConnected = false;
|
||||
std::atomic_bool backgroundAbilityWindowDelayed_ = false;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include "ability_manager_errors.h"
|
||||
#include "app_jump_control_rule.h"
|
||||
#include "bundle_mgr_helper.h"
|
||||
#ifndef SUPPORT_ERMS
|
||||
#include "erms_mgr_interface.h"
|
||||
#endif
|
||||
#include "hilog_wrapper.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
@ -170,22 +167,6 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
return DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
}
|
||||
|
||||
#ifndef SUPPORT_ERMS
|
||||
[[maybe_unused]] static sptr<AppExecFwk::IEcologicalRuleManager> CheckEcologicalRuleMgr()
|
||||
{
|
||||
// should remove when AG SA online
|
||||
int32_t ECOLOGICAL_RULE_SA_ID = 9999;
|
||||
auto remoteObject =
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->CheckSystemAbility(ECOLOGICAL_RULE_SA_ID);
|
||||
if (remoteObject == nullptr) {
|
||||
HILOG_ERROR("%{public}s error, failed to check ecological rule manager service.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return iface_cast<AppExecFwk::IEcologicalRuleManager>(remoteObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
[[maybe_unused]] static bool ParseJumpInterceptorWant(Want &targetWant, const std::string callerPkg)
|
||||
{
|
||||
if (callerPkg.empty()) {
|
||||
|
@ -28,7 +28,7 @@ const std::string ENABLE_APP_GALLERY_SELECTOR_UTIL = "abilitymanagerservice.supp
|
||||
inline bool IsEnableAppGallerySelector()
|
||||
{
|
||||
HILOG_DEBUG("call");
|
||||
std::string ret = OHOS::system::GetParameter(ENABLE_APP_GALLERY_SELECTOR_UTIL, "false");
|
||||
std::string ret = OHOS::system::GetParameter(ENABLE_APP_GALLERY_SELECTOR_UTIL, "true");
|
||||
if (ret == "true") {
|
||||
return true;
|
||||
}
|
||||
|
@ -64,7 +64,8 @@ private:
|
||||
std::shared_ptr<DataAbilityRecord> &record);
|
||||
void ReportDataAbilityReleased(const sptr<IRemoteObject> &client, bool isNotHap,
|
||||
std::shared_ptr<DataAbilityRecord> &record);
|
||||
|
||||
void DumpClientInfo(std::vector<std::string> &info, bool isClient,
|
||||
std::shared_ptr<DataAbilityRecord> dataAbilityRecord) const;
|
||||
private:
|
||||
ffrt::mutex mutex_;
|
||||
DataAbilityRecordPtrMap dataAbilityRecordsLoaded_;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
bool QueryDialogAppInfo(DialogAbilityInfo &dialogAbilityInfo, int32_t userId);
|
||||
|
||||
private:
|
||||
ffrt::mutex dialogSessionRecordLock_;
|
||||
mutable ffrt::mutex dialogSessionRecordLock_;
|
||||
std::unordered_map<std::string, sptr<DialogSessionInfo>> dialogSessionInfoMap_;
|
||||
std::unordered_map<std::string, std::shared_ptr<DialogCallerInfo>> dialogCallerInfoMap_;
|
||||
};
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
DisposedObserver(const AppExecFwk::DisposedRule &disposedRule,
|
||||
const std::shared_ptr<DisposedRuleInterceptor> &interceptor);
|
||||
~DisposedObserver() = default;
|
||||
sptr<AppExecFwk::IAppMgr> GetAppMgr();
|
||||
|
||||
private:
|
||||
void OnAbilityStateChanged(const AppExecFwk::AbilityStateData &abilityStateData) override;
|
||||
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SERVICES_INCLUDE_ECOLOGICAL_RULE_MANAGER_SERVICE_PROXY_H
|
||||
#define SERVICES_INCLUDE_ECOLOGICAL_RULE_MANAGER_SERVICE_PROXY_H
|
||||
|
||||
#include <mutex>
|
||||
#include "iremote_proxy.h"
|
||||
#include "ability_ecological_rule_mgr_service_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace EcologicalRuleMgrService {
|
||||
|
||||
using namespace std;
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
using AbilityInfo = OHOS::AppExecFwk::AbilityInfo;
|
||||
|
||||
class AbilityEcologicalRuleMgrServiceClient : public RefBase {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(AbilityEcologicalRuleMgrServiceClient);
|
||||
static sptr<AbilityEcologicalRuleMgrServiceClient> GetInstance();
|
||||
void OnRemoteSaDied(const wptr<IRemoteObject> &object);
|
||||
|
||||
int32_t EvaluateResolveInfos(const Want &want, const AbilityCallerInfo &callerInfo, int32_t type,
|
||||
vector<AbilityInfo> &abInfo, const vector<AppExecFwk::ExtensionAbilityInfo> &extInfo =
|
||||
vector<AppExecFwk::ExtensionAbilityInfo>());
|
||||
int32_t QueryStartExperience(const Want &want, const AbilityCallerInfo &callerInfo, AbilityExperienceRule &rule);
|
||||
|
||||
private:
|
||||
AbilityEcologicalRuleMgrServiceClient() {};
|
||||
~AbilityEcologicalRuleMgrServiceClient();
|
||||
static sptr<IAbilityEcologicalRuleMgrService> ConnectService();
|
||||
static bool CheckConnectService();
|
||||
|
||||
static mutex instanceLock_;
|
||||
static sptr<AbilityEcologicalRuleMgrServiceClient> instance_;
|
||||
static sptr<IAbilityEcologicalRuleMgrService> ecologicalRuleMgrServiceProxy_;
|
||||
static sptr<IRemoteObject::DeathRecipient> deathRecipient_;
|
||||
|
||||
static string ERMS_ORIGINAL_TARGET;
|
||||
};
|
||||
|
||||
class AbilityEcologicalRuleMgrServiceDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
AbilityEcologicalRuleMgrServiceDeathRecipient() {};
|
||||
~AbilityEcologicalRuleMgrServiceDeathRecipient() = default;
|
||||
void OnRemoteDied(const wptr<IRemoteObject> &object) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(AbilityEcologicalRuleMgrServiceDeathRecipient);
|
||||
};
|
||||
|
||||
class AbilityEcologicalRuleMgrServiceProxy : public OHOS::IRemoteProxy<IAbilityEcologicalRuleMgrService> {
|
||||
public:
|
||||
explicit AbilityEcologicalRuleMgrServiceProxy(const sptr<IRemoteObject> &object) :
|
||||
IRemoteProxy<IAbilityEcologicalRuleMgrService>(object)
|
||||
{}
|
||||
~AbilityEcologicalRuleMgrServiceProxy() = default;
|
||||
DISALLOW_COPY_AND_MOVE(AbilityEcologicalRuleMgrServiceProxy);
|
||||
|
||||
int32_t EvaluateResolveInfos(const Want &want, const AbilityCallerInfo &callerInfo, int32_t type,
|
||||
vector<AbilityInfo> &abilityInfo) override;
|
||||
int32_t QueryStartExperience(const Want &want, const AbilityCallerInfo &callerInfo,
|
||||
AbilityExperienceRule &rule) override;
|
||||
|
||||
private:
|
||||
template <typename T> bool ReadParcelableVector(vector<T> &parcelableVector, MessageParcel &reply);
|
||||
static inline BrokerDelegator<AbilityEcologicalRuleMgrServiceProxy> delegator_;
|
||||
};
|
||||
} // namespace EcologicalRuleMgrService
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SERVICES_INCLUDE_ECOLOGICAL_RULE_MANAGER_SERVICE_PROXY_H
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ABILITY_SERVICES_INCLUDE_ECOLOGICALRULEMANAGERSERVICE_INTERFACE_H
|
||||
#define ABILITY_SERVICES_INCLUDE_ECOLOGICALRULEMANAGERSERVICE_INTERFACE_H
|
||||
|
||||
#include <string>
|
||||
#include "iremote_broker.h"
|
||||
#include "ability_ecological_rule_mgr_service_param.h"
|
||||
#include "want.h"
|
||||
#include "ability_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace EcologicalRuleMgrService {
|
||||
class IAbilityEcologicalRuleMgrService : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.cloud.ecologicalrulemgrservice.IAbilityEcologicalRuleMgrService");
|
||||
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
|
||||
using AbilityInfo = OHOS::AppExecFwk::AbilityInfo;
|
||||
|
||||
virtual int32_t QueryStartExperience(const Want &want, const AbilityCallerInfo &callerInfo,
|
||||
AbilityExperienceRule &rule) = 0;
|
||||
virtual int32_t EvaluateResolveInfos(const Want &want, const AbilityCallerInfo &callerInfo, int32_t type,
|
||||
std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
|
||||
enum {
|
||||
QUERY_START_EXPERIENCE_CMD = 1,
|
||||
EVALUATE_RESOLVE_INFO_CMD = 2
|
||||
};
|
||||
|
||||
enum ErrCode {
|
||||
ERR_BASE = (-99),
|
||||
ERR_FAILED = (-1),
|
||||
ERR_PERMISSION_DENIED = (-2),
|
||||
ERR_OK = 0,
|
||||
};
|
||||
};
|
||||
} // namespace EcologicalRuleMgrService
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // ABILITY_SERVICES_INCLUDE_ECOLOGICALRULEMGRSERVICE_INTERFACE_H
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ABILITY_ECOLOGICALRULEMANAGERSERVICE_PARAM_H
|
||||
#define ABILITY_ECOLOGICALRULEMANAGERSERVICE_PARAM_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "parcel.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace EcologicalRuleMgrService {
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
|
||||
struct AbilityExperienceRule : public Parcelable {
|
||||
bool isAllow = true;
|
||||
std::string sceneCode = "";
|
||||
sptr<Want> replaceWant = nullptr;
|
||||
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
static AbilityExperienceRule *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
struct AbilityCallerInfo : public Parcelable {
|
||||
enum {
|
||||
TYPE_INVALID = 0,
|
||||
TYPE_HARMONY_APP,
|
||||
TYPE_ATOM_SERVICE,
|
||||
TYPE_QUICK_APP = 4,
|
||||
TYPE_BOXED_ATOM_SERVICE
|
||||
};
|
||||
|
||||
std::string packageName;
|
||||
int32_t uid = 0L;
|
||||
int32_t pid = 0L;
|
||||
|
||||
int32_t callerAppType = TYPE_INVALID;
|
||||
int32_t targetAppType = TYPE_INVALID;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
static AbilityCallerInfo *Unmarshalling(Parcel &parcel);
|
||||
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
} // namespace EcologicalRuleMgrService
|
||||
} // namespace OHOS
|
||||
#endif // ABILITY_ECOLOGICALRULEMANAGERSERVICE_PARAM_H
|
@ -22,10 +22,8 @@
|
||||
|
||||
#include "ability_record.h"
|
||||
#include "bundle_mgr_helper.h"
|
||||
#include "ecological_rule/ability_ecological_rule_mgr_service.h"
|
||||
#include "system_dialog_scheduler.h"
|
||||
#ifdef SUPPORT_ERMS
|
||||
#include "ecological_rule_mgr_service_client.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
@ -46,10 +44,8 @@ struct AddInfoParam {
|
||||
std::string typeName;
|
||||
std::vector<std::string> infoNames;
|
||||
};
|
||||
#ifdef SUPPORT_ERMS
|
||||
using namespace OHOS::EcologicalRuleMgrService;
|
||||
using ErmsCallerInfo = OHOS::EcologicalRuleMgrService::CallerInfo;
|
||||
#endif
|
||||
using ErmsCallerInfo = OHOS::EcologicalRuleMgrService::AbilityCallerInfo;
|
||||
/**
|
||||
* @class ImplicitStartProcessor
|
||||
* ImplicitStartProcessor.
|
||||
@ -73,8 +69,8 @@ private:
|
||||
std::vector<DialogAppInfo> &dialogAppInfos, std::string &deviceType, bool isMoreHapList);
|
||||
std::string MatchTypeAndUri(const AAFwk::Want &want);
|
||||
std::shared_ptr<AppExecFwk::BundleMgrHelper> GetBundleManagerHelper();
|
||||
std::vector<std::string> splitStr(const std::string& str, char delimiter);
|
||||
int queryBmsAppInfos(AbilityRequest &request, int32_t userId, std::vector<DialogAppInfo> &dialogAppInfos);
|
||||
std::vector<std::string> SplitStr(const std::string& str, char delimiter);
|
||||
int QueryBmsAppInfos(AbilityRequest &request, int32_t userId, std::vector<DialogAppInfo> &dialogAppInfos);
|
||||
|
||||
using StartAbilityClosure = std::function<int32_t()>;
|
||||
int CallStartAbilityInner(int32_t userId, const Want &want, const StartAbilityClosure &callBack,
|
||||
@ -89,9 +85,7 @@ private:
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos, int32_t userId);
|
||||
sptr<AppExecFwk::IDefaultApp> GetDefaultAppProxy();
|
||||
|
||||
#ifdef SUPPORT_ERMS
|
||||
void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId);
|
||||
#endif
|
||||
|
||||
void AddIdentity(int32_t tokenId, std::string identity);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user