init ipc for uicontet

Signed-off-by: lzr <liuzengrui1@huawei.com>
Change-Id: I6dbac4ab21e03cd0a9b0a59b5118af1b217b6c31
This commit is contained in:
lzr 2024-05-08 17:39:26 +08:00
parent 8653c0c309
commit c904a3cad0
14 changed files with 454 additions and 3 deletions

View File

@ -89,6 +89,7 @@ template("ace_ohos_standard_source_set") {
"//commonlibrary/c_utils/base/include",
"//foundation/arkui/napi/interfaces/kits",
"//foundation/arkui/napi/native_engine",
"//foundation/arkui/ace_engine/interfaces/inner_api/ui_session",
"//foundation/window/window_manager/interfaces/innerkits",
"//foundation/graphic/graphic_2d/rosen/modules/2d_engine",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src/drawing/engine_adapter",
@ -100,6 +101,7 @@ template("ace_ohos_standard_source_set") {
deps += [
"$ace_root/adapter/ohos/capability:ace_capability_ohos",
"$ace_root/interfaces/inner_api/ace:ace_uicontent",
"$ace_root/interfaces/inner_api/ui_session:ui_session",
"//third_party/zlib:shared_libz",
]

View File

@ -20,14 +20,15 @@
#include "ability_info.h"
#include "display_manager.h"
#include "dm/display_manager.h"
#include "interfaces/inner_api/ace/arkui_rect.h"
#include "interfaces/inner_api/ace/ui_content.h"
#include "interfaces/inner_api/ace/viewport_config.h"
#include "interfaces/inner_api/ui_session/ui_content_stub_impl.h"
#include "key_event.h"
#include "native_engine/native_engine.h"
#include "native_engine/native_value.h"
#include "wm/window.h"
#include "dm/display_manager.h"
#include "adapter/ohos/entrance/distributed_ui_manager.h"
#include "base/thread/task_executor.h"
@ -304,6 +305,11 @@ public:
void SetContentNodeGrayScale(float grayscale) override;
sptr<IRemoteObject> GetRemoteObj() override
{
return instance_;
}
private:
UIContentErrorCode InitializeInner(
OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, bool isNamedRouter);
@ -368,6 +374,7 @@ private:
std::shared_ptr<TaskWrapper> taskWrapper_;
sptr<IRemoteObject> parentToken_ = nullptr;
sptr<IRemoteObject> instance_ = new (std::nothrow) UIContentServiceStubImpl();
RefPtr<RenderBoundaryManager> renderBoundaryManager_ = Referenced::MakeRefPtr<RenderBoundaryManager>();
bool isUIExtensionSubWindow_ = false;
bool isUIExtensionAbilityProcess_ = false;

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ACE_UI_SERVICE_HILOG_H
#define OHOS_ACE_UI_SERVICE_HILOG_H
#include "hilog/log.h"
#define UISERVICE_LOG_DOMAIN 0xD003936
#define UISERVICE_LOG_TAG "AceUISession"
#define UISERVICE_FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
#define ACE_FMT_PREFIX "[%{public}s(%{public}s:%{public}d)]"
#define PRINT_LOG(level, fmt, ...) \
HILOG_IMPL(LOG_CORE, LOG_##level, UISERVICE_LOG_DOMAIN, UISERVICE_LOG_TAG, ACE_FMT_PREFIX fmt, UISERVICE_FILENAME, \
__FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOGE(fmt, ...) PRINT_LOG(ERROR, fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) PRINT_LOG(WARN, fmt, ##__VA_ARGS__)
#define LOGI(fmt, ...) PRINT_LOG(INFO, fmt, ##__VA_ARGS__)
#define LOGD(fmt, ...) PRINT_LOG(DEBUG, fmt, ##__VA_ARGS__)
#endif

View File

@ -0,0 +1,73 @@
/*
* 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 "interfaces/inner_api/ui_session/ui_content_proxy.h"
#include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
namespace OHOS::Ace {
int32_t UIContentServiceProxy::OnGetInspectorTree()
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOGW("OnGetInspectorTree write interface token failed");
return FAILED;
}
if (Remote()->SendRequest(UI_CONTENT_SERVICE_GET_TREE, data, reply, option) != ERR_NONE) {
LOGW("OnGetInspectorTree send request failed");
return REPLY_ERROR;
}
return NO_ERROR;
}
int32_t UIContentServiceProxy::OnReportUnfocusEvent()
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOGW("OnReportUnfocusEvent write interface token failed");
return FAILED;
}
if (Remote()->SendRequest(UI_CONTENT_SERVICE_REPORT_EVENT, data, reply, option) != ERR_NONE) {
LOGW("OnReportUnfocusEvent send request failed");
return REPLY_ERROR;
}
return NO_ERROR;
}
int32_t UIContentServiceProxy::RegisterRemoteObject(sptr<IRemoteObject> remoteObject)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOGW("RegisterRemoteObject write interface token failed");
return FAILED;
}
if (!data.WriteRemoteObject(remoteObject)) {
LOGW("RegisterRemoteObject write remoteObject failed");
return FAILED;
}
if (Remote()->SendRequest(UI_CONTENT_SERVICE_REGISTER, data, reply, option) != ERR_NONE) {
LOGW("RegisterRemoteObject send request failed");
return REPLY_ERROR;
}
return NO_ERROR;
}
} // namespace OHOS::Ace

View File

@ -0,0 +1,47 @@
/*
* 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 "interfaces/inner_api/ui_session/ui_content_stub.h"
#include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
namespace OHOS::Ace {
int32_t UiContentStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
{
if (data.ReadInterfaceToken() != GetDescriptor()) {
LOGW("ui_session InterfaceToken check failed");
return -1;
}
switch (code) {
case UI_CONTENT_SERVICE_GET_TREE: {
OnGetInspectorTreeInner(data, reply, option);
break;
}
case UI_CONTENT_SERVICE_REPORT_EVENT: {
OnReportUnfocusEventInner(data, reply, option);
break;
}
case UI_CONTENT_SERVICE_REGISTER: {
OnReportUnfocusEventInner(data, reply, option);
break;
}
default: {
LOGI("ui_session unknown transaction code %{public}d", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
}
return 0;
}
} // namespace OHOS::Ace

View File

@ -0,0 +1,45 @@
/*
* 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 "interfaces/inner_api/ui_session/ui_content_stub_impl.h"
#include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
namespace OHOS::Ace {
int32_t UIContentServiceStubImpl::OnGetInspectorTreeInner(
MessageParcel& data, MessageParcel& reply, MessageOption& option)
{
return NO_ERROR;
}
int32_t UIContentServiceStubImpl::OnReportUnfocusEventInner(
MessageParcel& data, MessageParcel& reply, MessageOption& option)
{
return NO_ERROR;
}
int32_t UIContentServiceStubImpl::RegisterRemoteObjectInner(
MessageParcel& data, MessageParcel& reply, MessageOption& option)
{
sptr<IRemoteObject> SAObject = data.ReadRemoteObject();
if (SAObject == nullptr) {
LOGW("RemoteObject is null,register remote object failed");
return FAILED;
}
SAObject_ = SAObject;
return NO_ERROR;
}
} // namespace OHOS::Ace

View File

@ -15,6 +15,7 @@ group("innerkits_target") {
deps = [
"form_render:ace_form_render",
"ui_service_manager:ui_service_mgr",
"ui_session:ui_session",
"xcomponent_controller:ace_xcomponent_controller",
]
}

View File

@ -32,7 +32,6 @@
#include "serializeable_object.h"
#include "viewport_config.h"
#include "constants.h"
namespace OHOS {
namespace AbilityRuntime {
@ -192,7 +191,6 @@ public:
virtual void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) {};
virtual void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& callback) {};
// for distribute UI source
virtual SerializeableObjectArray DumpUITree()
{
@ -404,6 +402,11 @@ public:
const std::function<void(std::vector<Ace::RectF>)>& callback) const {};
virtual void SetContentNodeGrayScale(float grayscale) {};
virtual sptr<IRemoteObject> GetRemoteObj()
{
return {};
}
};
} // namespace OHOS::Ace

View File

@ -0,0 +1,58 @@
# 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.
import("//build/ohos.gni")
import("//foundation/arkui/ace_engine/ace_config.gni")
config("uisession_manager_public_config") {
visibility = [ ":*" ]
include_dirs = [
"$ace_root/frameworks",
"include/",
]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
}
ohos_shared_library("ui_session") {
if (current_os == "ohos") {
sanitize = {
integer_overflow = true
boundary_sanitize = true
debug = ace_sanitize_debug
}
}
sources = [
"$ace_root/adapter/ohos/entrance/ui_session/ui_content_proxy.cpp",
"$ace_root/adapter/ohos/entrance/ui_session/ui_content_stub.cpp",
"$ace_root/adapter/ohos/entrance/ui_session/ui_content_stub_impl.cpp",
]
configs = [ "$ace_root:ace_config" ]
public_configs = [ ":uisession_manager_public_config" ]
external_deps = [
"ability_base:want",
"c_utils:utils",
"hilog:libhilog",
"ipc:ipc_core",
"samgr:samgr_proxy",
]
subsystem_name = ace_engine_subsystem
innerapi_tags = [ "platformsdk_indirect" ]
part_name = ace_engine_part
}

View File

@ -0,0 +1,24 @@
/*
* 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_INTERFACE_UI_CONTENT_ERRORS_H
#define FOUNDATION_ACE_INTERFACE_UI_CONTENT_ERRORS_H
#include "errors.h"
namespace OHOS::Ace {
enum ErrorCode { NO_ERROR = NO_ERROR, NOT_CONNECTED, FAILED, REPLY_ERROR };
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_ERRORS_H

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
#define FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
#include "iremote_proxy.h"
#include "ui_content_errors.h"
#include "ui_content_service_interface.h"
namespace OHOS::Ace {
class UIContentServiceProxy : public IRemoteProxy<IUiContentService> {
public:
explicit UIContentServiceProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IUiContentService>(impl) {};
virtual int32_t OnGetInspectorTree() override;
virtual int32_t OnReportUnfocusEvent() override;
virtual int32_t RegisterRemoteObject(sptr<IRemoteObject> remoteObject) override;
private:
static inline BrokerDelegator<UIContentServiceProxy> delegator_;
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_INTERFACE_UI_CONTENT_SERVICE_INTERFACE_H
#define FOUNDATION_ACE_INTERFACE_UI_CONTENT_SERVICE_INTERFACE_H
#include <iremote_broker.h>
#include "base/utils/macros.h"
namespace OHOS::Ace {
class ACE_FORCE_EXPORT IUiContentService : public OHOS::IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ace.UIContentService");
IUiContentService() = default;
~IUiContentService() override = default;
enum {
UI_CONTENT_SERVICE_GET_TREE,
UI_CONTENT_SERVICE_REPORT_EVENT,
UI_CONTENT_SERVICE_REGISTER,
};
virtual int32_t OnGetInspectorTree()
{
return 0;
};
virtual int32_t OnReportUnfocusEvent()
{
return 0;
};
virtual int32_t RegisterRemoteObject(sptr<IRemoteObject> remoteObject)
{
return 0;
};
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_SERVICE_INTERFACE_H

View File

@ -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_INTERFACE_UI_CONTENT_STUB_H
#define FOUNDATION_ACE_INTERFACE_UI_CONTENT_STUB_H
#include <iremote_object.h>
#include <iremote_stub.h>
#include "ui_content_service_interface.h"
namespace OHOS::Ace {
class UiContentStub : public IRemoteStub<IUiContentService> {
public:
virtual int32_t OnRemoteRequest(
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
private:
virtual int32_t OnGetInspectorTreeInner(MessageParcel& data, MessageParcel& reply, MessageOption& option) = 0;
virtual int32_t OnReportUnfocusEventInner(MessageParcel& data, MessageParcel& reply, MessageOption& option) = 0;
virtual int32_t RegisterRemoteObjectInner(MessageParcel& data, MessageParcel& reply, MessageOption& option) = 0;
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_STUB_H

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_INTERFACE_UI_CONTENT_STUB_IMPL_H
#define FOUNDATION_ACE_INTERFACE_UI_CONTENT_STUB_IMPL_H
#include <singleton.h>
#include "iremote_object.h"
#include "ui_content_errors.h"
#include "ui_content_stub.h"
#include "base/utils/macros.h"
namespace OHOS::Ace {
class ACE_FORCE_EXPORT UIContentServiceStubImpl : public UiContentStub {
private:
int32_t OnGetInspectorTreeInner(MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
int32_t OnReportUnfocusEventInner(MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
int32_t RegisterRemoteObjectInner(MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
sptr<IRemoteObject> SAObject_ = nullptr;
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_STUB_IMPL_H