diff --git a/ArkUIKit/AccessibilityCapi/.gitignore b/ArkUIKit/AccessibilityCapi/.gitignore
deleted file mode 100644
index d2ff20141ceed86d87c0ea5d99481973005bab2b..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-/node_modules
-/oh_modules
-/local.properties
-/.idea
-**/build
-/.hvigor
-.cxx
-/.clangd
-/.clang-format
-/.clang-tidy
-**/.test
-/.appanalyzer
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/element/string.json b/ArkUIKit/AccessibilityCapi/AppScope/resources/base/element/string.json
deleted file mode 100644
index 0edf05d24f2ca0e69a966f00825600f3d9474df8..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/element/string.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "StyledStringNDK"
- }
- ]
-}
diff --git a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/background.png b/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/background.png
deleted file mode 100644
index 923f2b3f27e915d6871871deea0420eb45ce102f..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/background.png and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/foreground.png b/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/foreground.png
deleted file mode 100644
index 97014d3e10e5ff511409c378cd4255713aecd85f..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/foreground.png and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/layered_image.json b/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/layered_image.json
deleted file mode 100644
index fb49920440fb4d246c82f9ada275e26123a2136a..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/AppScope/resources/base/media/layered_image.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "layered-image":
- {
- "background" : "$media:background",
- "foreground" : "$media:foreground"
- }
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/README.md b/ArkUIKit/AccessibilityCapi/README.md
deleted file mode 100644
index 96e5cf4108c03ff1b73e68b338ad8aba83b9d0c8..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/README.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# AccessibilityCapi
-
-## 介绍
-
-本示例通过使用[ArkUI指南文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui)中各场景的开发示例,展示在工程中,帮助开发者更好地理解ArkUI提供的组件及组件属性并合理使用。该工程中展示的代码详细描述可查如下链接:
-
-1. [native_node.h](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/capi-native-node-h.md)。
-
-2. [native_type.h](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/capi-native-type-h.md)。
-
-## 效果预览
-
-| 预览 |
-| -------------------------------------------- |
-
-
-## 使用说明
-1. 安装编译生成的hap包,并打开应用;
-2. 查看创建好的嵌入式组件,文本以及相应的无障碍属性;
-
-
-## 工程目录
-
-```
-AccessibilityCapi
-entry/src/main/ets/
-└── pages
- └── Index.ets (获取EmbeddedComponent组件和设置无障碍属性后的文本界面)
-entry/src/main/
-├── cpp
-│ ├── types
-│ │ └── libentry
-│ │ └── Index.d.ts (NDK函数对应的js映射)
-│ ├── CMakeLists.txt (CMake脚本)
-| ├── manager.cpp (创建文本实现CPP文件)
-| ├── manager.h
-│ └── napi_init.cpp (NDK函数)
-└── resources
- ├── base
- │ ├── element
- │ │ ├── color.json
- │ │ ├── float.json
- │ │ └── string.json
- │ └── media
-```
-
-## 相关权限
-
-不涉及
-
-## 依赖
-
-不涉及
-
-## 约束和限制
-
-1. 本示例支持标准系统上运行,支持设备:RK3568,Phone;
-
-2. 本示例支持API20版本SDK,版本号:6.0.0.49;
-
-3. 本示例需要使用DevEco Studio 5.1.1 Release(5.1.1.840)及以上版本才可编译运行。
-
-## 下载
-
-如需单独下载本工程,执行如下命令:
-
-```
-git init
-git config core.sparsecheckout true
-echo code/DocsSample/ArkUISample/AccessibilityCapi > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/build-profile.json5 b/ArkUIKit/AccessibilityCapi/build-profile.json5
deleted file mode 100644
index d4af2c1202415e3d1f77869225eaf8530f5cd138..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/build-profile.json5
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "app": {
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- "compileSdkVersion": 20,
- "targetSdkVersion": 20,
- "compatibleSdkVersion": 20,
- "runtimeOS": "OpenHarmony",
- "buildOption": {
- "strictMode": {
- "caseSensitiveCheck": true,
- "useNormalizedOHMUrl": true
- }
- }
- }
- ],
- "buildModeSet": [
- {
- "name": "debug"
- },
- {
- "name": "release"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/code-linter.json5 b/ArkUIKit/AccessibilityCapi/code-linter.json5
deleted file mode 100644
index 5c4682f8164874ec7e9cb8f99ff8b3228ffbc126..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/code-linter.json5
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "files": [
- "**/*.ets"
- ],
- "ignore": [
- "**/src/ohosTest/**/*",
- "**/src/test/**/*",
- "**/src/mock/**/*",
- "**/node_modules/**/*",
- "**/oh_modules/**/*",
- "**/build/**/*",
- "**/.preview/**/*"
- ],
- "ruleSet": [
- "plugin:@performance/recommended",
- "plugin:@typescript-eslint/recommended"
- ],
- "rules": {
- "@security/no-unsafe-aes": "error",
- "@security/no-unsafe-hash": "error",
- "@security/no-unsafe-mac": "warn",
- "@security/no-unsafe-dh": "error",
- "@security/no-unsafe-dsa": "error",
- "@security/no-unsafe-ecdsa": "error",
- "@security/no-unsafe-rsa-encrypt": "error",
- "@security/no-unsafe-rsa-sign": "error",
- "@security/no-unsafe-rsa-key": "error",
- "@security/no-unsafe-dsa-key": "error",
- "@security/no-unsafe-dh-key": "error",
- "@security/no-unsafe-3des": "error"
- }
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/.gitignore b/ArkUIKit/AccessibilityCapi/entry/.gitignore
deleted file mode 100644
index e2713a2779c5a3e0eb879efe6115455592caeea5..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-/node_modules
-/oh_modules
-/.preview
-/build
-/.cxx
-/.test
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/build-profile.json5 b/ArkUIKit/AccessibilityCapi/entry/build-profile.json5
deleted file mode 100644
index 685cf6eba0d6b16c8e9770781d9097cee9198c86..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/build-profile.json5
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "apiType": "stageMode",
- "buildOption": {
- "externalNativeOptions": {
- "path": "./src/main/cpp/CMakeLists.txt",
- "arguments": "",
- "cppFlags": "",
- "abiFilters": [
- "armeabi-v7a",
- "arm64-v8a",
- "x86_64"
- ]
- }
- },
- "buildOptionSet": [
- {
- "name": "release",
- "arkOptions": {
- "obfuscation": {
- "ruleOptions": {
- "enable": false,
- "files": [
- "./obfuscation-rules.txt"
- ]
- }
- }
- },
- "nativeLib": {
- "debugSymbol": {
- "strip": true,
- "exclude": []
- }
- }
- },
- ],
- "targets": [
- {
- "name": "default"
- },
- {
- "name": "ohosTest",
- }
- ]
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/hvigorfile.ts b/ArkUIKit/AccessibilityCapi/entry/hvigorfile.ts
deleted file mode 100644
index 8774588471ede4c1563f09d9a1d22f764bb1fd9e..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/hvigorfile.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
-
-export default {
- system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
- plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
-}
diff --git a/ArkUIKit/AccessibilityCapi/entry/obfuscation-rules.txt b/ArkUIKit/AccessibilityCapi/entry/obfuscation-rules.txt
deleted file mode 100644
index 272efb6ca3f240859091bbbfc7c5802d52793b0b..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/obfuscation-rules.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Define project specific obfuscation rules here.
-# You can include the obfuscation configuration files in the current module's build-profile.json5.
-#
-# For more details, see
-# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
-
-# Obfuscation options:
-# -disable-obfuscation: disable all obfuscations
-# -enable-property-obfuscation: obfuscate the property names
-# -enable-toplevel-obfuscation: obfuscate the names in the global scope
-# -compact: remove unnecessary blank spaces and all line feeds
-# -remove-log: remove all console.* statements
-# -print-namecache: print the name cache that contains the mapping from the old names to new names
-# -apply-namecache: reuse the given cache file
-
-# Keep options:
-# -keep-property-name: specifies property names that you want to keep
-# -keep-global-name: specifies names that you want to keep in the global scope
-
--enable-property-obfuscation
--enable-toplevel-obfuscation
--enable-filename-obfuscation
--enable-export-obfuscation
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/oh-package.json5 b/ArkUIKit/AccessibilityCapi/entry/oh-package.json5
deleted file mode 100644
index 5b21e253af246edab8b6ef4f10938f4417e8bc25..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/oh-package.json5
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "name": "entry",
- "version": "1.0.0",
- "description": "Please describe the basic information.",
- "main": "",
- "author": "",
- "license": "",
- "dependencies": {
- "libentry.so": "file:./src/main/cpp/types/libentry"
- }
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/CMakeLists.txt
deleted file mode 100644
index 6c7c3f44d0cf7201a8d4d9e6be3ef92aeaf1c74a..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# the minimum version of CMake.
-cmake_minimum_required(VERSION 3.5.0)
-project(CApi2)
-
-set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
-
-if(DEFINED PACKAGE_FIND_FILE)
- include(${PACKAGE_FIND_FILE})
-endif()
-
-include_directories(${NATIVERENDER_ROOT_PATH}
- ${NATIVERENDER_ROOT_PATH}/include)
-
-find_library(
- libace-lib
- ace_ndk.z
-)
-
-add_library(entry SHARED napi_init.cpp manager.cpp)
-target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so libability_base_want.so )
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/manager.h b/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/manager.h
deleted file mode 100644
index 945b6f6973906203a9cb1f7f13b2d45d2be524ab..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/manager.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2025 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 CAPI_MANAGER_H
-#define CAPI_MANAGER_H
-
-#include
-#include
-#include
-#include
-
-namespace NativeNode::Manager {
-using EventCallback = std::function;
-
-class NodeManager {
-public:
- ~NodeManager();
- ArkUI_NodeHandle BuildEmbeddedComponentSection(NodeManager* self, ArkUI_NativeNodeAPI_1* nodeApi);
- static NodeManager& GetInstance();
- void SetXComponent(OH_NativeXComponent* xComponent);
- void CreateNativeNode();
- ArkUI_NodeHandle BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
- ArkUI_NodeHandle BuildTextNodeWithoutAccessibilityFocus(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
- void CreateAccessibilityState();
- void SetAccessibilityDisabled(bool isDisabled);
- bool IsAccessibilityDisabled();
- void SetAccessibilitySelected(bool isSelected);
- bool IsAccessibilitySelected();
- void SetAccessibilityCheckedState(int32_t checkedState);
- int32_t GetAccessibilityCheckedState();
- void DisposeAccessibilityState();
- ArkUI_NodeHandle BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi);
-
- void CreateAccessibilityValue();
- void DisposeAccessibilityValue();
- void SetAccessibilityValueMin(int32_t min);
- int32_t GetAccessibilityValueMin();
- void SetAccessibilityValueMax(int32_t max);
- int32_t GetAccessibilityValueMax();
- void SetAccessibilityValueCurrent(int32_t current);
- int32_t GetAccessibilityValueCurrent();
- void SetAccessibilityValueText(const char* text);
- const char* GetAccessibilityValueText();
- void SetAccessibilityRangeMin(int32_t rangeMin);
- int32_t GetAccessibilityRangeMin();
- void SetAccessibilityRangeMax(int32_t rangeMax);
- int32_t GetAccessibilityRangeMax();
- void SetAccessibilityRangeCurrent(int32_t rangeCurrent);
- int32_t GetAccessibilityRangeCurrent();
-
- void CreateEmbeddedComponentOption();
- void DisposeEmbeddedComponentOption();
- void SetEmbeddedComponentOnError();
- void SetEmbeddedComponentOnTerminated();
-
- void SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* id);
- const char* GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, bool isGroup);
- bool GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, ArkUI_AccessibilityMode mode);
- ArkUI_AccessibilityMode GetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* text);
- const char* GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* description);
- const char* GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- int GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- uint32_t GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const uint32_t role);
- uint32_t GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
- void SetEmbeddedComponentWant(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
-
- void CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityValueSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityNodeIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityModeSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityTextSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityDescriptionSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateAccessibilityRoleSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
- void CreateUniqueIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
-
-private:
- NodeManager() = default;
- OH_NativeXComponent* xComponent_;
- std::unordered_map callbackMap_;
- ArkUI_AccessibilityState* accessibilityState_ = nullptr;
- ArkUI_AccessibilityValue* accessibilityValue_ = nullptr;
- ArkUI_EmbeddedComponentOption* embeddedComponentOption_ = nullptr;
-
- static void OnErrorCallback(int32_t code, const char* name, const char* message);
- static void OnTerminatedCallback(int32_t code, AbilityBase_Want* want);
-};
-}
-
-#endif //CAPI_MANAGER_H
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/napi_init.cpp
deleted file mode 100644
index 0ef82312dac42685be4726c2b45e6abcd9f3ef84..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/napi_init.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2025 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 "manager.h"
-#include
-#include
-
-static OH_NativeXComponent* GetXComponent(napi_env env, napi_value exports)
-{
- if ((env == nullptr) || (exports == nullptr)) {
- return nullptr;
- }
- napi_value exportInstance = nullptr;
- if (napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance) != napi_ok) {
- return nullptr;
- }
- OH_NativeXComponent* xComp = nullptr;
- if (napi_unwrap(env, exportInstance, reinterpret_cast(&xComp)) != napi_ok) {
- return nullptr;
- }
- return xComp;
-}
-
-static napi_value createNativeNode(napi_env env, napi_callback_info info)
-{
- NativeNode::Manager::NodeManager::GetInstance().CreateNativeNode();
- return nullptr;
-}
-
-EXTERN_C_START
-static napi_value Init(napi_env env, napi_value exports)
-{
- napi_property_descriptor desc[] = {
- { "createNativeNode", nullptr, createNativeNode, nullptr, nullptr, nullptr, napi_default, nullptr }
- };
- napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
- auto xComponent = GetXComponent(env, exports);
- if (xComponent) {
- NativeNode::Manager::NodeManager::GetInstance().SetXComponent(xComponent);
- }
- return exports;
-}
-EXTERN_C_END
-
-static napi_module demoModule = {
- .nm_version = 1,
- .nm_flags = 0,
- .nm_filename = nullptr,
- .nm_register_func = Init,
- .nm_modname = "entry",
- .nm_priv = ((void*)0),
- .reserved = { 0 },
-};
-
-extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
-{
- napi_module_register(&demoModule);
-}
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/types/libentry/Index.d.ts
deleted file mode 100644
index c09127fac743a5190aedf27d6e07056b20076bbd..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/types/libentry/Index.d.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-export const createNativeNode: () => void;
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/types/libentry/oh-package.json5 b/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/types/libentry/oh-package.json5
deleted file mode 100644
index 77052c679533e45a066030a9fc21cdbf9cbcf995..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/types/libentry/oh-package.json5
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "name": "libentry.so",
- "types": "./Index.d.ts",
- "version": "1.0.0",
- "description": "Please describe the basic information."
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/AccessibilityCapi/entry/src/main/ets/entryability/EntryAbility.ets
deleted file mode 100644
index 843c7f0c1f7b9a460e3dbbd2689e5b34016027d1..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/entryability/EntryAbility.ets
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2025 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { window } from '@kit.ArkUI';
-
-const DOMAIN = 0x0000;
-
-export default class EntryAbility extends UIAbility {
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
- }
-
- onDestroy(): void {
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage): void {
- // Main window is created, set main page for this ability
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err) => {
- if (err.code) {
- hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
- return;
- }
- hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
- });
- }
-
- onWindowStageDestroy(): void {
- // Main window is destroyed, release UI related resources
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground(): void {
- // Ability has brought to foreground
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
- }
-
- onBackground(): void {
- // Ability has back to background
- hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
- }
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/module.json5 b/ArkUIKit/AccessibilityCapi/entry/src/main/module.json5
deleted file mode 100644
index 08e8592585e8ab3f0c01368a3bd6844f0953652a..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/module.json5
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "module": {
- "name": "entry",
- "type": "entry",
- "description": "$string:module_desc",
- "mainElement": "EntryAbility",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:main_pages",
- "abilities": [
- {
- "name": "EntryAbility",
- "srcEntry": "./ets/entryability/EntryAbility.ets",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:layered_image",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:startIcon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- }
- ],
- "extensionAbilities": [
- {
- "name": "EntryBackupAbility",
- "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
- "type": "backup",
- "exported": false,
- "metadata": [
- {
- "name": "ohos.extension.backup",
- "resource": "$profile:backup_config"
- }
- ]
- },
- {
- "name": "SampleEmbeddedAbility",
- "srcEntry": "./ets/extensionAbility/SampleEmbeddedAbility.ets",
- "type": "embeddedUI"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/color.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/color.json
deleted file mode 100644
index 3c712962da3c2751c2b9ddb53559afcbd2b54a02..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/color.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- }
- ]
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/float.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/float.json
deleted file mode 100644
index 33ea22304f9b1485b5f22d811023701b5d4e35b6..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/float.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "float": [
- {
- "name": "page_text_font_size",
- "value": "50fp"
- }
- ]
-}
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/string.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/string.json
deleted file mode 100644
index 962ad62902d4b2b36e7111991d139c4f9f0a3574..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/element/string.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "StyledStringNDK"
- }
- ]
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/background.png b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/background.png
deleted file mode 100644
index 923f2b3f27e915d6871871deea0420eb45ce102f..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/background.png and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/foreground.png
deleted file mode 100644
index 97014d3e10e5ff511409c378cd4255713aecd85f..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/foreground.png and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/layered_image.json
deleted file mode 100644
index fb49920440fb4d246c82f9ada275e26123a2136a..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/layered_image.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "layered-image":
- {
- "background" : "$media:background",
- "foreground" : "$media:foreground"
- }
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/startIcon.png
deleted file mode 100644
index 205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/media/startIcon.png and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/profile/backup_config.json
deleted file mode 100644
index 78f40ae7c494d71e2482278f359ec790ca73471a..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/profile/backup_config.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "allowToBackupRestore": true
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/profile/main_pages.json
deleted file mode 100644
index 1898d94f58d6128ab712be2c68acc7c98e9ab9ce..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/base/profile/main_pages.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "src": [
- "pages/Index"
- ]
-}
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/dark/element/color.json b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/dark/element/color.json
deleted file mode 100644
index 79b11c2747aec33e710fd3a7b2b3c94dd9965499..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/dark/element/color.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#000000"
- }
- ]
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/rawfile/startIcon.png b/ArkUIKit/AccessibilityCapi/entry/src/main/resources/rawfile/startIcon.png
deleted file mode 100644
index 205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/entry/src/main/resources/rawfile/startIcon.png and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/ets/test/Ability.test.ets
deleted file mode 100644
index 7f30942b81554a399e89aa253c7089eca4f8d8d1..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/ets/test/Ability.test.ets
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2025 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 { hilog } from '@kit.PerformanceAnalysisKit';
-import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
-
-export default function abilityTest() {
- describe('ActsAbilityTest', () => {
- // Defines a test suite. Two parameters are supported: test suite name and test suite function.
- beforeAll(() => {
- // Presets an action, which is performed only once before all test cases of the test suite start.
- // This API supports only one parameter: preset action function.
- })
- beforeEach(() => {
- // Presets an action, which is performed before each unit test case starts.
- // The number of execution times is the same as the number of test cases defined by **it**.
- // This API supports only one parameter: preset action function.
- })
- afterEach(() => {
- // Presets a clear action, which is performed after each unit test case ends.
- // The number of execution times is the same as the number of test cases defined by **it**.
- // This API supports only one parameter: clear action function.
- })
- afterAll(() => {
- // Presets a clear action, which is performed after all test cases of the test suite end.
- // This API supports only one parameter: clear action function.
- })
- it('assertContain', 0, () => {
- // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
- hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
- let a = 'abc';
- let b = 'b';
- // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
- expect(a).assertContain(b);
- expect(a).assertEqual(a);
- })
- })
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/ets/test/List.test.ets
deleted file mode 100644
index c64e0b06938d246ce044186d4b2d02b500a89e14..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/ets/test/List.test.ets
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2025 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 abilityTest from './Ability.test';
-
-export default function testsuite() {
- abilityTest();
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/test/List.test.ets b/ArkUIKit/AccessibilityCapi/entry/src/test/List.test.ets
deleted file mode 100644
index a60c87c5cbb0badf7c3fd8975034590e6fafa992..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/test/List.test.ets
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2025 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 localUnitTest from './LocalUnit.test';
-
-export default function testsuite() {
- localUnitTest();
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/test/LocalUnit.test.ets b/ArkUIKit/AccessibilityCapi/entry/src/test/LocalUnit.test.ets
deleted file mode 100644
index 841bfd77e56060e50ec0924302a5ae624e76e3aa..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/entry/src/test/LocalUnit.test.ets
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2025 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
-
-export default function localUnitTest() {
- describe('localUnitTest', () => {
- // Defines a test suite. Two parameters are supported: test suite name and test suite function.
- beforeAll(() => {
- // Presets an action, which is performed only once before all test cases of the test suite start.
- // This API supports only one parameter: preset action function.
- });
- beforeEach(() => {
- // Presets an action, which is performed before each unit test case starts.
- // The number of execution times is the same as the number of test cases defined by **it**.
- // This API supports only one parameter: preset action function.
- });
- afterEach(() => {
- // Presets a clear action, which is performed after each unit test case ends.
- // The number of execution times is the same as the number of test cases defined by **it**.
- // This API supports only one parameter: clear action function.
- });
- afterAll(() => {
- // Presets a clear action, which is performed after all test cases of the test suite end.
- // This API supports only one parameter: clear action function.
- });
- it('assertContain', 0, () => {
- // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
- let a = 'abc';
- let b = 'b';
- // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
- expect(a).assertContain(b);
- expect(a).assertEqual(a);
- });
- });
-}
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/hvigor/hvigor-config.json5 b/ArkUIKit/AccessibilityCapi/hvigor/hvigor-config.json5
deleted file mode 100644
index 4d435603637cbbfe92ac9865537a0c1051810bb1..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/hvigor/hvigor-config.json5
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "modelVersion": "5.0.5",
- "dependencies": {
- },
- "execution": {
- // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */
- // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
- // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
- // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
- // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
- },
- "logging": {
- // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
- },
- "debugging": {
- // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
- },
- "nodeOptions": {
- // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
- // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
- }
-}
diff --git a/ArkUIKit/AccessibilityCapi/hvigorfile.ts b/ArkUIKit/AccessibilityCapi/hvigorfile.ts
deleted file mode 100644
index 6b365cacd0191d3b1178eb6b9807b1ae0add6271..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/hvigorfile.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
-
-export default {
- system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
- plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
-}
diff --git a/ArkUIKit/AccessibilityCapi/ohosTest.md b/ArkUIKit/AccessibilityCapi/ohosTest.md
deleted file mode 100644
index 9959c3755cd2fa1ff8d02f85ed0191c8fd268404..0000000000000000000000000000000000000000
--- a/ArkUIKit/AccessibilityCapi/ohosTest.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# AccessibilityCapi测试用例归档
-
-## 用例表
-
-| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
-| ------------------------ | ------------ | -------------------- | ------------------------ | -------- | -------- |
-| 拉起应用 | 设备正常运行 | 进入应用首页 | 成功拉起应用 | 是 | Pass |
-| EmbeddedComponent OnErrorCallback回调成功 | 设备正常运行 | hdc shell param set persist.sys.abilityms.multi_process_model false | EmbeddedComponent onError回调被触发,打印日志{OnErrorCallback: code=100018, name=start_ability_fail, message=Start ui extension ability failed, please check the want of UIextensionAbility.} | 是 | Pass |
-| EmbeddedComponent OnTerminatedCallback回调成功 | 设备正常运行 | hdc shell param set persist.sys.abilityms.multi_process_model true | EmbeddedComponent onError回调被触发,打印日志{OnTerminatedCallback: code=0} | 是 | Pass |
-| 文本无障碍属性设置 | 设备正常运行 | 进入应用首页 | 观测Get日志设置属性值与Set函数一致 | 是 | Pass |
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/screenshots/accessibility.jpeg b/ArkUIKit/AccessibilityCapi/screenshots/accessibility.jpeg
deleted file mode 100644
index 1dc3d8240395007aa2ba2d94a3ef022342588493..0000000000000000000000000000000000000000
Binary files a/ArkUIKit/AccessibilityCapi/screenshots/accessibility.jpeg and /dev/null differ
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/manager.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/AccessibilityMaker.cpp
similarity index 60%
rename from ArkUIKit/AccessibilityCapi/entry/src/main/cpp/manager.cpp
rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/AccessibilityMaker.cpp
index ef5de60af2601b44af2a5e83301d8cdf4c5e9bdd..99c94a69ca54d79d580debb8231eb399a605977e 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/cpp/manager.cpp
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/AccessibilityMaker.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "manager.h"
+
#include
#include
#include
#include
+#include "AccessibilityMaker.h"
-namespace NativeNode::Manager {
constexpr int32_t ACCESSIBILITY_VALUE_MIN = 0;
constexpr int32_t ACCESSIBILITY_VALUE_MAX = 100;
constexpr int32_t ACCESSIBILITY_VALUE_CURRENT = 50;
@@ -26,23 +26,19 @@ constexpr const char* ACCESSIBILITY_VALUE_TEXT = "Value";
constexpr int32_t ACCESSIBILITY_RANGE_MIN = 0;
constexpr int32_t ACCESSIBILITY_RANGE_MAX = 10;
constexpr int32_t ACCESSIBILITY_RANGE_CURRENT = 5;
-const unsigned int LOG_PRINT_DOMAIN = 0xFF00;
constexpr float COL_WIDTH_PX = 300.0f;
constexpr float TEXT_WIDTH_PX = 300.0f;
constexpr float TEXT_HEIGHT_PX = 100.0f;
constexpr float BORDER_WIDTH_PX = 1.0f;
-constexpr int WANT_STR_BUF_LEN = 10;
-constexpr int WANT_STR_COPY_LEN = 5;
-constexpr int WANT_URI_BUF_LEN = 10;
-constexpr int WANT_URI_COPY_LEN = 5;
-constexpr int EMBEDDED_COMPONENT_WIDTH = 480;
constexpr float BUTTON_WIDTH_PX = 200.0f;
constexpr float BUTTON_HEIGHT_PX = 50.0f;
constexpr float BUTTON_MARGIN_PX = 5.0f;
constexpr int EVENT_ID = 11111;
constexpr const char* SAMPLE_TEXT = "Hello Accessibility Sample";
+static ArkUI_AccessibilityState* accessibilityState_;
+static ArkUI_AccessibilityValue* accessibilityValue_;
-void NodeManager::CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"1. 通过 OH_ArkUI_AccessibilityState_SetSelected 设置无障碍状态:");
@@ -50,26 +46,26 @@ void NodeManager::CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* node
ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "Hello Accessibility Sample(non-selected)");
ArkUI_NodeHandle text3 = BuildTextNode(nodeApi, "Hello Accessibility Sample(selected)");
- this->CreateAccessibilityState();
- this->SetAccessibilityDisabled(false);
- bool disabled = this->IsAccessibilityDisabled();
+ CreateAccessibilityState();
+ SetAccessibilityDisabled(false);
+ bool disabled = IsAccessibilityDisabled();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "IsAccessibilityDisabled: disabled=%{public}d",
disabled);
- this->SetAccessibilitySelected(true);
- bool selected = this->IsAccessibilitySelected();
+ SetAccessibilitySelected(true);
+ bool selected = IsAccessibilitySelected();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "IsAccessibilitySelected: selected=%{public}d",
selected);
- ArkUI_AttributeItem accessibilityItem = { .object = this->accessibilityState_ };
+ ArkUI_AttributeItem accessibilityItem = { .object = accessibilityState_ };
nodeApi->setAttribute(text3, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
- this->SetAccessibilitySelected(false);
- accessibilityItem = { .object = this->accessibilityState_ };
+ SetAccessibilitySelected(false);
+ accessibilityItem = { .object = accessibilityState_ };
nodeApi->setAttribute(text2, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
nodeApi->addChild(column, text2);
nodeApi->addChild(column, text3);
nodeApi->addChild(parent, column);
}
-void NodeManager::CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"2. 通过 OH_ArkUI_AccessibilityState_SetCheckedState 设置无障碍状态:");
@@ -77,82 +73,82 @@ void NodeManager::CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeA
ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
ArkUI_NodeHandle checkbox = nodeApi->createNode(ARKUI_NODE_CHECKBOX);
ArkUI_NodeHandle checkbox2 = nodeApi->createNode(ARKUI_NODE_CHECKBOX);
- this->CreateAccessibilityState();
- this->SetAccessibilityDisabled(false);
- bool disabled = this->IsAccessibilityDisabled();
+ CreateAccessibilityState();
+ SetAccessibilityDisabled(false);
+ bool disabled = IsAccessibilityDisabled();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "IsAccessibilityDisabled: disabled=%{public}d",
disabled);
- this->SetAccessibilityCheckedState(ARKUI_ACCESSIBILITY_UNCHECKED);
- int32_t checkedState = this->GetAccessibilityCheckedState();
+ SetAccessibilityCheckedState(ARKUI_ACCESSIBILITY_UNCHECKED);
+ int32_t checkedState = GetAccessibilityCheckedState();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityCheckedState: state=%{public}d",
checkedState);
- ArkUI_AttributeItem accessibilityItem = { .object = this->accessibilityState_ };
+ ArkUI_AttributeItem accessibilityItem = { .object = accessibilityState_ };
nodeApi->setAttribute(parent, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
- this->SetAccessibilityCheckedState(ARKUI_ACCESSIBILITY_CHECKED);
- accessibilityItem = { .object = this->accessibilityState_ };
+ SetAccessibilityCheckedState(ARKUI_ACCESSIBILITY_CHECKED);
+ accessibilityItem = { .object = accessibilityState_ };
nodeApi->setAttribute(checkbox2, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
nodeApi->addChild(column, checkbox);
nodeApi->addChild(column, checkbox2);
nodeApi->addChild(parent, column);
}
-void NodeManager::CreateAccessibilityValueSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityValueSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"3. 通过 NODE_ACCESSIBILITY_VALUE 设置无障碍信息属性:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- this->CreateAccessibilityValue();
- this->SetAccessibilityValueMin(ACCESSIBILITY_VALUE_MIN);
- int32_t valueMin = this->GetAccessibilityValueMin();
+ CreateAccessibilityValue();
+ SetAccessibilityValueMin(ACCESSIBILITY_VALUE_MIN);
+ int32_t valueMin = GetAccessibilityValueMin();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueMin: min=%{public}d", valueMin);
- this->SetAccessibilityValueMax(ACCESSIBILITY_VALUE_MAX);
- int32_t valueMax = this->GetAccessibilityValueMax();
+ SetAccessibilityValueMax(ACCESSIBILITY_VALUE_MAX);
+ int32_t valueMax = GetAccessibilityValueMax();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueMax: max=%{public}d", valueMax);
- this->SetAccessibilityValueCurrent(ACCESSIBILITY_VALUE_CURRENT);
- int32_t valueCurrent = this->GetAccessibilityValueCurrent();
+ SetAccessibilityValueCurrent(ACCESSIBILITY_VALUE_CURRENT);
+ int32_t valueCurrent = GetAccessibilityValueCurrent();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueCurrent: current=%{public}d",
valueCurrent);
- this->SetAccessibilityValueText(ACCESSIBILITY_VALUE_TEXT);
- const char* valueText = this->GetAccessibilityValueText();
+ SetAccessibilityValueText(ACCESSIBILITY_VALUE_TEXT);
+ const char* valueText = GetAccessibilityValueText();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueText: text=%{public}s",
valueText);
- this->SetAccessibilityRangeMin(ACCESSIBILITY_RANGE_MIN);
- int32_t rangeMin = this->GetAccessibilityRangeMin();
+ SetAccessibilityRangeMin(ACCESSIBILITY_RANGE_MIN);
+ int32_t rangeMin = GetAccessibilityRangeMin();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRangeMin: min=%{public}d", rangeMin);
- this->SetAccessibilityRangeMax(ACCESSIBILITY_RANGE_MAX);
- int32_t rangeMax = this->GetAccessibilityValueMax();
- rangeMax = this->GetAccessibilityRangeMax();
+ SetAccessibilityRangeMax(ACCESSIBILITY_RANGE_MAX);
+ int32_t rangeMax = GetAccessibilityValueMax();
+ rangeMax = GetAccessibilityRangeMax();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRangeMax: max=%{public}d", rangeMax);
- this->SetAccessibilityRangeCurrent(ACCESSIBILITY_RANGE_CURRENT);
- int32_t rangeCurrent = this->GetAccessibilityRangeCurrent();
+ SetAccessibilityRangeCurrent(ACCESSIBILITY_RANGE_CURRENT);
+ int32_t rangeCurrent = GetAccessibilityRangeCurrent();
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRangeCurrent: current=%{public}d",
rangeCurrent);
- ArkUI_AttributeItem accessibilityValueItem = { .object = this->accessibilityValue_ };
+ ArkUI_AttributeItem accessibilityValueItem = { .object = accessibilityValue_ };
nodeApi->setAttribute(text2, NODE_ACCESSIBILITY_VALUE, &accessibilityValueItem);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateAccessibilityNodeIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityNodeIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi, "4. 通过 NODE_ID 获取无障碍节点ID:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- this->SetNodeId(nodeApi, text2, "test node id");
- const char* nodeId = this->GetNodeId(nodeApi, text2);
+ SetNodeId(nodeApi, text2, "test node id");
+ const char* nodeId = GetNodeId(nodeApi, text2);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetNodeId: id=%{public}s", nodeId);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"5. 通过 NODE_ACCESSIBILITY_GROUP 设置无障碍分组:");
ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "column子节点1");
ArkUI_NodeHandle text3 = BuildTextNode(nodeApi, "column子节点2");
- this->SetAccessibilityGroup(nodeApi, column, true);
- bool isGroup = this->GetAccessibilityGroup(nodeApi, column);
+ SetAccessibilityGroup(nodeApi, column, true);
+ bool isGroup = GetAccessibilityGroup(nodeApi, column);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityGroup: isGroup=%{public}d", isGroup);
nodeApi->addChild(column, text2);
nodeApi->addChild(column, text3);
@@ -160,57 +156,57 @@ void NodeManager::CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi
nodeApi->addChild(parent, column);
}
-void NodeManager::CreateAccessibilityModeSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityModeSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"6. 通过 NODE_ACCESSIBILITY_MODE 设置无障碍辅助服务模式(ACCESSIBILITY_MODE):");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "Hello Accessibility Sample(DISABLED, 不可被无障碍辅助服务所识别)");
- this->SetAccessibilityMode(nodeApi, text2, ARKUI_ACCESSIBILITY_MODE_DISABLED);
- ArkUI_AccessibilityMode mode = this->GetAccessibilityMode(nodeApi, text2);
+ SetAccessibilityMode(nodeApi, text2, ARKUI_ACCESSIBILITY_MODE_DISABLED);
+ ArkUI_AccessibilityMode mode = GetAccessibilityMode(nodeApi, text2);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityMode: mode=%{public}d", mode);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateAccessibilityTextSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityTextSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"7. 通过 NODE_ACCESSIBILITY_TEXT 设置无障碍文本:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- this->SetAccessibilityText(nodeApi, text2, "This is a text");
- const char* accessibilityText = this->GetAccessibilityText(nodeApi, text2);
+ SetAccessibilityText(nodeApi, text2, "This is a text");
+ const char* accessibilityText = GetAccessibilityText(nodeApi, text2);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityText: text=%{public}s",
accessibilityText);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateAccessibilityDescriptionSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityDescriptionSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"8. 通过 NODE_ACCESSIBILITY_DESCRIPTION 设置无障碍描述:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- this->SetAccessibilityDescription(nodeApi, text2, "This is accessibility description");
- const char* description = this->GetAccessibilityDescription(nodeApi, text2);
+ SetAccessibilityDescription(nodeApi, text2, "This is accessibility description");
+ const char* description = GetAccessibilityDescription(nodeApi, text2);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityDescription: description=%{public}s",
description);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateAccessibilityIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"9. 通过 NODE_ACCESSIBILITY_ID 获取无障碍ID:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- int accessibilityId = this->GetAccessibilityId(nodeApi, text2);
+ int accessibilityId = GetAccessibilityId(nodeApi, text2);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityId: id=%{public}d", accessibilityId);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi, "10. 设置无障碍支持操作事件:");
nodeApi->addChild(parent, text1);
@@ -224,7 +220,7 @@ void NodeManager::CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeA
nodeApi->setAttribute(button, NODE_WIDTH, &button_widthItem);
nodeApi->setAttribute(button, NODE_HEIGHT, &button_heightItem);
nodeApi->setAttribute(button, NODE_MARGIN, &marginItem);
- this->SetAccessibilityActions(nodeApi, button);
+ SetAccessibilityActions(nodeApi, button);
nodeApi->registerNodeEvent(button, NODE_ON_CLICK, 0, nullptr);
nodeApi->registerNodeEvent(button, NODE_ON_ACCESSIBILITY_ACTIONS, EVENT_ID, nullptr);
nodeApi->registerNodeEventReceiver([](ArkUI_NodeEvent *event) {
@@ -244,67 +240,34 @@ void NodeManager::CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeA
nodeApi->addChild(parent, button);
}
-void NodeManager::CreateAccessibilityRoleSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateAccessibilityRoleSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"11. 通过 NODE_ACCESSIBILITY_ROLE 设置无障碍组件类型:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- this->SetAccessibilityRole(nodeApi, text2, ARKUI_NODE_TEXT);
- uint32_t role = this->GetAccessibilityRole(nodeApi, text2);
+ SetAccessibilityRole(nodeApi, text2, ARKUI_NODE_TEXT);
+ uint32_t role = GetAccessibilityRole(nodeApi, text2);
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRole: role=%{public}u", role);
nodeApi->addChild(parent, text2);
}
-void NodeManager::CreateUniqueIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+void AccessibilityMaker::CreateUniqueIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
{
ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
"12. 通过 NODE_UNIQUE_ID 获取唯一ID:");
nodeApi->addChild(parent, text1);
ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
- this->GetUniqueId(nodeApi, text2);
+ GetUniqueId(nodeApi, text2);
nodeApi->addChild(parent, text2);
}
-ArkUI_NodeHandle NodeManager::BuildEmbeddedComponentSection(NodeManager* self, ArkUI_NativeNodeAPI_1* nodeApi)
-{
- // 创建嵌入式组件选项
- self->CreateEmbeddedComponentOption();
- // 设置错误回调
- self->SetEmbeddedComponentOnError();
- // 设置终止回调
- self->SetEmbeddedComponentOnTerminated();
- // 创建嵌入式组件节点
- ArkUI_NodeHandle embeddedNode = nodeApi->createNode(ARKUI_NODE_EMBEDDED_COMPONENT);
- // 设置嵌入式组件的want
- self->SetEmbeddedComponentWant(nodeApi, embeddedNode);
- // 将嵌入式组件选项设置给嵌入式组件
- ArkUI_AttributeItem embeddedComponentOptionItem = { .object = self->embeddedComponentOption_ };
- nodeApi->setAttribute(embeddedNode, NODE_EMBEDDED_COMPONENT_OPTION, &embeddedComponentOptionItem);
- ArkUI_NumberValue value[] = { EMBEDDED_COMPONENT_WIDTH };
- ArkUI_AttributeItem embeddedWidthItem = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
- nodeApi->setAttribute(embeddedNode, NODE_WIDTH, &embeddedWidthItem);
- nodeApi->setAttribute(embeddedNode, NODE_HEIGHT, &embeddedWidthItem);
- return embeddedNode;
-}
-
-NodeManager &NodeManager::GetInstance()
+ArkUI_NodeHandle AccessibilityMaker::CreateNativeNode()
{
- static NodeManager instance;
- return instance;
-}
-
-void NodeManager::SetXComponent(OH_NativeXComponent *xComponent) { xComponent_ = xComponent; }
-
-void NodeManager::CreateNativeNode()
-{
- if (!xComponent_) {
- return;
- }
ArkUI_NativeNodeAPI_1 *nodeApi = reinterpret_cast(
OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1"));
if (nodeApi == nullptr) {
- return;
+ return nullptr;
}
// 创建一个Column容器组件
ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
@@ -316,7 +279,6 @@ void NodeManager::CreateNativeNode()
CreateAccessibilitySelectedSection(nodeApi, column);
CreateAccessibilityCheckedSection(nodeApi, column);
- ArkUI_NodeHandle embeddedNode = BuildEmbeddedComponentSection(this, nodeApi);
CreateAccessibilityValueSection(nodeApi, column);
CreateAccessibilityNodeIdSection(nodeApi, column);
CreateAccessibilityGroupSection(nodeApi, column);
@@ -327,17 +289,12 @@ void NodeManager::CreateNativeNode()
CreateAccessibilityActionsSection(nodeApi, column);
CreateAccessibilityRoleSection(nodeApi, column);
CreateUniqueIdSection(nodeApi, column);
- ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "嵌入式组件:");
- nodeApi->addChild(column, text2);
- nodeApi->addChild(column, embeddedNode);
- // 将嵌入式组件添加到列容器
- nodeApi->addChild(column, embeddedNode);
// Column作为XComponent子组件
- OH_NativeXComponent_AttachNativeRootNode(xComponent_, scrollNode);
+ return scrollNode;
}
-ArkUI_NodeHandle NodeManager::BuildTextNodeWithoutAccessibilityFocus(ArkUI_NativeNodeAPI_1* nodeApi,
+ArkUI_NodeHandle AccessibilityMaker::BuildTextNodeWithoutAccessibilityFocus(ArkUI_NativeNodeAPI_1* nodeApi,
const char* content)
{
ArkUI_NodeHandle text = nodeApi->createNode(ARKUI_NODE_TEXT);
@@ -349,10 +306,10 @@ ArkUI_NodeHandle NodeManager::BuildTextNodeWithoutAccessibilityFocus(ArkUI_Nativ
nodeApi->setAttribute(text, NODE_HEIGHT, &textHeightItem);
ArkUI_AttributeItem valueItem = {.string = content};
nodeApi->setAttribute(text, NODE_TEXT_CONTENT, &valueItem);
- this->SetAccessibilityMode(nodeApi, text, ARKUI_ACCESSIBILITY_MODE_DISABLED);
+ SetAccessibilityMode(nodeApi, text, ARKUI_ACCESSIBILITY_MODE_DISABLED);
return text;
}
-ArkUI_NodeHandle NodeManager::BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content)
+ArkUI_NodeHandle AccessibilityMaker::BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content)
{
ArkUI_NodeHandle text = nodeApi->createNode(ARKUI_NODE_TEXT);
ArkUI_NumberValue textWidth[] = {{.f32 = TEXT_WIDTH_PX}};
@@ -366,7 +323,7 @@ ArkUI_NodeHandle NodeManager::BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, cons
return text;
}
-ArkUI_NodeHandle NodeManager::BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi)
+ArkUI_NodeHandle AccessibilityMaker::BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi)
{
ArkUI_NodeHandle column = nodeApi->createNode(ARKUI_NODE_COLUMN);
ArkUI_NumberValue colWidth[] = {{.f32 = COL_WIDTH_PX}};
@@ -375,28 +332,27 @@ ArkUI_NodeHandle NodeManager::BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi)
return column;
}
-NodeManager::~NodeManager()
+AccessibilityMaker::~AccessibilityMaker()
{
DisposeAccessibilityState();
DisposeAccessibilityValue();
- DisposeEmbeddedComponentOption();
}
-void NodeManager::CreateAccessibilityState()
+void AccessibilityMaker::CreateAccessibilityState()
{
if (!accessibilityState_) {
accessibilityState_ = OH_ArkUI_AccessibilityState_Create();
}
}
-void NodeManager::SetAccessibilityDisabled(bool isDisabled)
+void AccessibilityMaker::SetAccessibilityDisabled(bool isDisabled)
{
if (accessibilityState_) {
OH_ArkUI_AccessibilityState_SetDisabled(accessibilityState_, isDisabled);
}
}
-bool NodeManager::IsAccessibilityDisabled()
+bool AccessibilityMaker::IsAccessibilityDisabled()
{
if (accessibilityState_) {
return OH_ArkUI_AccessibilityState_IsDisabled(accessibilityState_);
@@ -404,14 +360,14 @@ bool NodeManager::IsAccessibilityDisabled()
return false;
}
-void NodeManager::SetAccessibilitySelected(bool isSelected)
+void AccessibilityMaker::SetAccessibilitySelected(bool isSelected)
{
if (accessibilityState_) {
OH_ArkUI_AccessibilityState_SetSelected(accessibilityState_, isSelected);
}
}
-bool NodeManager::IsAccessibilitySelected()
+bool AccessibilityMaker::IsAccessibilitySelected()
{
if (accessibilityState_) {
return OH_ArkUI_AccessibilityState_IsSelected(accessibilityState_);
@@ -419,14 +375,14 @@ bool NodeManager::IsAccessibilitySelected()
return false;
}
-void NodeManager::SetAccessibilityCheckedState(int32_t checkedState)
+void AccessibilityMaker::SetAccessibilityCheckedState(int32_t checkedState)
{
if (accessibilityState_) {
OH_ArkUI_AccessibilityState_SetCheckedState(accessibilityState_, checkedState);
}
}
-int32_t NodeManager::GetAccessibilityCheckedState()
+int32_t AccessibilityMaker::GetAccessibilityCheckedState()
{
if (accessibilityState_) {
return OH_ArkUI_AccessibilityState_GetCheckedState(accessibilityState_);
@@ -434,7 +390,7 @@ int32_t NodeManager::GetAccessibilityCheckedState()
return 0;
}
-void NodeManager::DisposeAccessibilityState()
+void AccessibilityMaker::DisposeAccessibilityState()
{
if (accessibilityState_) {
OH_ArkUI_AccessibilityState_Dispose(accessibilityState_);
@@ -442,14 +398,14 @@ void NodeManager::DisposeAccessibilityState()
}
}
-void NodeManager::CreateAccessibilityValue()
+void AccessibilityMaker::CreateAccessibilityValue()
{
if (!accessibilityValue_) {
accessibilityValue_ = OH_ArkUI_AccessibilityValue_Create();
}
}
-void NodeManager::DisposeAccessibilityValue()
+void AccessibilityMaker::DisposeAccessibilityValue()
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_Dispose(accessibilityValue_);
@@ -457,14 +413,14 @@ void NodeManager::DisposeAccessibilityValue()
}
}
-void NodeManager::SetAccessibilityValueMin(int32_t min)
+void AccessibilityMaker::SetAccessibilityValueMin(int32_t min)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetMin(accessibilityValue_, min);
}
}
-int32_t NodeManager::GetAccessibilityValueMin()
+int32_t AccessibilityMaker::GetAccessibilityValueMin()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetMin(accessibilityValue_);
@@ -472,14 +428,14 @@ int32_t NodeManager::GetAccessibilityValueMin()
return 0;
}
-void NodeManager::SetAccessibilityValueMax(int32_t max)
+void AccessibilityMaker::SetAccessibilityValueMax(int32_t max)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetMax(accessibilityValue_, max);
}
}
-int32_t NodeManager::GetAccessibilityValueMax()
+int32_t AccessibilityMaker::GetAccessibilityValueMax()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetMax(accessibilityValue_);
@@ -487,14 +443,14 @@ int32_t NodeManager::GetAccessibilityValueMax()
return 0;
}
-void NodeManager::SetAccessibilityValueCurrent(int32_t current)
+void AccessibilityMaker::SetAccessibilityValueCurrent(int32_t current)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetCurrent(accessibilityValue_, current);
}
}
-int32_t NodeManager::GetAccessibilityValueCurrent()
+int32_t AccessibilityMaker::GetAccessibilityValueCurrent()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetCurrent(accessibilityValue_);
@@ -502,14 +458,14 @@ int32_t NodeManager::GetAccessibilityValueCurrent()
return 0;
}
-void NodeManager::SetAccessibilityValueText(const char* text)
+void AccessibilityMaker::SetAccessibilityValueText(const char* text)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetText(accessibilityValue_, text);
}
}
-const char* NodeManager::GetAccessibilityValueText()
+const char* AccessibilityMaker::GetAccessibilityValueText()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetText(accessibilityValue_);
@@ -517,14 +473,14 @@ const char* NodeManager::GetAccessibilityValueText()
return nullptr;
}
-void NodeManager::SetAccessibilityRangeMin(int32_t rangeMin)
+void AccessibilityMaker::SetAccessibilityRangeMin(int32_t rangeMin)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetRangeMin(accessibilityValue_, rangeMin);
}
}
-int32_t NodeManager::GetAccessibilityRangeMin()
+int32_t AccessibilityMaker::GetAccessibilityRangeMin()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetRangeMin(accessibilityValue_);
@@ -532,14 +488,14 @@ int32_t NodeManager::GetAccessibilityRangeMin()
return 0;
}
-void NodeManager::SetAccessibilityRangeMax(int32_t rangeMax)
+void AccessibilityMaker::SetAccessibilityRangeMax(int32_t rangeMax)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetRangeMax(accessibilityValue_, rangeMax);
}
}
-int32_t NodeManager::GetAccessibilityRangeMax()
+int32_t AccessibilityMaker::GetAccessibilityRangeMax()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetRangeMax(accessibilityValue_);
@@ -547,14 +503,14 @@ int32_t NodeManager::GetAccessibilityRangeMax()
return 0;
}
-void NodeManager::SetAccessibilityRangeCurrent(int32_t rangeCurrent)
+void AccessibilityMaker::SetAccessibilityRangeCurrent(int32_t rangeCurrent)
{
if (accessibilityValue_) {
OH_ArkUI_AccessibilityValue_SetRangeCurrent(accessibilityValue_, rangeCurrent);
}
}
-int32_t NodeManager::GetAccessibilityRangeCurrent()
+int32_t AccessibilityMaker::GetAccessibilityRangeCurrent()
{
if (accessibilityValue_) {
return OH_ArkUI_AccessibilityValue_GetRangeCurrent(accessibilityValue_);
@@ -562,75 +518,7 @@ int32_t NodeManager::GetAccessibilityRangeCurrent()
return 0;
}
-void NodeManager::OnErrorCallback(int32_t code, const char* name, const char* msg)
-{
- // 用户自定义的错误处理逻辑
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnErrorCallback:\
- code=%{public}d, name=%{public}s, message=%{public}s", code, name, msg);
-}
-
-void NodeManager::OnTerminatedCallback(int32_t code, AbilityBase_Want* want)
-{
- // 用户自定义的终止处理逻辑
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: code=%{public}d", code);
- if (want == nullptr) {
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: want is nullptr");
- return;
- }
-
- AbilityBase_Element element;
- auto error = OH_AbilityBase_GetWantElement(want, &element);
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: bundleName=%{public}s,\
- abilityName=%{public}s, moduleName=%{public}s", element.bundleName, element.abilityName, element.moduleName);
- int wantInt = 0;
- error = OH_AbilityBase_GetWantInt32Param(want, "int", &wantInt);
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantInt=%{public}d", wantInt);
- bool wantBool = false;
- error = OH_AbilityBase_GetWantBoolParam(want, "bool2", &wantBool);
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantBool=%{public}d",
- wantBool);
- char wantString[WANT_STR_BUF_LEN];
- error = OH_AbilityBase_GetWantCharParam(want, "string", wantString, WANT_STR_COPY_LEN);
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantString=%{public}s",
- wantString);
- char wantUri[WANT_URI_BUF_LEN];
- error = OH_AbilityBase_GetWantUri(want, wantUri, WANT_URI_COPY_LEN);
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantUri=%{public}s", wantUri);
- int wantFd = 0;
- error = OH_AbilityBase_GetWantFd(want, "keyFd2", &wantFd);
- OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantFd=%{public}d", wantFd);
-}
-
-void NodeManager::CreateEmbeddedComponentOption()
-{
- if (!embeddedComponentOption_) {
- embeddedComponentOption_ = OH_ArkUI_EmbeddedComponentOption_Create();
- }
-}
-
-void NodeManager::DisposeEmbeddedComponentOption()
-{
- if (embeddedComponentOption_) {
- OH_ArkUI_EmbeddedComponentOption_Dispose(embeddedComponentOption_);
- embeddedComponentOption_ = nullptr;
- }
-}
-
-void NodeManager::SetEmbeddedComponentOnError()
-{
- if (embeddedComponentOption_) {
- OH_ArkUI_EmbeddedComponentOption_SetOnError(embeddedComponentOption_, OnErrorCallback);
- }
-}
-
-void NodeManager::SetEmbeddedComponentOnTerminated()
-{
- if (embeddedComponentOption_) {
- OH_ArkUI_EmbeddedComponentOption_SetOnTerminated(embeddedComponentOption_, OnTerminatedCallback);
- }
-}
-
-void NodeManager::SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* id)
+void AccessibilityMaker::SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* id)
{
if (nodeApi && node) {
ArkUI_AttributeItem idItem = {.string = id};
@@ -638,7 +526,7 @@ void NodeManager::SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle nod
}
}
-const char* NodeManager::GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+const char* AccessibilityMaker::GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attributeItem = nodeApi->getAttribute(node, NODE_ID);
@@ -649,7 +537,7 @@ const char* NodeManager::GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHan
return nullptr;
}
-void NodeManager::SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, bool isGroup)
+void AccessibilityMaker::SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, bool isGroup)
{
if (nodeApi && node) {
ArkUI_NumberValue value[] = {{.i32 = isGroup}};
@@ -658,7 +546,7 @@ void NodeManager::SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_No
}
}
-bool NodeManager::GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+bool AccessibilityMaker::GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attributeItem = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_GROUP);
@@ -669,7 +557,7 @@ bool NodeManager::GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_No
return false;
}
-void NodeManager::SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+void AccessibilityMaker::SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
ArkUI_AccessibilityMode mode)
{
if (nodeApi && node) {
@@ -679,7 +567,7 @@ void NodeManager::SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_Nod
}
}
-ArkUI_AccessibilityMode NodeManager::GetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+ArkUI_AccessibilityMode AccessibilityMaker::GetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_MODE);
@@ -690,7 +578,7 @@ ArkUI_AccessibilityMode NodeManager::GetAccessibilityMode(ArkUI_NativeNodeAPI_1*
return ARKUI_ACCESSIBILITY_MODE_AUTO;
}
-void NodeManager::SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+void AccessibilityMaker::SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
const char* description)
{
if (nodeApi && node) {
@@ -699,7 +587,7 @@ void NodeManager::SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, Ar
}
}
-const char* NodeManager::GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+const char* AccessibilityMaker::GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_DESCRIPTION);
@@ -710,7 +598,7 @@ const char* NodeManager::GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* node
return nullptr;
}
-int NodeManager::GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+int AccessibilityMaker::GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_ID);
@@ -721,7 +609,7 @@ int NodeManager::GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHa
return -1;
}
-void NodeManager::SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* text)
+void AccessibilityMaker::SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* text)
{
if (nodeApi && node) {
ArkUI_AttributeItem item = {.string = text};
@@ -729,7 +617,7 @@ void NodeManager::SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_Nod
}
}
-const char* NodeManager::GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+const char* AccessibilityMaker::GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_TEXT);
@@ -740,7 +628,7 @@ const char* NodeManager::GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, Ar
return nullptr;
}
-void NodeManager::SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+void AccessibilityMaker::SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
ArkUI_NumberValue value[] = {{ .u32 = ARKUI_ACCESSIBILITY_ACTION_CLICK}};
@@ -749,7 +637,7 @@ void NodeManager::SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_
}
}
-uint32_t NodeManager::GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+uint32_t AccessibilityMaker::GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_ACTIONS);
@@ -760,7 +648,8 @@ uint32_t NodeManager::GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, Ar
return 0U;
}
-void NodeManager::SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const uint32_t role)
+void AccessibilityMaker::SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ const uint32_t role)
{
if (nodeApi && node) {
ArkUI_NumberValue value[] = {{ .u32 = role}};
@@ -769,7 +658,7 @@ void NodeManager::SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_Nod
}
}
-uint32_t NodeManager::GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+uint32_t AccessibilityMaker::GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_ROLE);
@@ -780,7 +669,7 @@ uint32_t NodeManager::GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI
return 0U;
}
-void NodeManager::GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+void AccessibilityMaker::GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
{
if (nodeApi && node) {
const ArkUI_AttributeItem *attributeItem = nodeApi->getAttribute(node, NODE_UNIQUE_ID);
@@ -788,20 +677,4 @@ void NodeManager::GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle n
auto id = attributeItem->value[0].i32;
OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetUniqueId: id=%{public}d", id);
}
-}
-
-void NodeManager::SetEmbeddedComponentWant(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
-{
- if (nodeApi && node) {
- // 创建一个Want对象并设置相关属性
- AbilityBase_Element element = {
- .bundleName = "com.samples.accessibilityndk",
- .abilityName = "SampleEmbeddedAbility",
- .moduleName = ""
- };
- AbilityBase_Want* want = OH_AbilityBase_CreateWant(element);
- ArkUI_AttributeItem itemObjWant = {.object = want};
- nodeApi->setAttribute(node, NODE_EMBEDDED_COMPONENT_WANT, &itemObjWant);
- }
-}
-}
+}
\ No newline at end of file
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/AccessibilityMaker.h b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/AccessibilityMaker.h
new file mode 100644
index 0000000000000000000000000000000000000000..7b92b4a8a34bb1172c7b1139c38b95b227848fbd
--- /dev/null
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/AccessibilityMaker.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2025 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 NATIVE_NODE_SAMPLE_ACCESSIBILITYMAKER_H
+#define NATIVE_NODE_SAMPLE_ACCESSIBILITYMAKER_H
+
+#include
+#include
+#include
+#include
+#include "manager.h"
+
+class AccessibilityMaker {
+public:
+ AccessibilityMaker(){};
+ ~AccessibilityMaker();
+ static ArkUI_NodeHandle CreateNativeNode();
+ static ArkUI_NodeHandle BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
+ static ArkUI_NodeHandle BuildTextNodeWithoutAccessibilityFocus(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
+ static void CreateAccessibilityState();
+ static void SetAccessibilityDisabled(bool isDisabled);
+ static bool IsAccessibilityDisabled();
+ static void SetAccessibilitySelected(bool isSelected);
+ static bool IsAccessibilitySelected();
+ static void SetAccessibilityCheckedState(int32_t checkedState);
+ static int32_t GetAccessibilityCheckedState();
+ static void DisposeAccessibilityState();
+ static ArkUI_NodeHandle BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi);
+ static void CreateAccessibilityValue();
+ static void DisposeAccessibilityValue();
+ static void SetAccessibilityValueMin(int32_t min);
+ static int32_t GetAccessibilityValueMin();
+ static void SetAccessibilityValueMax(int32_t max);
+ static int32_t GetAccessibilityValueMax();
+ static void SetAccessibilityValueCurrent(int32_t current);
+ static int32_t GetAccessibilityValueCurrent();
+ static void SetAccessibilityValueText(const char* text);
+ static const char* GetAccessibilityValueText();
+ static void SetAccessibilityRangeMin(int32_t rangeMin);
+ static int32_t GetAccessibilityRangeMin();
+ static void SetAccessibilityRangeMax(int32_t rangeMax);
+ static int32_t GetAccessibilityRangeMax();
+ static void SetAccessibilityRangeCurrent(int32_t rangeCurrent);
+ static int32_t GetAccessibilityRangeCurrent();
+ static void SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* id);
+ static const char* GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, bool isGroup);
+ static bool GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ ArkUI_AccessibilityMode mode);
+ static ArkUI_AccessibilityMode GetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* text);
+ static const char* GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ const char* description);
+ static const char* GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static int GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static uint32_t GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const uint32_t role);
+ static uint32_t GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityValueSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityNodeIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityModeSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityTextSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityDescriptionSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityRoleSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateUniqueIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void OnErrorCallback(int32_t code, const char* name, const char* message);
+ static void OnTerminatedCallback(int32_t code, AbilityBase_Want* want);
+};
+
+#endif // NATIVE_NODE_SAMPLE_ACCESSIBILITYMAKER_H
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt
index cfabe964bcea4a2ae38e03d1a079b5a2c452ddec..9719cae2db95bdee47dcd66ac3f287b2db55c2f9 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/CMakeLists.txt
@@ -7,7 +7,7 @@ set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${NATIVERENDER_ROOT_PATH}
${NATIVERENDER_ROOT_PATH}/include)
-add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp SwiperMaker.cpp TextMaker.cpp)
+add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp SwiperMaker.cpp TextMaker.cpp AccessibilityMaker.cpp EmbeddedComponentMaker.cpp)
find_library(hilog-lib hilog_ndk.z)
@@ -17,4 +17,4 @@ find_library(libnapi-lib ace_napi.z)
target_link_libraries(entry PUBLIC ${hilog-lib} ${libace-lib} ${libnapi-lib})
-target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so)
\ No newline at end of file
+target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so libability_base_want.so)
\ No newline at end of file
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/EmbeddedComponentMaker.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/EmbeddedComponentMaker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9ca27d9e301430d88cfc1c0e3062c4560fe3732
--- /dev/null
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/EmbeddedComponentMaker.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2025 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 "EmbeddedComponentMaker.h"
+#include
+#include
+#include
+#include
+
+constexpr float TEXT_WIDTH_PX = 300.0f;
+constexpr float TEXT_HEIGHT_PX = 100.0f;
+constexpr int EMBEDDED_COMPONENT_WIDTH = 480;
+constexpr int WANT_STR_BUF_LEN = 10;
+constexpr int WANT_STR_COPY_LEN = 5;
+constexpr int WANT_URI_BUF_LEN = 10;
+constexpr int WANT_URI_COPY_LEN = 5;
+constexpr float COL_WIDTH_PX = 300.0f;
+static ArkUI_EmbeddedComponentOption* embeddedComponentOption_;
+
+ArkUI_NodeHandle EmbeddedComponentMaker::CreateNativeNode()
+{
+ ArkUI_NativeNodeAPI_1 *nodeApi = reinterpret_cast(
+ OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1"));
+ if (nodeApi == nullptr) {
+ return nullptr;
+ }
+ // 创建一个Column容器组件
+ ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
+
+ // 创建一个EmbeddedComponent组件节点
+ ArkUI_NodeHandle embeddedNode = BuildEmbeddedComponentSection(nodeApi);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "嵌入式组件:");
+ nodeApi->addChild(column, text2);
+
+ // 将嵌入式组件添加到列容器
+ nodeApi->addChild(column, embeddedNode);
+ // Column作为XComponent子组件
+ return column;
+}
+
+ArkUI_NodeHandle EmbeddedComponentMaker::BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi)
+{
+ ArkUI_NodeHandle column = nodeApi->createNode(ARKUI_NODE_COLUMN);
+ ArkUI_NumberValue colWidth[] = {{.f32 = COL_WIDTH_PX}};
+ ArkUI_AttributeItem widthItem = { colWidth, sizeof(colWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(column, NODE_WIDTH, &widthItem);
+ return column;
+}
+
+ArkUI_NodeHandle EmbeddedComponentMaker::BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content)
+{
+ ArkUI_NodeHandle text = nodeApi->createNode(ARKUI_NODE_TEXT);
+ ArkUI_NumberValue textWidth[] = {{.f32 = TEXT_WIDTH_PX}};
+ ArkUI_AttributeItem textWidthItem = { textWidth, sizeof(textWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_WIDTH, &textWidthItem);
+ ArkUI_NumberValue textHeight[] = {{.f32 = TEXT_HEIGHT_PX}};
+ ArkUI_AttributeItem textHeightItem = { textHeight, sizeof(textHeight) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_HEIGHT, &textHeightItem);
+ ArkUI_AttributeItem valueItem = {.string = content};
+ nodeApi->setAttribute(text, NODE_TEXT_CONTENT, &valueItem);
+ return text;
+}
+
+EmbeddedComponentMaker::~EmbeddedComponentMaker()
+{
+ DisposeEmbeddedComponentOption();
+}
+
+ArkUI_NodeHandle EmbeddedComponentMaker::BuildEmbeddedComponentSection(ArkUI_NativeNodeAPI_1* nodeApi)
+{
+ // 创建嵌入式组件选项
+ CreateEmbeddedComponentOption();
+ // 设置错误回调
+ SetEmbeddedComponentOnError();
+ // 设置终止回调
+ SetEmbeddedComponentOnTerminated();
+ // 创建嵌入式组件节点
+ ArkUI_NodeHandle embeddedNode = nodeApi->createNode(ARKUI_NODE_EMBEDDED_COMPONENT);
+ // 设置嵌入式组件的want
+ SetEmbeddedComponentWant(nodeApi, embeddedNode);
+ // 将嵌入式组件选项设置给嵌入式组件
+ ArkUI_AttributeItem embeddedComponentOptionItem = { .object = embeddedComponentOption_ };
+ nodeApi->setAttribute(embeddedNode, NODE_EMBEDDED_COMPONENT_OPTION, &embeddedComponentOptionItem);
+ ArkUI_NumberValue value[] = { EMBEDDED_COMPONENT_WIDTH };
+ ArkUI_AttributeItem embeddedWidthItem = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(embeddedNode, NODE_WIDTH, &embeddedWidthItem);
+ nodeApi->setAttribute(embeddedNode, NODE_HEIGHT, &embeddedWidthItem);
+ return embeddedNode;
+}
+
+void EmbeddedComponentMaker::CreateEmbeddedComponentOption()
+{
+ if (!embeddedComponentOption_) {
+ embeddedComponentOption_ = OH_ArkUI_EmbeddedComponentOption_Create();
+ }
+}
+
+void EmbeddedComponentMaker::DisposeEmbeddedComponentOption()
+{
+ if (embeddedComponentOption_) {
+ OH_ArkUI_EmbeddedComponentOption_Dispose(embeddedComponentOption_);
+ embeddedComponentOption_ = nullptr;
+ }
+}
+
+void EmbeddedComponentMaker::SetEmbeddedComponentOnError()
+{
+ if (embeddedComponentOption_) {
+ OH_ArkUI_EmbeddedComponentOption_SetOnError(embeddedComponentOption_, OnErrorCallback);
+ }
+}
+
+void EmbeddedComponentMaker::SetEmbeddedComponentOnTerminated()
+{
+ if (embeddedComponentOption_) {
+ OH_ArkUI_EmbeddedComponentOption_SetOnTerminated(embeddedComponentOption_, OnTerminatedCallback);
+ }
+}
+
+void EmbeddedComponentMaker::SetEmbeddedComponentWant(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ // 创建一个Want对象并设置相关属性
+ AbilityBase_Element element = {
+ .bundleName = "com.example.native_node_napi",
+ .abilityName = "SampleEmbeddedAbility",
+ .moduleName = ""
+ };
+ AbilityBase_Want* want = OH_AbilityBase_CreateWant(element);
+ ArkUI_AttributeItem itemObjWant = {.object = want};
+ nodeApi->setAttribute(node, NODE_EMBEDDED_COMPONENT_WANT, &itemObjWant);
+ }
+}
+
+void EmbeddedComponentMaker::OnErrorCallback(int32_t code, const char* name, const char* msg)
+{
+ // 用户自定义的错误处理逻辑
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnErrorCallback:\
+ code=%{public}d, name=%{public}s, message=%{public}s", code, name, msg);
+}
+
+void EmbeddedComponentMaker::OnTerminatedCallback(int32_t code, AbilityBase_Want* want)
+{
+ // 用户自定义的终止处理逻辑
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: code=%{public}d", code);
+ if (want == nullptr) {
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: want is nullptr");
+ return;
+ }
+
+ AbilityBase_Element element;
+ auto error = OH_AbilityBase_GetWantElement(want, &element);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: bundleName=%{public}s,\
+ abilityName=%{public}s, moduleName=%{public}s", element.bundleName, element.abilityName, element.moduleName);
+ int wantInt = 0;
+ error = OH_AbilityBase_GetWantInt32Param(want, "int", &wantInt);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantInt=%{public}d", wantInt);
+ bool wantBool = false;
+ error = OH_AbilityBase_GetWantBoolParam(want, "bool2", &wantBool);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantBool=%{public}d",
+ wantBool);
+ char wantString[WANT_STR_BUF_LEN];
+ error = OH_AbilityBase_GetWantCharParam(want, "string", wantString, WANT_STR_COPY_LEN);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantString=%{public}s",
+ wantString);
+ char wantUri[WANT_URI_BUF_LEN];
+ error = OH_AbilityBase_GetWantUri(want, wantUri, WANT_URI_COPY_LEN);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantUri=%{public}s", wantUri);
+ int wantFd = 0;
+ error = OH_AbilityBase_GetWantFd(want, "keyFd2", &wantFd);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantFd=%{public}d", wantFd);
+}
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/mock/Libentry.mock.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/EmbeddedComponentMaker.h
similarity index 33%
rename from ArkUIKit/AccessibilityCapi/entry/src/mock/Libentry.mock.ets
rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/EmbeddedComponentMaker.h
index 82fa70b5693ddab96d237d2d17d943d866b61465..30602fb6fbe89d59d1fb2c82b2974bf307cdf0ef 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/mock/Libentry.mock.ets
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/EmbeddedComponentMaker.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,10 +12,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-const NativeMock: Record = {
- 'add': (a: number, b: number) => {
- return a + b;
- },
+
+#ifndef NATIVE_NODE_SAMPLE_EMBEDDED_COMPONENT_MAKER_H
+#define NATIVE_NODE_SAMPLE_EMBEDDED_COMPONENT_MAKER_H
+
+#include
+#include
+#include
+#include
+#include "manager.h"
+
+class EmbeddedComponentMaker {
+public:
+ EmbeddedComponentMaker(){};
+ ~EmbeddedComponentMaker();
+ static ArkUI_NodeHandle CreateNativeNode();
+ static ArkUI_NodeHandle BuildEmbeddedComponentSection(ArkUI_NativeNodeAPI_1* nodeApi);
+ static ArkUI_NodeHandle BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
+ static ArkUI_NodeHandle BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi);
+ static void CreateEmbeddedComponentOption();
+ static void DisposeEmbeddedComponentOption();
+ static void SetEmbeddedComponentOnError();
+ static void SetEmbeddedComponentOnTerminated();
+ static void SetEmbeddedComponentWant(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void OnErrorCallback(int32_t code, const char* name, const char* message);
+ static void OnTerminatedCallback(int32_t code, AbilityBase_Want* want);
};
-export default NativeMock;
\ No newline at end of file
+#endif // NATIVE_NODE_SAMPLE_EMBEDDED_COMPONENT_MAKER_H
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp
index ed2671a0052a95e54f365715043c1acdaf03ac38..1914f9c6f4f5ea98e487e22981ea77e3874978c8 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.cpp
@@ -16,6 +16,8 @@
#include "manager.h"
#include "TextMaker.h"
#include "SwiperMaker.h"
+#include "AccessibilityMaker.h"
+#include "EmbeddedComponentMaker.h"
#include "baseUtils.h"
#include "napi/native_api.h"
#include
@@ -87,4 +89,58 @@ napi_value Manager::CreateNativeTextNode(napi_env env, napi_callback_info info)
}
}
return nullptr;
+}
+
+napi_value Manager::CreateNativeAccessibilityNode(napi_env env, napi_callback_info info)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN");
+ if ((env == nullptr) || (info == nullptr)) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode env or info is null");
+ return nullptr;
+ }
+ size_t argCnt = ConstIde::NUMBER_1;
+ napi_value args[ConstIde::NUMBER_1] = {nullptr};
+ if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode napi_get_cb_info failed");
+ }
+
+ ArkUI_NodeContentHandle nodeContentHandle = nullptr;
+
+ OH_ArkUI_GetNodeContentFromNapiValue(env, args[ConstIde::NUMBER_0], &nodeContentHandle);
+
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after");
+ if (nodeAPI_ != nullptr) {
+ if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) {
+ ArkUI_NodeHandle testNode = AccessibilityMaker::CreateNativeNode();
+ OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode);
+ }
+ }
+ return nullptr;
+}
+
+napi_value Manager::CreateNativeEmbeddedComponentNode(napi_env env, napi_callback_info info)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN");
+ if ((env == nullptr) || (info == nullptr)) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode env or info is null");
+ return nullptr;
+ }
+ size_t argCnt = ConstIde::NUMBER_1;
+ napi_value args[ConstIde::NUMBER_1] = {nullptr};
+ if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode napi_get_cb_info failed");
+ }
+
+ ArkUI_NodeContentHandle nodeContentHandle = nullptr;
+
+ OH_ArkUI_GetNodeContentFromNapiValue(env, args[ConstIde::NUMBER_0], &nodeContentHandle);
+
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after");
+ if (nodeAPI_ != nullptr) {
+ if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) {
+ ArkUI_NodeHandle testNode = EmbeddedComponentMaker::CreateNativeNode();
+ OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode);
+ }
+ }
+ return nullptr;
}
\ No newline at end of file
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h
index c48bca62869f5cf86dbefaecaa3bb8428e7213df..2cd15649fa18a8a0e88c1f766f663edc8f312fac 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/manager.h
@@ -33,6 +33,8 @@ public:
static napi_value CreateNativeTextNode(napi_env env, napi_callback_info info);
static napi_value CreateSwiperNativeNode(napi_env env, napi_callback_info info);
+ static napi_value CreateNativeAccessibilityNode(napi_env env, napi_callback_info info);
+ static napi_value CreateNativeEmbeddedComponentNode(napi_env env, napi_callback_info info);
private:
static Manager manager_;
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp
index 137fd9a4db5b48b7cbb63891c5eb836bef0c1c86..7673f991182ad080ca52e5a348568458d4aa53be 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/napi_init.cpp
@@ -30,6 +30,10 @@ static napi_value Init(napi_env env, napi_value exports)
nullptr},
{"createSwiperNativeNode", nullptr, Manager::CreateSwiperNativeNode, nullptr, nullptr, nullptr, napi_default,
nullptr},
+ {"createNativeAccessibilityNode", nullptr, Manager::CreateNativeAccessibilityNode, nullptr, nullptr, nullptr,
+ napi_default, nullptr},
+ {"createNativeEmbeddedComponentNode", nullptr, Manager::CreateNativeEmbeddedComponentNode, nullptr, nullptr,
+ nullptr, napi_default, nullptr},
// 参考新增其他createNative方法和Maker类
};
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts
index 53b54fda223da77a64fdacddced7837880bf3a09..ebd6298cce56cce0f6b1633805ed4b4320bc7330 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/cpp/types/libentry/Index.d.ts
@@ -14,4 +14,6 @@
*/
export const createNativeTextNode: (content: Object) =>void;
-export const createSwiperNativeNode: (content: Object) =>void;
\ No newline at end of file
+export const createSwiperNativeNode: (content: Object) =>void;
+export const createNativeAccessibilityNode: (content: Object) => void;
+export const createNativeEmbeddedComponentNode: (content: Object) => void;
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
similarity index 97%
rename from ArkUIKit/AccessibilityCapi/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
index 5198683956ff5596a6c1f50c4d3753453d2ee889..e1f327c40a2d8d67f76ef0d9d3ccd6e7bbf1c247 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
@@ -1,21 +1,21 @@
-/*
- * Copyright (c) 2025 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 { EmbeddedUIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'
-
-export default class SampleEmbeddedAbility extends EmbeddedUIExtensionAbility {
- onForeground() {
- this.context.terminateSelf()
- }
+/*
+ * Copyright (c) 2025 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 { EmbeddedUIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'
+
+export default class SampleEmbeddedAbility extends EmbeddedUIExtensionAbility {
+ onForeground() {
+ this.context.terminateSelf()
+ }
}
\ No newline at end of file
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/Index.ets
index 33921092fb8eeca5536a3d5513c014df642a7254..c37dc08307d07370a2c944484c325e903e2e021a 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/Index.ets
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/Index.ets
@@ -28,6 +28,8 @@ struct MenuIndex {
{ title: 'Text', url: 'pages/page_text' },
{ title: 'Swiper', url: 'pages/page_swiper' },
{ title: 'add your router', url: '' },
+ { title: 'accessibility', url: 'pages/page_accessibility' },
+ { title: 'embedded component', url: 'pages/page_embedded_component' },
];
build() {
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_accessibility.ets
similarity index 66%
rename from ArkUIKit/AccessibilityCapi/entry/src/main/ets/pages/Index.ets
rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_accessibility.ets
index 6685060c0e52d7b99439b8b513ea1e834539f586..9368bede5d6e3160cbddc45f7bd9235d4d4efeac 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/pages/Index.ets
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_accessibility.ets
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,25 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import testNapi from 'libentry.so';
+
+import Napi from 'libentry.so';
+import { NodeContent } from '@kit.ArkUI';
@Entry
@Component
struct Index {
-
+ private nodeContent = new NodeContent();
+ aboutToAppear() {
+ // 通过C-API创建节点,并添加到管理器nodeContent上
+ Napi.createNativeAccessibilityNode(this.nodeContent);
+ }
build() {
- Row() {
- Column() {
- XComponent({
- id: 'xComponent',
- type: XComponentType.NODE,
- libraryname: 'entry'
- }).onAppear(()=> {
- testNapi.createNativeNode()
- })
- }
- .width('100%')
+ Column() {
+ ContentSlot(this.nodeContent)
}
+ .width('100%')
.height('100%')
}
}
diff --git a/ArkUIKit/AccessibilityCapi/oh-package.json5 b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_embedded_component.ets
similarity index 59%
rename from ArkUIKit/AccessibilityCapi/oh-package.json5
rename to ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_embedded_component.ets
index 38abfd099681aeb547cf83a4966111dd5f4f6d13..040bd81c11fdffac89c05193b2125d60d09e20aa 100644
--- a/ArkUIKit/AccessibilityCapi/oh-package.json5
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/ets/pages/page_embedded_component.ets
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,13 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-{
- "modelVersion": "5.0.5",
- "description": "Please describe the basic information.",
- "dependencies": {
- },
- "devDependencies": {
- "@ohos/hypium": "1.0.21",
- "@ohos/hamock": "1.0.0"
+
+import Napi from 'libentry.so';
+import { NodeContent } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ private nodeContent = new NodeContent();
+ aboutToAppear() {
+ // 通过C-API创建节点,并添加到管理器nodeContent上
+ Napi.createNativeEmbeddedComponentNode(this.nodeContent);
+ }
+ build() {
+ Column() {
+ ContentSlot(this.nodeContent)
+ }
+ .width('100%')
+ .height('100%')
}
}
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/module.json5 b/ArkUIKit/NativeNodeBaseSample/entry/src/main/module.json5
index 6ab131223385e5f7e4f94f0e284489aff17ad82d..c5be971e98a651c460b6e756939f1f5a6572f0c3 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/module.json5
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/module.json5
@@ -60,6 +60,11 @@
"resource": "$profile:backup_config"
}
]
+ },
+ {
+ "name": "SampleEmbeddedAbility",
+ "srcEntry": "./ets/extensionAbility/SampleEmbeddedAbility.ets",
+ "type": "embeddedUI"
}
]
}
diff --git a/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json
index d6193374a0ef570c249f37376c5a922f7b023047..4b3bc0ef98fd459345044a27b621d78b3efaf6a8 100644
--- a/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json
+++ b/ArkUIKit/NativeNodeBaseSample/entry/src/main/resources/base/profile/main_pages.json
@@ -2,6 +2,8 @@
"src": [
"pages/Index",
"pages/page_text",
- "pages/page_swiper"
+ "pages/page_swiper",
+ "pages/page_accessibility",
+ "pages/page_embedded_component"
]
}
diff --git a/ArkUIKit/NativeTypeSample/README.md b/ArkUIKit/NativeTypeSample/README.md
index 0b897fba9d4b4a62f1412e3056437ade6b432c47..8cf4e4e3248a4b1b2178d24b356ef5b0e163d8af 100644
--- a/ArkUIKit/NativeTypeSample/README.md
+++ b/ArkUIKit/NativeTypeSample/README.md
@@ -24,7 +24,9 @@ entry/src/main/ets/
├── Index.ets (获取导航页面)
├── page_animation.ets (动效界面)
├── page_visual_effects.ets (视效界面)
- └── page_text.ets (文本界面)
+ ├── page_text.ets (文本界面)
+ ├── page_accessibility.ets (无障碍界面)
+ └── page_embedded_component.ets (嵌入式组件界面)
entry/src/main/
├── cpp
│ ├── types
@@ -47,7 +49,11 @@ entry/src/main/
| ├── baseUtils.cpp
| ├── baseUtils.h
| ├── TextMaker.cpp
-│ └── TextMaker.h
+│ ├── TextMaker.h
+| ├── AccessibilityMaker.cpp
+│ ├── AccessibilityMaker.h
+| ├── EmbeddedComponentMaker.cpp
+│ └── EmbeddedComponentMaker.h
└── resources
├── base
│ ├── element
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/AccessibilityMaker.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/AccessibilityMaker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..82317fee19cf6bd9ee79c5f6a3f8a8e4e0d4a1f0
--- /dev/null
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/AccessibilityMaker.cpp
@@ -0,0 +1,680 @@
+/*
+ * Copyright (c) 2025 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
+#include
+#include
+#include
+#include "AccessibilityMaker.h"
+
+constexpr int32_t ACCESSIBILITY_VALUE_MIN = 0;
+constexpr int32_t ACCESSIBILITY_VALUE_MAX = 100;
+constexpr int32_t ACCESSIBILITY_VALUE_CURRENT = 50;
+constexpr int32_t ACCESSIBILITY_RANGE_MIN = 0;
+constexpr int32_t ACCESSIBILITY_RANGE_MAX = 10;
+constexpr int32_t ACCESSIBILITY_RANGE_CURRENT = 5;
+constexpr int EVENT_ID = 11111;
+constexpr float COL_WIDTH_PX = 300.0f;
+constexpr float TEXT_WIDTH_PX = 300.0f;
+constexpr float TEXT_HEIGHT_PX = 100.0f;
+constexpr float BORDER_WIDTH_PX = 1.0f;
+constexpr float BUTTON_WIDTH_PX = 200.0f;
+constexpr float BUTTON_HEIGHT_PX = 50.0f;
+constexpr float BUTTON_MARGIN_PX = 5.0f;
+constexpr const char* SAMPLE_TEXT = "Hello Accessibility Sample";
+constexpr const char* ACCESSIBILITY_VALUE_TEXT = "Value";
+static ArkUI_AccessibilityState* accessibilityState_;
+static ArkUI_AccessibilityValue* accessibilityValue_;
+
+void AccessibilityMaker::CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "1. 通过 OH_ArkUI_AccessibilityState_SetSelected 设置无障碍状态:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "Hello Accessibility Sample(non-selected)");
+ ArkUI_NodeHandle text3 = BuildTextNode(nodeApi, "Hello Accessibility Sample(selected)");
+ CreateAccessibilityState();
+ SetAccessibilityDisabled(false);
+ bool disabled = IsAccessibilityDisabled();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "IsAccessibilityDisabled: disabled=%{public}d",
+ disabled);
+ SetAccessibilitySelected(true);
+ bool selected = IsAccessibilitySelected();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "IsAccessibilitySelected: selected=%{public}d",
+ selected);
+ ArkUI_AttributeItem accessibilityItem = { .object = accessibilityState_ };
+ nodeApi->setAttribute(text3, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
+ SetAccessibilitySelected(false);
+ accessibilityItem = { .object = accessibilityState_ };
+ nodeApi->setAttribute(text2, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
+ nodeApi->addChild(column, text2);
+ nodeApi->addChild(column, text3);
+ nodeApi->addChild(parent, column);
+}
+
+void AccessibilityMaker::CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "2. 通过 OH_ArkUI_AccessibilityState_SetCheckedState 设置无障碍状态:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
+ ArkUI_NodeHandle checkbox = nodeApi->createNode(ARKUI_NODE_CHECKBOX);
+ ArkUI_NodeHandle checkbox2 = nodeApi->createNode(ARKUI_NODE_CHECKBOX);
+ CreateAccessibilityState();
+ SetAccessibilityDisabled(false);
+ bool disabled = IsAccessibilityDisabled();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "IsAccessibilityDisabled: disabled=%{public}d",
+ disabled);
+ SetAccessibilityCheckedState(ARKUI_ACCESSIBILITY_UNCHECKED);
+ int32_t checkedState = GetAccessibilityCheckedState();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityCheckedState: state=%{public}d",
+ checkedState);
+ ArkUI_AttributeItem accessibilityItem = { .object = accessibilityState_ };
+ nodeApi->setAttribute(parent, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
+ SetAccessibilityCheckedState(ARKUI_ACCESSIBILITY_CHECKED);
+ accessibilityItem = { .object = accessibilityState_ };
+ nodeApi->setAttribute(checkbox2, NODE_ACCESSIBILITY_STATE, &accessibilityItem);
+ nodeApi->addChild(column, checkbox);
+ nodeApi->addChild(column, checkbox2);
+ nodeApi->addChild(parent, column);
+}
+
+void AccessibilityMaker::CreateAccessibilityValueSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "3. 通过 NODE_ACCESSIBILITY_VALUE 设置无障碍信息属性:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ CreateAccessibilityValue();
+ SetAccessibilityValueMin(ACCESSIBILITY_VALUE_MIN);
+ int32_t valueMin = GetAccessibilityValueMin();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueMin: min=%{public}d", valueMin);
+ SetAccessibilityValueMax(ACCESSIBILITY_VALUE_MAX);
+ int32_t valueMax = GetAccessibilityValueMax();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueMax: max=%{public}d", valueMax);
+ SetAccessibilityValueCurrent(ACCESSIBILITY_VALUE_CURRENT);
+ int32_t valueCurrent = GetAccessibilityValueCurrent();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueCurrent: current=%{public}d",
+ valueCurrent);
+ SetAccessibilityValueText(ACCESSIBILITY_VALUE_TEXT);
+ const char* valueText = GetAccessibilityValueText();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityValueText: text=%{public}s",
+ valueText);
+ SetAccessibilityRangeMin(ACCESSIBILITY_RANGE_MIN);
+ int32_t rangeMin = GetAccessibilityRangeMin();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRangeMin: min=%{public}d", rangeMin);
+ SetAccessibilityRangeMax(ACCESSIBILITY_RANGE_MAX);
+ int32_t rangeMax = GetAccessibilityValueMax();
+ rangeMax = GetAccessibilityRangeMax();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRangeMax: max=%{public}d", rangeMax);
+ SetAccessibilityRangeCurrent(ACCESSIBILITY_RANGE_CURRENT);
+ int32_t rangeCurrent = GetAccessibilityRangeCurrent();
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRangeCurrent: current=%{public}d",
+ rangeCurrent);
+ ArkUI_AttributeItem accessibilityValueItem = { .object = accessibilityValue_ };
+ nodeApi->setAttribute(text2, NODE_ACCESSIBILITY_VALUE, &accessibilityValueItem);
+ nodeApi->addChild(parent, text2);
+}
+
+void AccessibilityMaker::CreateAccessibilityNodeIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi, "4. 通过 NODE_ID 获取无障碍节点ID:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ SetNodeId(nodeApi, text2, "test node id");
+ const char* nodeId = GetNodeId(nodeApi, text2);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetNodeId: id=%{public}s", nodeId);
+ nodeApi->addChild(parent, text2);
+}
+
+void AccessibilityMaker::CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "5. 通过 NODE_ACCESSIBILITY_GROUP 设置无障碍分组:");
+ ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "column子节点1");
+ ArkUI_NodeHandle text3 = BuildTextNode(nodeApi, "column子节点2");
+ SetAccessibilityGroup(nodeApi, column, true);
+ bool isGroup = GetAccessibilityGroup(nodeApi, column);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityGroup: isGroup=%{public}d", isGroup);
+ nodeApi->addChild(column, text2);
+ nodeApi->addChild(column, text3);
+ nodeApi->addChild(parent, text1);
+ nodeApi->addChild(parent, column);
+}
+
+void AccessibilityMaker::CreateAccessibilityModeSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "6. 通过 NODE_ACCESSIBILITY_MODE 设置无障碍辅助服务模式(ACCESSIBILITY_MODE):");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "Hello Accessibility Sample(DISABLED, 不可被无障碍辅助服务所识别)");
+ SetAccessibilityMode(nodeApi, text2, ARKUI_ACCESSIBILITY_MODE_DISABLED);
+ ArkUI_AccessibilityMode mode = GetAccessibilityMode(nodeApi, text2);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityMode: mode=%{public}d", mode);
+ nodeApi->addChild(parent, text2);
+}
+
+
+void AccessibilityMaker::CreateAccessibilityTextSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "7. 通过 NODE_ACCESSIBILITY_TEXT 设置无障碍文本:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ SetAccessibilityText(nodeApi, text2, "This is a text");
+ const char* accessibilityText = GetAccessibilityText(nodeApi, text2);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityText: text=%{public}s",
+ accessibilityText);
+ nodeApi->addChild(parent, text2);
+}
+
+void AccessibilityMaker::CreateAccessibilityDescriptionSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "8. 通过 NODE_ACCESSIBILITY_DESCRIPTION 设置无障碍描述:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ SetAccessibilityDescription(nodeApi, text2, "This is accessibility description");
+ const char* description = GetAccessibilityDescription(nodeApi, text2);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityDescription: description=%{public}s",
+ description);
+ nodeApi->addChild(parent, text2);
+}
+
+void AccessibilityMaker::CreateAccessibilityIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "9. 通过 NODE_ACCESSIBILITY_ID 获取无障碍ID:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ int accessibilityId = GetAccessibilityId(nodeApi, text2);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityId: id=%{public}d", accessibilityId);
+ nodeApi->addChild(parent, text2);
+}
+
+void AccessibilityMaker::CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi, "10. 设置无障碍支持操作事件:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle button = nodeApi->createNode(ARKUI_NODE_BUTTON);
+ ArkUI_NumberValue button_widthValue[] = {BUTTON_WIDTH_PX};
+ ArkUI_AttributeItem button_widthItem = {button_widthValue, 1};
+ ArkUI_NumberValue button_heightValue1[] = {BUTTON_HEIGHT_PX};
+ ArkUI_AttributeItem button_heightItem = {button_heightValue1, 1};
+ ArkUI_NumberValue marginValue[] = {BUTTON_MARGIN_PX};
+ ArkUI_AttributeItem marginItem = {marginValue, 1};
+ nodeApi->setAttribute(button, NODE_WIDTH, &button_widthItem);
+ nodeApi->setAttribute(button, NODE_HEIGHT, &button_heightItem);
+ nodeApi->setAttribute(button, NODE_MARGIN, &marginItem);
+ SetAccessibilityActions(nodeApi, button);
+ nodeApi->registerNodeEvent(button, NODE_ON_CLICK, 0, nullptr);
+ nodeApi->registerNodeEvent(button, NODE_ON_ACCESSIBILITY_ACTIONS, EVENT_ID, nullptr);
+ nodeApi->registerNodeEventReceiver([](ArkUI_NodeEvent *event) {
+ auto eventId = OH_ArkUI_NodeEvent_GetTargetId(event);
+ if (eventId == EVENT_ID) {
+ auto componentEvent = OH_ArkUI_NodeEvent_GetNodeComponentEvent(event);
+ auto actionType = componentEvent->data[0].u32;
+ switch (actionType) {
+ case ARKUI_ACCESSIBILITY_ACTION_CLICK:
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "ARKUI_ACCESSIBILITY_ACTION_CLICK");
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ nodeApi->addChild(parent, button);
+}
+
+void AccessibilityMaker::CreateAccessibilityRoleSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "11. 通过 NODE_ACCESSIBILITY_ROLE 设置无障碍组件类型:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ SetAccessibilityRole(nodeApi, text2, ARKUI_NODE_TEXT);
+ uint32_t role = GetAccessibilityRole(nodeApi, text2);
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetAccessibilityRole: role=%{public}u", role);
+ nodeApi->addChild(parent, text2);
+}
+
+void AccessibilityMaker::CreateUniqueIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent)
+{
+ ArkUI_NodeHandle text1 = BuildTextNodeWithoutAccessibilityFocus(nodeApi,
+ "12. 通过 NODE_UNIQUE_ID 获取唯一ID:");
+ nodeApi->addChild(parent, text1);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, SAMPLE_TEXT);
+ GetUniqueId(nodeApi, text2);
+ nodeApi->addChild(parent, text2);
+}
+
+ArkUI_NodeHandle AccessibilityMaker::CreateNativeNode()
+{
+ ArkUI_NativeNodeAPI_1 *nodeApi = reinterpret_cast(
+ OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1"));
+ if (nodeApi == nullptr) {
+ return nullptr;
+ }
+ // 创建一个Column容器组件
+ ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
+ // 创建Text组件
+ ArkUI_NodeHandle text = BuildTextNode(nodeApi, SAMPLE_TEXT);
+
+ auto scrollNode = nodeApi->createNode(ARKUI_NODE_SCROLL);
+ nodeApi->addChild(scrollNode, column);
+
+ CreateAccessibilitySelectedSection(nodeApi, column);
+ CreateAccessibilityCheckedSection(nodeApi, column);
+ CreateAccessibilityValueSection(nodeApi, column);
+ CreateAccessibilityNodeIdSection(nodeApi, column);
+ CreateAccessibilityGroupSection(nodeApi, column);
+ CreateAccessibilityModeSection(nodeApi, column);
+ CreateAccessibilityTextSection(nodeApi, column);
+ CreateAccessibilityDescriptionSection(nodeApi, column);
+ CreateAccessibilityIdSection(nodeApi, column);
+ CreateAccessibilityActionsSection(nodeApi, column);
+ CreateAccessibilityRoleSection(nodeApi, column);
+ CreateUniqueIdSection(nodeApi, column);
+
+ // Column作为XComponent子组件
+ return scrollNode;
+}
+
+ArkUI_NodeHandle AccessibilityMaker::BuildTextNodeWithoutAccessibilityFocus(ArkUI_NativeNodeAPI_1* nodeApi,
+ const char* content)
+{
+ ArkUI_NodeHandle text = nodeApi->createNode(ARKUI_NODE_TEXT);
+ ArkUI_NumberValue textWidth[] = {{.f32 = TEXT_WIDTH_PX}};
+ ArkUI_AttributeItem textWidthItem = { textWidth, sizeof(textWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_WIDTH, &textWidthItem);
+ ArkUI_NumberValue textHeight[] = {{.f32 = TEXT_HEIGHT_PX}};
+ ArkUI_AttributeItem textHeightItem = { textHeight, sizeof(textHeight) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_HEIGHT, &textHeightItem);
+ ArkUI_AttributeItem valueItem = {.string = content};
+ nodeApi->setAttribute(text, NODE_TEXT_CONTENT, &valueItem);
+ SetAccessibilityMode(nodeApi, text, ARKUI_ACCESSIBILITY_MODE_DISABLED);
+ return text;
+}
+ArkUI_NodeHandle AccessibilityMaker::BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content)
+{
+ ArkUI_NodeHandle text = nodeApi->createNode(ARKUI_NODE_TEXT);
+ ArkUI_NumberValue textWidth[] = {{.f32 = TEXT_WIDTH_PX}};
+ ArkUI_AttributeItem textWidthItem = { textWidth, sizeof(textWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_WIDTH, &textWidthItem);
+ ArkUI_NumberValue textHeight[] = {{.f32 = TEXT_HEIGHT_PX}};
+ ArkUI_AttributeItem textHeightItem = { textHeight, sizeof(textHeight) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_HEIGHT, &textHeightItem);
+ ArkUI_AttributeItem valueItem = {.string = content};
+ nodeApi->setAttribute(text, NODE_TEXT_CONTENT, &valueItem);
+ return text;
+}
+
+ArkUI_NodeHandle AccessibilityMaker::BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi)
+{
+ ArkUI_NodeHandle column = nodeApi->createNode(ARKUI_NODE_COLUMN);
+ ArkUI_NumberValue colWidth[] = {{.f32 = COL_WIDTH_PX}};
+ ArkUI_AttributeItem widthItem = { colWidth, sizeof(colWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(column, NODE_WIDTH, &widthItem);
+ return column;
+}
+
+AccessibilityMaker::~AccessibilityMaker()
+{
+ DisposeAccessibilityState();
+ DisposeAccessibilityValue();
+}
+
+void AccessibilityMaker::CreateAccessibilityState()
+{
+ if (!accessibilityState_) {
+ accessibilityState_ = OH_ArkUI_AccessibilityState_Create();
+ }
+}
+
+void AccessibilityMaker::SetAccessibilityDisabled(bool isDisabled)
+{
+ if (accessibilityState_) {
+ OH_ArkUI_AccessibilityState_SetDisabled(accessibilityState_, isDisabled);
+ }
+}
+
+bool AccessibilityMaker::IsAccessibilityDisabled()
+{
+ if (accessibilityState_) {
+ return OH_ArkUI_AccessibilityState_IsDisabled(accessibilityState_);
+ }
+ return false;
+}
+
+void AccessibilityMaker::SetAccessibilitySelected(bool isSelected)
+{
+ if (accessibilityState_) {
+ OH_ArkUI_AccessibilityState_SetSelected(accessibilityState_, isSelected);
+ }
+}
+
+bool AccessibilityMaker::IsAccessibilitySelected()
+{
+ if (accessibilityState_) {
+ return OH_ArkUI_AccessibilityState_IsSelected(accessibilityState_);
+ }
+ return false;
+}
+
+void AccessibilityMaker::SetAccessibilityCheckedState(int32_t checkedState)
+{
+ if (accessibilityState_) {
+ OH_ArkUI_AccessibilityState_SetCheckedState(accessibilityState_, checkedState);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityCheckedState()
+{
+ if (accessibilityState_) {
+ return OH_ArkUI_AccessibilityState_GetCheckedState(accessibilityState_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::DisposeAccessibilityState()
+{
+ if (accessibilityState_) {
+ OH_ArkUI_AccessibilityState_Dispose(accessibilityState_);
+ accessibilityState_ = nullptr;
+ }
+}
+
+void AccessibilityMaker::CreateAccessibilityValue()
+{
+ if (!accessibilityValue_) {
+ accessibilityValue_ = OH_ArkUI_AccessibilityValue_Create();
+ }
+}
+
+void AccessibilityMaker::DisposeAccessibilityValue()
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_Dispose(accessibilityValue_);
+ accessibilityValue_ = nullptr;
+ }
+}
+
+void AccessibilityMaker::SetAccessibilityValueMin(int32_t min)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetMin(accessibilityValue_, min);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityValueMin()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetMin(accessibilityValue_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::SetAccessibilityValueMax(int32_t max)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetMax(accessibilityValue_, max);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityValueMax()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetMax(accessibilityValue_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::SetAccessibilityValueCurrent(int32_t current)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetCurrent(accessibilityValue_, current);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityValueCurrent()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetCurrent(accessibilityValue_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::SetAccessibilityValueText(const char* text)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetText(accessibilityValue_, text);
+ }
+}
+
+const char* AccessibilityMaker::GetAccessibilityValueText()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetText(accessibilityValue_);
+ }
+ return nullptr;
+}
+
+void AccessibilityMaker::SetAccessibilityRangeMin(int32_t rangeMin)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetRangeMin(accessibilityValue_, rangeMin);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityRangeMin()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetRangeMin(accessibilityValue_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::SetAccessibilityRangeMax(int32_t rangeMax)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetRangeMax(accessibilityValue_, rangeMax);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityRangeMax()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetRangeMax(accessibilityValue_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::SetAccessibilityRangeCurrent(int32_t rangeCurrent)
+{
+ if (accessibilityValue_) {
+ OH_ArkUI_AccessibilityValue_SetRangeCurrent(accessibilityValue_, rangeCurrent);
+ }
+}
+
+int32_t AccessibilityMaker::GetAccessibilityRangeCurrent()
+{
+ if (accessibilityValue_) {
+ return OH_ArkUI_AccessibilityValue_GetRangeCurrent(accessibilityValue_);
+ }
+ return 0;
+}
+
+void AccessibilityMaker::SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* id)
+{
+ if (nodeApi && node) {
+ ArkUI_AttributeItem idItem = {.string = id};
+ nodeApi->setAttribute(node, NODE_ID, &idItem);
+ }
+}
+
+const char* AccessibilityMaker::GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attributeItem = nodeApi->getAttribute(node, NODE_ID);
+ if (attributeItem) {
+ return attributeItem->string;
+ }
+ }
+ return nullptr;
+}
+
+void AccessibilityMaker::SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, bool isGroup)
+{
+ if (nodeApi && node) {
+ ArkUI_NumberValue value[] = {{.i32 = isGroup}};
+ ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(node, NODE_ACCESSIBILITY_GROUP, &item);
+ }
+}
+
+bool AccessibilityMaker::GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attributeItem = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_GROUP);
+ if (attributeItem) {
+ return attributeItem->value[0].i32;
+ }
+ }
+ return false;
+}
+
+void AccessibilityMaker::SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ ArkUI_AccessibilityMode mode)
+{
+ if (nodeApi && node) {
+ ArkUI_NumberValue value[] = {{.i32 = mode}};
+ ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(node, NODE_ACCESSIBILITY_MODE, &item);
+ }
+}
+
+ArkUI_AccessibilityMode AccessibilityMaker::GetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_MODE);
+ if (attr && attr->size > 0) {
+ return static_cast(attr->value[0].i32);
+ }
+ }
+ return ARKUI_ACCESSIBILITY_MODE_AUTO;
+}
+
+void AccessibilityMaker::SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ const char* description)
+{
+ if (nodeApi && node) {
+ ArkUI_AttributeItem item = {.string = description};
+ nodeApi->setAttribute(node, NODE_ACCESSIBILITY_DESCRIPTION, &item);
+ }
+}
+
+const char* AccessibilityMaker::GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_DESCRIPTION);
+ if (attr) {
+ return attr->string;
+ }
+ }
+ return nullptr;
+}
+
+int AccessibilityMaker::GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_ID);
+ if (attr && attr->size > 0) {
+ return attr->value[0].i32;
+ }
+ }
+ return -1;
+}
+
+void AccessibilityMaker::SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* text)
+{
+ if (nodeApi && node) {
+ ArkUI_AttributeItem item = {.string = text};
+ nodeApi->setAttribute(node, NODE_ACCESSIBILITY_TEXT, &item);
+ }
+}
+
+const char* AccessibilityMaker::GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_TEXT);
+ if (attr) {
+ return attr->string;
+ }
+ }
+ return nullptr;
+}
+
+void AccessibilityMaker::SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ ArkUI_NumberValue value[] = {{ .u32 = ARKUI_ACCESSIBILITY_ACTION_CLICK}};
+ ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(node, NODE_ACCESSIBILITY_ACTIONS, &item);
+ }
+}
+
+uint32_t AccessibilityMaker::GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_ACTIONS);
+ if (attr && attr->size > 0) {
+ return attr->value[0].u32;
+ }
+ }
+ return 0U;
+}
+
+void AccessibilityMaker::SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ const uint32_t role)
+{
+ if (nodeApi && node) {
+ ArkUI_NumberValue value[] = {{ .u32 = role}};
+ ArkUI_AttributeItem item = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(node, NODE_ACCESSIBILITY_ROLE, &item);
+ }
+}
+
+uint32_t AccessibilityMaker::GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem* attr = nodeApi->getAttribute(node, NODE_ACCESSIBILITY_ROLE);
+ if (attr && attr->size > 0) {
+ return attr->value[0].u32;
+ }
+ }
+ return 0U;
+}
+
+void AccessibilityMaker::GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ const ArkUI_AttributeItem *attributeItem = nodeApi->getAttribute(node, NODE_UNIQUE_ID);
+ // 组件id作为targetid来区分不同组件的事件。
+ auto id = attributeItem->value[0].i32;
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "GetUniqueId: id=%{public}d", id);
+ }
+}
\ No newline at end of file
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/AccessibilityMaker.h b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/AccessibilityMaker.h
new file mode 100644
index 0000000000000000000000000000000000000000..df986ca15e1aa76b5854e4f9ed89bb46ad08792f
--- /dev/null
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/AccessibilityMaker.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2025 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 NATIVE_TYPE_SAMPLE_ACCESSIBILITYMAKER_H
+#define NATIVE_TYPE_SAMPLE_ACCESSIBILITYMAKER_H
+
+#include
+#include
+#include
+#include
+#include "manager.h"
+
+class AccessibilityMaker {
+public:
+ AccessibilityMaker(){};
+ ~AccessibilityMaker();
+
+ static ArkUI_NodeHandle CreateNativeNode();
+ static ArkUI_NodeHandle BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
+ static ArkUI_NodeHandle BuildTextNodeWithoutAccessibilityFocus(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
+
+ static void CreateAccessibilityState();
+ static void SetAccessibilityDisabled(bool isDisabled);
+ static bool IsAccessibilityDisabled();
+ static void SetAccessibilitySelected(bool isSelected);
+ static bool IsAccessibilitySelected();
+ static void SetAccessibilityCheckedState(int32_t checkedState);
+ static int32_t GetAccessibilityCheckedState();
+ static void DisposeAccessibilityState();
+ static ArkUI_NodeHandle BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi);
+ static void CreateAccessibilityValue();
+ static void DisposeAccessibilityValue();
+ static void SetAccessibilityValueMin(int32_t min);
+ static int32_t GetAccessibilityValueMin();
+ static void SetAccessibilityValueMax(int32_t max);
+ static int32_t GetAccessibilityValueMax();
+ static void SetAccessibilityValueCurrent(int32_t current);
+ static int32_t GetAccessibilityValueCurrent();
+ static void SetAccessibilityValueText(const char* text);
+ static const char* GetAccessibilityValueText();
+ static void SetAccessibilityRangeMin(int32_t rangeMin);
+ static int32_t GetAccessibilityRangeMin();
+ static void SetAccessibilityRangeMax(int32_t rangeMax);
+ static int32_t GetAccessibilityRangeMax();
+ static void SetAccessibilityRangeCurrent(int32_t rangeCurrent);
+ static int32_t GetAccessibilityRangeCurrent();
+ static void SetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* id);
+ static const char* GetNodeId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, bool isGroup);
+ static bool GetAccessibilityGroup(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ ArkUI_AccessibilityMode mode);
+ static ArkUI_AccessibilityMode GetAccessibilityMode(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const char* text);
+ static const char* GetAccessibilityText(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node,
+ const char* description);
+ static const char* GetAccessibilityDescription(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static int GetAccessibilityId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static uint32_t GetAccessibilityActions(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void SetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node, const uint32_t role);
+ static uint32_t GetAccessibilityRole(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void GetUniqueId(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void CreateAccessibilityCheckedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilitySelectedSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityValueSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityNodeIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityGroupSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityModeSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityTextSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityDescriptionSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityActionsSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateAccessibilityRoleSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void CreateUniqueIdSection(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle parent);
+ static void OnErrorCallback(int32_t code, const char* name, const char* message);
+ static void OnTerminatedCallback(int32_t code, AbilityBase_Want* want);
+};
+
+#endif // NATIVE_TYPE_SAMPLE_ACCESSIBILITYMAKER_H
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt
index 3870e1647c773c33d9773c2925854f267f85864f..52e7b19fc1f6c3f79196de0312ace816005c0ef5 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/CMakeLists.txt
@@ -7,7 +7,7 @@ set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${NATIVERENDER_ROOT_PATH}
${NATIVERENDER_ROOT_PATH}/include)
-add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp SwiperMaker.cpp TextMaker.cpp)
+add_library(entry SHARED napi_init.cpp manager.cpp baseUtils.cpp SwiperMaker.cpp TextMaker.cpp AccessibilityMaker.cpp EmbeddedComponentMaker.cpp)
find_library(hilog-lib hilog_ndk.z)
@@ -17,4 +17,4 @@ find_library(libnapi-lib ace_napi.z)
target_link_libraries(entry PUBLIC ${hilog-lib} ${libace-lib} ${libnapi-lib})
-target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so)
\ No newline at end of file
+target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so libhilog_ndk.z.so libability_base_want.so)
\ No newline at end of file
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/EmbeddedComponentMaker.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/EmbeddedComponentMaker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61053e51137e058cd579be6691b9d473c9acf8a5
--- /dev/null
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/EmbeddedComponentMaker.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2025 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 "EmbeddedComponentMaker.h"
+#include
+#include
+#include
+#include
+
+constexpr float TEXT_WIDTH_PX = 300.0f;
+constexpr float TEXT_HEIGHT_PX = 100.0f;
+constexpr int EMBEDDED_COMPONENT_WIDTH = 480;
+constexpr int WANT_STR_BUF_LEN = 10;
+constexpr int WANT_STR_COPY_LEN = 5;
+constexpr int WANT_URI_BUF_LEN = 10;
+constexpr int WANT_URI_COPY_LEN = 5;
+constexpr float COL_WIDTH_PX = 300.0f;
+static ArkUI_EmbeddedComponentOption* embeddedComponentOption_;
+
+ArkUI_NodeHandle EmbeddedComponentMaker::CreateNativeNode()
+{
+ ArkUI_NativeNodeAPI_1 *nodeApi = reinterpret_cast(
+ OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_NODE, "ArkUI_NativeNodeAPI_1"));
+ if (nodeApi == nullptr) {
+ return nullptr;
+ }
+ // 创建一个Column容器组件
+ ArkUI_NodeHandle column = BuildColumnNode(nodeApi);
+
+ // 创建一个EmbeddedComponent组件节点
+ ArkUI_NodeHandle embeddedNode = BuildEmbeddedComponentSection(nodeApi);
+ ArkUI_NodeHandle text2 = BuildTextNode(nodeApi, "嵌入式组件:");
+ nodeApi->addChild(column, text2);
+
+ // 将嵌入式组件添加到列容器
+ nodeApi->addChild(column, embeddedNode);
+ // Column作为XComponent子组件
+ return column;
+}
+
+ArkUI_NodeHandle EmbeddedComponentMaker::BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi)
+{
+ ArkUI_NodeHandle column = nodeApi->createNode(ARKUI_NODE_COLUMN);
+ ArkUI_NumberValue colWidth[] = {{.f32 = COL_WIDTH_PX}};
+ ArkUI_AttributeItem widthItem = { colWidth, sizeof(colWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(column, NODE_WIDTH, &widthItem);
+ return column;
+}
+
+ArkUI_NodeHandle EmbeddedComponentMaker::BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content)
+{
+ ArkUI_NodeHandle text = nodeApi->createNode(ARKUI_NODE_TEXT);
+ ArkUI_NumberValue textWidth[] = {{.f32 = TEXT_WIDTH_PX}};
+ ArkUI_AttributeItem textWidthItem = { textWidth, sizeof(textWidth) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_WIDTH, &textWidthItem);
+ ArkUI_NumberValue textHeight[] = {{.f32 = TEXT_HEIGHT_PX}};
+ ArkUI_AttributeItem textHeightItem = { textHeight, sizeof(textHeight) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(text, NODE_HEIGHT, &textHeightItem);
+ ArkUI_AttributeItem valueItem = {.string = content};
+ nodeApi->setAttribute(text, NODE_TEXT_CONTENT, &valueItem);
+ return text;
+}
+
+EmbeddedComponentMaker::~EmbeddedComponentMaker()
+{
+ DisposeEmbeddedComponentOption();
+}
+
+ArkUI_NodeHandle EmbeddedComponentMaker::BuildEmbeddedComponentSection(ArkUI_NativeNodeAPI_1* nodeApi)
+{
+ // 创建嵌入式组件选项
+ CreateEmbeddedComponentOption();
+ // 设置错误回调
+ SetEmbeddedComponentOnError();
+ // 设置终止回调
+ SetEmbeddedComponentOnTerminated();
+ // 创建嵌入式组件节点
+ ArkUI_NodeHandle embeddedNode = nodeApi->createNode(ARKUI_NODE_EMBEDDED_COMPONENT);
+ // 设置嵌入式组件的want
+ SetEmbeddedComponentWant(nodeApi, embeddedNode);
+ // 将嵌入式组件选项设置给嵌入式组件
+ ArkUI_AttributeItem embeddedComponentOptionItem = { .object = embeddedComponentOption_ };
+ nodeApi->setAttribute(embeddedNode, NODE_EMBEDDED_COMPONENT_OPTION, &embeddedComponentOptionItem);
+ ArkUI_NumberValue value[] = { EMBEDDED_COMPONENT_WIDTH };
+ ArkUI_AttributeItem embeddedWidthItem = { value, sizeof(value) / sizeof(ArkUI_NumberValue) };
+ nodeApi->setAttribute(embeddedNode, NODE_WIDTH, &embeddedWidthItem);
+ nodeApi->setAttribute(embeddedNode, NODE_HEIGHT, &embeddedWidthItem);
+ return embeddedNode;
+}
+
+void EmbeddedComponentMaker::CreateEmbeddedComponentOption()
+{
+ if (!embeddedComponentOption_) {
+ embeddedComponentOption_ = OH_ArkUI_EmbeddedComponentOption_Create();
+ }
+}
+
+void EmbeddedComponentMaker::DisposeEmbeddedComponentOption()
+{
+ if (embeddedComponentOption_) {
+ OH_ArkUI_EmbeddedComponentOption_Dispose(embeddedComponentOption_);
+ embeddedComponentOption_ = nullptr;
+ }
+}
+
+void EmbeddedComponentMaker::SetEmbeddedComponentOnError()
+{
+ if (embeddedComponentOption_) {
+ OH_ArkUI_EmbeddedComponentOption_SetOnError(embeddedComponentOption_, OnErrorCallback);
+ }
+}
+
+void EmbeddedComponentMaker::SetEmbeddedComponentOnTerminated()
+{
+ if (embeddedComponentOption_) {
+ OH_ArkUI_EmbeddedComponentOption_SetOnTerminated(embeddedComponentOption_, OnTerminatedCallback);
+ }
+}
+
+void EmbeddedComponentMaker::SetEmbeddedComponentWant(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node)
+{
+ if (nodeApi && node) {
+ // 创建一个Want对象并设置相关属性
+ AbilityBase_Element element = {
+ .bundleName = "com.example.native_type_sample",
+ .abilityName = "SampleEmbeddedAbility",
+ .moduleName = ""
+ };
+ AbilityBase_Want* want = OH_AbilityBase_CreateWant(element);
+ ArkUI_AttributeItem itemObjWant = {.object = want};
+ nodeApi->setAttribute(node, NODE_EMBEDDED_COMPONENT_WANT, &itemObjWant);
+ }
+}
+
+void EmbeddedComponentMaker::OnErrorCallback(int32_t code, const char* name, const char* msg)
+{
+ // 用户自定义的错误处理逻辑
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnErrorCallback:\
+ code=%{public}d, name=%{public}s, message=%{public}s", code, name, msg);
+}
+
+void EmbeddedComponentMaker::OnTerminatedCallback(int32_t code, AbilityBase_Want* want)
+{
+ // 用户自定义的终止处理逻辑
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: code=%{public}d", code);
+ if (want == nullptr) {
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: want is nullptr");
+ return;
+ }
+
+ AbilityBase_Element element;
+ auto error = OH_AbilityBase_GetWantElement(want, &element);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: bundleName=%{public}s,\
+ abilityName=%{public}s, moduleName=%{public}s", element.bundleName, element.abilityName, element.moduleName);
+ int wantInt = 0;
+ error = OH_AbilityBase_GetWantInt32Param(want, "int", &wantInt);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantInt=%{public}d", wantInt);
+ bool wantBool = false;
+ error = OH_AbilityBase_GetWantBoolParam(want, "bool2", &wantBool);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantBool=%{public}d",
+ wantBool);
+ char wantString[WANT_STR_BUF_LEN];
+ error = OH_AbilityBase_GetWantCharParam(want, "string", wantString, WANT_STR_COPY_LEN);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantString=%{public}s",
+ wantString);
+ char wantUri[WANT_URI_BUF_LEN];
+ error = OH_AbilityBase_GetWantUri(want, wantUri, WANT_URI_COPY_LEN);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantUri=%{public}s", wantUri);
+ int wantFd = 0;
+ error = OH_AbilityBase_GetWantFd(want, "keyFd2", &wantFd);
+ OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "OnTerminatedCallback: wantFd=%{public}d", wantFd);
+}
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/EmbeddedComponentMaker.h
similarity index 33%
rename from ArkUIKit/AccessibilityCapi/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
rename to ArkUIKit/NativeTypeSample/entry/src/main/cpp/EmbeddedComponentMaker.h
index 4ce6449f0e91914e73d4502c9f2e8e9a395ea4b1..bcb604aabe93a37c0b8422aec03c2f02b1dc883d 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/EmbeddedComponentMaker.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,19 +12,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
-const DOMAIN = 0x0000;
+#ifndef NATIVE_TYPE_SAMPLE_EMBEDDED_COMPONENT_MAKER_H
+#define NATIVE_TYPE_SAMPLE_EMBEDDED_COMPONENT_MAKER_H
-export default class EntryBackupAbility extends BackupExtensionAbility {
- async onBackup() {
- hilog.info(DOMAIN, 'testTag', 'onBackup ok');
- await Promise.resolve();
- }
+#include
+#include
+#include
+#include
+#include "manager.h"
- async onRestore(bundleVersion: BundleVersion) {
- hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
- await Promise.resolve();
- }
-}
\ No newline at end of file
+class EmbeddedComponentMaker {
+public:
+ EmbeddedComponentMaker(){};
+ ~EmbeddedComponentMaker();
+
+ static ArkUI_NodeHandle CreateNativeNode();
+ static ArkUI_NodeHandle BuildEmbeddedComponentSection(ArkUI_NativeNodeAPI_1* nodeApi);
+ static ArkUI_NodeHandle BuildTextNode(ArkUI_NativeNodeAPI_1* nodeApi, const char* content);
+ static ArkUI_NodeHandle BuildColumnNode(ArkUI_NativeNodeAPI_1* nodeApi);
+
+ static void CreateEmbeddedComponentOption();
+ static void DisposeEmbeddedComponentOption();
+ static void SetEmbeddedComponentOnError();
+ static void SetEmbeddedComponentOnTerminated();
+ static void SetEmbeddedComponentWant(ArkUI_NativeNodeAPI_1* nodeApi, ArkUI_NodeHandle node);
+ static void OnErrorCallback(int32_t code, const char* name, const char* message);
+ static void OnTerminatedCallback(int32_t code, AbilityBase_Want* want);
+};
+
+#endif // NATIVE_TYPE_SAMPLE_EMBEDDED_COMPONENT_MAKER_H
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp
index 1f826dd7dbaeecd31c2b32df535e54a011a9263d..cdf33a45d00de619cc6199c285de9b694a222b71 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.cpp
@@ -18,6 +18,8 @@
#include "ArkUIVisualEffectsNode.h"
#include "SwiperMaker.h"
#include "TextMaker.h"
+#include "AccessibilityMaker.h"
+#include "EmbeddedComponentMaker.h"
#include "baseUtils.h"
#include "napi/native_api.h"
#include
@@ -223,4 +225,58 @@ napi_value DestroyNativeRoot(napi_env env, napi_callback_info info)
{
Manager::GetInstance()->DisposeRootNode();
return nullptr;
+}
+
+napi_value Manager::CreateNativeAccessibilityNode(napi_env env, napi_callback_info info)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN");
+ if ((env == nullptr) || (info == nullptr)) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode env or info is null");
+ return nullptr;
+ }
+ size_t argCnt = ConstIde::NUMBER_1;
+ napi_value args[ConstIde::NUMBER_1] = {nullptr};
+ if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode napi_get_cb_info failed");
+ }
+
+ ArkUI_NodeContentHandle nodeContentHandle = nullptr;
+
+ OH_ArkUI_GetNodeContentFromNapiValue(env, args[ConstIde::NUMBER_0], &nodeContentHandle);
+
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after");
+ if (nodeAPI_ != nullptr) {
+ if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) {
+ ArkUI_NodeHandle testNode = AccessibilityMaker::CreateNativeNode();
+ OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode);
+ }
+ }
+ return nullptr;
+}
+
+napi_value Manager::CreateNativeEmbeddedComponentNode(napi_env env, napi_callback_info info)
+{
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode BEGIN");
+ if ((env == nullptr) || (info == nullptr)) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode env or info is null");
+ return nullptr;
+ }
+ size_t argCnt = ConstIde::NUMBER_1;
+ napi_value args[ConstIde::NUMBER_1] = {nullptr};
+ if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) {
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "CreateNativeNode napi_get_cb_info failed");
+ }
+
+ ArkUI_NodeContentHandle nodeContentHandle = nullptr;
+
+ OH_ArkUI_GetNodeContentFromNapiValue(env, args[ConstIde::NUMBER_0], &nodeContentHandle);
+
+ OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Manager", "OH_ArkUI_GetBasicNodeAPI after");
+ if (nodeAPI_ != nullptr) {
+ if (nodeAPI_->createNode != nullptr && nodeAPI_->addChild != nullptr) {
+ ArkUI_NodeHandle testNode = EmbeddedComponentMaker::CreateNativeNode();
+ OH_ArkUI_NodeContent_AddNode(nodeContentHandle, testNode);
+ }
+ }
+ return nullptr;
}
\ No newline at end of file
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h
index c3102c226534da368528986951c4fe374690f31c..a7fdba11a733a338527fa9d52aade2ff828b5057 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/manager.h
@@ -64,6 +64,8 @@ public:
static napi_value CreateNativeSwiperNode(napi_env env, napi_callback_info info);
static napi_value CreateNativeTextNode(napi_env env, napi_callback_info info);
+ static napi_value CreateNativeAccessibilityNode(napi_env env, napi_callback_info info);
+ static napi_value CreateNativeEmbeddedComponentNode(napi_env env, napi_callback_info info);
private:
static Manager manager_;
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp
index 11726f043319622c95a36bae70ae5e785a62d0e8..36b4ed8f1b5477a5553ad0b6d860afdfa646e28b 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/napi_init.cpp
@@ -43,6 +43,10 @@ static napi_value Init(napi_env env, napi_value exports) {
{"createNativeRootVisualEffects3", nullptr, createNativeRootVisualEffects3,
nullptr, nullptr, nullptr, napi_default, nullptr},
{"destroyNativeRoot", nullptr, DestroyNativeRoot, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"createNativeAccessibilityNode", nullptr, Manager::CreateNativeAccessibilityNode, nullptr, nullptr, nullptr,
+ napi_default, nullptr},
+ {"createNativeEmbeddedComponentNode", nullptr, Manager::CreateNativeEmbeddedComponentNode, nullptr, nullptr,
+ nullptr, napi_default, nullptr},
// 参考Swiper新增其他createNative方法和Maker类
};
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts
index 1674b62426f66024e6a87cee75c6740ccd4081e7..a2f8dd0202b2a7210824d394d24963ebff3e9321 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/cpp/types/libentry/Index.d.ts
@@ -23,4 +23,6 @@ export const createNativeRootAnimation5: (content: Object) => void;
export const createNativeRootVisualEffects1: (content: Object) => void;
export const createNativeRootVisualEffects2: (content: Object) => void;
export const createNativeRootVisualEffects3: (content: Object) => void;
-export const destroyNativeRoot: () => void;
\ No newline at end of file
+export const destroyNativeRoot: () => void;
+export const createNativeAccessibilityNode: (content: Object) => void;
+export const createNativeEmbeddedComponentNode: (content: Object) => void;
\ No newline at end of file
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/mock/mock-config.json5 b/ArkUIKit/NativeTypeSample/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
similarity index 71%
rename from ArkUIKit/AccessibilityCapi/entry/src/mock/mock-config.json5
rename to ArkUIKit/NativeTypeSample/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
index 98b0ae79f0090e1fc381d54c959fb32c9f7563f4..e1f327c40a2d8d67f76ef0d9d3ccd6e7bbf1c247 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/mock/mock-config.json5
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/extensionAbility/SampleEmbeddedAbility.ets
@@ -1,19 +1,21 @@
-/*
- * Copyright (c) 2025 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.
- */
-{
- "libentry.so": {
- "source": "src/mock/Libentry.mock.ets"
- }
+/*
+ * Copyright (c) 2025 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 { EmbeddedUIExtensionAbility, UIExtensionContentSession, Want } from '@kit.AbilityKit'
+
+export default class SampleEmbeddedAbility extends EmbeddedUIExtensionAbility {
+ onForeground() {
+ this.context.terminateSelf()
+ }
}
\ No newline at end of file
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets
index 933af8631a69ca9c2375cece838158d2bcf07b51..9ec5e22ca89b99151d983888737324507dfd300f 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/Index.ets
@@ -29,6 +29,8 @@ struct MenuIndex {
{ title: 'text', url: 'pages/page_text' },
{ title: 'Animation', url: 'pages/page_animation' },
{ title: 'Visual Effects', url: 'pages/page_visual_effects' },
+ { title: 'accessibility', url: 'pages/page_accessibility' },
+ { title: 'embedded component', url: 'pages/page_embedded_component' },
];
build() {
diff --git a/ArkUIKit/AccessibilityCapi/AppScope/app.json5 b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_accessibility.ets
similarity index 59%
rename from ArkUIKit/AccessibilityCapi/AppScope/app.json5
rename to ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_accessibility.ets
index 6feb914f07fb2d4d991192960f658ff341d61fa6..9368bede5d6e3160cbddc45f7bd9235d4d4efeac 100644
--- a/ArkUIKit/AccessibilityCapi/AppScope/app.json5
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_accessibility.ets
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,13 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-{
- "app": {
- "bundleName": "com.samples.accessibilityndk",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:layered_image",
- "label": "$string:app_name"
+
+import Napi from 'libentry.so';
+import { NodeContent } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ private nodeContent = new NodeContent();
+ aboutToAppear() {
+ // 通过C-API创建节点,并添加到管理器nodeContent上
+ Napi.createNativeAccessibilityNode(this.nodeContent);
+ }
+ build() {
+ Column() {
+ ContentSlot(this.nodeContent)
+ }
+ .width('100%')
+ .height('100%')
}
}
diff --git a/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/module.json5 b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_embedded_component.ets
similarity index 59%
rename from ArkUIKit/AccessibilityCapi/entry/src/ohosTest/module.json5
rename to ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_embedded_component.ets
index f6bdce9946cb02c0385e5a8836c133c93945013d..040bd81c11fdffac89c05193b2125d60d09e20aa 100644
--- a/ArkUIKit/AccessibilityCapi/entry/src/ohosTest/module.json5
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/ets/pages/page_embedded_component.ets
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -12,15 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-{
- "module": {
- "name": "entry_test",
- "type": "feature",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false
+
+import Napi from 'libentry.so';
+import { NodeContent } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ private nodeContent = new NodeContent();
+ aboutToAppear() {
+ // 通过C-API创建节点,并添加到管理器nodeContent上
+ Napi.createNativeEmbeddedComponentNode(this.nodeContent);
+ }
+ build() {
+ Column() {
+ ContentSlot(this.nodeContent)
+ }
+ .width('100%')
+ .height('100%')
}
}
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/module.json5 b/ArkUIKit/NativeTypeSample/entry/src/main/module.json5
index 6ab131223385e5f7e4f94f0e284489aff17ad82d..c5be971e98a651c460b6e756939f1f5a6572f0c3 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/module.json5
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/module.json5
@@ -60,6 +60,11 @@
"resource": "$profile:backup_config"
}
]
+ },
+ {
+ "name": "SampleEmbeddedAbility",
+ "srcEntry": "./ets/extensionAbility/SampleEmbeddedAbility.ets",
+ "type": "embeddedUI"
}
]
}
diff --git a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json
index a6af93b80c472f148e10c507d751369d50df4077..d75958ede6b89d8c856598c74110a159fda60d25 100644
--- a/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json
+++ b/ArkUIKit/NativeTypeSample/entry/src/main/resources/base/profile/main_pages.json
@@ -2,6 +2,8 @@
"src": [
"pages/Index",
"pages/page_swiper",
- "pages/page_text"
+ "pages/page_text",
+ "pages/page_accessibility",
+ "pages/page_embedded_component"
]
}
diff --git a/ArkUIKit/NativeTypeSample/ohosTest.md b/ArkUIKit/NativeTypeSample/ohosTest.md
index e90656ad312855061e0b9607c06bd0cc58c8b5c7..d03b4ec1acc5f29496547da2cde4cfd81f5664d0 100644
--- a/ArkUIKit/NativeTypeSample/ohosTest.md
+++ b/ArkUIKit/NativeTypeSample/ohosTest.md
@@ -9,4 +9,7 @@
| swiper设置自定义导航点功能 | 应用位于首页 | 1.点击首页Swiper按钮 | 1.第二个swiper左上角有一个被选中为红色未被选中为灰色的导航栏,swiper内容为“0” | 否 | 验证通过 |
| swiper设置自定义数字导航栏功能 | 应用位于首页 | 1.点击首页Swiper按钮 | 1.第三个swiper左上角显示数字导航栏,左侧数字为1/14,其中数字1为红色,14为灰色,swiper内容为“0” | 否 | 验证通过 |
| 基础 Text 样式展示 | 应用加载完成 | 1.查看第一段文本 | 1.宽 200vp 高 30vp 带边框,斜体 600 字重,超长跑马灯、不可复制 | 否 | 验证通过 |
-| TextInput 输入功能 | 应用加载完成 | 1.点击输入框尝试输入 | 1.支持输入,第一个样式内联,第二个带清除按钮 | 否 | 验证通过 |
\ No newline at end of file
+| TextInput 输入功能 | 应用加载完成 | 1.点击输入框尝试输入 | 1.支持输入,第一个样式内联,第二个带清除按钮 | 否 | 验证通过 |
+| EmbeddedComponent OnErrorCallback回调成功 | 执行 hdc shell param set persist.sys.abilityms.multi_process_model false 后重启,应用位于首页 | 1.点击首页embedded component按钮 | EmbeddedComponent onError回调被触发,打印日志{OnErrorCallback: code=100018, name=start_ability_fail, message=Start ui extension ability failed, please check the want of UIextensionAbility.} | 否 | 验证通过 |
+| EmbeddedComponent OnTerminatedCallback回调成功 | 执行 hdc shell param set persist.sys.abilityms.multi_process_model true 后重启,应用位于首页 | 1.点击首页embedded component按钮 | EmbeddedComponent onError回调被触发,打印日志{OnTerminatedCallback: code=0} | 否 | 验证通过 |
+| 文本无障碍属性设置 | 应用位于首页 | 1.点击首页Accessibility按钮 | 观测Get日志设置属性值与Set函数一致 | 否 | 验证通过 |
\ No newline at end of file