mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 17:21:11 +00:00
Merge branch 'master' of gitee.com:openharmony/arkui_ace_engine into font
This commit is contained in:
commit
1e44899ecc
8
BUILD.gn
8
BUILD.gn
@ -26,8 +26,8 @@ config("ace_config") {
|
||||
|
||||
if (is_standard_system && !use_mingw_win && !use_mac) {
|
||||
include_dirs += [
|
||||
"//base/global/resmgr_standard/frameworks/resmgr/include",
|
||||
"//base/global/resmgr_standard/interfaces/innerkits/include",
|
||||
"//base/global/resource_management/frameworks/resmgr/include",
|
||||
"//base/global/resource_management/interfaces/inner_api/include",
|
||||
"$ace_root/adapter/ohos/services/uiservice/include",
|
||||
]
|
||||
}
|
||||
@ -76,8 +76,8 @@ config("ace_test_config") {
|
||||
|
||||
if (is_standard_system && !use_mingw_win && !use_mac) {
|
||||
include_dirs += [
|
||||
"//base/global/resmgr_standard/frameworks/resmgr/include",
|
||||
"//base/global/resmgr_standard/interfaces/innerkits/include",
|
||||
"//base/global/resource_management/frameworks/resmgr/include",
|
||||
"//base/global/resource_management/interfaces/inner_api/include",
|
||||
]
|
||||
|
||||
cflags_cc += [
|
||||
|
@ -128,7 +128,7 @@ if (enable_dump_drawcmd) {
|
||||
}
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.account_os_account_standard)) {
|
||||
defined(global_parts_info.account_os_account)) {
|
||||
os_account_exists = true
|
||||
ace_common_defines += [ "OS_ACCOUNT_EXISTS" ]
|
||||
} else {
|
||||
|
@ -52,6 +52,9 @@ group("ace_packages") {
|
||||
"$ace_root/frameworks/bridge/js_frontend/engine/jsi/debugger:ark_debugger",
|
||||
]
|
||||
|
||||
# pid Register
|
||||
# pid register
|
||||
deps += [ "$ace_root/frameworks/core/common/register:hdc_register" ]
|
||||
|
||||
# connect server
|
||||
deps += [ "$ace_root/frameworks/core/common/debugger:connectserver_debugger" ]
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
"unittest",
|
||||
"resmgr",
|
||||
"graphic",
|
||||
"bytrace_standard",
|
||||
"bytrace",
|
||||
"startup_l2"
|
||||
],
|
||||
"third_party": [
|
||||
@ -86,4 +86,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos/ace/ace_args.gni")
|
||||
import("//foundation/graphic/standard/graphic_config.gni")
|
||||
import("//foundation/graphic/graphic/graphic_config.gni")
|
||||
import("product_config.gni")
|
||||
|
||||
defines = [
|
||||
@ -65,13 +65,14 @@ plugin_components_support = true
|
||||
xcomponent_components_support = true
|
||||
pixel_map_support = true
|
||||
js_pa_support = true
|
||||
connect_server_support = false
|
||||
connect_server_support = true
|
||||
hdc_register_support = true
|
||||
pa_engine_path = "adapter/ohos/entrance/pa_engine"
|
||||
enable_rosen_backend = true
|
||||
enable_standard_input = true
|
||||
build_container_scope_lib = true
|
||||
multiple_window_support = true
|
||||
enable_ability_component = true
|
||||
|
||||
if (defined(is_experiment_build) && is_experiment_build) {
|
||||
web_components_support = true
|
||||
@ -83,6 +84,10 @@ if (defined(web_components_support) && web_components_support) {
|
||||
defines += [ "WEB_SUPPORTED" ]
|
||||
}
|
||||
|
||||
if (defined(enable_ability_component) && enable_ability_component) {
|
||||
defines += [ "ABILITY_COMPONENT_SUPPORTED" ]
|
||||
}
|
||||
|
||||
if (disable_gpu || enable_rosen_backend) {
|
||||
defines += [ "GPU_DISABLED" ]
|
||||
}
|
||||
|
@ -41,6 +41,28 @@ template("ace_capability_ohos_source_set") {
|
||||
external_deps += [ "pasteboard_native:pasteboard_client" ]
|
||||
defines += [ "SYSTEM_CLIPBOARD_SUPPORTED" ]
|
||||
}
|
||||
if (defined(config.enable_ability_component) &&
|
||||
config.enable_ability_component) {
|
||||
external_deps += [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:surface",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_core",
|
||||
"utils_base:utils",
|
||||
"window_manager:libwindow_extension_client",
|
||||
]
|
||||
deps = [ "//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client" ]
|
||||
sources += [
|
||||
"window_connection/window_extension_connection_ohos.cpp",
|
||||
"window_connection/window_extension_connection_proxy.cpp",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "window_extension_connection_ohos.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "element_name.h"
|
||||
#include "render_service_client/core/ui/rs_surface_node.h"
|
||||
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "frameworks/base/json/json_util.h"
|
||||
#include "frameworks/core/components_v2/ability_component/render_ability_component.h"
|
||||
|
||||
#ifdef OS_ACCOUNT_EXISTS
|
||||
#include "os_account_manager.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class ConnectionCallback : public Rosen::IWindowExtensionCallback {
|
||||
public:
|
||||
explicit ConnectionCallback(WeakPtr<RenderNode> node) : node_(std::move(node)) {}
|
||||
~ConnectionCallback() override = default;
|
||||
void OnWindowReady(const std::shared_ptr<Rosen::RSSurfaceNode>& rsSurfaceNode) override
|
||||
{
|
||||
LOGI("OnWindowReady and ready to connect extension");
|
||||
auto nodeStrong = node_.Upgrade();
|
||||
if (!nodeStrong) {
|
||||
LOGI("cannot replace sureface node because the render node is empty");
|
||||
return;
|
||||
}
|
||||
rsSurfaceNode->CreateNodeInRenderThread();
|
||||
auto rect = nodeStrong->GetPaintRect();
|
||||
auto offset = rect.GetOffset();
|
||||
auto size = rect.GetSize();
|
||||
rsSurfaceNode->SetFrame(static_cast<float>(offset.GetX()), static_cast<float>(offset.GetY()),
|
||||
static_cast<float>(size.Width()), static_cast<float>(size.Height()));
|
||||
nodeStrong->SyncRSNode(std::static_pointer_cast<RSNode>(rsSurfaceNode));
|
||||
nodeStrong->MarkNeedLayout();
|
||||
auto ability = AceType::DynamicCast<V2::RenderAbilityComponent>(nodeStrong);
|
||||
if (ability) {
|
||||
ability->FireConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void OnExtensionDisconnected() override
|
||||
{
|
||||
auto ability = AceType::DynamicCast<V2::RenderAbilityComponent>(node_.Upgrade());
|
||||
if (ability) {
|
||||
ability->FireDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyEvent(const std::shared_ptr<MMI::KeyEvent>& event) override {}
|
||||
void OnPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event) override {}
|
||||
void OnBackPress() override {}
|
||||
|
||||
private:
|
||||
WeakPtr<RenderNode> node_;
|
||||
};
|
||||
|
||||
void RectConverter(const Rect& rect, Rosen::Rect& rosenRect)
|
||||
{
|
||||
rosenRect.posX_ = static_cast<int>(rect.GetOffset().GetX());
|
||||
rosenRect.posY_ = static_cast<int>(rect.GetOffset().GetY());
|
||||
rosenRect.width_ = static_cast<uint32_t>(rect.GetSize().Width());
|
||||
rosenRect.height_ = static_cast<uint32_t>(rect.GetSize().Height());
|
||||
}
|
||||
|
||||
void WantConverter(const std::string& want, AppExecFwk::ElementName& element)
|
||||
{
|
||||
auto json = JsonUtil::ParseJsonString(want);
|
||||
element.SetAbilityName(json->GetValue("ability")->GetString());
|
||||
element.SetBundleName(json->GetValue("bundle")->GetString());
|
||||
}
|
||||
|
||||
void WindowExtensionConnectionAdapterOhos::ConnectExtension(
|
||||
const std::string& want, const Rect& rect, WeakPtr<RenderNode> node)
|
||||
{
|
||||
#if defined(ENABLE_ROSEN_BACKEND) && defined(OS_ACCOUNT_EXISTS)
|
||||
LOGI("connect to windows extension begin");
|
||||
windowExtension_ = std::make_unique<Rosen::WindowExtensionConnection>();
|
||||
std::vector<int32_t> userIds;
|
||||
ErrCode code = AccountSA::OsAccountManager::QueryActiveOsAccountIds(userIds);
|
||||
if (code != ERR_OK) {
|
||||
LOGE("fail to queryAccountId, so cannot connect extension");
|
||||
return;
|
||||
}
|
||||
Rosen::Rect rosenRect;
|
||||
RectConverter(rect, rosenRect);
|
||||
AppExecFwk::ElementName element;
|
||||
WantConverter(want, element);
|
||||
sptr<Rosen::IWindowExtensionCallback> callback = new ConnectionCallback(node);
|
||||
windowExtension_->ConnectExtension(element, rosenRect, userIds.front(), callback);
|
||||
#else
|
||||
LOGI("unrosen engine doesn't support ability component");
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowExtensionConnectionAdapterOhos::RemoveExtension()
|
||||
{
|
||||
if (windowExtension_) {
|
||||
LOGI("no implement for remove");
|
||||
} else {
|
||||
LOGI("ability doesn't connect to window extension. remove extension fail");
|
||||
}
|
||||
}
|
||||
|
||||
void WindowExtensionConnectionAdapterOhos::UpdateRect(const Rect& rect)
|
||||
{
|
||||
if (windowExtension_) {
|
||||
Rosen::Rect rosenRect;
|
||||
RectConverter(rect, rosenRect);
|
||||
windowExtension_->SetBounds(rosenRect);
|
||||
} else {
|
||||
LOGI("ability doesn't connect to window extension.cannot update rect region ");
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_WINDOW_CONNECTION_WINDOW_EXTENSION_CONNECTION_OHOS_H
|
||||
#define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_WINDOW_CONNECTION_WINDOW_EXTENSION_CONNECTION_OHOS_H
|
||||
|
||||
#include "window_extension_connection.h"
|
||||
|
||||
#include "core/common/window/window_extension_connection_adapter.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class ACE_EXPORT WindowExtensionConnectionAdapterOhos : public WindowExtensionConnectionAdapter {
|
||||
DECLARE_ACE_TYPE(WindowExtensionConnectionAdapterOhos, WindowExtensionConnectionAdapter);
|
||||
public:
|
||||
void ConnectExtension(const std::string& want, const Rect& rect, WeakPtr<RenderNode> node) override;
|
||||
void RemoveExtension() override;
|
||||
void UpdateRect(const Rect& rect) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Rosen::WindowExtensionConnection> windowExtension_;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
#endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_WINDOW_CONNECTION_WINDOW_EXTENSION_CONNECTION_OHOS_H
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "core/common/window/window_extension_connection_proxy.h"
|
||||
|
||||
#include "window_extension_connection_ohos.h"
|
||||
|
||||
#include "base/memory/ace_type.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
RefPtr<WindowExtensionConnectionAdapter> WindowExtensionConnectionProxy::CreateAdapter()
|
||||
{
|
||||
return AceType::MakeRefPtr<WindowExtensionConnectionAdapterOhos>();
|
||||
}
|
||||
} // namespace OHOS::Ace
|
@ -53,8 +53,8 @@ template("ace_ohos_standard_source_set") {
|
||||
|
||||
if (defined(config.enable_rosen_backend) && config.enable_rosen_backend) {
|
||||
configs += [
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_base:export_config",
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_client:render_service_client_config",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_base:export_config",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:render_service_client_config",
|
||||
]
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ template("ace_ohos_standard_source_set") {
|
||||
"$ace_flutter_engine_root/skia:ace_skia_$platform",
|
||||
"$ace_root/adapter/ohos/capability:ace_capability_ohos",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native",
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-common",
|
||||
"//foundation/windowmanager/dm:libdm",
|
||||
@ -85,7 +85,7 @@ template("ace_ohos_standard_source_set") {
|
||||
]
|
||||
|
||||
public_deps =
|
||||
[ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ]
|
||||
[ "//base/global/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "base/utils/system_properties.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/ace_engine.h"
|
||||
#include "core/common/connect_server_manager.h"
|
||||
#include "core/common/container_scope.h"
|
||||
#include "core/common/flutter/flutter_asset_manager.h"
|
||||
#include "core/common/flutter/flutter_task_executor.h"
|
||||
@ -624,7 +625,8 @@ void AceContainer::CreateContainer(int32_t instanceId, FrontendType type, bool i
|
||||
instanceId, type, isArkApp, aceAbility, std::move(callback), useCurrentEventRunner);
|
||||
AceEngine::Get().AddContainer(instanceId, aceContainer);
|
||||
|
||||
HdcRegister::Get().StartHdcRegister();
|
||||
HdcRegister::Get().StartHdcRegister(instanceId);
|
||||
ConnectServerManager::Get().AddInstance(instanceId);
|
||||
aceContainer->Initialize();
|
||||
ContainerScope scope(instanceId);
|
||||
auto front = aceContainer->GetFrontend();
|
||||
@ -647,7 +649,7 @@ void AceContainer::DestroyContainer(int32_t instanceId)
|
||||
LOGE("no AceContainer with id %{private}d in AceEngine", instanceId);
|
||||
return;
|
||||
}
|
||||
HdcRegister::Get().StopHdcRegister();
|
||||
HdcRegister::Get().StopHdcRegister(instanceId);
|
||||
container->Destroy();
|
||||
auto taskExecutor = container->GetTaskExecutor();
|
||||
if (taskExecutor) {
|
||||
@ -660,6 +662,7 @@ void AceContainer::DestroyContainer(int32_t instanceId)
|
||||
LOGI("Remove on Platform thread...");
|
||||
EngineHelper::RemoveEngine(instanceId);
|
||||
AceEngine::Get().RemoveContainer(instanceId);
|
||||
ConnectServerManager::Get().RemoveInstance(instanceId);
|
||||
}, TaskExecutor::TaskType::PLATFORM);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ template("js_pa_engine_ark") {
|
||||
"//foundation/arkui/napi:ace_napi_ark",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/graphic/standard:libwmclient",
|
||||
"//foundation/graphic/graphic:libwmclient",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
external_deps = [
|
||||
@ -94,7 +94,7 @@ template("js_pa_engine_ark") {
|
||||
]
|
||||
|
||||
public_deps =
|
||||
[ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ]
|
||||
[ "//base/global/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
|
||||
sources = [
|
||||
"$ace_root/adapter/ohos/entrance/pa_engine/engine/common/js_backend_timer_module.cpp",
|
||||
|
@ -290,7 +290,7 @@ bool JsiPaEngineInstance::InitJsEnv(bool debuggerMode, const std::unordered_map<
|
||||
if (debuggerMode) {
|
||||
libraryPath = ARK_DEBUGGER_LIB_PATH;
|
||||
}
|
||||
if (!runtime_->Initialize(libraryPath, isDebugMode_)) {
|
||||
if (!runtime_->Initialize(libraryPath, isDebugMode_, instanceId_)) {
|
||||
LOGE("JsiPaEngineInstance initialize runtime failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ template("js_pa_engine_qjs") {
|
||||
"//foundation/arkui/napi:ace_napi",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/graphic/standard:libwmclient",
|
||||
"//foundation/graphic/graphic:libwmclient",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
external_deps = [
|
||||
@ -65,7 +65,7 @@ template("js_pa_engine_qjs") {
|
||||
]
|
||||
|
||||
public_deps =
|
||||
[ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ]
|
||||
[ "//base/global/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
|
||||
sources = [
|
||||
"$ace_root/adapter/ohos/entrance/pa_engine/engine/common/js_backend_timer_module.cpp",
|
||||
|
@ -23,15 +23,16 @@ template("ace_osal_ohos_source_set") {
|
||||
defines += invoker.defines
|
||||
if (is_standard_system) {
|
||||
external_deps = [
|
||||
"bytrace_standard:bytrace_core",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"startup_l2:syspara",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
configs = [ "$ace_root:ace_config" ]
|
||||
} else {
|
||||
external_deps = [
|
||||
"bytrace:bytrace_core",
|
||||
"hilog:libhilog",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"startup:syspara",
|
||||
]
|
||||
|
||||
@ -59,8 +60,9 @@ template("ace_osal_ohos_source_set") {
|
||||
sources += [ "resource_adapter_impl.cpp" ]
|
||||
sources += [ "resource_convertor.cpp" ]
|
||||
deps = [ "$ace_flutter_engine_root/icu:ace_libicu_ohos" ]
|
||||
public_deps +=
|
||||
[ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ]
|
||||
public_deps += [
|
||||
"//base/global/resource_management/frameworks/resmgr:global_resmgr",
|
||||
]
|
||||
external_deps += [ "multimedia_image_standard:image" ]
|
||||
if (defined(config.accessibility_support) &&
|
||||
config.accessibility_support) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "base/log/ace_trace.h"
|
||||
|
||||
#include "bytrace.h"
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
#include "base/log/log.h"
|
||||
#include "base/utils/macros.h"
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "parameter.h"
|
||||
#include "parameters.h"
|
||||
|
||||
#include "base/log/log.h"
|
||||
@ -36,7 +37,7 @@ const char PROPERTY_DEVICE_TYPE_WATCH[] = "watch";
|
||||
const char PROPERTY_DEVICE_TYPE_CAR[] = "car";
|
||||
const char DISABLE_ROSEN_FILE_PATH[] = "/etc/disablerosen";
|
||||
const char DISABLE_WINDOW_ANIMATION_PATH[] = "/etc/disable_window_size_animation";
|
||||
const char ENABLE_DEBUG_BOUNDARY_FILE_PATH[] = "/etc/enable_paint_boundary";
|
||||
const char ENABLE_DEBUG_BOUNDARY_KEY[] = "persist.ace.debug.boundary.enabled";
|
||||
|
||||
constexpr int32_t ORIENTATION_PORTRAIT = 0;
|
||||
constexpr int32_t ORIENTATION_LANDSCAPE = 1;
|
||||
@ -54,17 +55,6 @@ bool IsTraceEnabled()
|
||||
system::GetParameter("debug.ace.trace.enabled", "0") == "1");
|
||||
}
|
||||
|
||||
bool IsDebugBoundaryEnabled()
|
||||
{
|
||||
if (system::GetParameter("persist.ace.debug.boundary.enabled", "0") == "1") {
|
||||
return true;
|
||||
}
|
||||
if (system::GetParameter("persist.ace.debug.boundary.enabled", "0") == "2") {
|
||||
return false;
|
||||
}
|
||||
return access(ENABLE_DEBUG_BOUNDARY_FILE_PATH, F_OK) == 0;
|
||||
}
|
||||
|
||||
bool IsRosenBackendEnabled()
|
||||
{
|
||||
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
|
||||
@ -128,6 +118,15 @@ bool SystemProperties::IsSyscapExist(const char* cap)
|
||||
#endif
|
||||
}
|
||||
|
||||
void SystemProperties::UpdateDebugBoundaryEnabled(const char *key, const char *value, void *context)
|
||||
{
|
||||
if (strcmp(value, "true") == 0) {
|
||||
debugBoundaryEnabled_ = true;
|
||||
} else if (strcmp(value, "false") == 0) {
|
||||
debugBoundaryEnabled_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SystemProperties::InitDeviceType(DeviceType)
|
||||
{
|
||||
// Do nothing, no need to store type here, use system property at 'GetDeviceType' instead.
|
||||
@ -177,7 +176,7 @@ ColorMode SystemProperties::colorMode_ { ColorMode::LIGHT };
|
||||
ScreenShape SystemProperties::screenShape_ { ScreenShape::NOT_ROUND };
|
||||
LongScreenType SystemProperties::LongScreen_ { LongScreenType::NOT_LONG };
|
||||
bool SystemProperties::rosenBackendEnabled_ = IsRosenBackendEnabled();
|
||||
bool SystemProperties::debugBoundaryEnabled_ = IsDebugBoundaryEnabled();
|
||||
bool SystemProperties::debugBoundaryEnabled_ = false;
|
||||
bool SystemProperties::windowAnimationEnabled_ = IsWindowAnimationEnabled();
|
||||
bool SystemProperties::debugEnabled_ = IsDebugEnabled();
|
||||
int32_t SystemProperties::windowPosX_ = 0;
|
||||
@ -234,7 +233,6 @@ void SystemProperties::InitDeviceInfo(
|
||||
traceEnabled_ = IsTraceEnabled();
|
||||
accessibilityEnabled_ = IsAccessibilityEnabled();
|
||||
rosenBackendEnabled_ = IsRosenBackendEnabled();
|
||||
debugBoundaryEnabled_ = IsDebugBoundaryEnabled();
|
||||
|
||||
if (isRound_) {
|
||||
screenShape_ = ScreenShape::ROUND;
|
||||
@ -243,6 +241,7 @@ void SystemProperties::InitDeviceInfo(
|
||||
}
|
||||
|
||||
InitDeviceTypeBySystemProperty();
|
||||
WatchParameter(ENABLE_DEBUG_BOUNDARY_KEY, SystemProperties::UpdateDebugBoundaryEnabled, nullptr);
|
||||
}
|
||||
|
||||
void SystemProperties::SetDeviceOrientation(int32_t orientation)
|
||||
|
@ -82,7 +82,7 @@ template("uiservice_static") {
|
||||
"//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-common",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
|
@ -55,6 +55,7 @@ UIMgrService::UIMgrService()
|
||||
|
||||
UIMgrService::~UIMgrService()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(uiMutex_);
|
||||
callbackMap_.clear();
|
||||
}
|
||||
|
||||
@ -496,6 +497,7 @@ int UIMgrService::Push(const AAFwk::Want& want, const std::string& name,
|
||||
{
|
||||
HILOG_INFO("UIMgrService::Push called start");
|
||||
std::map<std::string, sptr<IUIService>>::iterator iter;
|
||||
std::lock_guard<std::mutex> lock(uiMutex_);
|
||||
for (iter = callbackMap_.begin(); iter != callbackMap_.end(); ++iter) {
|
||||
sptr<IUIService> uiService = iter->second;
|
||||
if (uiService == nullptr) {
|
||||
@ -511,6 +513,7 @@ int UIMgrService::Request(const AAFwk::Want& want, const std::string& name, cons
|
||||
{
|
||||
HILOG_INFO("UIMgrService::Request called start");
|
||||
std::map<std::string, sptr<IUIService>>::iterator iter;
|
||||
std::lock_guard<std::mutex> lock(uiMutex_);
|
||||
for (iter = callbackMap_.begin(); iter != callbackMap_.end(); ++iter) {
|
||||
sptr<IUIService> uiService = iter->second;
|
||||
if (uiService == nullptr) {
|
||||
@ -545,7 +548,7 @@ std::shared_ptr<EventHandler> UIMgrService::GetEventHandler()
|
||||
int UIMgrService::HandleRegister(const AAFwk::Want& want, const sptr<IUIService>& uiService)
|
||||
{
|
||||
HILOG_INFO("UIMgrService::HandleRegister called start");
|
||||
std::lock_guard<std::mutex> lock_l(uiMutex_);
|
||||
std::lock_guard<std::mutex> lock(uiMutex_);
|
||||
std::string keyStr = GetCallBackKeyStr(want);
|
||||
HILOG_INFO("UIMgrService::HandleRegister keyStr = %{public}s", keyStr.c_str());
|
||||
bool exist = CheckCallBackFromMap(keyStr);
|
||||
@ -560,7 +563,7 @@ int UIMgrService::HandleRegister(const AAFwk::Want& want, const sptr<IUIService>
|
||||
int UIMgrService::HandleUnregister(const AAFwk::Want& want)
|
||||
{
|
||||
HILOG_INFO("UIMgrService::HandleUnregister called start");
|
||||
std::lock_guard<std::mutex> lock_l(uiMutex_);
|
||||
std::lock_guard<std::mutex> lock(uiMutex_);
|
||||
std::string keyStr = GetCallBackKeyStr(want);
|
||||
bool exist = CheckCallBackFromMap(keyStr);
|
||||
if (!exist) {
|
||||
@ -577,8 +580,7 @@ std::string UIMgrService::GetCallBackKeyStr(const AAFwk::Want& want)
|
||||
HILOG_INFO("UIMgrService::GetCallBackKeyStr called start");
|
||||
AppExecFwk::ElementName element = want.GetElement();
|
||||
std::string bundleName = element.GetBundleName();
|
||||
std::string abilityName = element.GetAbilityName();
|
||||
std::string keyStr = bundleName + abilityName;
|
||||
std::string keyStr = bundleName;
|
||||
HILOG_INFO("UIMgrService::GetCallBackKeyStr called end");
|
||||
return keyStr;
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
"name" : "ui_service",
|
||||
"path" : ["/system/bin/sa_main", "/system/profile/ui_service.xml"],
|
||||
"uid" : "system",
|
||||
"gid" : ["system", "shell"]
|
||||
"gid" : ["system", "shell"],
|
||||
"secon" : "u:r:ui_service:s0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ enable_rosen_backend = false
|
||||
enable_standard_input = false
|
||||
enable_system_clipboard = false
|
||||
ohos_standard_fontmgr = true
|
||||
enable_ability_component = false
|
||||
|
||||
if (form_components_support) {
|
||||
defines += [ "FORM_SUPPORTED" ]
|
||||
|
@ -38,6 +38,8 @@ if (enable_ark_preview) {
|
||||
xcomponent_components_support = true
|
||||
}
|
||||
|
||||
enable_ability_component = false
|
||||
|
||||
# windows platform defines and configs
|
||||
defines = [
|
||||
"WINDOWS_PLATFORM",
|
||||
|
@ -59,7 +59,7 @@ template("preview_entrance_source") {
|
||||
"//utils/native/base/include",
|
||||
"//third_party/flutter/glfw/include",
|
||||
]
|
||||
deps += [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
deps += [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
cflags_cc += [ "-DNONLS" ]
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ template("preview_entrance_source") {
|
||||
"//utils/native/base/include",
|
||||
"//third_party/flutter/glfw/include",
|
||||
]
|
||||
deps += [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
deps += [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ template("ace_test") {
|
||||
deps += [
|
||||
":copy_ark_shared_library(${current_toolchain})",
|
||||
":copy_icu_data_resource(${current_toolchain})",
|
||||
":copy_icu_shared_library(${current_toolchain})",
|
||||
":copy_napi_shared_library(${current_toolchain})",
|
||||
]
|
||||
} else {
|
||||
@ -102,42 +103,93 @@ if (enable_ark_preview) {
|
||||
ark_core_shared_library =
|
||||
get_label_info("//ark/runtime_core/libpandabase:libarkbase",
|
||||
"root_out_dir") + "/ark/ark"
|
||||
sources += [
|
||||
"$ark_core_shared_library/libarkbase.dll",
|
||||
"$ark_core_shared_library/libarkfile.dll",
|
||||
"$ark_core_shared_library/libarkziparchive.dll",
|
||||
]
|
||||
deps += [
|
||||
"//ark/runtime_core/libpandabase:libarkbase(${current_toolchain})",
|
||||
"//ark/runtime_core/libpandafile:libarkfile(${current_toolchain})",
|
||||
"//ark/runtime_core/libziparchive:libarkziparchive(${current_toolchain})",
|
||||
]
|
||||
if (use_mac) {
|
||||
sources += [
|
||||
"$ark_core_shared_library/libarkbase.dylib",
|
||||
"$ark_core_shared_library/libarkfile.dylib",
|
||||
"$ark_core_shared_library/libarkziparchive.dylib",
|
||||
]
|
||||
outputs =
|
||||
[ root_build_dir + "/clang_x64/common/common/{{source_file_part}}" ]
|
||||
} else {
|
||||
sources += [
|
||||
"$ark_core_shared_library/libarkbase.dll",
|
||||
"$ark_core_shared_library/libarkfile.dll",
|
||||
"$ark_core_shared_library/libarkziparchive.dll",
|
||||
]
|
||||
outputs = [ root_build_dir +
|
||||
"/mingw_x86_64/common/common/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
ark_js_shared_library =
|
||||
get_label_info("//ark/js_runtime:libark_jsruntime", "root_out_dir") +
|
||||
"/ark/ark_js_runtime"
|
||||
sources += [ "$ark_js_shared_library/libark_jsruntime.dll" ]
|
||||
deps += [ "//ark/js_runtime:libark_jsruntime" ]
|
||||
outputs =
|
||||
[ root_build_dir + "/mingw_x86_64/common/common/{{source_file_part}}" ]
|
||||
if (use_mac) {
|
||||
sources += [ "$ark_js_shared_library/libark_jsruntime.dylib" ]
|
||||
} else {
|
||||
sources += [ "$ark_js_shared_library/libark_jsruntime.dll" ]
|
||||
}
|
||||
}
|
||||
ohos_copy("copy_napi_shared_library") {
|
||||
shared_library_path =
|
||||
get_label_info("$ace_napi:ace_napi(${current_toolchain})",
|
||||
"root_out_dir")
|
||||
sources = [
|
||||
"$shared_library_path/arkui/napi/libace_napi.dll",
|
||||
"$shared_library_path/arkui/napi/libace_napi_ark.dll",
|
||||
]
|
||||
deps = [
|
||||
"$ace_napi:ace_napi(${current_toolchain})",
|
||||
"$ace_napi:ace_napi_ark(${current_toolchain})",
|
||||
]
|
||||
outputs =
|
||||
[ root_build_dir + "/mingw_x86_64/common/common/{{source_file_part}}" ]
|
||||
if (use_mac) {
|
||||
sources = [
|
||||
"$shared_library_path/arkui/napi/libace_napi.dylib",
|
||||
"$shared_library_path/arkui/napi/libace_napi_ark.dylib",
|
||||
]
|
||||
outputs =
|
||||
[ root_build_dir + "/clang_x64/common/common/{{source_file_part}}" ]
|
||||
} else {
|
||||
sources = [
|
||||
"$shared_library_path/arkui/napi/libace_napi.dll",
|
||||
"$shared_library_path/arkui/napi/libace_napi_ark.dll",
|
||||
]
|
||||
outputs = [ root_build_dir +
|
||||
"/mingw_x86_64/common/common/{{source_file_part}}" ]
|
||||
}
|
||||
}
|
||||
ohos_copy("copy_icu_shared_library") {
|
||||
shared_library_path =
|
||||
get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
|
||||
deps = [
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
]
|
||||
if (use_mac) {
|
||||
sources = [
|
||||
"$shared_library_path/thirdparty/icu/libhmicui18n.dylib",
|
||||
"$shared_library_path/thirdparty/icu/libhmicuuc.dylib",
|
||||
]
|
||||
outputs =
|
||||
[ root_build_dir + "/clang_x64/common/common/{{source_file_part}}" ]
|
||||
} else {
|
||||
sources = [
|
||||
"$shared_library_path/thirdparty/icu/libhmicui18n.dll",
|
||||
"$shared_library_path/thirdparty/icu/libhmicuuc.dll",
|
||||
]
|
||||
outputs = [ root_build_dir +
|
||||
"/mingw_x86_64/common/common/{{source_file_part}}" ]
|
||||
}
|
||||
}
|
||||
ohos_copy("copy_icu_data_resource") {
|
||||
sources = [ "//third_party/icu/icu4c/source/data/out/tmp/icudt67l.dat" ]
|
||||
outputs = [ root_build_dir + "/mingw_x86_64/common/common/icudt67l.dat" ]
|
||||
if (use_mac) {
|
||||
outputs = [ root_build_dir + "/clang_x64/common/common/icudt67l.dat" ]
|
||||
} else {
|
||||
outputs = [ root_build_dir + "/mingw_x86_64/common/common/icudt67l.dat" ]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ohos_copy("copy_napi_shared_library_for_test") {
|
||||
@ -195,9 +247,9 @@ ohos_copy("copy_resource_dynamic_library") {
|
||||
if (use_mac) {
|
||||
if (is_standard_system) {
|
||||
resource_manager_library = get_label_info(
|
||||
"//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_mac",
|
||||
"root_out_dir") + "/global/resmgr_standard/libglobal_resmgr_mac.dylib"
|
||||
deps = [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
"//base/global/resource_management/frameworks/resmgr:global_resmgr_mac",
|
||||
"root_out_dir") + "/global/resource_management/libglobal_resmgr_mac.dylib"
|
||||
deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
sources = [ resource_manager_library ]
|
||||
} else {
|
||||
sources = [
|
||||
@ -210,9 +262,9 @@ ohos_copy("copy_resource_dynamic_library") {
|
||||
} else {
|
||||
if (is_standard_system) {
|
||||
resource_manager_library = get_label_info(
|
||||
"//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_win",
|
||||
"root_out_dir") + "/global/resmgr_standard/libglobal_resmgr_win.dll"
|
||||
deps = [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
"//base/global/resource_management/frameworks/resmgr:global_resmgr_win",
|
||||
"root_out_dir") + "/global/resource_management/libglobal_resmgr_win.dll"
|
||||
deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
sources = [ resource_manager_library ]
|
||||
} else {
|
||||
sources = [
|
||||
|
@ -72,9 +72,9 @@ template("ace_osal_preview_source_set") {
|
||||
include_dirs = [ "//utils/native/base/include" ]
|
||||
defines += [ "OHOS_STANDARD_SYSTEM" ]
|
||||
if (platform == "windows") {
|
||||
deps += [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
deps += [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
} else if (platform == "mac") {
|
||||
deps += [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
deps += [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
}
|
||||
} else {
|
||||
sources += [ "resource_adapter_impl.cpp" ]
|
||||
|
@ -25,16 +25,13 @@ if (is_standard_system) {
|
||||
get_label_info("//utils/resources/systemres:systemres_hap",
|
||||
"target_out_dir") + "/resources"
|
||||
if (host_os == "mac") {
|
||||
resource_manager_library =
|
||||
get_label_info(
|
||||
"//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_mac",
|
||||
"root_out_dir") +
|
||||
"/global/resmgr_standard/libglobal_resmgr_mac.dylib"
|
||||
resource_manager_library = get_label_info(
|
||||
"//base/global/resource_management/frameworks/resmgr:global_resmgr_mac",
|
||||
"root_out_dir") + "/global/resource_management/libglobal_resmgr_mac.dylib"
|
||||
} else {
|
||||
resource_manager_library =
|
||||
get_label_info(
|
||||
"//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_win",
|
||||
"root_out_dir") + "/global/resmgr_standard/libglobal_resmgr_win.dll"
|
||||
resource_manager_library = get_label_info(
|
||||
"//base/global/resource_management/frameworks/resmgr:global_resmgr_win",
|
||||
"root_out_dir") + "/global/resource_management/libglobal_resmgr_win.dll"
|
||||
}
|
||||
} else {
|
||||
system_resource_hap_path =
|
||||
@ -114,6 +111,15 @@ if (is_standard_system) {
|
||||
ark_js_shared_library =
|
||||
get_label_info("//ark/js_runtime:libark_jsruntime", "root_out_dir") +
|
||||
"/ark/ark_js_runtime"
|
||||
deps = [
|
||||
"$ace_napi:ace_napi",
|
||||
"$ace_napi:ace_napi_ark",
|
||||
"//ark/js_runtime:libark_jsruntime",
|
||||
"//ark/runtime_core/libpandabase:libarkbase",
|
||||
"//ark/runtime_core/libpandafile:libarkfile",
|
||||
"//ark/runtime_core/libziparchive:libarkziparchive",
|
||||
"//third_party/libuv:uv",
|
||||
]
|
||||
if (use_mingw_win) {
|
||||
sources = [
|
||||
"$ark_core_shared_library/libarkbase.dll",
|
||||
@ -125,14 +131,16 @@ if (is_standard_system) {
|
||||
"$shared_library_path_uv/arkui/napi/libuv.dll",
|
||||
"//third_party/icu/icu4c/source/data/out/tmp/icudt67l.dat",
|
||||
]
|
||||
deps = [
|
||||
"$ace_napi:ace_napi",
|
||||
"$ace_napi:ace_napi_ark",
|
||||
"//ark/js_runtime:libark_jsruntime",
|
||||
"//ark/runtime_core/libpandabase:libarkbase",
|
||||
"//ark/runtime_core/libpandafile:libarkfile",
|
||||
"//ark/runtime_core/libziparchive:libarkziparchive",
|
||||
"//third_party/libuv:uv",
|
||||
} else {
|
||||
sources = [
|
||||
"$ark_core_shared_library/libarkbase.dylib",
|
||||
"$ark_core_shared_library/libarkfile.dylib",
|
||||
"$ark_core_shared_library/libarkziparchive.dylib",
|
||||
"$ark_js_shared_library/libark_jsruntime.dylib",
|
||||
"$shared_library_path_napi/arkui/napi/libace_napi.dylib",
|
||||
"$shared_library_path_napi/arkui/napi/libace_napi_ark.dylib",
|
||||
"$shared_library_path_uv/arkui/napi/libuv.dylib",
|
||||
"//third_party/icu/icu4c/source/data/out/tmp/icudt67l.dat",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
@ -188,9 +196,9 @@ if (is_standard_system) {
|
||||
|
||||
ohos_copy("copy_resource_dynamic_library_standard") {
|
||||
if (host_os == "mac") {
|
||||
deps = [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac(${current_toolchain})" ]
|
||||
} else {
|
||||
deps = [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
deps = [ "//base/global/resource_management/frameworks/resmgr:global_resmgr_win(${current_toolchain})" ]
|
||||
}
|
||||
|
||||
sources = [ resource_manager_library ]
|
||||
|
@ -443,11 +443,11 @@ template("flutter_engine_shell") {
|
||||
"$flutter_root/engine/flutter/shell/platform/ohos/ohos_surface_gl.cc",
|
||||
]
|
||||
|
||||
public_deps = [ "//foundation/graphic/standard:libgl" ]
|
||||
public_deps = [ "//foundation/graphic/graphic:libgl" ]
|
||||
}
|
||||
deps += [
|
||||
"//foundation/graphic/standard/rosen/modules/composer:libcomposer",
|
||||
"//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic/rosen/modules/composer:libcomposer",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
]
|
||||
external_deps = [
|
||||
|
@ -86,7 +86,7 @@ template("make_skia_deps") {
|
||||
":harfbuzz_config",
|
||||
]
|
||||
public_deps =
|
||||
[ "//foundation/graphic/standard/rosen/build/skia:skia_ohos" ]
|
||||
[ "//foundation/graphic/graphic/rosen/build/skia:skia_ohos" ]
|
||||
} else if (platform == "ohos" && defined(config.enable_native_view) &&
|
||||
config.enable_native_view) {
|
||||
public_configs = [
|
||||
@ -886,7 +886,7 @@ template("ace_skia_core") {
|
||||
]
|
||||
} else {
|
||||
if (is_standard_system) {
|
||||
public_deps = [ "//foundation/graphic/standard:libgl" ]
|
||||
public_deps = [ "//foundation/graphic/graphic:libgl" ]
|
||||
} else {
|
||||
aosp_deps = [
|
||||
"shared_library:libEGL",
|
||||
@ -1505,7 +1505,7 @@ template("ace_gpu") {
|
||||
if (!defined(config.disable_gpu) || !config.disable_gpu) {
|
||||
# Ohos or Android platform
|
||||
if (is_standard_system) {
|
||||
public_deps = [ "//foundation/graphic/standard:libgl" ]
|
||||
public_deps = [ "//foundation/graphic/graphic:libgl" ]
|
||||
} else {
|
||||
aosp_deps = [
|
||||
"shared_library:libEGL",
|
||||
|
@ -279,6 +279,8 @@ public:
|
||||
return windowAnimationEnabled_;
|
||||
}
|
||||
|
||||
static void UpdateDebugBoundaryEnabled(const char *key, const char *value, void *context);
|
||||
|
||||
private:
|
||||
static bool traceEnabled_;
|
||||
static bool accessibilityEnabled_;
|
||||
|
@ -56,6 +56,11 @@ public:
|
||||
return (domNode == nullptr) ? nullptr : domNode->GetRootComponent();
|
||||
}
|
||||
|
||||
size_t GetComponentsCount() const
|
||||
{
|
||||
return domNodes_.size();
|
||||
}
|
||||
|
||||
const RefPtr<StackComponent>& GetRootStackComponent() const
|
||||
{
|
||||
return rootStackComponent_;
|
||||
|
@ -95,6 +95,7 @@ DOMNode::DOMNode(NodeId nodeId, const std::string& nodeName) : nodeId_(nodeId),
|
||||
{
|
||||
rootComponent_ = AceType::MakeRefPtr<ComposedComponent>(std::to_string(nodeId), nodeName);
|
||||
boxComponent_ = AceType::MakeRefPtr<BoxComponent>();
|
||||
boxComponent_->SetEnableDebugBoundary(true);
|
||||
CreateDeclaration(nodeName);
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,6 @@ template("declarative_js_engine") {
|
||||
"jsview/action_sheet/js_action_sheet.cpp",
|
||||
"jsview/dialog/js_alert_dialog.cpp",
|
||||
"jsview/dialog/js_custom_dialog_controller.cpp",
|
||||
"jsview/js_ability_component.cpp",
|
||||
"jsview/js_ability_component_controller.cpp",
|
||||
"jsview/js_animator.cpp",
|
||||
"jsview/js_badge.cpp",
|
||||
"jsview/js_blank.cpp",
|
||||
@ -224,6 +222,8 @@ template("declarative_js_engine") {
|
||||
"jsview/js_view_context.cpp",
|
||||
"jsview/js_view_functions.cpp",
|
||||
"jsview/js_view_stack_processor.cpp",
|
||||
"jsview/js_water_flow.cpp",
|
||||
"jsview/js_water_flow_item.cpp",
|
||||
"jsview/menu/js_context_menu.cpp",
|
||||
"jsview/scroll_bar/js_scroll_bar.cpp",
|
||||
"sharedata/js_share_data.cpp",
|
||||
@ -250,6 +250,14 @@ template("declarative_js_engine") {
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(config.enable_ability_component) &&
|
||||
config.enable_ability_component) {
|
||||
sources += [
|
||||
"jsview/js_ability_component.cpp",
|
||||
"jsview/js_ability_component_controller.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(config.web_components_support) &&
|
||||
config.web_components_support) {
|
||||
sources += [
|
||||
|
@ -802,6 +802,7 @@ void DeclarativeFrontend::DumpFrontend() const
|
||||
delegate_->GetState(routerIndex, routerName, routerPath);
|
||||
|
||||
if (DumpLog::GetInstance().GetDumpFile()) {
|
||||
DumpLog::GetInstance().AddDesc("Components: " + std::to_string(delegate_->GetComponentsCount()));
|
||||
DumpLog::GetInstance().AddDesc("Path: " + routerPath);
|
||||
DumpLog::GetInstance().AddDesc("Length: " + std::to_string(routerIndex));
|
||||
DumpLog::GetInstance().Print(0, routerName, 0);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "base/log/event_report.h"
|
||||
#include "core/common/ace_application_info.h"
|
||||
#include "core/common/ace_view.h"
|
||||
#include "core/common/connect_server_manager.h"
|
||||
#include "core/common/container.h"
|
||||
#include "core/common/container_scope.h"
|
||||
#include "frameworks/bridge/common/utils/engine_helper.h"
|
||||
@ -190,7 +191,7 @@ bool JsiDeclarativeEngineInstance::InitJsEnv(bool debuggerMode,
|
||||
if (debuggerMode) {
|
||||
libraryPath = ARK_DEBUGGER_LIB_PATH;
|
||||
}
|
||||
if (!usingSharedRuntime_ && !runtime_->Initialize(libraryPath, isDebugMode_)) {
|
||||
if (!usingSharedRuntime_ && !runtime_->Initialize(libraryPath, isDebugMode_, instanceId_)) {
|
||||
LOGE("Js Engine initialize runtime failed");
|
||||
return false;
|
||||
}
|
||||
@ -711,6 +712,7 @@ bool JsiDeclarativeEngine::Initialize(const RefPtr<FrontendDelegate>& delegate)
|
||||
}
|
||||
nativeEngine_ = nativeArkEngine;
|
||||
}
|
||||
engineInstance_->SetInstanceId(instanceId_);
|
||||
engineInstance_->SetDebugMode(NeedDebugBreakPoint());
|
||||
bool result = engineInstance_->InitJsEnv(IsDebugVersion(), GetExtraNativeObject(), arkRuntime);
|
||||
if (!result) {
|
||||
@ -780,7 +782,13 @@ void JsiDeclarativeEngine::SetPostTask(NativeEngine* nativeEngine)
|
||||
void JsiDeclarativeEngine::RegisterInitWorkerFunc()
|
||||
{
|
||||
auto weakInstance = AceType::WeakClaim(AceType::RawPtr(engineInstance_));
|
||||
auto&& initWorkerFunc = [weakInstance](NativeEngine* nativeEngine) {
|
||||
bool debugVersion = IsDebugVersion();
|
||||
bool debugMode = NeedDebugBreakPoint();
|
||||
std::string libraryPath = "";
|
||||
if (debugVersion) {
|
||||
libraryPath = ARK_DEBUGGER_LIB_PATH;
|
||||
}
|
||||
auto&& initWorkerFunc = [weakInstance, debugMode, libraryPath](NativeEngine* nativeEngine) {
|
||||
LOGI("WorkerCore RegisterInitWorkerFunc called");
|
||||
if (nativeEngine == nullptr) {
|
||||
LOGE("nativeEngine is nullptr");
|
||||
@ -796,6 +804,11 @@ void JsiDeclarativeEngine::RegisterInitWorkerFunc()
|
||||
LOGE("instance is nullptr");
|
||||
return;
|
||||
}
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
ConnectServerManager::Get().AddInstance(gettid());
|
||||
auto vm = const_cast<EcmaVM*>(arkNativeEngine->GetEcmaVm());
|
||||
panda::JSNApi::StartDebugger(libraryPath.c_str(), vm, debugMode, gettid());
|
||||
#endif
|
||||
instance->InitConsoleModule(arkNativeEngine);
|
||||
|
||||
std::vector<uint8_t> buffer((uint8_t*)_binary_jsEnumStyle_abc_start, (uint8_t*)_binary_jsEnumStyle_abc_end);
|
||||
@ -807,6 +820,33 @@ void JsiDeclarativeEngine::RegisterInitWorkerFunc()
|
||||
nativeEngine_->SetInitWorkerFunc(initWorkerFunc);
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
void JsiDeclarativeEngine::RegisterOffWorkerFunc()
|
||||
{
|
||||
auto weakInstance = AceType::WeakClaim(AceType::RawPtr(engineInstance_));
|
||||
bool debugVersion = IsDebugVersion();
|
||||
auto&& offWorkerFunc = [debugVersion](NativeEngine* nativeEngine) {
|
||||
LOGI("WorkerCore RegisterOffWorkerFunc called");
|
||||
if (!debugVersion) {
|
||||
return;
|
||||
}
|
||||
if (nativeEngine == nullptr) {
|
||||
LOGE("nativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
auto arkNativeEngine = static_cast<ArkNativeEngine*>(nativeEngine);
|
||||
if (arkNativeEngine == nullptr) {
|
||||
LOGE("arkNativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
ConnectServerManager::Get().RemoveInstance(gettid());
|
||||
auto vm = const_cast<EcmaVM*>(arkNativeEngine->GetEcmaVm());
|
||||
panda::JSNApi::StopDebugger(vm);
|
||||
};
|
||||
nativeEngine_->SetOffWorkerFunc(offWorkerFunc);
|
||||
}
|
||||
#endif
|
||||
|
||||
void JsiDeclarativeEngine::RegisterAssetFunc()
|
||||
{
|
||||
auto weakDelegate = AceType::WeakClaim(AceType::RawPtr(engineInstance_->GetDelegate()));
|
||||
@ -830,6 +870,9 @@ void JsiDeclarativeEngine::RegisterAssetFunc()
|
||||
void JsiDeclarativeEngine::RegisterWorker()
|
||||
{
|
||||
RegisterInitWorkerFunc();
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
RegisterOffWorkerFunc();
|
||||
#endif
|
||||
RegisterAssetFunc();
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,11 @@ public:
|
||||
isDebugMode_ = isDebugMode;
|
||||
}
|
||||
|
||||
void SetInstanceId(int32_t instanceId)
|
||||
{
|
||||
instanceId_ = instanceId;
|
||||
}
|
||||
|
||||
void SetRootView(int32_t pageId, panda::Global<panda::ObjectRef> value)
|
||||
{
|
||||
rootViewMap_.emplace(pageId, value);
|
||||
@ -174,6 +179,7 @@ private:
|
||||
mutable std::mutex mutex_;
|
||||
bool isDebugMode_ = true;
|
||||
bool usingSharedRuntime_ = false;
|
||||
int32_t instanceId_ = 0;
|
||||
static bool isModulePreloaded_;
|
||||
static bool isModuleInitialized_;
|
||||
static shared_ptr<JsRuntime> globalRuntime_;
|
||||
@ -298,6 +304,7 @@ private:
|
||||
|
||||
void RegisterWorker();
|
||||
void RegisterInitWorkerFunc();
|
||||
void RegisterOffWorkerFunc();
|
||||
void RegisterAssetFunc();
|
||||
bool ExecuteAbc(const std::string &fileName);
|
||||
|
||||
|
@ -140,6 +140,8 @@
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_context.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow_item.h"
|
||||
#if !defined(WINDOWS_PLATFORM) and !defined(MAC_PLATFORM)
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent_controller.h"
|
||||
@ -856,7 +858,9 @@ static const std::unordered_map<std::string, std::function<void(BindingTarget)>>
|
||||
{ "ActionSheet", JSActionSheet::JSBind },
|
||||
{ "AlertDialog", JSAlertDialog::JSBind },
|
||||
{ "ContextMenu", JSContextMenu::JSBind },
|
||||
#ifdef ABILITY_COMPONENT_SUPPORTED
|
||||
{ "AbilityComponent", JSAbilityComponent::JSBind },
|
||||
#endif
|
||||
{ "TextArea", JSTextArea::JSBind },
|
||||
{ "TextInput", JSTextInput::JSBind },
|
||||
{ "TextClock", JSTextClock::JSBind },
|
||||
@ -926,7 +930,9 @@ static const std::unordered_map<std::string, std::function<void(BindingTarget)>>
|
||||
{ "TextTimerController", JSTextTimerController::JSBind },
|
||||
{ "Checkbox", JSCheckbox::JSBind },
|
||||
{ "CheckboxGroup", JSCheckboxGroup::JSBind },
|
||||
{ "Refresh", JSRefresh::JSBind }
|
||||
{ "Refresh", JSRefresh::JSBind },
|
||||
{ "WaterFlow", JSWaterFlow::JSBind },
|
||||
{ "FlowItem", JSWaterFlowItem::JSBind }
|
||||
};
|
||||
|
||||
void RegisterAllModule(BindingTarget globalObj)
|
||||
|
@ -140,6 +140,8 @@
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_register.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_local_storage.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow_item.h"
|
||||
#ifdef XCOMPONENT_SUPPORTED
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent_controller.h"
|
||||
@ -952,6 +954,9 @@ void JsRegisterViews(BindingTarget globalObj)
|
||||
JSTextPickerDialog::JSBind(globalObj);
|
||||
JSCheckbox::JSBind(globalObj);
|
||||
JSCheckboxGroup::JSBind(globalObj);
|
||||
JSWaterFlow::JSBind(globalObj);
|
||||
JSWaterFlowItem::JSBind(globalObj);
|
||||
|
||||
|
||||
JSObjectTemplate toggleType;
|
||||
toggleType.Constant("Checkbox", 0);
|
||||
@ -968,9 +973,10 @@ void JsRegisterViews(BindingTarget globalObj)
|
||||
JSActionSheet::JSBind(globalObj);
|
||||
JSAlertDialog::JSBind(globalObj);
|
||||
JSContextMenu::JSBind(globalObj);
|
||||
#ifdef ABILITY_COMPONENT_SUPPORTED
|
||||
JSAbilityComponent::JSBind(globalObj);
|
||||
JSAbilityComponentController::JSBind(globalObj);
|
||||
|
||||
#endif
|
||||
JSCustomDialogController::JSBind(globalObj);
|
||||
JSShareData::JSBind(globalObj);
|
||||
|
||||
|
@ -136,6 +136,8 @@
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_context.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow_item.h"
|
||||
#if !defined(WINDOWS_PLATFORM) and !defined(MAC_PLATFORM)
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent_controller.h"
|
||||
@ -633,7 +635,9 @@ static const std::unordered_map<std::string, std::function<void(BindingTarget)>>
|
||||
{"ActionSheet", JSActionSheet::JSBind},
|
||||
{"AlertDialog", JSAlertDialog::JSBind},
|
||||
{"ContextMenu", JSContextMenu::JSBind },
|
||||
#ifdef ABILITY_COMPONENT_SUPPORTED
|
||||
{"AbilityComponent", JSAbilityComponent::JSBind},
|
||||
#endif
|
||||
{"TextArea", JSTextArea::JSBind},
|
||||
{"TextInput", JSTextInput::JSBind},
|
||||
{"TextClock", JSTextClock::JSBind},
|
||||
@ -696,7 +700,9 @@ static const std::unordered_map<std::string, std::function<void(BindingTarget)>>
|
||||
{"TextTimerController", JSTextTimerController::JSBind},
|
||||
{"TextClockController", JSTextClockController::JSBind},
|
||||
{"Checkbox", JSCheckbox::JSBind},
|
||||
{"CheckboxGroup", JSCheckboxGroup::JSBind}
|
||||
{"CheckboxGroup", JSCheckboxGroup::JSBind},
|
||||
{"WaterFlow", JSWaterFLow::JSBind},
|
||||
{"FlowItem", JSFLowItem::JSBind}
|
||||
};
|
||||
|
||||
void RegisterAllModule(BindingTarget globalObj)
|
||||
|
@ -919,6 +919,16 @@ void FrontendDelegateDeclarative::GetState(int32_t& index, std::string& name, st
|
||||
}
|
||||
}
|
||||
|
||||
size_t FrontendDelegateDeclarative::GetComponentsCount()
|
||||
{
|
||||
auto pipelineContext = pipelineContextHolder_.Get();
|
||||
const auto& pageElement = pipelineContext->GetLastPage();
|
||||
if (pageElement) {
|
||||
return pageElement->GetComponentsCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string FrontendDelegateDeclarative::GetParams()
|
||||
{
|
||||
if (pageParamMap_.find(pageId_) != pageParamMap_.end()) {
|
||||
|
@ -137,6 +137,7 @@ public:
|
||||
void Clear() override;
|
||||
int32_t GetStackSize() const override;
|
||||
void GetState(int32_t& index, std::string& name, std::string& path) override;
|
||||
size_t GetComponentsCount() override;
|
||||
std::string GetParams() override;
|
||||
void TriggerPageUpdate(int32_t pageId, bool directExecute = false) override;
|
||||
|
||||
|
@ -15,7 +15,9 @@
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_ability_component.h"
|
||||
|
||||
#include "frameworks/base/json/json_util.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_ability_component_controller.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_common_def.h"
|
||||
#include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
|
||||
|
||||
@ -31,6 +33,8 @@ void JSAbilityComponent::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSAbilityComponent>::StaticMethod("onAbilityCreated", &JSAbilityComponent::JsOnAbilityCreated, opt);
|
||||
JSClass<JSAbilityComponent>::StaticMethod("onAbilityMoveToFront", &JSAbilityComponent::JsOnAbilityMovedFront, opt);
|
||||
JSClass<JSAbilityComponent>::StaticMethod("onAbilityWillRemove", &JSAbilityComponent::JsOnAbilityWillRemove, opt);
|
||||
JSClass<JSAbilityComponent>::StaticMethod("width", &JSAbilityComponent::Width, opt);
|
||||
JSClass<JSAbilityComponent>::StaticMethod("height", &JSAbilityComponent::Height, opt);
|
||||
JSClass<JSAbilityComponent>::Inherit<JSViewAbstract>();
|
||||
JSClass<JSAbilityComponent>::Bind<>(globalObj);
|
||||
}
|
||||
@ -40,13 +44,26 @@ void JSAbilityComponent::Create(const JSCallbackInfo& info)
|
||||
if (info.Length() != 1 || !info[0]->IsObject()) {
|
||||
return;
|
||||
}
|
||||
auto component = AceType::MakeRefPtr<OHOS::Ace::AbilityComponent>();
|
||||
RefPtr<AbilityComponent> component;
|
||||
auto obj = JSRef<JSObject>::Cast(info[0]);
|
||||
|
||||
// Parse want
|
||||
JSRef<JSVal> wantValue = obj->GetProperty("want");
|
||||
if (wantValue->IsObject()) {
|
||||
component = AceType::MakeRefPtr<OHOS::Ace::AbilityComponent>();
|
||||
component->SetWant(wantValue->ToString());
|
||||
} else {
|
||||
RefPtr<V2::AbilityComponent> ability = AceType::MakeRefPtr<OHOS::Ace::V2::AbilityComponent>();
|
||||
auto jsonStr = JsonUtil::Create(true);
|
||||
if (obj->GetProperty("bundleName")->IsNull() || obj->GetProperty("bundleName")->IsUndefined() ||
|
||||
obj->GetProperty("abilityName")->IsNull() || obj->GetProperty("abilityName")->IsUndefined()) {
|
||||
LOGI("bundleName or abilityName is undefined");
|
||||
return;
|
||||
}
|
||||
jsonStr->Put("bundle", obj->GetProperty("bundleName")->ToString().c_str());
|
||||
jsonStr->Put("ability", obj->GetProperty("abilityName")->ToString().c_str());
|
||||
ability->SetWant(jsonStr->ToString());
|
||||
ViewStackProcessor::GetInstance()->Push(ability);
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse controller
|
||||
@ -86,4 +103,30 @@ void JSAbilityComponent::JsOnAbilityWillRemove(const JSCallbackInfo& info)
|
||||
JSViewBindEvent(&AbilityComponent::SetOnAbilityWillRemove, info);
|
||||
}
|
||||
|
||||
void JSAbilityComponent::Width(const JSCallbackInfo& info)
|
||||
{
|
||||
JSViewAbstract::JsWidth(info);
|
||||
auto component = AceType::DynamicCast<V2::AbilityComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
|
||||
if (component) {
|
||||
Dimension value;
|
||||
if (!ParseJsDimensionVp(info[0], value)) {
|
||||
return;
|
||||
}
|
||||
component->SetWidth(static_cast<float>(value.ConvertToVp()));
|
||||
}
|
||||
}
|
||||
|
||||
void JSAbilityComponent::Height(const JSCallbackInfo& info)
|
||||
{
|
||||
JSViewAbstract::JsHeight(info);
|
||||
auto component = AceType::DynamicCast<V2::AbilityComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
|
||||
if (component) {
|
||||
Dimension value;
|
||||
if (!ParseJsDimensionVp(info[0], value)) {
|
||||
return;
|
||||
}
|
||||
component->SetHeight(static_cast<float>(value.ConvertToVp()));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_ABILITY_COMPONENT_H
|
||||
|
||||
#include "core/components/ability_component/ability_component.h"
|
||||
#include "core/components_v2/ability_component/ability_component.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_interactable_view.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
|
||||
|
||||
@ -29,6 +30,8 @@ public:
|
||||
|
||||
static void JsOnReady(const JSCallbackInfo& info);
|
||||
static void JsOnDestroy(const JSCallbackInfo& info);
|
||||
static void Height(const JSCallbackInfo& info);
|
||||
static void Width(const JSCallbackInfo& info);
|
||||
static void JsOnAbilityCreated(const JSCallbackInfo& info);
|
||||
static void JsOnAbilityMovedFront(const JSCallbackInfo& info);
|
||||
static void JsOnAbilityWillRemove(const JSCallbackInfo& info);
|
||||
|
@ -19,27 +19,12 @@
|
||||
#include <iterator>
|
||||
|
||||
#include "core/components/panel/sliding_panel_component_v2.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_view_common_def.h"
|
||||
#include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
namespace {
|
||||
|
||||
JSRef<JSVal> SlidingPanelSizeChangeEventToJSValue(const SlidingPanelSizeChangeEvent& eventInfo)
|
||||
{
|
||||
JSRef<JSObject> obj = JSRef<JSObject>::New();
|
||||
std::string modeStr = "half";
|
||||
const PanelMode& mode = eventInfo.GetMode();
|
||||
if (mode == PanelMode::FULL) {
|
||||
modeStr = "full";
|
||||
} else if (mode == PanelMode::MINI) {
|
||||
modeStr = "mini";
|
||||
}
|
||||
obj->SetProperty<std::string>("mode", modeStr.c_str());
|
||||
obj->SetProperty<double>("width", eventInfo.GetWidth());
|
||||
obj->SetProperty<double>("height", eventInfo.GetHeight());
|
||||
return JSRef<JSVal>::Cast(obj);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void JSSlidingPanel::Create(const JSCallbackInfo& info)
|
||||
@ -276,18 +261,16 @@ void JSSlidingPanel::JsPanelBorder(const JSCallbackInfo& info)
|
||||
void JSSlidingPanel::SetOnSizeChange(const JSCallbackInfo& args)
|
||||
{
|
||||
if (args[0]->IsFunction()) {
|
||||
auto onSizeChangeFunc = AceType::MakeRefPtr<JsEventFunction<SlidingPanelSizeChangeEvent, 1>>(
|
||||
JSRef<JSFunc>::Cast(args[0]), SlidingPanelSizeChangeEventToJSValue);
|
||||
auto onSizeChange = EventMarker(
|
||||
[execCtx = args.GetExecutionContext(), func = std::move(onSizeChangeFunc)](const BaseEventInfo* param) {
|
||||
[execCtx = args.GetExecutionContext(), func = JSRef<JSFunc>::Cast(args[0])](const BaseEventInfo* info) {
|
||||
JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
|
||||
auto sizeChange = TypeInfoHelper::DynamicCast<SlidingPanelSizeChangeEvent>(param);
|
||||
if (!sizeChange) {
|
||||
LOGE("HandleSizeChangeEvent, sizeChange == nullptr");
|
||||
auto eventInfo = TypeInfoHelper::DynamicCast<SlidingPanelSizeChangeEvent>(info);
|
||||
if (!eventInfo) {
|
||||
return;
|
||||
}
|
||||
auto params = ConvertToJSValues(eventInfo->GetWidth(), eventInfo->GetHeight(), eventInfo->GetMode());
|
||||
ACE_SCORING_EVENT("SlidingPanel.OnSizeChange");
|
||||
func->Execute(*sizeChange);
|
||||
func->Call(JSRef<JSObject>(), params.size(), params.data());
|
||||
});
|
||||
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
|
||||
auto panel = AceType::DynamicCast<SlidingPanelComponent>(component);
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "bridge/declarative_frontend/engine/functions/js_function.h"
|
||||
#include "bridge/declarative_frontend/engine/functions/js_on_area_change_function.h"
|
||||
#include "bridge/declarative_frontend/jsview/js_utils.h"
|
||||
#ifdef PLUGIN_COMPONENT_SUPPORTED
|
||||
#include "core/common/plugin_manager.h"
|
||||
#endif
|
||||
#include "core/components_v2/extensions/events/on_area_change_extension.h"
|
||||
#ifdef USE_V8_ENGINE
|
||||
#include "bridge/declarative_frontend/engine/v8/functions/v8_function.h"
|
||||
@ -4334,6 +4337,26 @@ void JSViewAbstract::SetDirection(const std::string& dir)
|
||||
|
||||
RefPtr<ThemeConstants> JSViewAbstract::GetThemeConstants()
|
||||
{
|
||||
#ifdef PLUGIN_COMPONENT_SUPPORTED
|
||||
if (Container::CurrentId() >= MIN_PLUGIN_SUBCONTAINER_ID) {
|
||||
auto pluginContainer = PluginManager::GetInstance().GetPluginSubContainer(Container::CurrentId());
|
||||
if (!pluginContainer) {
|
||||
LOGW("pluginContainer is null");
|
||||
return nullptr;
|
||||
}
|
||||
auto pliginPipelineContext = pluginContainer->GetPipelineContext();
|
||||
if (!pliginPipelineContext) {
|
||||
LOGE("pliginPipelineContext is null!");
|
||||
return nullptr;
|
||||
}
|
||||
auto pluginThemeManager = pliginPipelineContext->GetThemeManager();
|
||||
if (!pluginThemeManager) {
|
||||
LOGE("pluginThemeManager is null!");
|
||||
return nullptr;
|
||||
}
|
||||
return pluginThemeManager->GetThemeConstants();
|
||||
}
|
||||
#endif
|
||||
auto container = Container::Current();
|
||||
if (!container) {
|
||||
LOGW("container is null");
|
||||
|
@ -60,7 +60,7 @@ VisualState JSViewStackProcessor::StringToVisualState(const std::string& stateSt
|
||||
if (stateString == "pressed") {
|
||||
return VisualState::PRESSED;
|
||||
}
|
||||
if (stateString == "disables") {
|
||||
if (stateString == "disabled") {
|
||||
return VisualState::DISABLED;
|
||||
}
|
||||
if (stateString == "hover") {
|
||||
|
150
frameworks/bridge/declarative_frontend/jsview/js_water_flow.cpp
Normal file
150
frameworks/bridge/declarative_frontend/jsview/js_water_flow.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow.h"
|
||||
|
||||
#include "bridge/declarative_frontend/jsview/js_view_common_def.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_interactable_view.h"
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_scroller.h"
|
||||
#include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
|
||||
#include "frameworks/core/components_v2/water_flow/water_flow_component.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
namespace {
|
||||
const std::vector<FlexDirection> LAYOUT_DIRECTION = { FlexDirection::ROW, FlexDirection::COLUMN,
|
||||
FlexDirection::ROW_REVERSE, FlexDirection::COLUMN_REVERSE };
|
||||
} // namespace
|
||||
|
||||
void JSWaterFlow::Create(const JSCallbackInfo& args)
|
||||
{
|
||||
LOGI("Create component: WaterFLow");
|
||||
if (args.Length() < 1) {
|
||||
LOGE("Arg is wrong, it is supposed to have at least 1 arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args[0]->IsObject()) {
|
||||
LOGE("Arg is not object");
|
||||
return;
|
||||
}
|
||||
|
||||
JSRef<JSObject> obj = JSRef<JSObject>::Cast(args[0]);
|
||||
JSRef<JSVal> crossSplice = obj->GetProperty("crossSplice");
|
||||
if (!crossSplice->IsNumber()) {
|
||||
LOGW("Args is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
// create waterflow component
|
||||
std::list<RefPtr<OHOS::Ace::Component>> componentChildren;
|
||||
auto waterflowComponent =
|
||||
AceType::MakeRefPtr<V2::WaterFlowComponent>(componentChildren, crossSplice->ToNumber<int32_t>());
|
||||
|
||||
// mainLength
|
||||
JSRef<JSVal> jsMainLength = obj->GetProperty("mainLength");
|
||||
Dimension mainLength;
|
||||
if (ParseJsDimensionVp(jsMainLength, mainLength)) {
|
||||
waterflowComponent->SetMainLength(mainLength);
|
||||
} else {
|
||||
LOGW("The parameter of mainLength not exists.");
|
||||
}
|
||||
|
||||
// scroller
|
||||
if (args.Length() > 1 && args[1]->IsObject()) {
|
||||
JSScroller* jsScroller = JSRef<JSObject>::Cast(args[1])->Unwrap<JSScroller>();
|
||||
if (jsScroller) {
|
||||
auto positionController = AceType::MakeRefPtr<V2::WaterFlowPositionController>();
|
||||
jsScroller->SetController(positionController);
|
||||
waterflowComponent->SetController(positionController);
|
||||
|
||||
// Init scroll bar proxy.
|
||||
auto proxy = jsScroller->GetScrollBarProxy();
|
||||
if (!proxy) {
|
||||
proxy = AceType::MakeRefPtr<ScrollBarProxy>();
|
||||
jsScroller->SetScrollBarProxy(proxy);
|
||||
}
|
||||
waterflowComponent->SetScrollBarProxy(proxy);
|
||||
}
|
||||
} else {
|
||||
LOGW("The parameter of scroller not exists.");
|
||||
}
|
||||
|
||||
ViewStackProcessor::GetInstance()->Push(waterflowComponent);
|
||||
}
|
||||
|
||||
void JSWaterFlow::JSBind(BindingTarget globalObj)
|
||||
{
|
||||
LOGD("JSWaterFlow:JSBind");
|
||||
JSClass<JSWaterFlow>::Declare("WaterFlow");
|
||||
|
||||
MethodOptions opt = MethodOptions::NONE;
|
||||
JSClass<JSWaterFlow>::StaticMethod("create", &JSWaterFlow::Create, opt);
|
||||
JSClass<JSWaterFlow>::StaticMethod("columnsGap", &JSWaterFlow::SetColumnsGap, opt);
|
||||
JSClass<JSWaterFlow>::StaticMethod("rowsGap", &JSWaterFlow::SetRowsGap, opt);
|
||||
JSClass<JSWaterFlow>::StaticMethod("layoutDirection", &JSWaterFlow::SetLayoutDirection, opt);
|
||||
JSClass<JSWaterFlow>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
|
||||
JSClass<JSWaterFlow>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
|
||||
|
||||
JSClass<JSWaterFlow>::Inherit<JSContainerBase>();
|
||||
JSClass<JSWaterFlow>::Inherit<JSViewAbstract>();
|
||||
JSClass<JSWaterFlow>::Bind<>(globalObj);
|
||||
}
|
||||
|
||||
void JSWaterFlow::SetColumnsGap(const JSCallbackInfo& info)
|
||||
{
|
||||
if (info.Length() < 1) {
|
||||
LOGE("Arg is wrong, it is supposed to have at least 1 argument");
|
||||
return;
|
||||
}
|
||||
Dimension colGap;
|
||||
if (!ParseJsDimensionVp(info[0], colGap)) {
|
||||
return;
|
||||
}
|
||||
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
|
||||
auto waterflow = AceType::DynamicCast<V2::WaterFlowComponent>(component);
|
||||
if (waterflow) {
|
||||
waterflow->SetColumnsGap(colGap);
|
||||
}
|
||||
}
|
||||
|
||||
void JSWaterFlow::SetRowsGap(const JSCallbackInfo& info)
|
||||
{
|
||||
if (info.Length() < 1) {
|
||||
LOGE("Arg is wrong, it is supposed to have at least 1 argument");
|
||||
return;
|
||||
}
|
||||
Dimension rowGap;
|
||||
if (!ParseJsDimensionVp(info[0], rowGap)) {
|
||||
return;
|
||||
}
|
||||
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
|
||||
auto waterflow = AceType::DynamicCast<V2::WaterFlowComponent>(component);
|
||||
if (waterflow) {
|
||||
waterflow->SetRowsGap(rowGap);
|
||||
}
|
||||
}
|
||||
|
||||
void JSWaterFlow::SetLayoutDirection(int32_t value)
|
||||
{
|
||||
if (value >= 0 && value < static_cast<int32_t>(LAYOUT_DIRECTION.size())) {
|
||||
auto component = ViewStackProcessor::GetInstance()->GetMainComponent();
|
||||
auto waterflow = AceType::DynamicCast<V2::WaterFlowComponent>(component);
|
||||
if (waterflow) {
|
||||
// not support the other layoutDirection except default for now.
|
||||
waterflow->SetLayoutDirection(FlexDirection::COLUMN);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WATER_FLOW_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WATER_FLOW_H
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
class JSWaterFlow : public JSContainerBase {
|
||||
public:
|
||||
static void Create(const JSCallbackInfo& args);
|
||||
static void JSBind(BindingTarget globalObj);
|
||||
|
||||
protected:
|
||||
static void SetColumnsGap(const JSCallbackInfo& info);
|
||||
static void SetRowsGap(const JSCallbackInfo& info);
|
||||
static void SetLayoutDirection(int32_t value);
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WATER_FLOW_H
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_water_flow_item.h"
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/view_stack_processor.h"
|
||||
#include "frameworks/core/components_v2/water_flow/water_flow_item_component.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
void JSWaterFlowItem::Create()
|
||||
{
|
||||
auto itemComponent = AceType::MakeRefPtr<V2::WaterFlowItemComponent>();
|
||||
ViewStackProcessor::GetInstance()->Push(itemComponent);
|
||||
}
|
||||
|
||||
void JSWaterFlowItem::JSBind(BindingTarget globalObj)
|
||||
{
|
||||
LOGD("JSWaterFlowItem:JSBind");
|
||||
JSClass<JSWaterFlowItem>::Declare("FlowItem");
|
||||
|
||||
MethodOptions opt = MethodOptions::NONE;
|
||||
JSClass<JSWaterFlowItem>::StaticMethod("create", &JSWaterFlowItem::Create, opt);
|
||||
JSClass<JSWaterFlowItem>::StaticMethod("rowSpan", &JSWaterFlowItem::SetRowSpan, opt);
|
||||
JSClass<JSWaterFlowItem>::StaticMethod("columnSpan", &JSWaterFlowItem::SetColumnSpan, opt);
|
||||
|
||||
JSClass<JSWaterFlowItem>::Inherit<JSContainerBase>();
|
||||
JSClass<JSWaterFlowItem>::Inherit<JSViewAbstract>();
|
||||
JSClass<JSWaterFlowItem>::Bind<>(globalObj);
|
||||
}
|
||||
|
||||
void JSWaterFlowItem::SetRowSpan(int32_t rowSpan)
|
||||
{
|
||||
auto flowItem =
|
||||
AceType::DynamicCast<V2::WaterFlowItemComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
|
||||
if (flowItem) {
|
||||
flowItem->SetRowSpan(rowSpan);
|
||||
}
|
||||
}
|
||||
|
||||
void JSWaterFlowItem::SetColumnSpan(int32_t columnSpan)
|
||||
{
|
||||
auto flowItem =
|
||||
AceType::DynamicCast<V2::WaterFlowItemComponent>(ViewStackProcessor::GetInstance()->GetMainComponent());
|
||||
if (flowItem) {
|
||||
flowItem->SetColumnSpan(columnSpan);
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WATER_FLOW_ITEM_H
|
||||
#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WATER_FLOW_ITEM_H
|
||||
|
||||
#include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h"
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
class JSWaterFlowItem : public JSContainerBase {
|
||||
public:
|
||||
static void JSBind(BindingTarget globalObj);
|
||||
static void Create();
|
||||
|
||||
protected:
|
||||
static void SetRowSpan(int32_t rowSpan);
|
||||
static void SetColumnSpan(int32_t columnSpan);
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_WATER_FLOW_ITEM_H
|
@ -578,6 +578,7 @@ void JSWeb::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSWeb>::StaticMethod("fileFromUrlAccess", &JSWeb::FileFromUrlAccess);
|
||||
JSClass<JSWeb>::StaticMethod("databaseAccess", &JSWeb::DatabaseAccess);
|
||||
JSClass<JSWeb>::StaticMethod("textZoomAtio", &JSWeb::TextZoomAtio);
|
||||
JSClass<JSWeb>::StaticMethod("webDebuggingAccess", &JSWeb::WebDebuggingAccessEnabled);
|
||||
JSClass<JSWeb>::Inherit<JSViewAbstract>();
|
||||
JSClass<JSWeb>::Bind(globalObj);
|
||||
JSWebDialog::JSBind(globalObj);
|
||||
@ -1055,7 +1056,7 @@ JSRef<JSVal> FileSelectorEventToJSValue(const FileSelectorEvent& eventInfo)
|
||||
JSRef<JSObject> paramObj = JSClass<JSFileSelectorParam>::NewInstance();
|
||||
auto fileSelectorParam = Referenced::Claim(paramObj->Unwrap<JSFileSelectorParam>());
|
||||
fileSelectorParam->SetParam(eventInfo);
|
||||
|
||||
|
||||
JSRef<JSObject> resultObj = JSClass<JSFileSelectorResult>::NewInstance();
|
||||
auto fileSelectorResult = Referenced::Claim(resultObj->Unwrap<JSFileSelectorResult>());
|
||||
fileSelectorResult->SetResult(eventInfo);
|
||||
@ -1354,4 +1355,15 @@ void JSWeb::TextZoomAtio(int32_t textZoomAtioNum)
|
||||
}
|
||||
webComponent->SetTextZoomAtio(textZoomAtioNum);
|
||||
}
|
||||
|
||||
void JSWeb::WebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled)
|
||||
{
|
||||
auto stack = ViewStackProcessor::GetInstance();
|
||||
auto webComponent = AceType::DynamicCast<WebComponent>(stack->GetMainComponent());
|
||||
if (!webComponent) {
|
||||
LOGE("JSWeb: MainComponent is null.");
|
||||
return;
|
||||
}
|
||||
webComponent->SetWebDebuggingAccessEnabled(isWebDebuggingAccessEnabled);
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
static void FileFromUrlAccess(bool isFileFromUrlAccessEnabled);
|
||||
static void DatabaseAccess(bool isDatabaseAccessEnabled);
|
||||
static void TextZoomAtio(int32_t textZoomAtioNum);
|
||||
static void WebDebuggingAccessEnabled(bool isWebDebuggingAccessEnabled);
|
||||
|
||||
protected:
|
||||
static void OnCommonDialog(const JSCallbackInfo& args, int dialogEventType);
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
{
|
||||
JSClass<JSWebCookie>::Declare("WebCookie");
|
||||
JSClass<JSWebCookie>::CustomMethod("setCookie", &JSWebCookie::SetCookie);
|
||||
JSClass<JSWebCookie>::CustomMethod("getCookie", &JSWebCookie::GetCookie);
|
||||
JSClass<JSWebCookie>::CustomMethod("deleteEntireCookie", &JSWebCookie::DeleteEntirelyCookie);
|
||||
JSClass<JSWebCookie>::CustomMethod("saveCookieSync", &JSWebCookie::SaveCookieSync);
|
||||
JSClass<JSWebCookie>::Bind(globalObj, JSWebCookie::Constructor, JSWebCookie::Destructor);
|
||||
}
|
||||
@ -108,6 +110,30 @@ public:
|
||||
args.SetReturnValue(returnValue);
|
||||
}
|
||||
|
||||
void GetCookie(const JSCallbackInfo& args)
|
||||
{
|
||||
if (!manager_) {
|
||||
return;
|
||||
}
|
||||
if (args.Length() < 1 || !args[0]->IsString()) {
|
||||
LOGW("invalid url params");
|
||||
return;
|
||||
}
|
||||
std::string url = args[0]->ToString();
|
||||
std::string result = manager_->GetCookie(url);
|
||||
auto jsVal = JSVal(ToJSValue(result));
|
||||
auto returnValue = JSRef<JSVal>::Make(jsVal);
|
||||
args.SetReturnValue(returnValue);
|
||||
}
|
||||
|
||||
void DeleteEntirelyCookie(const JSCallbackInfo& args)
|
||||
{
|
||||
if (!manager_) {
|
||||
return;
|
||||
}
|
||||
manager_->DeleteEntirelyCookie();
|
||||
}
|
||||
|
||||
void SaveCookieSync(const JSCallbackInfo& args)
|
||||
{
|
||||
if (!manager_) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "core/components/web/web_component.h"
|
||||
#include "core/components/xcomponent/xcomponent_component.h"
|
||||
#include "core/components_v2/list/list_item_component.h"
|
||||
#include "core/components_v2/water_flow/water_flow_item_component.h"
|
||||
#include "core/pipeline/base/component.h"
|
||||
#include "core/pipeline/base/multi_composed_component.h"
|
||||
#include "core/pipeline/base/sole_child_component.h"
|
||||
@ -197,9 +198,7 @@ RefPtr<BoxComponent> ViewStackProcessor::GetBoxComponent()
|
||||
}
|
||||
|
||||
RefPtr<BoxComponent> boxComponent = AceType::MakeRefPtr<OHOS::Ace::BoxComponent>();
|
||||
if (SystemProperties::GetDebugBoundaryEnabled()) {
|
||||
boxComponent->SetEnableDebugBoundary(true);
|
||||
}
|
||||
boxComponent->SetEnableDebugBoundary(true);
|
||||
wrappingComponentsMap.emplace("box", boxComponent);
|
||||
return boxComponent;
|
||||
}
|
||||
@ -558,7 +557,8 @@ RefPtr<Component> ViewStackProcessor::WrapComponents()
|
||||
std::unordered_map<std::string, RefPtr<Component>> videoMap;
|
||||
|
||||
bool isItemComponent = AceType::InstanceOf<V2::ListItemComponent>(mainComponent) ||
|
||||
AceType::InstanceOf<GridLayoutItemComponent>(mainComponent);
|
||||
AceType::InstanceOf<GridLayoutItemComponent>(mainComponent) ||
|
||||
AceType::InstanceOf<V2::WaterFlowItemComponent>(mainComponent);
|
||||
|
||||
RefPtr<Component> itemChildComponent;
|
||||
|
||||
@ -816,8 +816,7 @@ RefPtr<Component> ViewStackProcessor::GetScoringComponent() const
|
||||
void ViewStackProcessor::CreateInspectorComposedComponent(const std::string& inspectorTag)
|
||||
{
|
||||
if (V2::InspectorComposedComponent::HasInspectorFinished(inspectorTag)) {
|
||||
auto composedComponent =
|
||||
AceType::MakeRefPtr<V2::InspectorComposedComponent>(GenerateId(), inspectorTag);
|
||||
auto composedComponent = AceType::MakeRefPtr<V2::InspectorComposedComponent>(GenerateId(), inspectorTag);
|
||||
auto& wrappingComponentsMap = componentsStack_.top();
|
||||
wrappingComponentsMap.emplace("inspector", composedComponent);
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ Local<JSValueRef> FunctionCallback(panda::JsiRuntimeCallInfo *info)
|
||||
return package->Callback(info);
|
||||
}
|
||||
|
||||
bool ArkJSRuntime::Initialize(const std::string &libraryPath, bool isDebugMode)
|
||||
bool ArkJSRuntime::Initialize(const std::string &libraryPath, bool isDebugMode, int32_t instanceId)
|
||||
{
|
||||
LOGI("Ark: create jsvm");
|
||||
RuntimeOption option;
|
||||
option.SetGcType(RuntimeOption::GC_TYPE::GEN_GC);
|
||||
#ifndef WINDOWS_PLATFORM
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
option.SetArkProperties(SystemProperties::GetArkProperties());
|
||||
option.SetAsmInterOption(SystemProperties::GetAsmInterOption());
|
||||
#endif
|
||||
@ -49,6 +49,7 @@ bool ArkJSRuntime::Initialize(const std::string &libraryPath, bool isDebugMode)
|
||||
option.SetDebuggerLibraryPath(libraryPath);
|
||||
libPath_ = libraryPath;
|
||||
isDebugMode_ = isDebugMode;
|
||||
instanceId_ = instanceId;
|
||||
|
||||
vm_ = JSNApi::CreateJSVM(option);
|
||||
return vm_ != nullptr;
|
||||
@ -66,7 +67,7 @@ void ArkJSRuntime::Reset()
|
||||
{
|
||||
if (vm_ != nullptr) {
|
||||
if (!usingExistVM_) {
|
||||
#ifndef WINDOWS_PLATFORM
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
JSNApi::StopDebugger(vm_);
|
||||
#endif
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
@ -101,12 +102,10 @@ bool ArkJSRuntime::EvaluateJsCode(const uint8_t *buffer, int32_t size)
|
||||
bool ArkJSRuntime::ExecuteJsBin(const std::string &fileName)
|
||||
{
|
||||
JSExecutionScope executionScope(vm_);
|
||||
static bool debugFlag = true;
|
||||
if (debugFlag && !libPath_.empty()) {
|
||||
#ifndef WINDOWS_PLATFORM
|
||||
JSNApi::StartDebugger(libPath_.c_str(), vm_, isDebugMode_);
|
||||
if (!libPath_.empty()) {
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
JSNApi::StartDebugger(libPath_.c_str(), vm_, isDebugMode_, instanceId_);
|
||||
#endif
|
||||
debugFlag = false;
|
||||
}
|
||||
LocalScope scope(vm_);
|
||||
bool ret = JSNApi::Execute(vm_, fileName, PANDA_MAIN_FUNCTION);
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
#if !defined(WINDOWS_PLATFORM)
|
||||
bool StartDebugger(const char *libraryPath, EcmaVM *vm) const;
|
||||
#endif
|
||||
bool Initialize(const std::string &libraryPath, bool isDebugMode) override;
|
||||
bool Initialize(const std::string &libraryPath, bool isDebugMode, int32_t instanceId) override;
|
||||
bool InitializeFromExistVM(EcmaVM* vm);
|
||||
void Reset() override;
|
||||
void SetLogPrint(LOG_PRINT out) override;
|
||||
@ -86,6 +86,7 @@ public:
|
||||
|
||||
private:
|
||||
EcmaVM *vm_ = nullptr;
|
||||
int32_t instanceId_ = 0;
|
||||
std::vector<PandaFunctionData *> dataList_;
|
||||
LOG_PRINT print_ { nullptr };
|
||||
UncaughtExceptionCallback uncaughtErrorHandler_ { nullptr };
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
namespace {
|
||||
std::unique_ptr<Inspector> g_inspector = nullptr;
|
||||
void* g_handle = nullptr;
|
||||
thread_local Inspector* g_inspector = nullptr;
|
||||
thread_local void* g_handle = nullptr;
|
||||
constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.so";
|
||||
|
||||
void* HandleClient(void* const server)
|
||||
@ -40,8 +40,11 @@ void* HandleClient(void* const server)
|
||||
void* GetArkDynFunction(const char* symbol)
|
||||
{
|
||||
if (g_handle == nullptr) {
|
||||
LOGE("Failed to open shared library %{public}s, reason: %{public}sn", ARK_DEBUGGER_SHARED_LIB, dlerror());
|
||||
return nullptr;
|
||||
g_handle = dlopen(ARK_DEBUGGER_SHARED_LIB, RTLD_LAZY);
|
||||
if (g_handle == nullptr) {
|
||||
LOGE("Failed to open shared library %{public}s, reason: %{public}sn", ARK_DEBUGGER_SHARED_LIB, dlerror());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
auto function = dlsym(g_handle, symbol);
|
||||
@ -53,10 +56,11 @@ void* GetArkDynFunction(const char* symbol)
|
||||
|
||||
void DispatchMsgToArk(int sign)
|
||||
{
|
||||
if (g_inspector->isDispatchingMsg_) {
|
||||
if (g_inspector == nullptr || g_inspector->websocketServer_ == nullptr || g_inspector->isDispatchingMsg_) {
|
||||
return;
|
||||
}
|
||||
auto processMsg = reinterpret_cast<void (*)(const std::string &)>(GetArkDynFunction("DispatchProtocolMessage"));
|
||||
auto processMsg = reinterpret_cast<void (*)(void *, const std::string &)>(
|
||||
GetArkDynFunction("DispatchProtocolMessage"));
|
||||
if (processMsg == nullptr) {
|
||||
LOGE("processMessage is empty");
|
||||
return;
|
||||
@ -65,7 +69,7 @@ void DispatchMsgToArk(int sign)
|
||||
while (!g_inspector->websocketServer_->ideMsgQueue.empty()) {
|
||||
const std::string message = g_inspector->websocketServer_->ideMsgQueue.front();
|
||||
g_inspector->websocketServer_->ideMsgQueue.pop();
|
||||
processMsg(message);
|
||||
processMsg(g_inspector->vm_, message);
|
||||
std::string startDebugging("Runtime.runIfWaitingForDebugger");
|
||||
if (message.find(startDebugging, 0) != std::string::npos) {
|
||||
g_inspector->waitingForDebugger_ = false;
|
||||
@ -74,40 +78,47 @@ void DispatchMsgToArk(int sign)
|
||||
g_inspector->isDispatchingMsg_ = false;
|
||||
}
|
||||
|
||||
void OnMessage()
|
||||
{
|
||||
pthread_kill(g_inspector->tid_, SIGALRM);
|
||||
return;
|
||||
}
|
||||
|
||||
void SendReply(const std::string& message)
|
||||
{
|
||||
if (g_inspector->websocketServer_ != nullptr) {
|
||||
if (g_inspector != nullptr && g_inspector->websocketServer_ != nullptr) {
|
||||
g_inspector->websocketServer_->SendReply(message);
|
||||
}
|
||||
}
|
||||
|
||||
void ResetService()
|
||||
{
|
||||
if (g_inspector != nullptr && g_inspector->websocketServer_ != nullptr) {
|
||||
g_inspector->websocketServer_->StopServer();
|
||||
delete g_inspector;
|
||||
g_inspector = nullptr;
|
||||
}
|
||||
if (g_handle != nullptr) {
|
||||
dlclose(g_handle);
|
||||
g_handle = nullptr;
|
||||
}
|
||||
if (g_inspector->websocketServer_ != nullptr) {
|
||||
g_inspector->websocketServer_->StopServer();
|
||||
g_inspector.reset();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool StartDebug(const std::string& componentName, void *vm, bool isDebugMode)
|
||||
void Inspector::OnMessage()
|
||||
{
|
||||
pthread_kill(tid_, SIGALRM);
|
||||
return;
|
||||
}
|
||||
|
||||
void Inspector::InitializeInspector(const std::string& componentName, int32_t instanceId)
|
||||
{
|
||||
websocketServer_ = std::make_unique<WsServer>(componentName, std::bind(&Inspector::OnMessage, this), instanceId);
|
||||
}
|
||||
|
||||
bool StartDebug(const std::string& componentName, void *vm, bool isDebugMode, int32_t instanceId)
|
||||
{
|
||||
LOGI("StartDebug: %{private}s", componentName.c_str());
|
||||
g_inspector = std::make_unique<Inspector>();
|
||||
g_inspector->websocketServer_ = std::make_unique<WsServer>(componentName, std::bind(&OnMessage));
|
||||
g_inspector = new Inspector();
|
||||
g_inspector->InitializeInspector(componentName, instanceId);
|
||||
g_inspector->tid_ = pthread_self();
|
||||
g_inspector->waitingForDebugger_ = isDebugMode;
|
||||
g_inspector->vm_ = vm;
|
||||
|
||||
g_handle = dlopen(ARK_DEBUGGER_SHARED_LIB, RTLD_LAZY);
|
||||
if (g_handle == nullptr) {
|
||||
@ -142,19 +153,12 @@ void StopDebug(const std::string& componentName)
|
||||
if (g_inspector == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (g_inspector->websocketServer_ != nullptr) {
|
||||
g_inspector->websocketServer_->StopServer();
|
||||
g_inspector.reset();
|
||||
}
|
||||
auto uninitialize = reinterpret_cast<void (*)()>(GetArkDynFunction("UninitializeDebugger"));
|
||||
auto uninitialize = reinterpret_cast<void (*)(void *)>(GetArkDynFunction("UninitializeDebugger"));
|
||||
if (uninitialize == nullptr) {
|
||||
return;
|
||||
}
|
||||
uninitialize();
|
||||
if (g_handle != nullptr) {
|
||||
dlclose(g_handle);
|
||||
g_handle = nullptr;
|
||||
}
|
||||
uninitialize(g_inspector->vm_);
|
||||
ResetService();
|
||||
LOGI("StopDebug end");
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ extern "C" {
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
bool StartDebug(const std::string& componentName, void *vm, bool isDebugMode);
|
||||
bool StartDebug(const std::string& componentName, void *vm, bool isDebugMode, int32_t instanceId);
|
||||
|
||||
void StopDebug(const std::string& componentName);
|
||||
|
||||
@ -45,14 +45,17 @@ void StopDebug(const std::string& componentName);
|
||||
class Inspector {
|
||||
public:
|
||||
Inspector() = default;
|
||||
~Inspector() {}
|
||||
~Inspector() = default;
|
||||
|
||||
void OnMessage();
|
||||
void InitializeInspector(const std::string& componentName, int32_t instanceId);
|
||||
|
||||
pthread_t tid_;
|
||||
std::unique_ptr<WsServer> websocketServer_;
|
||||
void *vm_ = nullptr;
|
||||
static constexpr int DEBUGGER_WAIT_SLEEP_TIME = 100;
|
||||
volatile bool waitingForDebugger_ = true;
|
||||
volatile bool isDispatchingMsg_ = false;
|
||||
|
||||
};
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
||||
|
@ -20,22 +20,51 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "base/log/log.h"
|
||||
thread_local boost::asio::io_context g_ioContext;
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
|
||||
void DispatchMsgToSocket(int sign)
|
||||
{
|
||||
g_ioContext.stop();
|
||||
}
|
||||
|
||||
void WsServer::RunServer()
|
||||
{
|
||||
terminateExecution_ = false;
|
||||
try {
|
||||
boost::asio::io_context ioContext;
|
||||
int appPid = getpid();
|
||||
tid_ = pthread_self();
|
||||
std::string pidStr = std::to_string(appPid);
|
||||
std::string sockName = '\0' + pidStr + componentName_;
|
||||
LOGI("WsServer RunServer: %{public}d%{public}s", appPid, componentName_.c_str());
|
||||
std::string instanceIdStr("");
|
||||
auto& connectFlag = connectState_;
|
||||
/**
|
||||
* The old version of IDE is not compatible with the new images due to the connect server.
|
||||
* The First instance will use "pid" instead of "pid + instanceId" to avoid this.
|
||||
* If old version of IDE does not get the instanceId by connect server, it can still connect the debug server.
|
||||
*/
|
||||
if (instanceId_ != 0) {
|
||||
instanceIdStr = std::to_string(instanceId_);
|
||||
}
|
||||
std::string sockName = '\0' + pidStr + instanceIdStr + componentName_;
|
||||
LOGI("WsServer RunServer: %{public}d%{public}d%{public}s", appPid, instanceId_, componentName_.c_str());
|
||||
localSocket::endpoint endPoint(sockName);
|
||||
localSocket::socket socket(ioContext);
|
||||
localSocket::acceptor acceptor(ioContext, endPoint);
|
||||
acceptor.accept(socket);
|
||||
localSocket::socket socket(g_ioContext);
|
||||
localSocket::acceptor acceptor(g_ioContext, endPoint);
|
||||
acceptor.async_accept(socket, [&connectFlag](const boost::system::error_code& error) {
|
||||
if (!error) {
|
||||
connectFlag = true;
|
||||
}
|
||||
});
|
||||
if (signal(SIGURG, &DispatchMsgToSocket) == SIG_ERR) {
|
||||
LOGE("WsServer RunServer: Error exception");
|
||||
return;
|
||||
}
|
||||
g_ioContext.run();
|
||||
if (terminateExecution_ || !connectState_) {
|
||||
return;
|
||||
}
|
||||
webSocket_ = std::unique_ptr<websocket::stream<localSocket::socket>>(
|
||||
std::make_unique<websocket::stream<localSocket::socket>>(std::move(socket)));
|
||||
webSocket_->accept();
|
||||
@ -60,6 +89,9 @@ void WsServer::StopServer()
|
||||
{
|
||||
LOGI("WsServer StopServer");
|
||||
terminateExecution_ = true;
|
||||
if (!connectState_) {
|
||||
pthread_kill(tid_, SIGURG);
|
||||
}
|
||||
}
|
||||
|
||||
void WsServer::SendReply(const std::string& message) const
|
||||
|
@ -32,8 +32,8 @@ using localSocket = boost::asio::local::stream_protocol;
|
||||
|
||||
class WsServer {
|
||||
public:
|
||||
WsServer(const std::string& component, const std::function<void()>& onMessage)
|
||||
: componentName_(component), wsOnMessage_(onMessage)
|
||||
WsServer(const std::string& component, const std::function<void()>& onMessage, int32_t instanceId)
|
||||
: instanceId_(instanceId), componentName_(component), wsOnMessage_(onMessage)
|
||||
{}
|
||||
~WsServer() = default;
|
||||
void RunServer();
|
||||
@ -42,7 +42,10 @@ public:
|
||||
std::queue<const std::string> ideMsgQueue;
|
||||
|
||||
private:
|
||||
volatile bool connectState_ {false};
|
||||
volatile bool terminateExecution_ { false };
|
||||
int32_t instanceId_ {0};
|
||||
pthread_t tid_ {0};
|
||||
std::string componentName_ {};
|
||||
std::function<void()> wsOnMessage_ {};
|
||||
std::unique_ptr<websocket::stream<localSocket::socket>> webSocket_ { nullptr };
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
virtual ~JsRuntime() = default;
|
||||
|
||||
// Prepare js environment, returns true if success.
|
||||
virtual bool Initialize(const std::string &libraryPath, bool isDebugMode) = 0;
|
||||
virtual bool Initialize(const std::string &libraryPath, bool isDebugMode, int32_t instanceId = 0) = 0;
|
||||
virtual void Reset() = 0;
|
||||
virtual void SetLogPrint(LOG_PRINT out) = 0;
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "bridge/js_frontend/engine/jsi/ark_js_runtime.h"
|
||||
#include "bridge/js_frontend/engine/jsi/ark_js_value.h"
|
||||
#include "core/common/ace_application_info.h"
|
||||
#include "core/common/connect_server_manager.h"
|
||||
#include "core/common/container.h"
|
||||
#include "core/common/container_scope.h"
|
||||
#include "core/components/common/layout/grid_system_manager.h"
|
||||
@ -62,6 +63,8 @@ extern const char _binary_strip_native_min_abc_end[];
|
||||
|
||||
namespace OHOS::Ace::Framework {
|
||||
|
||||
const int SYSTEM_BASE = 10;
|
||||
|
||||
#ifdef APP_USE_ARM
|
||||
const std::string ARK_DEBUGGER_LIB_PATH = "/system/lib/libark_debugger.z.so";
|
||||
#else
|
||||
@ -774,34 +777,55 @@ std::string GetDeviceInfo()
|
||||
infoList->Put("manufacturer", SystemProperties::GetManufacturer().c_str());
|
||||
infoList->Put("model", SystemProperties::GetModel().c_str());
|
||||
infoList->Put("product", SystemProperties::GetProduct().c_str());
|
||||
|
||||
if (AceApplicationInfo::GetInstance().GetLanguage().empty()) {
|
||||
infoList->Put("language", "N/A");
|
||||
std::string tmp = SystemProperties::GetApiVersion();
|
||||
if (tmp != SystemProperties::INVALID_PARAM) {
|
||||
char* tmpEnd = nullptr;
|
||||
infoList->Put("apiVersion", static_cast<int32_t>(
|
||||
std::strtol(SystemProperties::GetApiVersion().c_str(), &tmpEnd, SYSTEM_BASE)));
|
||||
} else {
|
||||
infoList->Put("language", AceApplicationInfo::GetInstance().GetLanguage().c_str());
|
||||
infoList->Put("apiVersion", "N/A");
|
||||
}
|
||||
if (AceApplicationInfo::GetInstance().GetCountryOrRegion().empty()) {
|
||||
infoList->Put("region", "N/A");
|
||||
tmp = SystemProperties::GetReleaseType();
|
||||
if (tmp != SystemProperties::INVALID_PARAM) {
|
||||
infoList->Put("releaseType", tmp.c_str());
|
||||
} else {
|
||||
infoList->Put("region", AceApplicationInfo::GetInstance().GetCountryOrRegion().c_str());
|
||||
infoList->Put("releaseType", "N/A");
|
||||
}
|
||||
tmp = SystemProperties::GetParamDeviceType();
|
||||
if (tmp != SystemProperties::INVALID_PARAM) {
|
||||
infoList->Put("deviceType", tmp.c_str());
|
||||
} else {
|
||||
infoList->Put("deviceType", "N/A");
|
||||
}
|
||||
tmp = SystemProperties::GetLanguage();
|
||||
if (tmp != SystemProperties::INVALID_PARAM) {
|
||||
infoList->Put("language", tmp.c_str());
|
||||
} else {
|
||||
infoList->Put("language", "N/A");
|
||||
}
|
||||
tmp = SystemProperties::GetRegion();
|
||||
if (tmp != SystemProperties::INVALID_PARAM) {
|
||||
infoList->Put("region", tmp.c_str());
|
||||
} else {
|
||||
infoList->Put("region", "N/A");
|
||||
}
|
||||
|
||||
auto container = Container::Current();
|
||||
int32_t width = container ? container->GetViewWidth() : 0;
|
||||
if (width != 0) {
|
||||
infoList->Put("windowWidth", std::to_string(width).c_str());
|
||||
infoList->Put("windowWidth", width);
|
||||
} else {
|
||||
infoList->Put("windowWidth", "N/A");
|
||||
}
|
||||
|
||||
int32_t height = container ? container->GetViewHeight() : 0;
|
||||
if (height != 0) {
|
||||
infoList->Put("windowHeight", std::to_string(height).c_str());
|
||||
infoList->Put("windowHeight", height);
|
||||
} else {
|
||||
infoList->Put("windowHeight", "N/A");
|
||||
}
|
||||
|
||||
infoList->Put("screenDensity", std::to_string(SystemProperties::GetResolution()).c_str());
|
||||
infoList->Put("screenDensity", SystemProperties::GetResolution());
|
||||
|
||||
bool isRound = SystemProperties::GetIsScreenRound();
|
||||
if (isRound) {
|
||||
@ -2927,7 +2951,7 @@ bool JsiEngineInstance::InitJsEnv(bool debugger_mode, const std::unordered_map<s
|
||||
if (debugger_mode) {
|
||||
library_path = ARK_DEBUGGER_LIB_PATH;
|
||||
}
|
||||
if (!runtime_->Initialize(library_path, isDebugMode_)) {
|
||||
if (!runtime_->Initialize(library_path, isDebugMode_, GetInstanceId())) {
|
||||
LOGE("Js Engine initialize runtime failed");
|
||||
return false;
|
||||
}
|
||||
@ -3144,7 +3168,13 @@ void JsiEngine::SetPostTask(NativeEngine* nativeEngine)
|
||||
void JsiEngine::RegisterInitWorkerFunc()
|
||||
{
|
||||
auto weakInstance = AceType::WeakClaim(AceType::RawPtr(engineInstance_));
|
||||
auto&& initWorkerFunc = [weakInstance](NativeEngine* nativeEngine) {
|
||||
bool debugVersion = IsDebugVersion();
|
||||
bool debugMode = NeedDebugBreakPoint();
|
||||
std::string libraryPath = "";
|
||||
if (debugVersion) {
|
||||
libraryPath = ARK_DEBUGGER_LIB_PATH;
|
||||
}
|
||||
auto&& initWorkerFunc = [weakInstance, debugMode, libraryPath](NativeEngine* nativeEngine) {
|
||||
LOGI("WorkerCore RegisterInitWorkerFunc called");
|
||||
if (nativeEngine == nullptr) {
|
||||
LOGE("nativeEngine is nullptr");
|
||||
@ -3160,6 +3190,11 @@ void JsiEngine::RegisterInitWorkerFunc()
|
||||
LOGE("instance is nullptr");
|
||||
return;
|
||||
}
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
ConnectServerManager::Get().AddInstance(gettid());
|
||||
auto vm = const_cast<EcmaVM*>(arkNativeEngine->GetEcmaVm());
|
||||
panda::JSNApi::StartDebugger(libraryPath.c_str(), vm, debugMode, gettid());
|
||||
#endif
|
||||
instance->RegisterConsoleModule(arkNativeEngine);
|
||||
// load jsfwk
|
||||
if (!arkNativeEngine->ExecuteJsBin("/system/etc/strip.native.min.abc")) {
|
||||
@ -3169,6 +3204,33 @@ void JsiEngine::RegisterInitWorkerFunc()
|
||||
nativeEngine_->SetInitWorkerFunc(initWorkerFunc);
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
void JsiEngine::RegisterOffWorkerFunc()
|
||||
{
|
||||
auto weakInstance = AceType::WeakClaim(AceType::RawPtr(engineInstance_));
|
||||
bool debugVersion = IsDebugVersion();
|
||||
auto&& offWorkerFunc = [debugVersion](NativeEngine* nativeEngine) {
|
||||
LOGI("WorkerCore RegisterOffWorkerFunc called");
|
||||
if (!debugVersion) {
|
||||
return;
|
||||
}
|
||||
if (nativeEngine == nullptr) {
|
||||
LOGE("nativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
auto arkNativeEngine = static_cast<ArkNativeEngine*>(nativeEngine);
|
||||
if (arkNativeEngine == nullptr) {
|
||||
LOGE("arkNativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
ConnectServerManager::Get().RemoveInstance(gettid());
|
||||
auto vm = const_cast<EcmaVM*>(arkNativeEngine->GetEcmaVm());
|
||||
panda::JSNApi::StopDebugger(vm);
|
||||
};
|
||||
nativeEngine_->SetOffWorkerFunc(offWorkerFunc);
|
||||
}
|
||||
#endif
|
||||
|
||||
void JsiEngine::RegisterAssetFunc()
|
||||
{
|
||||
auto weakDelegate = AceType::WeakClaim(AceType::RawPtr(engineInstance_->GetDelegate()));
|
||||
@ -3192,6 +3254,9 @@ void JsiEngine::RegisterAssetFunc()
|
||||
void JsiEngine::RegisterWorker()
|
||||
{
|
||||
RegisterInitWorkerFunc();
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
RegisterOffWorkerFunc();
|
||||
#endif
|
||||
RegisterAssetFunc();
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,6 @@ public:
|
||||
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
|
||||
bool CallCurlFunction(const OHOS::Ace::RequestData& requestData, int32_t callbackId);
|
||||
#endif
|
||||
|
||||
void SetArkNativeEngine(ArkNativeEngine* nativeEngine)
|
||||
{
|
||||
nativeEngine_ = nativeEngine;
|
||||
@ -174,6 +173,7 @@ private:
|
||||
void GetLoadOptions(std::string& optionStr, bool isMainPage, bool hasAppCode);
|
||||
void RegisterWorker();
|
||||
void RegisterInitWorkerFunc();
|
||||
void RegisterOffWorkerFunc();
|
||||
void RegisterAssetFunc();
|
||||
bool ExecuteAbc(const std::string &fileName);
|
||||
bool CallAppFunc(const std::string& appFuncName);
|
||||
|
@ -46,8 +46,6 @@ ohos_shared_library("v8_debugger") {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
|
||||
deps += [ "//third_party/boost:boost" ]
|
||||
|
||||
include_dirs = [
|
||||
"$ace_root",
|
||||
"$ace_root/frameworks",
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
virtual int32_t GetStackSize() const = 0;
|
||||
// Gets current page's states
|
||||
virtual void GetState(int32_t& index, std::string& name, std::string& path) = 0;
|
||||
// Gets current page's components count
|
||||
virtual size_t GetComponentsCount() = 0;
|
||||
// Gets current page's params
|
||||
virtual std::string GetParams()
|
||||
{
|
||||
|
@ -721,6 +721,23 @@ void FrontendDelegateImpl::GetState(int32_t& index, std::string& name, std::stri
|
||||
}
|
||||
}
|
||||
|
||||
size_t FrontendDelegateImpl::GetComponentsCount()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (pageRouteStack_.empty()) {
|
||||
return 0;
|
||||
}
|
||||
auto itPage = pageMap_.find(pageRouteStack_.back().pageId);
|
||||
if (itPage == pageMap_.end()) {
|
||||
return 0;
|
||||
}
|
||||
auto domDoc = itPage->second->GetDomDocument();
|
||||
if (!domDoc) {
|
||||
return 0;
|
||||
}
|
||||
return domDoc->GetComponentsCount();
|
||||
}
|
||||
|
||||
std::string FrontendDelegateImpl::GetParams()
|
||||
{
|
||||
if (pageParamMap_.find(pageId_) != pageParamMap_.end()) {
|
||||
|
@ -269,6 +269,7 @@ public:
|
||||
void Clear() override;
|
||||
int32_t GetStackSize() const override;
|
||||
void GetState(int32_t& index, std::string& name, std::string& path) override;
|
||||
size_t GetComponentsCount() override;
|
||||
std::string GetParams() override;
|
||||
void TriggerPageUpdate(int32_t pageId, bool directExecute = false) override;
|
||||
|
||||
|
@ -732,6 +732,7 @@ void JsFrontend::DumpFrontend() const
|
||||
}
|
||||
|
||||
if (DumpLog::GetInstance().GetDumpFile()) {
|
||||
DumpLog::GetInstance().AddDesc("Components: " + std::to_string(delegate_->GetComponentsCount()));
|
||||
DumpLog::GetInstance().AddDesc("Path: " + routerPath);
|
||||
DumpLog::GetInstance().AddDesc("Length: " + std::to_string(routerIndex));
|
||||
DumpLog::GetInstance().Print(0, routerName, 0);
|
||||
|
@ -755,6 +755,7 @@ void PluginFrontend::DumpFrontend() const
|
||||
delegate_->GetState(routerIndex, routerName, routerPath);
|
||||
|
||||
if (DumpLog::GetInstance().GetDumpFile()) {
|
||||
DumpLog::GetInstance().AddDesc("Components: " + std::to_string(delegate_->GetComponentsCount()));
|
||||
DumpLog::GetInstance().AddDesc("Path: " + routerPath);
|
||||
DumpLog::GetInstance().AddDesc("Length: " + std::to_string(routerIndex));
|
||||
DumpLog::GetInstance().Print(0, routerName, 0);
|
||||
|
@ -821,6 +821,16 @@ void PluginFrontendDelegate::GetState(int32_t& index, std::string& name, std::st
|
||||
}
|
||||
}
|
||||
|
||||
size_t PluginFrontendDelegate::GetComponentsCount()
|
||||
{
|
||||
auto pipelineContext = pipelineContextHolder_.Get();
|
||||
const auto& pageElement = pipelineContext->GetLastPage();
|
||||
if (pageElement) {
|
||||
return pageElement->GetComponentsCount();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string PluginFrontendDelegate::GetParams()
|
||||
{
|
||||
if (pageParamMap_.find(pageId_) != pageParamMap_.end()) {
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
void Clear() override;
|
||||
int32_t GetStackSize() const override;
|
||||
void GetState(int32_t& index, std::string& name, std::string& path) override;
|
||||
size_t GetComponentsCount() override;
|
||||
std::string GetParams() override;
|
||||
void TriggerPageUpdate(int32_t pageId, bool directExecute = false) override;
|
||||
|
||||
|
@ -327,11 +327,12 @@ template("ace_core_source_set") {
|
||||
"$ace_root/frameworks/core/components_v2/pattern_lock:ace_core_components_pattern_lock_$platform",
|
||||
"$ace_root/frameworks/core/components_v2/swiper:ace_core_components_swiper_v2_$platform",
|
||||
"$ace_root/frameworks/core/components_v2/tabs:ace_core_components_tabs_v2_$platform",
|
||||
"$ace_root/frameworks/core/components_v2/water_flow:ace_core_components_water_flow_v2_$platform",
|
||||
]
|
||||
|
||||
if (defined(config.enable_rosen_backend) && config.enable_rosen_backend) {
|
||||
sources += [ "animation/native_curve_helper.cpp" ]
|
||||
deps += [ "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client" ]
|
||||
deps += [ "//foundation/graphic/graphic/rosen/modules/render_service_client:librender_service_client" ]
|
||||
}
|
||||
|
||||
if (!use_mingw_win && !use_mac && !is_wearable_product &&
|
||||
@ -350,6 +351,11 @@ template("ace_core_source_set") {
|
||||
deps += [ "$ace_root/frameworks/core/components/xcomponent:ace_core_components_xcomponent_$platform" ]
|
||||
}
|
||||
|
||||
if (defined(config.enable_ability_component) &&
|
||||
config.enable_ability_component) {
|
||||
deps += [ "$ace_root/frameworks/core/components_v2/ability_component:ace_core_components_ability_v2_$platform" ]
|
||||
}
|
||||
|
||||
if (defined(config.form_components_support) &&
|
||||
config.form_components_support) {
|
||||
if (!use_mingw_win && !use_mac) {
|
||||
|
@ -221,7 +221,8 @@ ohos_unittest("AnimationTest") {
|
||||
]
|
||||
} else {
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
deps += [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ]
|
||||
deps +=
|
||||
[ "//base/global/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
}
|
||||
|
||||
if (!is_standard_system) {
|
||||
|
@ -225,7 +225,8 @@ ohos_unittest("SvgAnimateTest") {
|
||||
]
|
||||
} else {
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
deps += [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ]
|
||||
deps +=
|
||||
[ "//base/global/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
}
|
||||
|
||||
if (!is_standard_system) {
|
||||
|
@ -26,27 +26,24 @@ namespace OHOS::Ace {
|
||||
|
||||
namespace {
|
||||
|
||||
using StartServer = bool (*)(const std::string& packageName, const bool flagNeedDebugBreakPoint);
|
||||
using StartUnixSocket = void (*)(const std::string& packageName);
|
||||
using StartServer = bool (*)(const std::string& packageName);
|
||||
using SendMessage = void (*)(const std::string& message);
|
||||
using StopServer = void (*)(const std::string& packageName);
|
||||
using AddMessage = void (*)(const int32_t instanceId, const std::string& message);
|
||||
using RemoveMessage = void (*)(const int32_t instanceId);
|
||||
using IsAttachStart = bool (*)();
|
||||
using StoreMessage = void (*)(int32_t instanceId, const std::string& message);
|
||||
using RemoveMessage = void (*)(int32_t instanceId);
|
||||
using WaitForDebugger = bool (*)();
|
||||
|
||||
} // namespace
|
||||
|
||||
ConnectServerManager::ConnectServerManager(): isNeedDebugBreakPoint_(false), handlerConnectServerSo_(nullptr)
|
||||
ConnectServerManager::ConnectServerManager(): handlerConnectServerSo_(nullptr)
|
||||
{
|
||||
isDebugVersion_ = AceApplicationInfo::GetInstance().IsDebugVersion();
|
||||
if (!isDebugVersion_) {
|
||||
return;
|
||||
}
|
||||
isNeedDebugBreakPoint_ = AceApplicationInfo::GetInstance().IsNeedDebugBreakPoint();
|
||||
packageName_ = AceApplicationInfo::GetInstance().GetPackageName();
|
||||
OpenConnectServerSo();
|
||||
LoadConnectServerSo();
|
||||
StartConnectServer();
|
||||
StartHdcSocket();
|
||||
}
|
||||
|
||||
ConnectServerManager::~ConnectServerManager()
|
||||
@ -64,7 +61,7 @@ ConnectServerManager& ConnectServerManager::Get()
|
||||
return connectServerManager;
|
||||
}
|
||||
|
||||
void ConnectServerManager::OpenConnectServerSo()
|
||||
void ConnectServerManager::LoadConnectServerSo()
|
||||
{
|
||||
const std::string soDir = "libconnectserver_debugger.z.so";
|
||||
handlerConnectServerSo_ = dlopen(soDir.c_str(), RTLD_LAZY);
|
||||
@ -94,7 +91,7 @@ void ConnectServerManager::StartConnectServer()
|
||||
LOGE("startServer = NULL, dlerror = %s", dlerror());
|
||||
return;
|
||||
}
|
||||
startServer(packageName_, isNeedDebugBreakPoint_);
|
||||
startServer(packageName_);
|
||||
}
|
||||
|
||||
void ConnectServerManager::StopConnectServer()
|
||||
@ -112,24 +109,9 @@ void ConnectServerManager::StopConnectServer()
|
||||
stopServer(packageName_);
|
||||
}
|
||||
|
||||
void ConnectServerManager::StartHdcSocket()
|
||||
void ConnectServerManager::AddInstance(int32_t instanceId, const std::string& instanceName)
|
||||
{
|
||||
LOGI("Start HDC registration with unix socket");
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
LOGE("handlerConnectServerSo_ is null");
|
||||
return;
|
||||
}
|
||||
StartUnixSocket startUnixSocket = (StartUnixSocket)dlsym(handlerConnectServerSo_, "StartUnixSocket");
|
||||
if (startUnixSocket == nullptr) {
|
||||
LOGE("startUnixSocket = NULL, dlerror = %s", dlerror());
|
||||
return;
|
||||
}
|
||||
startUnixSocket(packageName_);
|
||||
}
|
||||
|
||||
void ConnectServerManager::AddInstance(const int32_t instanceId, const std::string instanceName)
|
||||
{
|
||||
if (!isDebugVersion_) {
|
||||
if (!isDebugVersion_ || handlerConnectServerSo_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
LOGI("AddInstance %{public}d", instanceId);
|
||||
@ -144,34 +126,31 @@ void ConnectServerManager::AddInstance(const int32_t instanceId, const std::stri
|
||||
// Get the message including information of new instance, which will be send to IDE.
|
||||
std::string message = GetInstanceMapMessage("addInstance", instanceId);
|
||||
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
LOGE("handlerConnectServerSo_ is null");
|
||||
WaitForDebugger waitForDebugger = (WaitForDebugger)dlsym(handlerConnectServerSo_, "WaitForDebugger");
|
||||
if (waitForDebugger == nullptr) {
|
||||
return;
|
||||
}
|
||||
IsAttachStart isAttachStart = (IsAttachStart)dlsym(handlerConnectServerSo_, "IsAttachStart");
|
||||
if (isAttachStart != nullptr) {
|
||||
isNeedDebugBreakPoint_ = isNeedDebugBreakPoint_ || isAttachStart();
|
||||
}
|
||||
if (isNeedDebugBreakPoint_) {
|
||||
if (!waitForDebugger()) { // waitForDebugger : waitForDebugger means the connection state of the connect server
|
||||
AceApplicationInfo::GetInstance().SetNeedDebugBreakPoint(true);
|
||||
SendMessage sendMessage = (SendMessage)dlsym(handlerConnectServerSo_, "SendMessage");
|
||||
if (sendMessage != nullptr) {
|
||||
sendMessage(message);
|
||||
sendMessage(message); // if connected, message will be sent immediately.
|
||||
}
|
||||
} else {
|
||||
AddMessage addMessage = (AddMessage)dlsym(handlerConnectServerSo_, "AddMessage");
|
||||
if (addMessage != nullptr) {
|
||||
addMessage(instanceId, message);
|
||||
} else { // if not connected, message will be stored and sent later when "connected" coming.
|
||||
StoreMessage storeMessage = (StoreMessage)dlsym(handlerConnectServerSo_, "StoreMessage");
|
||||
if (storeMessage != nullptr) {
|
||||
storeMessage(instanceId, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectServerManager::RemoveInstance(const int32_t instanceId)
|
||||
void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
{
|
||||
if (!isDebugVersion_) {
|
||||
if (!isDebugVersion_ || handlerConnectServerSo_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
LOGI("RemoveInstance %{public}d", instanceId);
|
||||
|
||||
// Get the message including information of deleted instance, which will be send to IDE.
|
||||
std::string message = GetInstanceMapMessage("destroyInstance", instanceId);
|
||||
size_t numInstance = 0;
|
||||
@ -183,15 +162,11 @@ void ConnectServerManager::RemoveInstance(const int32_t instanceId)
|
||||
LOGW("Instance name not found with instance id: %{public}d", instanceId);
|
||||
}
|
||||
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
LOGE("handlerConnectServerSo_ is null");
|
||||
WaitForDebugger waitForDebugger = (WaitForDebugger)dlsym(handlerConnectServerSo_, "WaitForDebugger");
|
||||
if (waitForDebugger == nullptr) {
|
||||
return;
|
||||
}
|
||||
IsAttachStart isAttachStart = (IsAttachStart)dlsym(handlerConnectServerSo_, "IsAttachStart");
|
||||
if (isAttachStart != nullptr) {
|
||||
isNeedDebugBreakPoint_ = isNeedDebugBreakPoint_ || isAttachStart();
|
||||
}
|
||||
if (isNeedDebugBreakPoint_) {
|
||||
if (!waitForDebugger()) {
|
||||
SendMessage sendMessage = (SendMessage)dlsym(handlerConnectServerSo_, "SendMessage");
|
||||
if (sendMessage != nullptr) {
|
||||
sendMessage(message);
|
||||
@ -204,7 +179,7 @@ void ConnectServerManager::RemoveInstance(const int32_t instanceId)
|
||||
}
|
||||
}
|
||||
|
||||
std::string ConnectServerManager::GetInstanceMapMessage(const char* messageType, const int32_t instanceId)
|
||||
std::string ConnectServerManager::GetInstanceMapMessage(const char* messageType, int32_t instanceId)
|
||||
{
|
||||
auto message = JsonUtil::Create(true);
|
||||
message->Put("type", messageType);
|
||||
|
@ -25,25 +25,23 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
class ConnectServerManager {
|
||||
class ACE_EXPORT ConnectServerManager {
|
||||
public:
|
||||
~ConnectServerManager();
|
||||
static ConnectServerManager& Get();
|
||||
void AddInstance(const int32_t instanceId, const std::string instanceName);
|
||||
void RemoveInstance(const int32_t instanceId);
|
||||
void AddInstance(int32_t instanceId, const std::string& instanceName = "PandaDebugger");
|
||||
void RemoveInstance(int32_t instanceId);
|
||||
|
||||
private:
|
||||
ConnectServerManager();
|
||||
void OpenConnectServerSo();
|
||||
void LoadConnectServerSo();
|
||||
void CloseConnectServerSo();
|
||||
void StartConnectServer();
|
||||
void StopConnectServer();
|
||||
void StartHdcSocket();
|
||||
std::string GetInstanceMapMessage(const char* messageType, const int32_t instanceId);
|
||||
std::string GetInstanceMapMessage(const char* messageType, int32_t instanceId);
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
bool isDebugVersion_;
|
||||
bool isNeedDebugBreakPoint_;
|
||||
void* handlerConnectServerSo_;
|
||||
std::string packageName_;
|
||||
std::unordered_map<int32_t, std::string> instanceMap_;
|
||||
|
@ -31,14 +31,9 @@ ohos_shared_library("connectserver_debugger") {
|
||||
"BOOST_CLANG",
|
||||
]
|
||||
|
||||
defines += ace_common_defines
|
||||
defines += [ "ACE_LOG_TAG=\"ConnectServer\"" ]
|
||||
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
deps += [
|
||||
"//third_party/boost:boost",
|
||||
"//utils/native/base:utilsecurec",
|
||||
]
|
||||
external_deps = hilog_deps
|
||||
|
||||
include_dirs = [
|
||||
"$ace_root",
|
||||
@ -46,14 +41,12 @@ ohos_shared_library("connectserver_debugger") {
|
||||
"$ace_root/frameworks/core/common/debugger",
|
||||
"//third_party/boost",
|
||||
"//third_party/boost/boost",
|
||||
"//utils/native/base/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"$ace_root/adapter/ohos/osal/log_wrapper.cpp",
|
||||
"connect_inspector.cpp",
|
||||
"connect_server.cpp",
|
||||
"unix_socket.cpp",
|
||||
]
|
||||
|
||||
configs = [ ":connectserver_debugger_config" ]
|
||||
|
@ -15,13 +15,9 @@
|
||||
|
||||
#include "frameworks/core/common/debugger/connect_inspector.h"
|
||||
#include "base/log/log.h"
|
||||
#include "frameworks/core/common/debugger/connect_server.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
std::unique_ptr<ConnectServer> g_connectServer = nullptr;
|
||||
void* g_debugger = nullptr;
|
||||
std::map<int32_t, std::string> g_infoBuffer;
|
||||
bool g_isAttachStart = false;
|
||||
int g_ideWaitTime = 100;
|
||||
std::unique_ptr<ConnectInspector> g_inspector = nullptr;
|
||||
|
||||
void* HandleDebugManager(void* const server)
|
||||
{
|
||||
@ -34,18 +30,6 @@ void* HandleDebugManager(void* const server)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* HandleHDC(void* const server)
|
||||
{
|
||||
LOGI("HandleHDC");
|
||||
if (server == nullptr) {
|
||||
LOGE("HandleHDC server nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
int32_t pid = getpid();
|
||||
static_cast<ConnectServer*>(server)->Register(pid);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void OnMessage(const std::string& message)
|
||||
{
|
||||
if (message.empty()) {
|
||||
@ -56,19 +40,11 @@ void OnMessage(const std::string& message)
|
||||
|
||||
std::string checkMessage = "connected";
|
||||
if (message.find(checkMessage, 0) != std::string::npos) {
|
||||
LOGI("Find the targeted string: %{private}s", message.c_str());
|
||||
if (g_connectServer != nullptr) {
|
||||
g_connectServer->waitingForDebugger_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
checkMessage = "attachStart";
|
||||
if (message.find(checkMessage, 0) != std::string::npos) {
|
||||
LOGI("Find the attach command: %{private}s", message.c_str());
|
||||
g_isAttachStart = true;
|
||||
if (g_connectServer != nullptr) {
|
||||
for (auto it = g_infoBuffer.begin(); it != g_infoBuffer.end(); it++) {
|
||||
g_connectServer->SendMessage(it->second);
|
||||
LOGI("Find the target string: %{private}s", message.c_str());
|
||||
if (g_inspector != nullptr && g_inspector->connectServer_ != nullptr) {
|
||||
g_inspector->waitingForDebugger_ = false;
|
||||
for (auto &info : g_inspector->infoBuffer_) {
|
||||
g_inspector->connectServer_->SendMessage(info.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,86 +52,70 @@ void OnMessage(const std::string& message)
|
||||
|
||||
void ResetService()
|
||||
{
|
||||
if (g_connectServer != nullptr) {
|
||||
g_connectServer->StopServer();
|
||||
g_connectServer.reset();
|
||||
if (g_inspector != nullptr && g_inspector->connectServer_ != nullptr) {
|
||||
g_inspector->connectServer_->StopServer();
|
||||
g_inspector->connectServer_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void StartServer(const std::string& componentName, const bool flagNeedDebugBreakPoint)
|
||||
void StartServer(const std::string& componentName)
|
||||
{
|
||||
LOGI("StartServer: %{private}s", componentName.c_str());
|
||||
g_connectServer = std::make_unique<ConnectServer>(componentName, std::bind(&OnMessage, std::placeholders::_1),
|
||||
flagNeedDebugBreakPoint);
|
||||
g_inspector = std::make_unique<ConnectInspector>();
|
||||
g_inspector->connectServer_ = std::make_unique<ConnectServer>(componentName,
|
||||
std::bind(&OnMessage, std::placeholders::_1));
|
||||
|
||||
pthread_t tid;
|
||||
if (pthread_create(&tid, nullptr, &HandleDebugManager, static_cast<void*>(g_connectServer.get())) != 0) {
|
||||
if (pthread_create(&tid, nullptr, &HandleDebugManager,
|
||||
static_cast<void*>(g_inspector->connectServer_.get())) != 0) {
|
||||
LOGE("pthread_create fail!");
|
||||
ResetService();
|
||||
return;
|
||||
}
|
||||
|
||||
while (g_connectServer->waitingForDebugger_) {
|
||||
usleep(g_ideWaitTime);
|
||||
}
|
||||
LOGI("StartServer connected.");
|
||||
}
|
||||
|
||||
void StartUnixSocket(const std::string& componentName)
|
||||
{
|
||||
LOGI("StartUnixSocket: %{private}s", componentName.c_str());
|
||||
while (g_connectServer == nullptr) {
|
||||
LOGI("Waiting for the Connect Server");
|
||||
usleep(g_ideWaitTime);
|
||||
}
|
||||
LOGI("pid is %{private}d", getpid());
|
||||
pthread_t tid;
|
||||
if (pthread_create(&tid, nullptr, &HandleHDC, static_cast<void*>(g_connectServer.get())) != 0) {
|
||||
LOGE("pthread_create fail!");
|
||||
return;
|
||||
}
|
||||
LOGI("StartServer Continue.");
|
||||
}
|
||||
|
||||
void StopServer(const std::string& componentName)
|
||||
{
|
||||
LOGI("StopServer: %{private}s", componentName.c_str());
|
||||
if (g_connectServer != nullptr) {
|
||||
g_connectServer->StopServer();
|
||||
g_connectServer.reset();
|
||||
}
|
||||
ResetService();
|
||||
LOGI("StopServer end");
|
||||
}
|
||||
|
||||
void AddMessage(const int32_t instanceId, const std::string& message)
|
||||
void StoreMessage(int32_t instanceId, const std::string& message)
|
||||
{
|
||||
LOGI("Add message to information buffer.");
|
||||
if (g_infoBuffer.count(instanceId) == 1) {
|
||||
if (g_inspector->infoBuffer_.count(instanceId) == 1) {
|
||||
LOGE("The message with the current instance id has been existed.");
|
||||
return;
|
||||
}
|
||||
g_infoBuffer[instanceId] = message;
|
||||
g_inspector->infoBuffer_[instanceId] = message;
|
||||
}
|
||||
|
||||
void RemoveMessage(const int32_t instanceId)
|
||||
void RemoveMessage(int32_t instanceId)
|
||||
{
|
||||
LOGI("Remove message from information buffer.");
|
||||
if (g_infoBuffer.count(instanceId) != 1) {
|
||||
if (g_inspector->infoBuffer_.count(instanceId) != 1) {
|
||||
LOGE("The message with the current instance id does not exist.");
|
||||
return;
|
||||
}
|
||||
g_infoBuffer.erase(instanceId);
|
||||
g_inspector->infoBuffer_.erase(instanceId);
|
||||
}
|
||||
|
||||
void SendMessage(const std::string& message)
|
||||
{
|
||||
LOGI("Enter SendMessage");
|
||||
if (g_connectServer != nullptr) {
|
||||
g_connectServer->SendMessage(message);
|
||||
if (g_inspector != nullptr && g_inspector->connectServer_ != nullptr && !g_inspector->waitingForDebugger_) {
|
||||
g_inspector->connectServer_->SendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsAttachStart()
|
||||
bool WaitForDebugger()
|
||||
{
|
||||
return g_isAttachStart;
|
||||
if (g_inspector == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return g_inspector->waitingForDebugger_;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -17,7 +17,9 @@
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DEBUGGER_CONNECT_INSPECTOR_H
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "frameworks/core/common/debugger/connect_server.h"
|
||||
namespace OHOS::Ace {
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@ -25,25 +27,34 @@ extern "C" {
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
void StartServer(const std::string& componentName, const bool flagNeedDebugBreakPoint);
|
||||
|
||||
void StartUnixSocket(const std::string& componentName);
|
||||
void StartServer(const std::string& componentName);
|
||||
|
||||
void StopServer(const std::string& componentName);
|
||||
|
||||
void SendMessage(const std::string& message);
|
||||
|
||||
void AddMessage(const int32_t instanceId, const std::string& message);
|
||||
void StoreMessage(int32_t instanceId, const std::string& message);
|
||||
|
||||
void RemoveMessage(const int32_t instanceId);
|
||||
void RemoveMessage(int32_t instanceId);
|
||||
|
||||
bool IsAttachStart();
|
||||
bool WaitForDebugger();
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* End of #ifdef __cplusplus */
|
||||
|
||||
class ConnectInspector {
|
||||
public:
|
||||
ConnectInspector() = default;
|
||||
~ConnectInspector() = default;
|
||||
|
||||
std::string componentName_ {};
|
||||
std::unordered_map<int32_t, std::string> infoBuffer_;
|
||||
std::unique_ptr<ConnectServer> connectServer_;
|
||||
volatile bool waitingForDebugger_ = true;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DEBUGGER_CONNECT_INSPECTOR_H
|
||||
|
@ -17,13 +17,10 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <thread>
|
||||
#include "base/log/log.h"
|
||||
#include "frameworks/core/common/debugger/unix_socket.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
std::unique_ptr<UnixSocketClient> g_unixSocket = nullptr;
|
||||
|
||||
void ConnectServer::RunServer()
|
||||
{
|
||||
@ -83,29 +80,4 @@ void ConnectServer::SendMessage(const std::string& message) const
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectServer::WaitMessage() const
|
||||
{
|
||||
beast::flat_buffer buffer;
|
||||
webSocket_->read(buffer);
|
||||
std::string message = boost::beast::buffers_to_string(buffer.data());
|
||||
LOGI("receive msg from Debug Manager message=%s", message.c_str());
|
||||
wsOnMessage_(std::move(message));
|
||||
}
|
||||
|
||||
void ConnectServer::Register(int32_t pid)
|
||||
{
|
||||
g_unixSocket = std::make_unique<UnixSocketClient>();
|
||||
int connRes = g_unixSocket->UnixSocketConn();
|
||||
if (connRes < 0) {
|
||||
return;
|
||||
}
|
||||
LOGI("Unix Socket Connect Successfully");
|
||||
int res = g_unixSocket->SendMessage(pid);
|
||||
if (res < 0) {
|
||||
LOGE("Register Failed!");
|
||||
return;
|
||||
}
|
||||
LOGI("Register Successfully!");
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -30,18 +30,13 @@ using localSocket = boost::asio::local::stream_protocol;
|
||||
|
||||
class ConnectServer {
|
||||
public:
|
||||
ConnectServer(const std::string& bundle, std::function<void(std::string)> onMessage, bool flagNeedDebugBreakPoint)
|
||||
: bundleName_(bundle), wsOnMessage_(std::move(onMessage))
|
||||
{
|
||||
waitingForDebugger_ = flagNeedDebugBreakPoint;
|
||||
}
|
||||
ConnectServer(const std::string& bundleName, std::function<void(std::string)> onMessage)
|
||||
: bundleName_(bundleName), wsOnMessage_(std::move(onMessage))
|
||||
{}
|
||||
~ConnectServer() = default;
|
||||
void RunServer();
|
||||
void StopServer();
|
||||
void SendMessage(const std::string& message) const;
|
||||
void WaitMessage() const;
|
||||
void Register(int32_t pid);
|
||||
bool waitingForDebugger_;
|
||||
|
||||
private:
|
||||
volatile bool terminateExecution_ = false;
|
||||
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 "frameworks/core/common/debugger/unix_socket.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "base/log/log.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
static constexpr uint32_t SLEEP_TIME_MS = 500U;
|
||||
static constexpr int CONTROL_SOCK_SEND_TIMEOUT = 10U;
|
||||
|
||||
int32_t UnixSocketClient::UnixSocketConn()
|
||||
{
|
||||
uint32_t sleep_ms = SLEEP_TIME_MS;
|
||||
const uint32_t SLEEP_MAX_MS = 4 * SLEEP_TIME_MS;
|
||||
control_sock = TEMP_FAILURE_RETRY(socket(AF_UNIX, SOCK_STREAM, 0));
|
||||
if (control_sock < 0) {
|
||||
LOGE("Could not create control socket");
|
||||
return FAIL_CAUSE_SOCKET_NO_CLIENT;
|
||||
}
|
||||
errno_t errRet = memset_s(&controlAddrUn, sizeof(controlAddrUn), 0, sizeof(controlAddrUn));
|
||||
if (errRet != EOK) {
|
||||
LOGE("Socket memset_s fail");
|
||||
return FAIL_CAUSE_SOCKET_NO_CLIENT;
|
||||
}
|
||||
controlAddrUn.sun_family = AF_UNIX;
|
||||
errno_t errNum = memcpy_s(controlAddrUn.sun_path, JDWP_CONTROL_NAME_LEN, JDWP_CONTROL_NAME, JDWP_CONTROL_NAME_LEN);
|
||||
if (errNum != EOK) {
|
||||
LOGE("Socket memcpy_s fail");
|
||||
return FAIL_CAUSE_SOCKET_NO_CLIENT;
|
||||
}
|
||||
control_addr_len = sizeof(controlAddrUn.sun_family) + JDWP_CONTROL_NAME_LEN;
|
||||
int keepalive = 1;
|
||||
setsockopt(control_sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepalive, sizeof(keepalive));
|
||||
while (true) {
|
||||
int ret = TEMP_FAILURE_RETRY(connect(control_sock, (struct sockaddr *)&controlAddrUn, control_addr_len));
|
||||
if (ret >= 0) {
|
||||
LOGI("Connect Successful");
|
||||
return SOCKET_SUCCESS;
|
||||
}
|
||||
const int sleep_times = 2;
|
||||
usleep(sleep_ms * SLEEP_TIME_MS * sleep_times);
|
||||
sleep_ms += (sleep_ms >> 1);
|
||||
if (sleep_ms > SLEEP_MAX_MS) {
|
||||
sleep_ms = SLEEP_MAX_MS;
|
||||
}
|
||||
return FAIL_CAUSE_SOCKET_COMMON_FAIL;
|
||||
}
|
||||
return FAIL_CAUSE_SOCKET_COMMON_FAIL;
|
||||
}
|
||||
|
||||
int32_t UnixSocketClient::SendMessage(int32_t pid)
|
||||
{
|
||||
std::string pidStr = std::to_string(pid);
|
||||
int pidSize = pidStr.size();
|
||||
int buffSize = pidSize + 1;
|
||||
char buff[buffSize];
|
||||
if (control_sock < 0) {
|
||||
LOGE("Error Occur!");
|
||||
return FAIL_CAUSE_SEND_MSG_FAIL;
|
||||
}
|
||||
errno_t errRet = strncpy_s(buff, buffSize, pidStr.c_str(), pidSize);
|
||||
if (errRet != EOK) {
|
||||
LOGE("Send Message fail");
|
||||
return FAIL_CAUSE_SEND_MSG_FAIL;
|
||||
}
|
||||
struct timeval timeout {
|
||||
};
|
||||
timeout.tv_sec = CONTROL_SOCK_SEND_TIMEOUT;
|
||||
timeout.tv_usec = 0;
|
||||
setsockopt(control_sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
|
||||
int ret = TEMP_FAILURE_RETRY(send(control_sock, buff, pidSize, 0));
|
||||
if (ret >= 0) {
|
||||
LOGI("PID sent as '%s' to HDC", buff);
|
||||
return SOCKET_SUCCESS;
|
||||
}
|
||||
LOGE("Weird, can't send JDWP process pid to HDC");
|
||||
return FAIL_CAUSE_SEND_MSG_FAIL;
|
||||
}
|
||||
|
||||
void UnixSocketClient::UnixSocketClose()
|
||||
{
|
||||
close(control_sock);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DEBUGGER_UNIX_SOCKET_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DEBUGGER_UNIX_SOCKET_H
|
||||
#define FAIL_CAUSE_SOCKET_NO_CLIENT (-1003)
|
||||
#define FAIL_CAUSE_SOCKET_COMMON_FAIL (-1004)
|
||||
#define FAIL_CAUSE_SEND_MSG_FAIL (-1005)
|
||||
#define JDWP_CONTROL_NAME "\0jdwp-control"
|
||||
#define JDWP_CONTROL_NAME_LEN (sizeof(JDWP_CONTROL_NAME)-1)
|
||||
#define SOCKET_SUCCESS 0
|
||||
|
||||
#include <sys/un.h>
|
||||
namespace OHOS::Ace {
|
||||
class UnixSocketClient {
|
||||
public:
|
||||
UnixSocketClient() = default;
|
||||
~UnixSocketClient() {}
|
||||
int32_t UnixSocketConn();
|
||||
int32_t SendMessage(int32_t pid);
|
||||
void UnixSocketClose();
|
||||
private:
|
||||
int32_t control_sock = -1;
|
||||
struct sockaddr_un controlAddrUn;
|
||||
int32_t control_addr_len;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DEBUGGER_UNIX_SOCKET_H
|
@ -56,13 +56,16 @@ void HdcRegister::LoadRegisterSo()
|
||||
}
|
||||
}
|
||||
|
||||
void HdcRegister::StartHdcRegister()
|
||||
void HdcRegister::StartHdcRegister(int32_t instanceId)
|
||||
{
|
||||
LOGI("Start Hdc Register");
|
||||
if (registerHandler_ == nullptr) {
|
||||
LOGE("registerHandler_ is null");
|
||||
return;
|
||||
}
|
||||
if (instanceId != 0) {
|
||||
return; // Applications and abilities should only call this function once, especially in multi-instance.
|
||||
}
|
||||
StartRegister startRegister = (StartRegister)dlsym(registerHandler_, "StartConnect");
|
||||
if (startRegister == nullptr) {
|
||||
LOGE("startRegister = NULL, dlerror = %s", dlerror());
|
||||
@ -71,9 +74,9 @@ void HdcRegister::StartHdcRegister()
|
||||
startRegister(pkgName_);
|
||||
}
|
||||
|
||||
void HdcRegister::StopHdcRegister()
|
||||
void HdcRegister::StopHdcRegister(int32_t instanceId)
|
||||
{
|
||||
if (!isDebugVersion_) {
|
||||
if (!isDebugVersion_ || instanceId != 0) {
|
||||
return;
|
||||
}
|
||||
LOGI("Stop Hdc Register");
|
||||
|
@ -26,13 +26,13 @@ namespace OHOS::Ace {
|
||||
|
||||
class HdcRegister {
|
||||
public:
|
||||
HdcRegister();
|
||||
~HdcRegister() = default;
|
||||
static HdcRegister& Get();
|
||||
void StartHdcRegister();
|
||||
void StopHdcRegister();
|
||||
void StartHdcRegister(int32_t instanceId);
|
||||
void StopHdcRegister(int32_t instanceId);
|
||||
|
||||
private:
|
||||
HdcRegister();
|
||||
void LoadRegisterSo();
|
||||
|
||||
bool isDebugVersion_;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
std::shared_ptr<PluginUtils> PluginManager::pluginUtils_ = nullptr;
|
||||
std::map<int64_t, RefPtr<PluginSubContainer>> PluginManager::pluginSubContainerMap_;
|
||||
PluginManager::PluginManager() {}
|
||||
|
||||
PluginManager::~PluginManager()
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::map<int64_t, RefPtr<PluginSubContainer>> pluginSubContainerMap_;
|
||||
static std::map<int64_t, RefPtr<PluginSubContainer>> pluginSubContainerMap_;
|
||||
std::mutex nonmatchedContainerMutex_;
|
||||
std::unordered_map<std::string, RefPtr<PluginSubContainer>> nonmatchedContainerMap_;
|
||||
std::mutex parentContainerMutex_;
|
||||
|
@ -93,10 +93,11 @@ bool TryCloseLoop(uv_loop_t *ptrLoop, const char *callerName)
|
||||
|
||||
void FreeInstance()
|
||||
{
|
||||
if (clsHdcJdwpSimulator != nullptr) {
|
||||
delete clsHdcJdwpSimulator;
|
||||
clsHdcJdwpSimulator = nullptr;
|
||||
if (clsHdcJdwpSimulator == nullptr) {
|
||||
return; // if clsHdcJdwpSimulator is nullptr, should return immediately.
|
||||
}
|
||||
delete clsHdcJdwpSimulator;
|
||||
clsHdcJdwpSimulator = nullptr;
|
||||
uv_stop(&loopMain);
|
||||
TryCloseLoop(&loopMain, "Hdcjdwp exit");
|
||||
LOGI("jdwp_process exit.");
|
||||
@ -134,6 +135,9 @@ void* HdcConnectRun(void* pkgContent)
|
||||
|
||||
void StartConnect(const std::string& pkgName)
|
||||
{
|
||||
if (clsHdcJdwpSimulator != nullptr) {
|
||||
return;
|
||||
}
|
||||
pthread_t tid;
|
||||
g_connectManagement = std::make_unique<ConnectManagement>();
|
||||
g_connectManagement->SetPkgName(pkgName);
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_WINDOW_EXTENSION_CONNECTION_ADAPTER_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_WINDOW_EXTENSION_CONNECTION_ADAPTER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/referenced.h"
|
||||
#include "base/thread/task_executor.h"
|
||||
#include "base/geometry/rect.h"
|
||||
#include "core/pipeline/base/render_node.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class ACE_EXPORT WindowExtensionConnectionAdapter : public AceType {
|
||||
DECLARE_ACE_TYPE(WindowExtensionConnectionAdapter, AceType);
|
||||
|
||||
public:
|
||||
virtual void Show() {}
|
||||
virtual void Hide() {}
|
||||
virtual void RequestFocus() {}
|
||||
|
||||
virtual void ConnectExtension(const std::string& want, const Rect& rect, WeakPtr<RenderNode> node) = 0;
|
||||
virtual void UpdateRect(const Rect& rect) = 0;
|
||||
virtual void RemoveExtension() = 0;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_WINDOW_EXTENSION_CONNECTION_ADAPTER_H
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_WINDOW_EXTENSION_CONNECTION_PROXY_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_WINDOW_EXTENSION_CONNECTION_PROXY_H
|
||||
|
||||
#include "base/memory/referenced.h"
|
||||
#include "core/common/window/window_extension_connection_adapter.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class ACE_EXPORT WindowExtensionConnectionProxy {
|
||||
public:
|
||||
static RefPtr<WindowExtensionConnectionAdapter> CreateAdapter();
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_WINDOW_WINDOW_EXTENSION_CONNECTION_PROXY_H
|
@ -357,7 +357,7 @@ void FlutterRenderBox::Paint(RenderContext& context, const Offset& offset)
|
||||
outerRRect, canvas->canvas(), frontDecoration_->GetColorBlend(), bgColor);
|
||||
}
|
||||
}
|
||||
if (RenderBox::needPaintDebugBoundary_) {
|
||||
if (RenderBox::needPaintDebugBoundary_ && SystemProperties::GetDebugBoundaryEnabled()) {
|
||||
flutter::Canvas* canvas = renderContext->GetCanvas();
|
||||
if (canvas == nullptr) {
|
||||
LOGE("Paint canvas is null.");
|
||||
|
@ -327,7 +327,7 @@ void RosenRenderBox::Paint(RenderContext& context, const Offset& offset)
|
||||
RosenDecorationPainter::PaintColorBlend(outerRRect, canvas, frontDecoration_->GetColorBlend(), bgColor);
|
||||
}
|
||||
}
|
||||
if (RenderBox::needPaintDebugBoundary_) {
|
||||
if (RenderBox::needPaintDebugBoundary_ && SystemProperties::GetDebugBoundaryEnabled()) {
|
||||
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
|
||||
if (canvas == nullptr) {
|
||||
LOGE("Paint canvas is null.");
|
||||
|
@ -52,7 +52,7 @@ build_component("camera") {
|
||||
sources += [ "standard_system/camera.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/standard:libwmclient",
|
||||
"//foundation/graphic/graphic:libwmclient",
|
||||
"//foundation/multimedia/camera_standard/frameworks/native/camera:camera_framework",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
@ -392,11 +392,7 @@ int32_t CameraCallback::PrepareVideo(sptr<OHOS::CameraStandard::CameraManager> c
|
||||
}
|
||||
|
||||
MakeDir(DEFAULT_CATCH_PATH);
|
||||
ret = recorder_->SetOutputPath(DEFAULT_CATCH_PATH);
|
||||
if (ret != ERR_OK) {
|
||||
LOGE("Camera SetOutputPath failed. ret= %{private}d", ret);
|
||||
return -1;
|
||||
}
|
||||
// need use fd not path
|
||||
ret = recorder_->Prepare();
|
||||
if (ret != ERR_OK) {
|
||||
LOGE("Prepare failed. ret= %{private}d", ret);
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
namespace {
|
||||
constexpr double BOUNDARY_STROKE_WIDTH = 3.0;
|
||||
constexpr double BOUNDARY_STROKE_WIDTH = 1.0;
|
||||
constexpr double BOUNDARY_CORNER_LENGTH = 8.0;
|
||||
constexpr uint32_t BOUNDARY_COLOR = 0xFFFA2A2D;
|
||||
constexpr uint32_t BOUNDARY_CORNER_COLOR = 0xFF007DFF;
|
||||
|
@ -89,7 +89,7 @@ template("build_component") {
|
||||
if (defined(config.enable_rosen_backend) && config.enable_rosen_backend &&
|
||||
defined(invoker.rosen_sources)) {
|
||||
sources += invoker.rosen_sources
|
||||
configs += [ "//foundation/graphic/standard/rosen/modules/render_service_client:render_service_client_config" ]
|
||||
configs += [ "//foundation/graphic/graphic/rosen/modules/render_service_client:render_service_client_config" ]
|
||||
}
|
||||
|
||||
if (defined(config.enable_standard_input) &&
|
||||
|
@ -334,19 +334,12 @@ void FormElement::OnActionEvent(const std::string& action) const
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef OHOS_STANDARD_SYSTEM
|
||||
if ("router" == type) {
|
||||
#ifdef OHOS_STANDARD_SYSTEM
|
||||
auto context = GetContext().Upgrade();
|
||||
if (context) {
|
||||
LOGI("send action evetn to ability to process");
|
||||
context->OnActionEvent(formManagerBridge_->WrapAction(action));
|
||||
formManagerBridge_->OnActionEvent(action);
|
||||
}
|
||||
#else
|
||||
HandleOnRouterEvent(eventAction);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (formManagerBridge_) {
|
||||
LOGI("send action event to ability.");
|
||||
|
@ -283,6 +283,37 @@ void FormManagerDelegate::AddFormUninstallCallback(const OnFormUninstallCallback
|
||||
onFormUninstallCallback_ = callback;
|
||||
}
|
||||
|
||||
bool FormManagerDelegate::ParseAction(const std::string &action, AAFwk::Want &want)
|
||||
{
|
||||
auto eventAction = JsonUtil::ParseJsonString(action);
|
||||
auto bundleName = eventAction->GetValue("bundleName");
|
||||
auto abilityName = eventAction->GetValue("abilityName");
|
||||
auto params = eventAction->GetValue("params");
|
||||
auto bundle = bundleName->GetString();
|
||||
auto ability = abilityName->GetString();
|
||||
LOGI("bundle:%{public}s ability:%{public}s, params:%{public}s", bundle.c_str(), ability.c_str(),
|
||||
params->GetString().c_str());
|
||||
if (bundle.empty()) {
|
||||
bundle = wantCache_.GetElement().GetBundleName();
|
||||
}
|
||||
if (ability.empty()) {
|
||||
LOGE("action ability is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
want.SetElementName(bundle, ability);
|
||||
if (params->IsValid()) {
|
||||
auto child = params->GetChild();
|
||||
while (child->IsValid()) {
|
||||
auto key = child->GetKey();
|
||||
auto value = child->GetString();
|
||||
want.SetParam(key, value);
|
||||
child = child->GetNext();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FormManagerDelegate::OnActionEvent(const std::string& action)
|
||||
{
|
||||
auto eventAction = JsonUtil::ParseJsonString(action);
|
||||
@ -304,7 +335,12 @@ void FormManagerDelegate::OnActionEvent(const std::string& action)
|
||||
|
||||
#ifdef OHOS_STANDARD_SYSTEM
|
||||
if (type == "router") {
|
||||
AppExecFwk::FormMgr::GetInstance().RouterEvent(runningCardId_);
|
||||
AAFwk::Want want;
|
||||
if (!ParseAction(action, want)) {
|
||||
LOGE("Failed to parse want");
|
||||
} else {
|
||||
AppExecFwk::FormMgr::GetInstance().RouterEvent(runningCardId_, want);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -411,16 +447,5 @@ void FormManagerDelegate::OnDeathReceived()
|
||||
LOGE("relink to form manager fail!!!");
|
||||
}
|
||||
}
|
||||
|
||||
std::string FormManagerDelegate::WrapAction(const std::string& action)
|
||||
{
|
||||
auto eventAction = JsonUtil::ParseJsonString(action);
|
||||
if (!eventAction->Contains("bundleName")) {
|
||||
eventAction->Put("bundleName", wantCache_.GetElement().GetBundleName().c_str());
|
||||
}
|
||||
auto newAction = eventAction->ToString();
|
||||
OHOS::AppExecFwk::FormMgr::GetInstance().UpdateRouterAction(runningCardId_, newAction);
|
||||
return newAction;
|
||||
}
|
||||
#endif
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
void AddFormUninstallCallback(const OnFormUninstallCallback& callback);
|
||||
|
||||
void OnActionEvent(const std::string& action);
|
||||
std::string WrapAction(const std::string& action);
|
||||
#ifdef OHOS_STANDARD_SYSTEM
|
||||
void ProcessFormUpdate(const AppExecFwk::FormJsInfo &formJsInfo);
|
||||
void ProcessFormUninstall(const int64_t formId);
|
||||
@ -84,6 +83,7 @@ private:
|
||||
void OnFormAcquired(const std::string& param);
|
||||
void OnFormUpdate(const std::string& param);
|
||||
void OnFormError(const std::string& param);
|
||||
bool ParseAction(const std::string& action, AAFwk::Want &want);
|
||||
|
||||
onFormAcquiredCallbackForJava onFormAcquiredCallbackForJava_;
|
||||
OnFormUpdateCallbackForJava onFormUpdateCallbackForJava_;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "core/common/frontend.h"
|
||||
#include "core/common/text_field_manager.h"
|
||||
#include "core/components/transform/transform_element.h"
|
||||
#include "core/components_v2/inspector/inspector_composed_element.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
@ -153,4 +154,25 @@ void PageElement::Dump()
|
||||
}
|
||||
}
|
||||
|
||||
int32_t PageElement::GetComponentsCount()
|
||||
{
|
||||
int32_t result = 0;
|
||||
std::queue<RefPtr<Element>> elements;
|
||||
elements.push(AceType::Claim(this));
|
||||
while (!elements.empty()) {
|
||||
auto& element = elements.front();
|
||||
auto inspectorElement = AceType::DynamicCast<V2::InspectorComposedElement>(element);
|
||||
if (inspectorElement != nullptr) {
|
||||
result++;
|
||||
}
|
||||
const auto& children = element->GetChildren();
|
||||
for (const auto& child : children) {
|
||||
elements.push(child);
|
||||
}
|
||||
elements.pop();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
@ -90,6 +90,7 @@ public:
|
||||
void RemoveGeometryTransition(const std::string& id);
|
||||
void FinishCreateGeometryTransition(const std::string& id);
|
||||
void Dump() override;
|
||||
int32_t GetComponentsCount();
|
||||
|
||||
protected:
|
||||
bool RequestNextFocus(bool vertical, bool reverse, const Rect& rect) override;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user